Class: Refinery::RecommendationsGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/generators/refinery/recommendations_generator.rb', line 22

def add_assets
  #insert_into_file "app/assets/javascripts/application.js", "//= require recommendations \n", :after => "jquery_ujs\n"

  # Add our own require:
  content = File.read("app/assets/stylesheets/application.css")
  if content.match(/require_tree\s+\.\s*$/)
    # Good enough - that'll include our recommendationd.css
  else
    style_require_block = " *= require recommendations\n"
    insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
  end
  
  #copy_file "recommendations.js", "app/assets/javascripts/recommendations.js"
  #copy_file "recommendations.css.scss", "app/assets/stylesheets/recommendations.css.scss"
  #directory 'images', 'app/assets/images'
  directory 'helpers', 'app/helpers'
end

#append_load_seed_dataObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/refinery/recommendations_generator.rb', line 11

def append_load_seed_data
  create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
  append_file 'db/seeds.rb', :verbose => true do
    <<-EOH

# Added by Refinery CMS Recommendations extension
Refinery::Recommendations::Engine.load_seed
    EOH
  end
end

#rake_dbObject



7
8
9
# File 'lib/generators/refinery/recommendations_generator.rb', line 7

def rake_db
  rake("refinery_recommendations:install:migrations")
end