entropi-bootstrap-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +7 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +21 -0
  5. data/README.rdoc +87 -0
  6. data/Rakefile +12 -0
  7. data/bootstrap-rails.gemspec +32 -0
  8. data/features/bootstrap_layout.feature +12 -0
  9. data/features/bootstrap_scaffold.feature +80 -0
  10. data/features/step_definitions/common_steps.rb +62 -0
  11. data/features/step_definitions/rails_setup_steps.rb +6 -0
  12. data/features/support/env.rb +6 -0
  13. data/features/support/matchers.rb +7 -0
  14. data/lib/.DS_Store +0 -0
  15. data/lib/bootstrap-rails.rb +1 -0
  16. data/lib/bootstrap/rails.rb +10 -0
  17. data/lib/bootstrap/rails/engine.rb +7 -0
  18. data/lib/bootstrap/rails/railtie.rb +17 -0
  19. data/lib/bootstrap/rails/version.rb +9 -0
  20. data/lib/generators/.DS_Store +0 -0
  21. data/lib/generators/bootstrap.rb +28 -0
  22. data/lib/generators/bootstrap/.DS_Store +0 -0
  23. data/lib/generators/bootstrap/layout/USAGE +25 -0
  24. data/lib/generators/bootstrap/layout/layout_generator.rb +21 -0
  25. data/lib/generators/bootstrap/layout/templates/error_messages_helper.rb +23 -0
  26. data/lib/generators/bootstrap/layout/templates/layout.html.erb +29 -0
  27. data/lib/generators/bootstrap/layout/templates/layout_helper.rb +22 -0
  28. data/lib/generators/bootstrap/scaffold/.DS_Store +0 -0
  29. data/lib/generators/bootstrap/scaffold/USAGE +51 -0
  30. data/lib/generators/bootstrap/scaffold/scaffold_generator.rb +313 -0
  31. data/lib/generators/bootstrap/scaffold/templates/actions/create.rb +8 -0
  32. data/lib/generators/bootstrap/scaffold/templates/actions/destroy.rb +5 -0
  33. data/lib/generators/bootstrap/scaffold/templates/actions/edit.rb +3 -0
  34. data/lib/generators/bootstrap/scaffold/templates/actions/index.rb +3 -0
  35. data/lib/generators/bootstrap/scaffold/templates/actions/new.rb +3 -0
  36. data/lib/generators/bootstrap/scaffold/templates/actions/show.rb +3 -0
  37. data/lib/generators/bootstrap/scaffold/templates/actions/update.rb +8 -0
  38. data/lib/generators/bootstrap/scaffold/templates/controller.rb +3 -0
  39. data/lib/generators/bootstrap/scaffold/templates/fixtures.yml +9 -0
  40. data/lib/generators/bootstrap/scaffold/templates/helper.rb +2 -0
  41. data/lib/generators/bootstrap/scaffold/templates/migration.rb +16 -0
  42. data/lib/generators/bootstrap/scaffold/templates/model.rb +4 -0
  43. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/actions/create.rb +11 -0
  44. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
  45. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
  46. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/actions/index.rb +4 -0
  47. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/actions/new.rb +4 -0
  48. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/actions/show.rb +4 -0
  49. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/actions/update.rb +11 -0
  50. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/controller.rb +8 -0
  51. data/lib/generators/bootstrap/scaffold/templates/tests/rspec/model.rb +7 -0
  52. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/actions/create.rb +13 -0
  53. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
  54. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
  55. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/actions/index.rb +6 -0
  56. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/actions/new.rb +6 -0
  57. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/actions/show.rb +6 -0
  58. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/actions/update.rb +13 -0
  59. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/controller.rb +5 -0
  60. data/lib/generators/bootstrap/scaffold/templates/tests/shoulda/model.rb +7 -0
  61. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/actions/create.rb +11 -0
  62. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
  63. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/actions/edit.rb +4 -0
  64. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/actions/index.rb +4 -0
  65. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/actions/new.rb +4 -0
  66. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/actions/show.rb +4 -0
  67. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/actions/update.rb +11 -0
  68. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/controller.rb +5 -0
  69. data/lib/generators/bootstrap/scaffold/templates/tests/testunit/model.rb +7 -0
  70. data/lib/generators/bootstrap/scaffold/templates/views/erb/_form.html.erb +14 -0
  71. data/lib/generators/bootstrap/scaffold/templates/views/erb/edit.html.erb +14 -0
  72. data/lib/generators/bootstrap/scaffold/templates/views/erb/index.html.erb +39 -0
  73. data/lib/generators/bootstrap/scaffold/templates/views/erb/new.html.erb +7 -0
  74. data/lib/generators/bootstrap/scaffold/templates/views/erb/show.html.erb +23 -0
  75. data/vendor/assets/css/bootstrap.css +1987 -0
  76. data/vendor/assets/css/bootstrap.min.css +264 -0
  77. data/vendor/assets/css/jquery.bootstrap.css +140 -0
  78. data/vendor/assets/javascripts/bootstrap.js +103 -0
  79. data/vendor/assets/javascripts/jquery.bootstrap.js +143 -0
  80. data/vendor/assets/javascripts/jquery.tablesorter.2.0.5.js +0 -0
  81. metadata +227 -0
Binary file
@@ -0,0 +1,7 @@
1
+ Manifest
2
+ pkg
3
+ doc
4
+ *.gem
5
+ tmp/**/*
6
+ Gemfile.lock
7
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Dependencies specified in bootstrap-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Nicholas W. Watson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,87 @@
1
+ = Bootstrap Rails
2
+
3
+ This contains "Twitter's Bootstrap CSS":https://github.com/twitter/bootstrap and an accompanying JQuery Plugin for
4
+ utilizing things such as pop-overs and modals.
5
+
6
+ In addition, it as generators based off of Ryan Bates "nifty-generators":https://github.com/ryanb/nifty-generators/.
7
+ enables you to create fully styled user interfaces using Bootstrap CSS with very little effort.
8
+
9
+ == Setup
10
+
11
+ === Rails 3
12
+
13
+ Add the gem to your Gemfile.
14
+
15
+ gem "bootstrap-rails"
16
+
17
+ Then you can run any of the included generators.
18
+
19
+ rails g bootstrap:scaffold Recipe name:string index new
20
+
21
+ == Included Generators
22
+
23
+ * bootstrap:layout: generates generic layout, stylesheet, and helper files.
24
+ * bootstrap:scaffold: generates a controller and optional model/migration.
25
+
26
+ To view the README for each generator, run it with the +help+ option.
27
+
28
+ rails g bootstrap:layout --help
29
+
30
+ == Troubleshooting and FAQs
31
+
32
+ <b>What is the difference between bootstrap:scaffold and built-in scaffold?</b>
33
+
34
+ One of the primary differences is that bootstrap:scaffold allows you to choose which controller actions to generate.
35
+
36
+ rails g bootstrap:scaffold post name:string index new edit
37
+
38
+ There are a few changes to the generated code as well, such as no XML format by default.
39
+
40
+ It also offers support for Shoulda, and RSpec.
41
+
42
+
43
+ <b>I get "undefined method 'title'" error.</b>
44
+
45
+ Try running bootstrap:layout, that will generate this helper method. Or you can just change the templates to whatever approach you prefer for setting the title.
46
+
47
+
48
+ <b>I can't set new attributes in my model.</b>
49
+
50
+ Add the attribute to the attr_accessible line in the model.
51
+
52
+
53
+ <b>I get "undefined method 'root_url'" error.</b>
54
+
55
+ Some generators default redirecting to the root_url. Set this in your routes.rb file like this (substituting your controller name).
56
+
57
+ root :to => "home#index"
58
+
59
+
60
+ <b>I get a missing database error.</b>
61
+
62
+ Run <tt>rake db:migrate</tt>.
63
+
64
+
65
+ <b>I get a routing error when I try to submit a form.</b>
66
+
67
+ Try restarting your development server. Sometimes it doesn't detect the change in the routing.
68
+
69
+
70
+ <b>The tests/specs don't work.</b>
71
+
72
+ Make sure you have mocha installed and require it in your spec/test helper.
73
+
74
+ gem install mocha
75
+
76
+ # in spec_helper.rb
77
+ config.mock_with :mocha
78
+
79
+ # in test_helper.rb
80
+ require 'mocha'
81
+
82
+ == Found a bug?
83
+
84
+ If you are having a problem with Bootstrap Rails, first look at the FAQs above. If you still cannot resolve it, please submit an issue here.
85
+
86
+ http://github.com/entropillc/bootstrap-rails/issues
87
+
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'bundler'
4
+ require 'cucumber'
5
+ require 'cucumber/rake/task'
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ #Cucumber::Rake::Task.new(:features) do |t|
9
+ # t.cucumber_opts = "features --format progress"
10
+ #end
11
+
12
+ #task :default => :features
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bootstrap/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "entropi-bootstrap-rails"
6
+ s.version = Bootstrap::Rails::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Nicholas W. Watson"]
9
+ s.email = ["nwwatson@gmail.com"]
10
+ s.summary = "Use Bootstrap CSS Toolkit with BootSsrap Jquery plugin with Rails 3"
11
+ s.description = "This gem provides Boostrap CSS and a JQuery plugin interation for your Rails 3 application."
12
+
13
+ s.files = Dir["{lib,features,vendor}/**/*", "[A-Z]*"]
14
+
15
+ s.required_rubygems_version = ">= 1.3.6"
16
+ s.rubyforge_project = "bootstrap-rails"
17
+
18
+
19
+ s.add_dependency "railties", "~> 3.0"
20
+ s.add_dependency "thor", "~> 0.14"
21
+ s.add_dependency "jquery-rails", "~> 1.0.14"
22
+ s.add_development_dependency 'rspec-rails', '~> 2.6.1'
23
+ s.add_development_dependency 'cucumber', '~> 1.0.6'
24
+ s.add_development_dependency 'rails', '~> 3.1.0'
25
+ s.add_development_dependency 'mocha', '~> 0.10.0'
26
+ s.add_development_dependency 'sqlite3-ruby', '~> 1.3.1'
27
+ s.add_development_dependency "bundler", "~> 1.0.0"
28
+
29
+ s.files = `git ls-files`.split("\n")
30
+ s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
31
+ s.require_path = 'lib'
32
+ end
@@ -0,0 +1,12 @@
1
+ Feature: Bootstrap Layout Generator
2
+ In order to have a layout
3
+ As a rails developer
4
+ I want to generate a simple layout
5
+
6
+ Scenario: Generate normal application layout
7
+ Given a new Rails app
8
+ When I run "rails g bootstrap:layout -f"
9
+ Then I should see "stylesheet_link_tag "application"" in file "app/views/layouts/application.html.erb"
10
+ Then I should see "h(page_title" in file "app/helpers/layout_helper.rb"
11
+ And I should see file "app/helpers/layout_helper.rb"
12
+ And I should see file "app/helpers/error_messages_helper.rb"
@@ -0,0 +1,80 @@
1
+ Feature: Bootstrap Scaffold Generator
2
+ In order to manage a resource
3
+ As a rails developer
4
+ I want to generate a model, controller, and views for that resource
5
+
6
+ Scenario: Generate scaffold for simple resource
7
+ Given a new Rails app
8
+ When I run "rails g bootstrap:scaffold Project name:string"
9
+ Then I should see the following files
10
+ | app/models/project.rb |
11
+ | app/controllers/projects_controller.rb |
12
+ | app/helpers/projects_helper.rb |
13
+ | app/views/projects/index.html.erb |
14
+ | app/views/projects/show.html.erb |
15
+ | app/views/projects/new.html.erb |
16
+ | app/views/projects/edit.html.erb |
17
+ | db/migrate |
18
+ And I should see "resources :projects" in file "config/routes.rb"
19
+ And I should see "gem "mocha", :group => :test" in file "Gemfile"
20
+ When I run "rails g bootstrap:layout -f"
21
+ And I run "rake db:migrate"
22
+ And I should successfully run "rails g bootstrap:scaffold Project -f"
23
+ Then I should successfully run "rake test"
24
+
25
+ Scenario: Generate scaffold with rspec tests
26
+ Given a new Rails app
27
+ When I run "rails g bootstrap:scaffold Project name:string --rspec"
28
+ Then I should see the following files
29
+ | spec/models/project_spec.rb |
30
+ | spec/controllers/projects_controller_spec.rb |
31
+ When I run "rails g bootstrap:scaffold Task project_id:integer"
32
+ Then I should see the following files
33
+ | spec/models/task_spec.rb |
34
+ | spec/controllers/tasks_controller_spec.rb |
35
+ When I run "rails g bootstrap:layout -f"
36
+ And I run "rake db:migrate"
37
+ And I add "gem 'rspec-rails', '>= 2.6.1'" to file "Gemfile"
38
+ And I run "rails g rspec:install"
39
+ And I replace "mock_with :rspec" with "mock_with :mocha" in file "spec/spec_helper.rb"
40
+ Then I should successfully run "rake spec"
41
+
42
+ Scenario: Report error when invalid model name
43
+ Given a new Rails app
44
+ Then I should see "Usage:" when running "rails g bootstrap:scaffold name:string parent_id:integer"
45
+
46
+ Scenario: Generate scaffold for namespaced resource
47
+ Given a new Rails app
48
+ When I run "rails g bootstrap:scaffold Admin::User name:string"
49
+ Then I should see the following files
50
+ | app/models/user.rb |
51
+ | app/controllers/admin/users_controller.rb |
52
+ | app/helpers/admin/users_helper.rb |
53
+ | app/views/admin/users/index.html.erb |
54
+ | app/views/admin/users/show.html.erb |
55
+ | app/views/admin/users/new.html.erb |
56
+ | app/views/admin/users/edit.html.erb |
57
+ | db/migrate |
58
+ And I should see "class User" in file "app/models/user.rb"
59
+ And I should not see "set_table_name :" in file "app/models/user.rb"
60
+ And I should see "namespace(:admin){ resources :users }" in file "config/routes.rb"
61
+ When I run "rails g bootstrap:layout -f"
62
+ And I run "rake db:migrate"
63
+ And I should successfully run "rails g bootstrap:scaffold Admin::User -f"
64
+ Then I should successfully run "rake test"
65
+
66
+ Scenario: Generate scaffold with a namespaced model
67
+ Given a new Rails app
68
+ When I run "rails g bootstrap:scaffold Admin::User name:string --namespace_model"
69
+ Then I should see "class Admin::User" in file "app/models/admin/user.rb"
70
+ And I should see "set_table_name :admin_users" in file "app/models/admin/user.rb"
71
+ When I run "rails g bootstrap:layout -f"
72
+ And I run "rake db:migrate"
73
+ And I should successfully run "rails g bootstrap:scaffold Admin::User -f --namespace_model"
74
+ Then I should successfully run "rake test"
75
+
76
+ Scenario: Given scaffold with a new and index action
77
+ Given a new Rails app
78
+ When I run "rails g bootstrap:scaffold Project name:string index new"
79
+ Then I should see "class Project" in file "app/models/project.rb"
80
+ And I should see "<%= form_for @project do |f| %>" in file "app/views/projects/new.html.erb"
@@ -0,0 +1,62 @@
1
+ When /^I run "([^\"]*)"$/ do |command|
2
+ system("cd #{@current_directory} && #{command}").should be_true
3
+ end
4
+
5
+ When /^I add "([^\"]*)" to file "([^\"]*)"$/ do |content, short_path|
6
+ path = File.join(@current_directory, short_path)
7
+ File.should exist(path)
8
+ File.open(path, 'a') { |f| f.write(content + "\n") }
9
+ end
10
+
11
+ When /^I replace "([^\"]*)" with "([^\"]*)" in file "([^\"]*)"$/ do |old_content, new_content, short_path|
12
+ path = File.join(@current_directory, short_path)
13
+ File.should exist(path)
14
+ content = File.read(path).gsub(old_content, new_content)
15
+ File.open(path, 'w') { |f| f.write(content) }
16
+ end
17
+
18
+ When /^I insert "([^\"]*)" into "([^\"]*)" after line (\d+)$/ do |content, short_path, after_line|
19
+ path = File.join(@current_directory, short_path)
20
+ File.should exist(path)
21
+ lines = File.read(path).split("\n")
22
+ lines[after_line.to_i, 0] = content
23
+ File.open(path, 'w') { |f| f.write(lines.join("\n")) }
24
+ end
25
+
26
+ Then /^I should see file "([^\"]*)"$/ do |path|
27
+ File.should exist(File.join(@current_directory, path))
28
+ end
29
+
30
+ Then /^I should see "(.*)" in file "([^\"]*)"$/ do |content, short_path|
31
+ path = File.join(@current_directory, short_path)
32
+ File.should exist(path)
33
+ File.readlines(path).join.should include(content)
34
+ end
35
+
36
+ Then /^I should not see "(.*)" in file "([^\"]*)"$/ do |content, short_path|
37
+ path = File.join(@current_directory, short_path)
38
+ File.should exist(path)
39
+ File.readlines(path).join.should_not include(content)
40
+ end
41
+
42
+ Then /^I should see the following files$/ do |table|
43
+ table.raw.flatten.each do |path|
44
+ File.should exist(File.join(@current_directory, path))
45
+ end
46
+ end
47
+
48
+ Then /^I should see the following in file "([^\"]*)"$/ do |short_path, table|
49
+ path = File.join(@current_directory, short_path)
50
+ File.should exist(path)
51
+ table.raw.flatten.each do |content|
52
+ File.readlines(path).join.should include(content)
53
+ end
54
+ end
55
+
56
+ Then /^I should successfully run "([^\"]*)"$/ do |command|
57
+ system("cd #{@current_directory} && #{command}").should be_true
58
+ end
59
+
60
+ Then /^I should see "([^\"]*)" when running "([^\"]*)"$/ do |expected_response, command|
61
+ `cd #{@current_directory} && #{command}`.should include(expected_response)
62
+ end
@@ -0,0 +1,6 @@
1
+ Given /^a new Rails app$/ do
2
+ FileUtils.mkdir_p("tmp")
3
+ system("rails new tmp/rails_app").should be_true
4
+ system("ln -s ../../../lib/generators tmp/rails_app/lib/generators").should be_true
5
+ @current_directory = File.expand_path("tmp/rails_app")
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'cucumber'
2
+ require 'rspec'
3
+
4
+ Before do
5
+ FileUtils.rm_rf "tmp/rails_app"
6
+ end
@@ -0,0 +1,7 @@
1
+ RSpec::Matchers.define :exist do |path|
2
+ match do
3
+ File.exist?(path)
4
+ end
5
+ failure_message_for_should { "Expected #{path} to exist but no file found" }
6
+ failure_message_for_should_not { "Expected #{path} to not exist but file was found" }
7
+ end
Binary file
@@ -0,0 +1 @@
1
+ require 'bootstrap/rails'
@@ -0,0 +1,10 @@
1
+ module Bootstrap
2
+ module Rails
3
+ if ::Rails.version < "3.1"
4
+ require 'bootstrap/rails/railtie'
5
+ else
6
+ require 'bootstrap/rails/engine'
7
+ end
8
+ require 'bootstrap/rails/version'
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Bootstrap
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ # Configure Rails 3.0 to use public/javascripts/jquery et al
2
+ module Bootstrap
3
+ module Rails
4
+
5
+ class Railtie < ::Rails::Railtie
6
+ config.before_configuration do
7
+
8
+ bootstrap_css_defaults = %w(bootstrap, jquery.bootstrap)
9
+ boostrap_js_defaults = %w(jquery.boostrap.js, jquery.tablesorter)
10
+
11
+ config.action_view.stylesheet_expansions[:defaults] |= bootstrap_css_defaults
12
+ config.action_view.javascript_expansions[:defaults] |= boostrap_js_defaults
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Bootstrap
2
+ module Rails
3
+ VERSION = "0.1.0"
4
+ JQUERY_RAILS = "1.6.2"
5
+ JQUERY_TABLESORTER = "2.0.5"
6
+ BOOTSTRAP_VERSION = "1.2.0"
7
+ BOOTSTRAP_JS = "0"
8
+ end
9
+ end
Binary file
@@ -0,0 +1,28 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Bootstrap
4
+ module Generators
5
+ class Base < ::Rails::Generators::Base
6
+ def self.source_root
7
+ @_bootstrap_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'bootstrap', generator_name, 'templates'))
8
+ end
9
+
10
+ def self.banner
11
+ "rails generate bootstrap:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
12
+ end
13
+
14
+ private
15
+
16
+ def add_gem(name, options = {})
17
+ gemfile_content = File.read(destination_path("Gemfile"))
18
+ File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
19
+ gem name, options unless gemfile_content.include? name
20
+ end
21
+
22
+ def print_usage
23
+ self.class.help(Thor::Base.shell.new)
24
+ exit
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ Description:
2
+ The bootstrap_layout generator creates a basic layout, stylesheet and
3
+ helper which will give some structure to a starting Rails app.
4
+
5
+ The generator takes one argument which will be the name of the
6
+ layout and stylesheet files. If no argument is passed then it defaults
7
+ to "application".
8
+
9
+ The helper module includes some methods which can be called in any
10
+ template or partial to set variables to be used in the layout, such as
11
+ page title and javascript/stylesheet includes.
12
+
13
+ Examples:
14
+ rails generate bootstrap:layout
15
+
16
+ Layout: app/views/layouts/application.html.erb
17
+ Stylesheet: public/stylesheets/application.css
18
+ Helper: app/helpers/layout_helper.rb
19
+
20
+
21
+ rails generate bootstrap:layout admin
22
+
23
+ Layout: app/views/layouts/admin.html.erb
24
+ Stylesheet: public/stylesheets/admin.css
25
+ Helper: app/helpers/layout_helper.rb