stasis-extensions 1.0.0 → 1.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f382f030749af3220ec76a803c11c787b733aa77
4
+ data.tar.gz: 52d5f2f3aed1213533a250a178b6385f2f010fc7
5
+ SHA512:
6
+ metadata.gz: c4cc108c70c743f982196ff0b9bc2fb554d63095f46b18bfa703af19b930b2ef2e43786570f8cbef64699ae43622b223de6fa76f285977d508ced3d43dfb5aa0
7
+ data.tar.gz: 58d6e1a7dc3dfbcc84778c53aa175bf82f7df6b5912b29e3128d989d5234d9fa55878e16efe64fc61780f31d693b8167c78bae9f95cdf6d38359b1bd4d2f374e
data/.gitignore CHANGED
@@ -13,6 +13,7 @@ pkg
13
13
  rdoc
14
14
  spec/reports
15
15
  spec/fixtures/project/public
16
+ spec/fixtures/project/css/.sass-cache
16
17
  test/tmp
17
18
  test/version_tmp
18
19
  tmp
data/README.md CHANGED
@@ -53,6 +53,16 @@ Similar to the preceding asset_path helper, the specified path will be expanded
53
53
 
54
54
  Similar to the asset_path helper, but the path is rendered for css use (ie. wrapped in `url(...)`).
55
55
 
56
+ ### content helper
57
+
58
+ A helper method has been added to support Rails-like deferred content.
59
+
60
+ #### content_for(symbol)
61
+
62
+ Similar to the Rails `content_for` helper which allows the user to yield content defined in a view from within a layout.
63
+
64
+ Instead of using `yield` to render the content within the layout, simply call the helper without a block to retrieve the previously rendered content.
65
+
56
66
  ## Contributing
57
67
 
58
68
  1. Fork it
@@ -2,8 +2,10 @@ require 'stasis'
2
2
  require 'stasis/extensions/version'
3
3
 
4
4
  require 'stasis/extensions/assets'
5
+ require 'stasis/extensions/content_for'
5
6
  require 'stasis/extensions/i18n'
6
7
  require 'stasis/extensions/sass'
7
8
 
8
9
  Stasis.register Stasis::Extensions::Assets
10
+ Stasis.register Stasis::Extensions::ContentFor
9
11
  Stasis.register Stasis::Extensions::I18n
@@ -0,0 +1,34 @@
1
+ class Stasis
2
+ module Extensions
3
+ class ContentFor < Stasis::Plugin
4
+ before_all :before_all
5
+ reset :reset
6
+
7
+ def initialize(stasis)
8
+ @stasis = stasis
9
+ reset
10
+ end
11
+
12
+ def before_all
13
+ define_helpers
14
+ end
15
+
16
+ def reset
17
+ @content = {}
18
+ end
19
+
20
+ protected
21
+
22
+ def define_helpers
23
+ @stasis.controller.helpers do
24
+ def content_for(key, &block)
25
+ @content ||= {}
26
+ @content[key] ||= ""
27
+ @content[key] << capture_haml(&block) if block_given?
28
+ @content[key]
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  class Stasis
2
2
  module Extensions
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ .top= content_for :top
2
+ = yield
3
+ .bottom= content_for :bottom
@@ -0,0 +1,10 @@
1
+ THIS IS A TEST
2
+
3
+ - content_for :bottom do
4
+ GOODBYE
5
+
6
+ - content_for :top do
7
+ HELLO
8
+
9
+ - content_for :top do
10
+ WORLD
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis::Extensions::ContentFor do
4
+
5
+ let(:project_folder) { File.expand_path('../../../../fixtures/project', __FILE__) }
6
+ let(:stasis) { Stasis.new(project_folder) }
7
+
8
+ describe "an instance of the plugin" do
9
+ describe "when rendered" do
10
+ describe "#content_for" do
11
+ it "should render the captured content" do
12
+ stasis_render 'content_for/view.haml', :layout => 'content_for/layout.haml'
13
+ html = <<-ENDOFHTML
14
+ <div class='top'>
15
+ HELLO
16
+ WORLD
17
+ </div>
18
+ THIS IS A TEST
19
+ <div class='bottom'>GOODBYE</div>
20
+ ENDOFHTML
21
+ expect(contents_of('public/content_for/view')).to eq(html.chomp)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -5,6 +5,10 @@ describe Stasis::Extensions do
5
5
  expect(Stasis::Plugin.plugins).to include(Stasis::Extensions::Assets)
6
6
  end
7
7
 
8
+ it "should register the ContentFor plugin" do
9
+ expect(Stasis::Plugin.plugins).to include(Stasis::Extensions::ContentFor)
10
+ end
11
+
8
12
  it "should register the I18n plugin" do
9
13
  expect(Stasis::Plugin.plugins).to include(Stasis::Extensions::I18n)
10
14
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,10 @@
1
1
  require 'simplecov'
2
+ require 'simplecov-rcov'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ SimpleCov::Formatter::RcovFormatter,
7
+ ]
2
8
 
3
9
  SimpleCov.start do
4
10
  add_filter '/test/'
@@ -39,7 +45,10 @@ def project_path(file)
39
45
  end
40
46
 
41
47
  def stasis_render(*only)
48
+ options = only.last.is_a?(Hash) ? only.pop : {}
42
49
  wd = Dir.getwd
50
+
51
+ stasis.controller.layout options[:layout] if options[:layout]
43
52
  stasis.render *only
44
53
  ensure
45
54
  Dir.chdir(wd)
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "i18n"
22
22
  spec.add_dependency "sass"
23
- spec.add_dependency "stasis"
23
+ spec.add_dependency "stasis", "~>0.2.0"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.3"
26
26
  spec.add_development_dependency "guard"
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rake"
30
30
  spec.add_development_dependency "rspec"
31
31
  spec.add_development_dependency "simplecov"
32
+ spec.add_development_dependency "simplecov-rcov"
32
33
  end
metadata CHANGED
@@ -1,174 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stasis-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - S. Brent Faulkner
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-24 00:00:00.000000000 Z
11
+ date: 2014-08-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: i18n
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sass
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: stasis
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: 0.2.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: 0.2.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '1.3'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '1.3'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: guard
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: guard-rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: haml
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rake
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: rspec
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: simplecov
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov-rcov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
164
158
  - !ruby/object:Gem::Version
165
159
  version: '0'
166
160
  type: :development
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
163
  requirements:
171
- - - ! '>='
164
+ - - ">="
172
165
  - !ruby/object:Gem::Version
173
166
  version: '0'
174
167
  description: plugin(s) for stasis providing i18n support and asset fingerprinting
@@ -178,8 +171,8 @@ executables: []
178
171
  extensions: []
179
172
  extra_rdoc_files: []
180
173
  files:
181
- - .gitignore
182
- - .travis.yml
174
+ - ".gitignore"
175
+ - ".travis.yml"
183
176
  - Gemfile
184
177
  - Guardfile
185
178
  - LICENSE.txt
@@ -187,14 +180,16 @@ files:
187
180
  - Rakefile
188
181
  - lib/stasis/extensions.rb
189
182
  - lib/stasis/extensions/assets.rb
183
+ - lib/stasis/extensions/content_for.rb
190
184
  - lib/stasis/extensions/i18n.rb
191
185
  - lib/stasis/extensions/sass.rb
192
186
  - lib/stasis/extensions/version.rb
193
187
  - spec/fixtures/project/assets/asset_path.haml
194
188
  - spec/fixtures/project/assets/asset_url.haml
195
189
  - spec/fixtures/project/config/locales/en.yml
190
+ - spec/fixtures/project/content_for/layout.haml
191
+ - spec/fixtures/project/content_for/view.haml
196
192
  - spec/fixtures/project/controller.rb
197
- - spec/fixtures/project/css/.sass-cache/5c363f5deb88bb376880318aed5e301825a18d6e/compiled.css.scssc
198
193
  - spec/fixtures/project/css/compiled.css.scss
199
194
  - spec/fixtures/project/css/simple.css
200
195
  - spec/fixtures/project/i18n/body_class.haml
@@ -204,6 +199,7 @@ files:
204
199
  - spec/fixtures/project/js/compiled.js.erb
205
200
  - spec/fixtures/project/js/simple.js
206
201
  - spec/lib/stasis/extensions/assets_spec.rb
202
+ - spec/lib/stasis/extensions/content_for_spec.rb
207
203
  - spec/lib/stasis/extensions/i18n_spec.rb
208
204
  - spec/lib/stasis/extensions/sass_spec.rb
209
205
  - spec/lib/stasis/extensions_spec.rb
@@ -212,40 +208,34 @@ files:
212
208
  homepage: http://github.com/mosaicxm/stasis-extensions
213
209
  licenses:
214
210
  - MIT
211
+ metadata: {}
215
212
  post_install_message:
216
213
  rdoc_options: []
217
214
  require_paths:
218
215
  - lib
219
216
  required_ruby_version: !ruby/object:Gem::Requirement
220
- none: false
221
217
  requirements:
222
- - - ! '>='
218
+ - - ">="
223
219
  - !ruby/object:Gem::Version
224
220
  version: '0'
225
- segments:
226
- - 0
227
- hash: -798725933815868513
228
221
  required_rubygems_version: !ruby/object:Gem::Requirement
229
- none: false
230
222
  requirements:
231
- - - ! '>='
223
+ - - ">="
232
224
  - !ruby/object:Gem::Version
233
225
  version: '0'
234
- segments:
235
- - 0
236
- hash: -798725933815868513
237
226
  requirements: []
238
227
  rubyforge_project:
239
- rubygems_version: 1.8.23
228
+ rubygems_version: 2.2.2
240
229
  signing_key:
241
- specification_version: 3
230
+ specification_version: 4
242
231
  summary: plugin(s) for stasis providing i18n support and asset fingerprinting
243
232
  test_files:
244
233
  - spec/fixtures/project/assets/asset_path.haml
245
234
  - spec/fixtures/project/assets/asset_url.haml
246
235
  - spec/fixtures/project/config/locales/en.yml
236
+ - spec/fixtures/project/content_for/layout.haml
237
+ - spec/fixtures/project/content_for/view.haml
247
238
  - spec/fixtures/project/controller.rb
248
- - spec/fixtures/project/css/.sass-cache/5c363f5deb88bb376880318aed5e301825a18d6e/compiled.css.scssc
249
239
  - spec/fixtures/project/css/compiled.css.scss
250
240
  - spec/fixtures/project/css/simple.css
251
241
  - spec/fixtures/project/i18n/body_class.haml
@@ -255,6 +245,7 @@ test_files:
255
245
  - spec/fixtures/project/js/compiled.js.erb
256
246
  - spec/fixtures/project/js/simple.js
257
247
  - spec/lib/stasis/extensions/assets_spec.rb
248
+ - spec/lib/stasis/extensions/content_for_spec.rb
258
249
  - spec/lib/stasis/extensions/i18n_spec.rb
259
250
  - spec/lib/stasis/extensions/sass_spec.rb
260
251
  - spec/lib/stasis/extensions_spec.rb