Class: Homeland::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_imagesObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/homeland/install_generator.rb', line 42

def add_images
  %w(jquery.chosen.png).each do |fname|
    path = "#{Rails.root}/vendor/assets/images/#{fname}"
    if File.exists?(path)
      puts "Skipping vendor/assets/images/#{fname} creation, as file already exists!"
    else
      puts "Adding assets (vendor/assets/images/#{fname})..."
      template "images/#{fname}", path
    end
  end
end

#add_initializerObject



8
9
10
11
12
13
14
15
16
# File 'lib/generators/homeland/install_generator.rb', line 8

def add_initializer
  path = "#{Rails.root}/config/initializers/homeland.rb"
  if File.exists?(path)
    puts "Skipping config/initializers/homeland.rb creation, as file already exists!"
  else
    puts "Adding Homeland initializer (config/initializers/homeland.rb)..."
    template "initializer.rb", path
  end
end

#add_javascriptsObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/homeland/install_generator.rb', line 18

def add_javascripts
  %w(jquery.hotkeys.js jquery.timeago.js jquery.chosen.js).each do |fname|
    path = "#{Rails.root}/vendor/assets/javascripts/#{fname}"
    if File.exists?(path)
      puts "Skipping vendor/assets/javascripts/#{fname} creation, as file already exists!"
    else
      puts "Adding assets (vendor/assets/javascripts/#{fname})..."
      template "javascripts/#{fname}", path
    end
  end
end

#add_localesObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/generators/homeland/install_generator.rb', line 54

def add_locales
  %w(zh-CN.yml).each do |fname|
    path = "#{Rails.root}/config/locales/homeland.#{fname}"
    if File.exists?(path)
      puts "Skipping config/locales/homeland.#{fname} creation, as file already exists!"
    else
      puts "Adding assets (config/locales/homeland.#{fname})..."
      template "locales/homeland.#{fname}", path
    end
  end
end

#add_stylesheetsObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/homeland/install_generator.rb', line 30

def add_stylesheets
  %w(jquery.chosen.scss).each do |fname|
    path = "#{Rails.root}/vendor/assets/stylesheets/#{fname}"
    if File.exists?(path)
      puts "Skipping vendor/assets/stylesheets/#{fname} creation, as file already exists!"
    else
      puts "Adding assets (vendor/assets/stylesheets/#{fname})..."
      template "stylesheets/#{fname}", path
    end
  end
end