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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03d11be340dfdfbe9429027eea09427b33711f01
4
- data.tar.gz: 021164f4f2572bfe50b5166ac75a1f907e45701d
3
+ metadata.gz: 71640998c57a08a4e6c54a9e4032c8dc6e62103e
4
+ data.tar.gz: b3144c8b738791f72078ad47ab5dbc2cec62b887
5
5
  SHA512:
6
- metadata.gz: 41e957e136f11cb0728cc34952721402623beac66471f3eb192b31222b2f4d6b006fd65e40f8c79f870b8f49c064aad91d3f4ba1ce0dc8909a24477fc2e6aaec
7
- data.tar.gz: ddb0eb003efbf93085b9ad522f5da784c92f77b17f4c7f29415e891fecec0077ff31f839bf555fee920e917b3c68300064c47d2e42e3d2f0093fdd1c37caa468
6
+ metadata.gz: ec46011292f1bc4c02917ee9c343d744de91211aa8d73050e8afa102ba6e24f19bb5e3d291c684229be828cbc1c73661a564e088ac651d1cd45d42cbc29297ac
7
+ data.tar.gz: ac172e41b8fb44b6eaf62682cf35a07f512de7b988f081ffbbf97956d48062a7a7988fbbb37405bbe4092c4ef72fc26e5e430f47ef95518f4c926b0e2fdb608f
data/Changelog.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## 0.0.11 - 2014-05-03
3
+ ## 0.0.12 - 2014-05-05
4
+
5
+ * Change `title` returns always "title" in home
6
+
7
+ ## 0.0.11 - 2014-05-04
4
8
 
5
9
  * Added helpers (`home?`, `meta`, `title`)
6
10
  * Added haml to dependencies
@@ -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}.css'}"
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}.js'}"
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}'}"
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module Cigars
3
- VERSION = '0.0.11'
3
+ VERSION = '0.0.12'
4
4
  end
5
5
  end
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('/') { haml '= css' }
152
-
153
- get('/custom') { haml '= css :custom' }
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
- visit '/custom'
164
- body.should == "<link href='custom.css' rel='stylesheet'>\n"
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
- get('/') { haml '= title "title"' }
308
- get('/prefix') { haml '= title "title", "prefix - "' }
309
- get('/suffix') { haml '= title "title", " - suffix", true' }
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 '/suffix'
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.11
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-04 00:00:00.000000000 Z
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra