class Styler::Generator

Public Instance Methods

install() click to toggle source
# File lib/styler/generator.rb, line 11
def install
  if styler_files_already_exist? && !options[:force]
    puts "styler files already installed, doing nothing."
  else
    install_files
    puts "styler files installed to #{install_path}/"
  end
end
remove() click to toggle source
# File lib/styler/generator.rb, line 39
def remove
  remove_styler_directory
end
update() click to toggle source
# File lib/styler/generator.rb, line 22
def update
  if styler_files_already_exist?
    remove_styler_directory
    install_files
    puts "styler files updated."
  else
    puts "No existing styler installation. Doing nothing."
  end
end
version() click to toggle source
# File lib/styler/generator.rb, line 33
def version
  say "Styler #{Styler::VERSION}"
end

Private Instance Methods

all_stylesheets() click to toggle source
# File lib/styler/generator.rb, line 77
def all_stylesheets
  Dir["#{stylesheets_directory}/*"]
end
copy_in_scss_files() click to toggle source
# File lib/styler/generator.rb, line 73
def copy_in_scss_files
  FileUtils.cp_r(all_stylesheets, install_path)
end
install_files() click to toggle source
# File lib/styler/generator.rb, line 60
def install_files
  make_install_directory
  copy_in_scss_files
end
install_path() click to toggle source
# File lib/styler/generator.rb, line 50
def install_path
  @install_path ||= if options[:path]
      Pathname.new(File.join(options[:path], 'vendor/assets/stylesheets/styler'))
      #Pathname.new(File.join(options[:path], 'styler'))
    else
      Pathname.new('vendor/assets/stylesheets/styler')
      #Pathname.new('styler')
    end
end
make_install_directory() click to toggle source
# File lib/styler/generator.rb, line 69
def make_install_directory
  FileUtils.mkdir_p(install_path)
end
remove_styler_directory() click to toggle source
# File lib/styler/generator.rb, line 65
def remove_styler_directory
  FileUtils.rm_rf("styler")
end
styler_files_already_exist?() click to toggle source
# File lib/styler/generator.rb, line 46
def styler_files_already_exist?
  install_path.exist?
end
stylesheets_directory() click to toggle source
# File lib/styler/generator.rb, line 81
def stylesheets_directory
  File.join(top_level_directory, "app", "assets", "stylesheets")
end
top_level_directory() click to toggle source
# File lib/styler/generator.rb, line 85
def top_level_directory
  File.dirname(File.dirname(File.dirname(__FILE__)))
end