class Kentucky::Generator

Public Instance Methods

install() click to toggle source
# File lib/kentucky/generator.rb, line 11
def install
  if kentucky_files_already_exist? && !options[:force]
    puts "Kentucky files already installed, doing nothing."
  else
    create_site_structure if !options[:force]
    install_files
    puts "Kentucky files installed to #{install_path_kentucky}/"
  end
end
update() click to toggle source
# File lib/kentucky/generator.rb, line 23
def update
  if kentucky_files_already_exist?
    remove_kentucky_directory
    create_kentucky_directory
    install_files
    puts "Kentucky files updated."
  else
    puts "No existing Kentucky installation. Doing nothing."
  end
end
version() click to toggle source
# File lib/kentucky/generator.rb, line 35
def version
  say "Kentucky #{Kentucky::VERSION}"
end

Private Instance Methods

all_stylesheets() click to toggle source
# File lib/kentucky/generator.rb, line 108
def all_stylesheets
  Dir["#{stylesheets_directory}/*"]
end
copy_in_scss_files() click to toggle source
# File lib/kentucky/generator.rb, line 83
def copy_in_scss_files
  FileUtils.cp_r(kentucky_stylesheets, install_path_kentucky)
  FileUtils.cp(master_stylesheet, install_path_scss)
end
create_kentucky_directory() click to toggle source
# File lib/kentucky/generator.rb, line 60
def create_kentucky_directory
  FileUtils.mkdir(install_path_kentucky)
end
create_site_structure() click to toggle source
# File lib/kentucky/generator.rb, line 45
def create_site_structure
  make_install_directory
  if options[:dir]
    dirs = %w(images scripts scss css)
    dirs.each do |dir|
      FileUtils.mkdir(install_path + Pathname.new(dir))
    end
  end
  create_kentucky_directory
end
install_files() click to toggle source
# File lib/kentucky/generator.rb, line 79
def install_files
  copy_in_scss_files
end
install_path() click to toggle source
# File lib/kentucky/generator.rb, line 68
def install_path
  if options[:path]
    path = Pathname.new(options[:path])
  else
    path = Pathname.new('.')
  end

  @install_path = path
  return path
end
install_path_kentucky() click to toggle source
# File lib/kentucky/generator.rb, line 96
def install_path_kentucky
  return install_path_scss + Pathname.new("kentucky")
end
install_path_scss() click to toggle source
# File lib/kentucky/generator.rb, line 88
def install_path_scss
  if options[:dir]
    return install_path + Pathname.new("scss")
  else
    return install_path
  end
end
kentucky_directory() click to toggle source
# File lib/kentucky/generator.rb, line 112
def kentucky_directory
  File.join(stylesheets_directory, "kentucky")
end
kentucky_files_already_exist?() click to toggle source
# File lib/kentucky/generator.rb, line 41
def kentucky_files_already_exist?
  install_path_kentucky.exist?
end
kentucky_stylesheets() click to toggle source
# File lib/kentucky/generator.rb, line 104
def kentucky_stylesheets
  Dir["#{kentucky_directory}/*"]
end
make_install_directory() click to toggle source
# File lib/kentucky/generator.rb, line 56
def make_install_directory
  FileUtils.mkdir_p(install_path)
end
master_stylesheet() click to toggle source
# File lib/kentucky/generator.rb, line 100
def master_stylesheet
  Dir["#{stylesheets_directory}/style.scss"]
end
remove_kentucky_directory() click to toggle source
# File lib/kentucky/generator.rb, line 64
def remove_kentucky_directory
  FileUtils.rm_rf(install_path_kentucky)
end
stylesheets_directory() click to toggle source
# File lib/kentucky/generator.rb, line 116
def stylesheets_directory
  File.join(top_level_directory, "app", "assets", "stylesheets")
end
top_level_directory() click to toggle source
# File lib/kentucky/generator.rb, line 120
def top_level_directory
  File.dirname(File.dirname(File.dirname(__FILE__)))
end