class CsTemplate::Generator

Public Instance Methods

destroy() click to toggle source
# File lib/cs_template/generator.rb, line 15
def destroy
  sass_files_destroy
end
install() click to toggle source
# File lib/cs_template/generator.rb, line 8
def install
  sass_files_install
  gem_install 'bourbon'
  gem_install 'neat'
end

Private Instance Methods

asset_path(dir_name) click to toggle source
# File lib/cs_template/generator.rb, line 71
def asset_path(dir_name)
  root_dir = File.dirname(File.dirname(File.dirname(__FILE__)))
  File.join root_dir, 'app', 'assets', 'stylesheets', dir_name
end
copy_directory(dir_name) click to toggle source
# File lib/cs_template/generator.rb, line 51
def copy_directory(dir_name)
  a_path = asset_path dir_name
  l_path = local_path dir_name
  return if empty_directory?(a_path) || File.directory?(l_path)
  FileUtils.cp_r a_path, './'
end
destroy_directory(dir_name) click to toggle source
# File lib/cs_template/generator.rb, line 65
def destroy_directory(dir_name)
  path = local_path dir_name
  return if !File.directory? path
  FileUtils.rm_r path
end
empty_directory?(path) click to toggle source
# File lib/cs_template/generator.rb, line 80
def empty_directory?(path)
  (Dir[path].entries - %w{ . .. }).empty?
end
gem_install(gem) click to toggle source
# File lib/cs_template/generator.rb, line 84
def gem_install(gem)
  FileUtils.cd 'vendor'
  system "#{gem} install"
  FileUtils.cd '../'
end
init_directory(dir_name) click to toggle source
# File lib/cs_template/generator.rb, line 58
def init_directory(dir_name)
  a_path = asset_path dir_name
  l_path = local_path dir_name
  return if !empty_directory?(a_path) || File.directory?(l_path)
  FileUtils.mkdir_p dir_name
end
local_path(dir_name) click to toggle source
# File lib/cs_template/generator.rb, line 76
def local_path(dir_name)
  "./#{dir_name}"
end
main_scss() click to toggle source
# File lib/cs_template/generator.rb, line 25
def main_scss
  'main.scss'
end
main_scss_destroy() click to toggle source
# File lib/cs_template/generator.rb, line 47
def main_scss_destroy
  File.file?(main_scss) && FileUtils.rm_r(local_path(main_scss))
end
main_scss_install() click to toggle source
# File lib/cs_template/generator.rb, line 36
def main_scss_install
  !File.file?(main_scss) && FileUtils.cp_r(asset_path(main_scss), './')
end
sass_files_destroy() click to toggle source
# File lib/cs_template/generator.rb, line 40
def sass_files_destroy
  seven_one_pattern.each do |dir_name|
    destroy_directory(dir_name) || nil
  end
  main_scss_destroy
end
sass_files_install() click to toggle source
# File lib/cs_template/generator.rb, line 29
def sass_files_install
  seven_one_pattern.each do |dir_name|
    copy_directory(dir_name) || init_directory(dir_name) || nil
  end
  main_scss_install
end
seven_one_pattern() click to toggle source
# File lib/cs_template/generator.rb, line 21
def seven_one_pattern
  %w(base components layout pages themes utils vendor)
end