Class: Venus::Generators::BootstrapGenerator
- Defined in:
- lib/generators/venus/bootstrap/bootstrap_generator.rb
Instance Method Summary collapse
- #asks ⇒ Object
- #assets ⇒ Object
- #copy_example_layout ⇒ Object
- #gemfile ⇒ Object
- #name ⇒ Object
- #simple_form_config ⇒ Object
- #unicorn ⇒ Object
Methods inherited from Base
next_migration_number, source_root
Instance Method Details
#asks ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/generators/venus/bootstrap/bootstrap_generator.rb', line 10 def asks @target_js = ask?('target content append for js file?', 'application.js') @target_css = ask?('target content append for css file?', 'application.css') @example_layout = ask?("Export example layout", 'bootstrap') @unicorn = ask?("Use theme unicorn admin", true) say 'checking dependent gems "simple_form"...' generate 'venus:simple_form' unless has_gem?('simple_form') end |
#assets ⇒ Object
24 25 26 27 28 |
# File 'lib/generators/venus/bootstrap/bootstrap_generator.rb', line 24 def assets css_assets_require(@target_css, "twitter/bootstrap") css_assets_require(@target_css, "twitter/bootstrap-responsive", :after => "twitter/bootstrap") js_assets_require(@target_js, "twitter/bootstrap") end |
#copy_example_layout ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/generators/venus/bootstrap/bootstrap_generator.rb', line 47 def copy_example_layout target_css = @target_css.gsub(".css", "").gsub(".scss", "").gsub(".sass", "") target_js = @target_js.gsub(".js", "").gsub(".coffee", "") to_file = "app/views/layouts/#{@example_layout}.html.erb" copy_file("img/glyphicons-halflings-white.png", "app/assets/images/img/glyphicons-halflings-white.png") copy_file("img/glyphicons-halflings.png", "app/assets/images/img/glyphicons-halflings.png") if @unicorn unicorn_file = "app/views/layouts/admin_unicorn.html.erb" copy_file("unicorn.layout", unicorn_file) replace_in_file(unicorn_file, "@target_css", target_css) replace_in_file(unicorn_file, "@target_js", target_js) copy_file("img/breadcrumb.png", "app/assets/images/img/breadcrumb.png") copy_file("img/menu-active.png", "app/assets/images/img/menu-active.png") puts "see more uncorn admin example: http://wrapbootstrap.com/preview/WB0F35928" end # copy origin bootstrap layout @unicorn = false copy_file("bootstrap.layout", to_file) replace_in_file(to_file, "@target_css", target_css) replace_in_file(to_file, "@target_js", target_js) puts "see more bootdtrap usage: http://twitter.github.com/bootstrap/" end |
#gemfile ⇒ Object
19 20 21 22 |
# File 'lib/generators/venus/bootstrap/bootstrap_generator.rb', line 19 def gemfile add_gem('anjlab-bootstrap-rails', ">= 2.3', :require => 'bootstrap-rails") bundle_install end |
#name ⇒ Object
6 7 8 |
# File 'lib/generators/venus/bootstrap/bootstrap_generator.rb', line 6 def name "bootstrap" end |
#simple_form_config ⇒ Object
42 43 44 45 |
# File 'lib/generators/venus/bootstrap/bootstrap_generator.rb', line 42 def simple_form_config to_file = "config/initializers/simple_form.rb" insert_template(to_file, "simple_form_config.erb", :before => "\nend\n") if has_file?(to_file) end |
#unicorn ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/venus/bootstrap/bootstrap_generator.rb', line 30 def unicorn if @unicorn template("unicorn.js", "app/assets/javascripts/unicorn.js") template("unicorn.main.css", "app/assets/stylesheets/unicorn.main.css") template("unicorn.grey.css", "app/assets/stylesheets/unicorn.grey.css") css_assets_require(@target_css, "unicorn.main", :after => "twitter/bootstrap-responsive") css_assets_require(@target_css, "unicorn.grey", :after => "unicorn.main") js_assets_require(@target_js, "unicorn", :after => "twitter/bootstrap") end end |