blocks 1.2.5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe Blocks do
4
+ it "should provide a util method to render a template" do
5
+ view = stub
6
+ options = stub
7
+ partial = stub
8
+ block = Proc.new { |options| }
9
+ base_mock = mock
10
+ base_mock.expects(:render_template).with(partial)
11
+ Blocks::Base.expects(:new).with(view, options).returns(base_mock)
12
+
13
+ Blocks.render_template(view, partial, options, &block)
14
+ end
15
+
16
+ it "should provide a setup method that can be called from an initializer" do
17
+ Blocks.template_folder.should eql("blocks")
18
+ Blocks.setup do |config|
19
+ config.should eql(Blocks)
20
+ config.template_folder = "shared"
21
+ end
22
+ Blocks.template_folder.should eql("shared")
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe Blocks::ViewAdditions do
4
+ before(:each) do
5
+ @view_class = Class.new
6
+ @view = @view_class.new
7
+ @view_class.send(:include, Blocks::ViewAdditions::ClassMethods)
8
+ end
9
+
10
+ describe "blocks method" do
11
+ it "should pass the view as the only parameter to Blocks::Base initialization" do
12
+ Blocks::Base.expects(:new).with {|view| view == @view}
13
+ @view.blocks
14
+ end
15
+
16
+ it "should memoize the Blocks::Base instance for 'blocks' call" do
17
+ Blocks::Base.expects(:new).once.with {|view| view == @view}.returns "something"
18
+ @view.blocks.should eql "something"
19
+ @view.blocks.should eql "something"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'blocks' # and any other gems you need
5
+
6
+ def print_hash(hash)
7
+ hash.inject("") { |s, (k, v)| "#{s} #{k}: #{v}." }
8
+ end
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :mocha
12
+
13
+ config.before :each do
14
+ Blocks.template_folder = "blocks"
15
+ Blocks.surrounding_tag_surrounds_before_and_after_blocks = true
16
+ Blocks.use_partials = false
17
+ end
18
+ end
19
+
metadata CHANGED
@@ -1,43 +1,300 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blocks
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 11
4
5
  prerelease:
5
- version: 1.2.5
6
+ segments:
7
+ - 2
8
+ - 1
9
+ - 0
10
+ version: 2.1.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Andrew Hunter
9
- - Todd Fisher
10
14
  autorequire:
11
15
  bindir: bin
12
16
  cert_chain: []
13
17
 
14
- date: 2011-04-26 00:00:00 -04:00
15
- default_executable:
16
- dependencies: []
17
-
18
- description: content_for with parameters, with advanced options such as a table generator (table_for)
19
- email: andrew@captico.com
18
+ date: 2013-08-06 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ requirement: *id001
31
+ prerelease: false
32
+ name: blocks
33
+ type: :runtime
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ hash: 7
41
+ segments:
42
+ - 3
43
+ - 0
44
+ - 0
45
+ version: 3.0.0
46
+ requirement: *id002
47
+ prerelease: false
48
+ name: rails
49
+ type: :runtime
50
+ - !ruby/object:Gem::Dependency
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirement: *id003
61
+ prerelease: false
62
+ name: jeweler
63
+ type: :development
64
+ - !ruby/object:Gem::Dependency
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirement: *id004
75
+ prerelease: false
76
+ name: jeweler
77
+ type: :development
78
+ - !ruby/object:Gem::Dependency
79
+ version_requirements: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ requirement: *id005
89
+ prerelease: false
90
+ name: jeweler
91
+ type: :development
92
+ - !ruby/object:Gem::Dependency
93
+ version_requirements: &id006 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirement: *id006
103
+ prerelease: false
104
+ name: jeweler
105
+ type: :development
106
+ - !ruby/object:Gem::Dependency
107
+ version_requirements: &id007 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ requirement: *id007
117
+ prerelease: false
118
+ name: jeweler
119
+ type: :development
120
+ - !ruby/object:Gem::Dependency
121
+ version_requirements: &id008 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ requirement: *id008
131
+ prerelease: false
132
+ name: jeweler
133
+ type: :development
134
+ - !ruby/object:Gem::Dependency
135
+ version_requirements: &id009 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ requirement: *id009
145
+ prerelease: false
146
+ name: jeweler
147
+ type: :development
148
+ - !ruby/object:Gem::Dependency
149
+ version_requirements: &id010 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
157
+ version: "0"
158
+ requirement: *id010
159
+ prerelease: false
160
+ name: jeweler
161
+ type: :development
162
+ - !ruby/object:Gem::Dependency
163
+ version_requirements: &id011 !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ requirement: *id011
173
+ prerelease: false
174
+ name: jeweler
175
+ type: :development
176
+ - !ruby/object:Gem::Dependency
177
+ version_requirements: &id012 !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ hash: 3
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ requirement: *id012
187
+ prerelease: false
188
+ name: jeweler
189
+ type: :development
190
+ - !ruby/object:Gem::Dependency
191
+ version_requirements: &id013 !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ hash: 3
197
+ segments:
198
+ - 0
199
+ version: "0"
200
+ requirement: *id013
201
+ prerelease: false
202
+ name: jeweler
203
+ type: :development
204
+ - !ruby/object:Gem::Dependency
205
+ version_requirements: &id014 !ruby/object:Gem::Requirement
206
+ none: false
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ hash: 3
211
+ segments:
212
+ - 0
213
+ version: "0"
214
+ requirement: *id014
215
+ prerelease: false
216
+ name: jeweler
217
+ type: :development
218
+ - !ruby/object:Gem::Dependency
219
+ version_requirements: &id015 !ruby/object:Gem::Requirement
220
+ none: false
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ hash: 3
225
+ segments:
226
+ - 0
227
+ version: "0"
228
+ requirement: *id015
229
+ prerelease: false
230
+ name: jeweler
231
+ type: :development
232
+ - !ruby/object:Gem::Dependency
233
+ version_requirements: &id016 !ruby/object:Gem::Requirement
234
+ none: false
235
+ requirements:
236
+ - - ">="
237
+ - !ruby/object:Gem::Version
238
+ hash: 3
239
+ segments:
240
+ - 0
241
+ version: "0"
242
+ requirement: *id016
243
+ prerelease: false
244
+ name: jeweler
245
+ type: :development
246
+ - !ruby/object:Gem::Dependency
247
+ version_requirements: &id017 !ruby/object:Gem::Requirement
248
+ none: false
249
+ requirements:
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ hash: 3
253
+ segments:
254
+ - 0
255
+ version: "0"
256
+ requirement: *id017
257
+ prerelease: false
258
+ name: jeweler
259
+ type: :development
260
+ - !ruby/object:Gem::Dependency
261
+ version_requirements: &id018 !ruby/object:Gem::Requirement
262
+ none: false
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ hash: 3
267
+ segments:
268
+ - 0
269
+ version: "0"
270
+ requirement: *id018
271
+ prerelease: false
272
+ name: jeweler
273
+ type: :development
274
+ description: Blocks goes beyond blocks and partials
275
+ email: hunterae@gmail.com
20
276
  executables: []
21
277
 
22
278
  extensions: []
23
279
 
24
280
  extra_rdoc_files:
25
- - LICENSE
26
281
  - README.rdoc
27
282
  files:
28
- - lib/blocks/builder.rb
29
- - lib/blocks/container.rb
30
- - lib/blocks/engine.rb
31
- - lib/blocks/list_for.rb
32
- - lib/blocks/table_for.rb
33
- - lib/blocks.rb
34
- - app/helpers/blocks/helper_methods.rb
35
- - app/views/blocks/_list.html.erb
36
- - app/views/blocks/_table.html.erb
283
+ - CHANGELOG.rdoc
37
284
  - README.rdoc
38
- - LICENSE
39
- has_rdoc: true
40
- homepage: https://github.com/hunterae/blocks
285
+ - Rakefile
286
+ - VERSION
287
+ - lib/blocks.rb
288
+ - lib/blocks/base.rb
289
+ - lib/blocks/container.rb
290
+ - lib/blocks/controller_additions.rb
291
+ - lib/blocks/view_additions.rb
292
+ - rails/init.rb
293
+ - spec/blocks/base_spec.rb
294
+ - spec/blocks/blocks_spec.rb
295
+ - spec/blocks/view_additions_spec.rb
296
+ - spec/spec_helper.rb
297
+ homepage: http://github.com/hunterae/blocks
41
298
  licenses: []
42
299
 
43
300
  post_install_message:
@@ -45,25 +302,30 @@ rdoc_options: []
45
302
 
46
303
  require_paths:
47
304
  - lib
48
- - app
49
305
  required_ruby_version: !ruby/object:Gem::Requirement
50
306
  none: false
51
307
  requirements:
52
308
  - - ">="
53
309
  - !ruby/object:Gem::Version
310
+ hash: 3
311
+ segments:
312
+ - 0
54
313
  version: "0"
55
314
  required_rubygems_version: !ruby/object:Gem::Requirement
56
315
  none: false
57
316
  requirements:
58
317
  - - ">="
59
318
  - !ruby/object:Gem::Version
319
+ hash: 3
320
+ segments:
321
+ - 0
60
322
  version: "0"
61
323
  requirements: []
62
324
 
63
- rubyforge_project: blocks
64
- rubygems_version: 1.5.0
325
+ rubyforge_project:
326
+ rubygems_version: 1.8.24
65
327
  signing_key:
66
328
  specification_version: 3
67
- summary: content_for with parameters, with advanced options such as a table generator (table_for)
329
+ summary: Blocks is an intricate way of rendering blocks of code, while combining some of the best features of content blocks and partials, and adding several new features that go above and beyond what a simple content_for with yield or a render :partial is capable of doing.
68
330
  test_files: []
69
331
 
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) <year> <copyright holders>
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.
@@ -1,35 +0,0 @@
1
- module Blocks
2
- module HelperMethods
3
- def blocks
4
- options = {}
5
- options[:view] = self
6
-
7
- @blocks ||= Blocks::Builder.new(options)
8
- end
9
-
10
- def evaluated_content_options(options={}, parameters={})
11
- evaluated_options = {}
12
- options.each_pair { |k, v| evaluated_options[k] = (v.is_a?(Proc) ? v.call(parameters) : v)}
13
- evaluated_options
14
- end
15
-
16
- def table_for(records, options={}, &block)
17
- options[:view] = self
18
- options[:records] = records
19
- options[:block] = block
20
- options[:row_html] = {:class => lambda { |parameters| cycle('odd', 'even')}} if options[:row_html].nil?
21
-
22
- Blocks::TableFor.new(options).render
23
- end
24
-
25
- def list_for(*args, &block)
26
- options = args.extract_options!
27
-
28
- options[:view] = self
29
- options[:records] = args.first
30
- options[:block] = block
31
-
32
- Blocks::ListFor.new(options).render
33
- end
34
- end
35
- end