bootstrap-generators 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -4
- data/bootstrap-generators.gemspec +0 -1
- data/lib/bootstrap-generators.rb +2 -0
- data/lib/bootstrap/generators/version.rb +1 -1
- data/lib/generators/bootstrap/install/install_generator.rb +0 -8
- data/lib/generators/bootstrap/install/templates/lib/templates/erb/controller/view.html.erb +4 -0
- data/lib/generators/bootstrap/install/templates/lib/templates/erb/scaffold/_form.html.erb +19 -11
- data/test/lib/generators/bootstrap/install_generator_test.rb +21 -0
- data/test/test_helper.rb +1 -41
- metadata +13 -31
- data/lib/generators/bootstrap/install/templates/app/inputs/boolean_input.rb +0 -11
- data/lib/generators/bootstrap/install/templates/app/inputs/date_time_input.rb +0 -11
- data/lib/generators/bootstrap/install/templates/app/inputs/mapping_input.rb +0 -11
- data/lib/generators/bootstrap/install/templates/app/inputs/string_input.rb +0 -11
- data/lib/generators/bootstrap/install/templates/app/inputs/text_input.rb +0 -11
- data/lib/generators/bootstrap/install/templates/config/initializers/simple_form.rb +0 -93
- data/test/lib/generators/erubis/controller_generator_test.rb +0 -17
- data/test/lib/generators/erubis/scaffold_generator_test.rb +0 -31
data/README.md
CHANGED
@@ -6,10 +6,8 @@ Add it to your Gemfile:
|
|
6
6
|
|
7
7
|
`gem "bootstrap-generators"`
|
8
8
|
|
9
|
-
Add simple_form to your Gemfile
|
10
|
-
|
11
|
-
`gem "simple_form"`
|
12
|
-
|
13
9
|
Run the generator:
|
14
10
|
|
15
11
|
`rails generate bootstrap:install`
|
12
|
+
|
13
|
+
Once you've done that, any time you generate a controller or scaffold, you'll get [Bootstrap](http://twitter.github.com/bootstrap/) templates.
|
data/lib/bootstrap-generators.rb
CHANGED
@@ -6,14 +6,6 @@ module Bootstrap
|
|
6
6
|
desc "Copy BootstrapGenerators default files"
|
7
7
|
source_root File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
|
-
def copy_simple_form_inputs
|
10
|
-
directory 'app'
|
11
|
-
end
|
12
|
-
|
13
|
-
def copy_simple_form_config
|
14
|
-
directory 'config'
|
15
|
-
end
|
16
|
-
|
17
9
|
def copy_lib
|
18
10
|
directory 'lib'
|
19
11
|
end
|
@@ -1,17 +1,25 @@
|
|
1
|
-
<%%=
|
2
|
-
<%% if
|
3
|
-
<div class="alert-message error">
|
4
|
-
|
1
|
+
<%%= form_for(@<%= singular_table_name %>) do |f| %>
|
2
|
+
<%% if @<%= singular_table_name %>.errors.any? %>
|
3
|
+
<div class="alert-message block-message error">
|
4
|
+
<p><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</p>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%%= msg %></li>
|
9
|
+
<%% end %>
|
10
|
+
</ul>
|
5
11
|
</div>
|
6
12
|
<%% end %>
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
<%%= f
|
11
|
-
|
14
|
+
<% attributes.each do |attribute| -%>
|
15
|
+
<div class="clearfix">
|
16
|
+
<%%= f.label :<%= attribute.name %> %>
|
17
|
+
<div class="input">
|
18
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %>, :class => "<%= [:datetime_select, :date_select].include?(attribute.field_type) ? 'small' : 'xxlarge' %>" %>
|
19
|
+
</div>
|
12
20
|
</div>
|
13
|
-
|
21
|
+
<% end -%>
|
14
22
|
<div class="actions">
|
15
|
-
<%%= f.
|
23
|
+
<%%= f.submit :class => "btn primary" %>
|
16
24
|
</div>
|
17
|
-
<%% end %>
|
25
|
+
<%% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Bootstrap::Generators::InstallGeneratorTest < ::Rails::Generators::TestCase
|
4
|
+
destination File.join(Rails.root)
|
5
|
+
tests Bootstrap::Generators::InstallGenerator
|
6
|
+
|
7
|
+
setup :prepare_destination
|
8
|
+
setup :copy_routes
|
9
|
+
|
10
|
+
test "should copy controller templates" do
|
11
|
+
run_generator
|
12
|
+
|
13
|
+
assert_file "lib/templates/erb/controller/view.html.erb"
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should copy scaffold templates" do
|
17
|
+
run_generator
|
18
|
+
|
19
|
+
%w(index edit new show _form).each { |view| assert_file "lib/templates/erb/scaffold/#{view}.html.erb" }
|
20
|
+
end
|
21
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -31,44 +31,4 @@ def copy_routes
|
|
31
31
|
FileUtils.cp File.expand_path(routes), destination
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
# it yields the content of the class.
|
36
|
-
#
|
37
|
-
# assert_file "test/functional/accounts_controller_test.rb" do |controller_test|
|
38
|
-
# assert_class "AccountsControllerTest", controller_test do |klass|
|
39
|
-
# assert_match /context "index action"/, klass
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
#
|
43
|
-
def assert_class(klass, content)
|
44
|
-
assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/m, "Expected to have class #{klass}"
|
45
|
-
yield $2.strip if block_given?
|
46
|
-
end
|
47
|
-
|
48
|
-
def generator_list
|
49
|
-
{
|
50
|
-
:rails => ['scaffold', 'controller'],
|
51
|
-
:erubis => ['scaffold']
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
def path_prefix(name)
|
56
|
-
case name
|
57
|
-
when :rails
|
58
|
-
'rails/generators'
|
59
|
-
else
|
60
|
-
'generators'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def require_generators(generator_list)
|
65
|
-
generator_list.each do |name, generators|
|
66
|
-
generators.each do |generator_name|
|
67
|
-
require File.join(path_prefix(name), name.to_s, generator_name.to_s, "#{generator_name}_generator")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
alias :require_generator :require_generators
|
72
|
-
|
73
|
-
require_generators generator_list
|
74
|
-
|
34
|
+
require 'generators/bootstrap/install/install_generator'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152076780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152076780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: test-unit
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152089360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152089360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152102240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152102240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: railties
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152243120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,18 +54,7 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: simple_form
|
60
|
-
requirement: &2152253220 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.5.0
|
66
|
-
type: :runtime
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *2152253220
|
57
|
+
version_requirements: *2152243120
|
69
58
|
description: Bootstrap-generators provides Twitter Bootstrap generators for Rails
|
70
59
|
3. Bootstrap is a toolkit from Twitter designed to kickstart development of webapps
|
71
60
|
and sites. Checkout http://twitter.github.com/bootstrap.
|
@@ -85,23 +74,17 @@ files:
|
|
85
74
|
- lib/bootstrap/generators/railtie.rb
|
86
75
|
- lib/bootstrap/generators/version.rb
|
87
76
|
- lib/generators/bootstrap/install/install_generator.rb
|
88
|
-
- lib/generators/bootstrap/install/templates/app/inputs/boolean_input.rb
|
89
|
-
- lib/generators/bootstrap/install/templates/app/inputs/date_time_input.rb
|
90
|
-
- lib/generators/bootstrap/install/templates/app/inputs/mapping_input.rb
|
91
|
-
- lib/generators/bootstrap/install/templates/app/inputs/string_input.rb
|
92
|
-
- lib/generators/bootstrap/install/templates/app/inputs/text_input.rb
|
93
77
|
- lib/generators/bootstrap/install/templates/application.html.erb
|
94
78
|
- lib/generators/bootstrap/install/templates/bootstrap-generators.css.scss
|
95
79
|
- lib/generators/bootstrap/install/templates/bootstrap-generators.js
|
96
|
-
- lib/generators/bootstrap/install/templates/
|
80
|
+
- lib/generators/bootstrap/install/templates/lib/templates/erb/controller/view.html.erb
|
97
81
|
- lib/generators/bootstrap/install/templates/lib/templates/erb/scaffold/_form.html.erb
|
98
82
|
- lib/generators/bootstrap/install/templates/lib/templates/erb/scaffold/edit.html.erb
|
99
83
|
- lib/generators/bootstrap/install/templates/lib/templates/erb/scaffold/index.html.erb
|
100
84
|
- lib/generators/bootstrap/install/templates/lib/templates/erb/scaffold/new.html.erb
|
101
85
|
- lib/generators/bootstrap/install/templates/lib/templates/erb/scaffold/show.html.erb
|
102
86
|
- test/fixtures/routes.rb
|
103
|
-
- test/lib/generators/
|
104
|
-
- test/lib/generators/erubis/scaffold_generator_test.rb
|
87
|
+
- test/lib/generators/bootstrap/install_generator_test.rb
|
105
88
|
- test/test_helper.rb
|
106
89
|
- vendor/assets/javascripts/bootstrap-alerts.js
|
107
90
|
- vendor/assets/javascripts/bootstrap-dropdown.js
|
@@ -139,6 +122,5 @@ specification_version: 3
|
|
139
122
|
summary: Bootstrap-generators provides Twitter Bootstrap generators for Rails 3.
|
140
123
|
test_files:
|
141
124
|
- test/fixtures/routes.rb
|
142
|
-
- test/lib/generators/
|
143
|
-
- test/lib/generators/erubis/scaffold_generator_test.rb
|
125
|
+
- test/lib/generators/bootstrap/install_generator_test.rb
|
144
126
|
- test/test_helper.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class BooleanInput < SimpleForm::Inputs::BooleanInput
|
2
|
-
def label_input
|
3
|
-
content = "".html_safe
|
4
|
-
[ :input, :error, :hint ].each do |component|
|
5
|
-
next if options[component] == false
|
6
|
-
rendered = send(component)
|
7
|
-
content.safe_concat rendered.to_s if rendered
|
8
|
-
end
|
9
|
-
(options[:label] == false ? "" : label) + "<div class=\"input\"><ul class=\"inputs-list\"><li><label>#{content}</label></li></ul></div>".html_safe
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class DateTimeInput < SimpleForm::Inputs::DateTimeInput
|
2
|
-
def label_input
|
3
|
-
content = "".html_safe
|
4
|
-
[ :input, :error, :hint ].each do |component|
|
5
|
-
next if options[component] == false
|
6
|
-
rendered = send(component)
|
7
|
-
content.safe_concat rendered.to_s if rendered
|
8
|
-
end
|
9
|
-
(options[:label] == false ? "" : label) + "<div class=\"input\">#{content}</div>".html_safe
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class MappingInput < SimpleForm::Inputs::MappingInput
|
2
|
-
def label_input
|
3
|
-
content = "".html_safe
|
4
|
-
[ :input, :error, :hint ].each do |component|
|
5
|
-
next if options[component] == false
|
6
|
-
rendered = send(component)
|
7
|
-
content.safe_concat rendered.to_s if rendered
|
8
|
-
end
|
9
|
-
(options[:label] == false ? "" : label) + "<div class=\"input\">#{content}</div>".html_safe
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class StringInput < SimpleForm::Inputs::StringInput
|
2
|
-
def label_input
|
3
|
-
content = "".html_safe
|
4
|
-
[ :input, :error, :hint ].each do |component|
|
5
|
-
next if options[component] == false
|
6
|
-
rendered = send(component)
|
7
|
-
content.safe_concat rendered.to_s if rendered
|
8
|
-
end
|
9
|
-
(options[:label] == false ? "" : label) + "<div class=\"input\">#{content}</div>".html_safe
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class TextInput < SimpleForm::Inputs::TextInput
|
2
|
-
def label_input
|
3
|
-
content = "".html_safe
|
4
|
-
[ :input, :error, :hint ].each do |component|
|
5
|
-
next if options[component] == false
|
6
|
-
rendered = send(component)
|
7
|
-
content.safe_concat rendered.to_s if rendered
|
8
|
-
end
|
9
|
-
(options[:label] == false ? "" : label) + "<div class=\"input\">#{content}</div>".html_safe
|
10
|
-
end
|
11
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# Use this setup block to configure all options available in SimpleForm.
|
2
|
-
SimpleForm.setup do |config|
|
3
|
-
# Components used by the form builder to generate a complete input. You can remove
|
4
|
-
# any of them, change the order, or even add your own components to the stack.
|
5
|
-
config.components = [ :placeholder, :label_input ]
|
6
|
-
|
7
|
-
# Default tag used on hints.
|
8
|
-
# config.hint_tag = :span
|
9
|
-
|
10
|
-
# CSS class to add to all hint tags.
|
11
|
-
config.hint_class = :"help-block"
|
12
|
-
|
13
|
-
# CSS class used on errors.
|
14
|
-
config.error_class = :"help-inline"
|
15
|
-
|
16
|
-
# Default tag used on errors.
|
17
|
-
# config.error_tag = :span
|
18
|
-
|
19
|
-
# Method used to tidy up errors.
|
20
|
-
# config.error_method = :first
|
21
|
-
|
22
|
-
# Default tag used for error notification helper.
|
23
|
-
# config.error_notification_tag = :p
|
24
|
-
|
25
|
-
# CSS class to add for error notification helper.
|
26
|
-
# config.error_notification_class = :error_notification
|
27
|
-
|
28
|
-
# ID to add for error notification helper.
|
29
|
-
# config.error_notification_id = nil
|
30
|
-
|
31
|
-
# You can wrap all inputs in a pre-defined tag.
|
32
|
-
# config.wrapper_tag = :div
|
33
|
-
|
34
|
-
# CSS class to add to all wrapper tags.
|
35
|
-
config.wrapper_class = :clearfix
|
36
|
-
|
37
|
-
# CSS class to add to the wrapper if the field has errors.
|
38
|
-
config.wrapper_error_class = :error
|
39
|
-
|
40
|
-
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
41
|
-
# config.collection_wrapper_tag = nil
|
42
|
-
|
43
|
-
# You can wrap each item in a collection of radio/check boxes with a tag, defaulting to span.
|
44
|
-
# config.item_wrapper_tag = :span
|
45
|
-
|
46
|
-
# Series of attempts to detect a default label method for collection.
|
47
|
-
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
48
|
-
|
49
|
-
# Series of attempts to detect a default value method for collection.
|
50
|
-
# config.collection_value_methods = [ :id, :to_s ]
|
51
|
-
|
52
|
-
# How the label text should be generated altogether with the required text.
|
53
|
-
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
54
|
-
|
55
|
-
# You can define the class to use on all labels. Default is nil.
|
56
|
-
# config.label_class = nil
|
57
|
-
|
58
|
-
# You can define the class to use on all forms. Default is simple_form.
|
59
|
-
# config.form_class = :"form-stacked"
|
60
|
-
|
61
|
-
# Whether attributes are required by default (or not). Default is true.
|
62
|
-
# config.required_by_default = true
|
63
|
-
|
64
|
-
# Tell browsers whether to use default HTML5 validations (novalidate option).
|
65
|
-
# Default is enabled.
|
66
|
-
# config.browser_validations = true
|
67
|
-
|
68
|
-
# Determines whether HTML5 types (:email, :url, :search, :tel) and attributes
|
69
|
-
# (e.g. required) are used or not. True by default.
|
70
|
-
# Having this on in non-HTML5 compliant sites can cause odd behavior in
|
71
|
-
# HTML5-aware browsers such as Chrome.
|
72
|
-
# config.html5 = true
|
73
|
-
|
74
|
-
# Custom mappings for input types. This should be a hash containing a regexp
|
75
|
-
# to match as key, and the input type that will be used when the field name
|
76
|
-
# matches the regexp as value.
|
77
|
-
# config.input_mappings = { /count/ => :integer }
|
78
|
-
|
79
|
-
# Collection of methods to detect if a file type was given.
|
80
|
-
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
81
|
-
|
82
|
-
# Default priority for time_zone inputs.
|
83
|
-
# config.time_zone_priority = nil
|
84
|
-
|
85
|
-
# Default priority for country inputs.
|
86
|
-
# config.country_priority = nil
|
87
|
-
|
88
|
-
# Default size for text inputs.
|
89
|
-
# config.default_input_size = 50
|
90
|
-
|
91
|
-
# When false, do not use translations for labels, hints or placeholders.
|
92
|
-
# config.translate = true
|
93
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Erubis::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
|
4
|
-
destination File.join(Rails.root)
|
5
|
-
tests Rails::Generators::ControllerGenerator
|
6
|
-
arguments %w(Account foo bar --template-engine erubis)
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
setup :copy_routes
|
10
|
-
|
11
|
-
test "should invoke template engine" do
|
12
|
-
run_generator
|
13
|
-
assert_file "app/views/account/foo.html.erb", %r(app/views/account/foo\.html\.erb)
|
14
|
-
assert_file "app/views/account/bar.html.erb", %r(app/views/account/bar\.html\.erb)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Erubis::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
|
4
|
-
destination File.join(Rails.root)
|
5
|
-
tests Rails::Generators::ScaffoldGenerator
|
6
|
-
arguments %w(product_line title:string price:integer --template-engine erubis)
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
setup :copy_routes
|
10
|
-
|
11
|
-
test "should invoke template engine" do
|
12
|
-
run_generator
|
13
|
-
|
14
|
-
%w(index edit new show _form).each { |view| assert_file "app/views/product_lines/#{view}.html.erb" }
|
15
|
-
assert_no_file "app/views/layouts/product_lines.html.erb"
|
16
|
-
end
|
17
|
-
|
18
|
-
test "should revoke template engine" do
|
19
|
-
run_generator
|
20
|
-
run_generator ["product_line"], :behavior => :revoke
|
21
|
-
|
22
|
-
assert_no_file "app/views/product_lines"
|
23
|
-
assert_no_file "app/views/layouts/product_lines.html.erb"
|
24
|
-
end
|
25
|
-
|
26
|
-
test "should invoke form builder" do
|
27
|
-
run_generator %w(product_line title:string price:integer --template-engine erubis --form-builder some-form-builder)
|
28
|
-
assert_no_file "app/views/product_lines/_form.html.erb"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|