wrap_it 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -11
- data/.rspec +2 -0
- data/Gemfile +0 -3
- data/Gemfile.rails4 +5 -0
- data/Gemfile.sinatra +5 -0
- data/README.md +138 -24
- data/Rakefile +14 -1
- data/lib/wrap_it/base.rb +47 -20
- data/lib/wrap_it/callbacks.rb +10 -5
- data/lib/wrap_it/container.rb +91 -38
- data/lib/wrap_it/enums.rb +1 -1
- data/lib/wrap_it/frameworks.rb +24 -0
- data/lib/wrap_it/helpers.rb +74 -0
- data/lib/wrap_it/module_helpers.rb +23 -0
- data/lib/wrap_it/sections.rb +81 -0
- data/lib/wrap_it/switches.rb +11 -10
- data/lib/wrap_it/text_container.rb +6 -1
- data/lib/wrap_it/version.rb +1 -1
- data/lib/wrap_it.rb +9 -63
- data/log/development.log +174 -0
- data/sections_explained.md +70 -0
- data/spec/frameworks/log/development.log +1633 -0
- data/spec/frameworks/rails_app.rb +61 -0
- data/spec/frameworks/sinatra_app.rb +32 -0
- data/spec/{rails → integration}/base_spec.rb +7 -7
- data/spec/integration/container_spec.rb +92 -0
- data/spec/integration/examples_spec.rb +54 -0
- data/spec/integration/text_container_spec.rb +13 -0
- data/spec/lib/base_spec.rb +0 -6
- data/spec/lib/container_spec.rb +1 -6
- data/spec/lib/helpers_spec.rb +26 -0
- data/spec/lib/html_class_spec.rb +2 -2
- data/spec/lib/sections_spec.rb +72 -0
- data/spec/lib/text_container_spec.rb +19 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/example_groups/integration_example_group.rb +72 -0
- data/spec/support/example_groups/wrap_it_example_group.rb +6 -4
- data/wrap_it.gemspec +7 -4
- metadata +49 -25
- data/spec/internal/log/test.log +0 -619
- data/spec/rails/container_spec.rb +0 -30
- data/spec/support/example_groups/rails_example_group.rb +0 -79
data/log/development.log
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
Started GET "/test" for 127.0.0.1 at 2014-01-18 17:55:22 +0400
|
4
|
+
|
5
|
+
ActionController::RoutingError (No route matches [GET] "/test"):
|
6
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
|
7
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
|
8
|
+
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
|
9
|
+
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
|
10
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
|
11
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
|
12
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
|
13
|
+
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
|
14
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
|
15
|
+
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
|
16
|
+
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
|
17
|
+
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
|
18
|
+
rack (1.5.2) lib/rack/lock.rb:17:in `call'
|
19
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
|
20
|
+
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
|
21
|
+
railties (4.0.2) lib/rails/engine.rb:511:in `call'
|
22
|
+
railties (4.0.2) lib/rails/application.rb:97:in `call'
|
23
|
+
railties (4.0.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
|
24
|
+
rack-test (0.6.2) lib/rack/mock_session.rb:30:in `request'
|
25
|
+
rack-test (0.6.2) lib/rack/test.rb:230:in `process_request'
|
26
|
+
rack-test (0.6.2) lib/rack/test.rb:57:in `get'
|
27
|
+
/home/alexiss/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/forwardable.rb:171:in `get'
|
28
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:60:in `process'
|
29
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:35:in `process_and_follow_redirects'
|
30
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:21:in `visit'
|
31
|
+
capybara (2.2.1) lib/capybara/rack_test/driver.rb:42:in `visit'
|
32
|
+
capybara (2.2.1) lib/capybara/session.rb:197:in `visit'
|
33
|
+
capybara (2.2.1) lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
|
34
|
+
spec/integration_spec.rb:44:in `render'
|
35
|
+
spec/integration/text_container_spec.rb:6:in `block (3 levels) in <top (required)>'
|
36
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:114:in `instance_eval'
|
37
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:114:in `block in run'
|
38
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:254:in `with_around_each_hooks'
|
39
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:111:in `run'
|
40
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:390:in `block in run_examples'
|
41
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:386:in `map'
|
42
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:386:in `run_examples'
|
43
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:371:in `run'
|
44
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `block in run'
|
45
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `map'
|
46
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `run'
|
47
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `block in run'
|
48
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `map'
|
49
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `run'
|
50
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
|
51
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `map'
|
52
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `block in run'
|
53
|
+
rspec-core (2.14.7) lib/rspec/core/reporter.rb:58:in `report'
|
54
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:25:in `run'
|
55
|
+
rspec-core (2.14.7) lib/rspec/core/runner.rb:80:in `run'
|
56
|
+
rspec-core (2.14.7) lib/rspec/core/runner.rb:17:in `block in autorun'
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Started GET "/test" for 127.0.0.1 at 2014-01-18 18:22:38 +0400
|
62
|
+
|
63
|
+
ActionController::RoutingError (No route matches [GET] "/test"):
|
64
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
|
65
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
|
66
|
+
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
|
67
|
+
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
|
68
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
|
69
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
|
70
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
|
71
|
+
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
|
72
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
|
73
|
+
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
|
74
|
+
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
|
75
|
+
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
|
76
|
+
rack (1.5.2) lib/rack/lock.rb:17:in `call'
|
77
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
|
78
|
+
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
|
79
|
+
railties (4.0.2) lib/rails/engine.rb:511:in `call'
|
80
|
+
railties (4.0.2) lib/rails/application.rb:97:in `call'
|
81
|
+
railties (4.0.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
|
82
|
+
rack-test (0.6.2) lib/rack/mock_session.rb:30:in `request'
|
83
|
+
rack-test (0.6.2) lib/rack/test.rb:230:in `process_request'
|
84
|
+
rack-test (0.6.2) lib/rack/test.rb:57:in `get'
|
85
|
+
/home/alexiss/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/forwardable.rb:171:in `get'
|
86
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:60:in `process'
|
87
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:35:in `process_and_follow_redirects'
|
88
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:21:in `visit'
|
89
|
+
capybara (2.2.1) lib/capybara/rack_test/driver.rb:42:in `visit'
|
90
|
+
capybara (2.2.1) lib/capybara/session.rb:197:in `visit'
|
91
|
+
capybara (2.2.1) lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
|
92
|
+
spec/integration_spec.rb:44:in `render'
|
93
|
+
spec/integration/text_container_spec.rb:6:in `block (3 levels) in <top (required)>'
|
94
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:114:in `instance_eval'
|
95
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:114:in `block in run'
|
96
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:254:in `with_around_each_hooks'
|
97
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:111:in `run'
|
98
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:390:in `block in run_examples'
|
99
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:386:in `map'
|
100
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:386:in `run_examples'
|
101
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:371:in `run'
|
102
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `block in run'
|
103
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `map'
|
104
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `run'
|
105
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `block in run'
|
106
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `map'
|
107
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `run'
|
108
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
|
109
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `map'
|
110
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `block in run'
|
111
|
+
rspec-core (2.14.7) lib/rspec/core/reporter.rb:58:in `report'
|
112
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:25:in `run'
|
113
|
+
rspec-core (2.14.7) lib/rspec/core/runner.rb:80:in `run'
|
114
|
+
rspec-core (2.14.7) lib/rspec/core/runner.rb:17:in `block in autorun'
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
Started GET "/test" for 127.0.0.1 at 2014-01-18 18:23:13 +0400
|
120
|
+
|
121
|
+
ActionController::RoutingError (No route matches [GET] "/test"):
|
122
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
|
123
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
|
124
|
+
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
|
125
|
+
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
|
126
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
|
127
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
|
128
|
+
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
|
129
|
+
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
|
130
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
|
131
|
+
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
|
132
|
+
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
|
133
|
+
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
|
134
|
+
rack (1.5.2) lib/rack/lock.rb:17:in `call'
|
135
|
+
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
|
136
|
+
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
|
137
|
+
railties (4.0.2) lib/rails/engine.rb:511:in `call'
|
138
|
+
railties (4.0.2) lib/rails/application.rb:97:in `call'
|
139
|
+
railties (4.0.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
|
140
|
+
rack-test (0.6.2) lib/rack/mock_session.rb:30:in `request'
|
141
|
+
rack-test (0.6.2) lib/rack/test.rb:230:in `process_request'
|
142
|
+
rack-test (0.6.2) lib/rack/test.rb:57:in `get'
|
143
|
+
/home/alexiss/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/forwardable.rb:171:in `get'
|
144
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:60:in `process'
|
145
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:35:in `process_and_follow_redirects'
|
146
|
+
capybara (2.2.1) lib/capybara/rack_test/browser.rb:21:in `visit'
|
147
|
+
capybara (2.2.1) lib/capybara/rack_test/driver.rb:42:in `visit'
|
148
|
+
capybara (2.2.1) lib/capybara/session.rb:197:in `visit'
|
149
|
+
capybara (2.2.1) lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
|
150
|
+
spec/integration_spec.rb:44:in `render'
|
151
|
+
spec/integration/text_container_spec.rb:6:in `block (3 levels) in <top (required)>'
|
152
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:114:in `instance_eval'
|
153
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:114:in `block in run'
|
154
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:254:in `with_around_each_hooks'
|
155
|
+
rspec-core (2.14.7) lib/rspec/core/example.rb:111:in `run'
|
156
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:390:in `block in run_examples'
|
157
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:386:in `map'
|
158
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:386:in `run_examples'
|
159
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:371:in `run'
|
160
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `block in run'
|
161
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `map'
|
162
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `run'
|
163
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `block in run'
|
164
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `map'
|
165
|
+
rspec-core (2.14.7) lib/rspec/core/example_group.rb:372:in `run'
|
166
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
|
167
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `map'
|
168
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:28:in `block in run'
|
169
|
+
rspec-core (2.14.7) lib/rspec/core/reporter.rb:58:in `report'
|
170
|
+
rspec-core (2.14.7) lib/rspec/core/command_line.rb:25:in `run'
|
171
|
+
rspec-core (2.14.7) lib/rspec/core/runner.rb:80:in `run'
|
172
|
+
rspec-core (2.14.7) lib/rspec/core/runner.rb:17:in `block in autorun'
|
173
|
+
|
174
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# wrap_it sections
|
2
|
+
|
3
|
+
Sections intended to simplify elements thats include complex html markup. Also it makes capturing process clearly when you have more that one classes in hierarhy. Sections is just an array of strings, containing html with corresponding ordered array of section names. So, you can define some sections in base class and some in its descendant. Then you can place its respecting each other in any level of hierarchy without changes in other classes. And after that all classes in capture callbacks puts html markup into sections. Finally, all sections joined in specific order and gives result of rendering.
|
4
|
+
|
5
|
+
`WrapIt::Base` class defines three sections: `:content`, `:render_arguments`, ``render_block`. Main is `:content`. This section will contain content, captured from template. `render_arguments` and `render_block` sections contains content, retrieved from arguments and blocl, specified in `render` method call. `WrapIt::TextContainer` module adds `:body` section that contains first text argument, specified with helper call, or `:text` or `:body` option. `WrapIt::Container` adds `:children` section that contains all rendered children items.
|
6
|
+
|
7
|
+
For example, lets look on [Twitter Bootstrap input groups](http://getbootstrap.com/components/#input-groups-basic):
|
8
|
+
|
9
|
+
```html
|
10
|
+
<div class="input-group">
|
11
|
+
<span class="input-group-addon">@</span>
|
12
|
+
<input type="text" class="form-control" placeholder="Username">
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div class="input-group">
|
16
|
+
<input type="text" class="form-control">
|
17
|
+
<span class="input-group-addon">.00</span>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="input-group">
|
21
|
+
<span class="input-group-addon">$</span>
|
22
|
+
<input type="text" class="form-control">
|
23
|
+
<span class="input-group-addon">.00</span>
|
24
|
+
</div>
|
25
|
+
```
|
26
|
+
|
27
|
+
We have main element `input`, wrapped into `div`, and optionally appended or prepended with `span` elements. So, lets code:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
module BS
|
31
|
+
class InputGroup < WrapIt::Base
|
32
|
+
section :append, :prepend
|
33
|
+
place :prepend, before: :content
|
34
|
+
place :append, after: :content
|
35
|
+
|
36
|
+
after_initialize do
|
37
|
+
@prepend = options.delete(:prepend)
|
38
|
+
@append = options.delete(:append)
|
39
|
+
end
|
40
|
+
|
41
|
+
after_capture do
|
42
|
+
unless @prepend.nil?
|
43
|
+
self[:prepend] = content_tag('span', @prepend,
|
44
|
+
class: 'input-group-addon')
|
45
|
+
end
|
46
|
+
unless @append.nil?
|
47
|
+
self[:append] = content_tag('span', @append,
|
48
|
+
class: 'input-group-addon')
|
49
|
+
end
|
50
|
+
if self[:content].empty?
|
51
|
+
# inject type and class into user-defined options
|
52
|
+
options[:type] = 'text'
|
53
|
+
add_html_class 'form-control'
|
54
|
+
self[:content] = content_tag('input', '', options)
|
55
|
+
# pass to wrapper div only 'input-group' class
|
56
|
+
options.clear
|
57
|
+
add_html_class 'input-group'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
Now to render above html we can use it as follows:
|
63
|
+
|
64
|
+
```html
|
65
|
+
<%= input_group prepend: '@', placeholder: 'Username' %>
|
66
|
+
<%= input_group append: '.00' %>
|
67
|
+
<%= input_group append: '.00', prepend: '$' %>
|
68
|
+
```
|
69
|
+
|
70
|
+
Have a fun!
|