Class: SmileGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/smile_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/smile_generator.rb', line 4

def create_initializer_file
  copy_file "smilies.yml", "#{Rails.root}/config/smilies.yml"

  if Dir.exists?("#{Rails.root}/app/assets/")
    FileUtils.mkpath("#{Rails.root}/app/assets/images/smilies")
    files = Dir.glob("#{File.expand_path('../templates/smilies', __FILE__)}/*")
    FileUtils.cp_r files, "#{Rails.root}/app/assets/images/smilies/"
    copy_file "smilies.css", "#{Rails.root}/app/assets/stylesheets/smilies.css"
  else
    FileUtils.mkpath("#{Rails.root}/public/images/smilies")
    files = Dir.glob("#{File.expand_path('../templates/smilies', __FILE__)}/*")
    FileUtils.cp_r files, "#{Rails.root}/public/images/smilies/"
    copy_file "smilies.css", "#{Rails.root}/public/stylesheets/smilies.css"
  end

  template "smileys.rb", "config/initializers/smileys.rb"
end