sinatra-cigars 0.0.11 → 0.0.12
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 +4 -4
- data/Changelog.md +5 -1
- data/lib/sinatra/cigars/helpers.rb +9 -3
- data/lib/sinatra/cigars/version.rb +1 -1
- data/spec/helpers_spec.rb +71 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71640998c57a08a4e6c54a9e4032c8dc6e62103e
|
4
|
+
data.tar.gz: b3144c8b738791f72078ad47ab5dbc2cec62b887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec46011292f1bc4c02917ee9c343d744de91211aa8d73050e8afa102ba6e24f19bb5e3d291c684229be828cbc1c73661a564e088ac651d1cd45d42cbc29297ac
|
7
|
+
data.tar.gz: ac172e41b8fb44b6eaf62682cf35a07f512de7b988f081ffbbf97956d48062a7a7988fbbb37405bbe4092c4ef72fc26e5e430f47ef95518f4c926b0e2fdb608f
|
data/Changelog.md
CHANGED
@@ -28,15 +28,15 @@ module Sinatra
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def css href = '/style'
|
31
|
-
render_haml "%link{rel: 'stylesheet', href: '#{href
|
31
|
+
render_haml "%link{rel: 'stylesheet', href: '#{render_tag(href, '.css')}'}"
|
32
32
|
end
|
33
33
|
|
34
34
|
def js src
|
35
|
-
render_haml "%script{src: '#{src
|
35
|
+
render_haml "%script{src: '#{render_tag(src, '.js')}'}"
|
36
36
|
end
|
37
37
|
|
38
38
|
def title str, prefix = "", suffix = false
|
39
|
-
render_haml "%title= '#{suffix ? str + prefix : prefix + str}'"
|
39
|
+
home? ? render_haml("%title= '#{str}'") : render_haml("%title= '#{suffix ? str + prefix : prefix + str}'")
|
40
40
|
end
|
41
41
|
|
42
42
|
def livereload
|
@@ -56,6 +56,12 @@ module Sinatra
|
|
56
56
|
Haml::Engine.new(code).render
|
57
57
|
end
|
58
58
|
|
59
|
+
def render_tag code, ext
|
60
|
+
code = "/#{code}" unless code.is_a? String
|
61
|
+
code = code + ext unless code.end_with? ext
|
62
|
+
production? ? code + '?' + `git rev-parse --short HEAD`.chomp : code
|
63
|
+
end
|
64
|
+
|
59
65
|
def meta_hash hash
|
60
66
|
a = hash.first
|
61
67
|
render_haml "%meta{name: '#{a.first}', content: '#{a.last}'}"
|
data/spec/helpers_spec.rb
CHANGED
@@ -145,28 +145,71 @@ describe Sinatra::Cigars::Helpers, type: :feature do
|
|
145
145
|
|
146
146
|
describe 'css' do
|
147
147
|
before do
|
148
|
+
@rev = `git rev-parse --short HEAD`.chomp
|
149
|
+
|
148
150
|
mock_app do
|
149
151
|
helpers Sinatra::Cigars::Helpers
|
150
152
|
|
151
|
-
get('/')
|
152
|
-
|
153
|
-
get('/
|
153
|
+
get('/') { haml '= css' }
|
154
|
+
get('/symbol') { haml '= css :symbol' }
|
155
|
+
get('/string') { haml '= css "string"' }
|
156
|
+
get('/ext') { haml '= css "/ext.css"' }
|
154
157
|
end
|
155
158
|
end
|
156
159
|
|
157
160
|
it do
|
161
|
+
ENV['RACK_ENV'] = 'test'
|
158
162
|
visit '/'
|
159
163
|
body.should == "<link href='/style.css' rel='stylesheet'>\n"
|
160
164
|
end
|
161
165
|
|
162
166
|
it do
|
163
|
-
|
164
|
-
|
167
|
+
ENV['RACK_ENV'] = 'production'
|
168
|
+
visit '/'
|
169
|
+
body.should == "<link href='/style.css?#{@rev}' rel='stylesheet'>\n"
|
170
|
+
end
|
171
|
+
|
172
|
+
it do
|
173
|
+
ENV['RACK_ENV'] = 'test'
|
174
|
+
visit '/symbol'
|
175
|
+
body.should == "<link href='/symbol.css' rel='stylesheet'>\n"
|
176
|
+
end
|
177
|
+
|
178
|
+
it do
|
179
|
+
ENV['RACK_ENV'] = 'production'
|
180
|
+
visit '/symbol'
|
181
|
+
body.should == "<link href='/symbol.css?#{@rev}' rel='stylesheet'>\n"
|
182
|
+
end
|
183
|
+
|
184
|
+
it do
|
185
|
+
ENV['RACK_ENV'] = 'test'
|
186
|
+
visit '/string'
|
187
|
+
body.should == "<link href='string.css' rel='stylesheet'>\n"
|
188
|
+
end
|
189
|
+
|
190
|
+
it do
|
191
|
+
ENV['RACK_ENV'] = 'production'
|
192
|
+
visit '/string'
|
193
|
+
body.should == "<link href='string.css?#{@rev}' rel='stylesheet'>\n"
|
194
|
+
end
|
195
|
+
|
196
|
+
it do
|
197
|
+
ENV['RACK_ENV'] = 'test'
|
198
|
+
visit '/ext'
|
199
|
+
body.should == "<link href='/ext.css' rel='stylesheet'>\n"
|
200
|
+
end
|
201
|
+
|
202
|
+
it do
|
203
|
+
ENV['RACK_ENV'] = 'production'
|
204
|
+
visit '/ext'
|
205
|
+
body.should == "<link href='/ext.css?#{@rev}' rel='stylesheet'>\n"
|
165
206
|
end
|
166
207
|
end
|
167
208
|
|
168
209
|
describe 'js' do
|
169
210
|
before do
|
211
|
+
@rev = `git rev-parse --short HEAD`.chomp
|
212
|
+
|
170
213
|
mock_app do
|
171
214
|
helpers Sinatra::Cigars::Helpers
|
172
215
|
|
@@ -175,9 +218,16 @@ describe Sinatra::Cigars::Helpers, type: :feature do
|
|
175
218
|
end
|
176
219
|
|
177
220
|
it do
|
221
|
+
ENV['RACK_ENV'] = 'test'
|
178
222
|
visit '/'
|
179
223
|
body.should == "<script src='/script.js'></script>\n"
|
180
224
|
end
|
225
|
+
|
226
|
+
it do
|
227
|
+
ENV['RACK_ENV'] = 'production'
|
228
|
+
visit '/'
|
229
|
+
body.should == "<script src='/script.js?#{@rev}'></script>\n"
|
230
|
+
end
|
181
231
|
end
|
182
232
|
|
183
233
|
describe 'livereload' do
|
@@ -304,25 +354,29 @@ describe Sinatra::Cigars::Helpers, type: :feature do
|
|
304
354
|
mock_app do
|
305
355
|
helpers Sinatra::Cigars::Helpers
|
306
356
|
|
307
|
-
|
308
|
-
|
309
|
-
|
357
|
+
helpers do
|
358
|
+
def haml_title
|
359
|
+
haml <<-EOF.gsub /^ {12}/, ''
|
360
|
+
= title 'title'
|
361
|
+
= title 'title', 'prefix - '
|
362
|
+
= title 'title', ' - suffix', true
|
363
|
+
EOF
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
get('/') { haml_title }
|
368
|
+
get('/page') { haml_title }
|
310
369
|
end
|
311
370
|
end
|
312
371
|
|
313
|
-
it do
|
372
|
+
it 'returns always "title" at home' do
|
314
373
|
visit '/'
|
315
|
-
body.should == "<title>title</title>\n"
|
316
|
-
end
|
317
|
-
|
318
|
-
it do
|
319
|
-
visit '/prefix'
|
320
|
-
body.should == "<title>prefix - title</title>\n"
|
374
|
+
body.should == "<title>title</title>\n<title>title</title>\n<title>title</title>\n"
|
321
375
|
end
|
322
376
|
|
323
377
|
it do
|
324
|
-
visit '/
|
325
|
-
body.should == "<title>title - suffix</title>\n"
|
378
|
+
visit '/page'
|
379
|
+
body.should == "<title>title</title>\n<title>prefix - title</title>\n<title>title - suffix</title>\n"
|
326
380
|
end
|
327
381
|
end
|
328
382
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-cigars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seiichi Yonezawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|