sinatra-cigars 0.0.10 → 0.0.11
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/.gitignore +1 -0
- data/Changelog.md +10 -0
- data/lib/sinatra/cigars/helpers.rb +25 -0
- data/lib/sinatra/cigars/version.rb +1 -1
- data/sinatra-cigars.gemspec +1 -0
- data/spec/helpers_spec.rb +92 -0
- metadata +17 -3
- data/Gemfile.lock +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03d11be340dfdfbe9429027eea09427b33711f01
|
4
|
+
data.tar.gz: 021164f4f2572bfe50b5166ac75a1f907e45701d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41e957e136f11cb0728cc34952721402623beac66471f3eb192b31222b2f4d6b006fd65e40f8c79f870b8f49c064aad91d3f4ba1ce0dc8909a24477fc2e6aaec
|
7
|
+
data.tar.gz: ddb0eb003efbf93085b9ad522f5da784c92f77b17f4c7f29415e891fecec0077ff31f839bf555fee920e917b3c68300064c47d2e42e3d2f0093fdd1c37caa468
|
data/.gitignore
CHANGED
data/Changelog.md
ADDED
@@ -19,6 +19,14 @@ module Sinatra
|
|
19
19
|
ENV['RACK_ENV'] == 'production'
|
20
20
|
end
|
21
21
|
|
22
|
+
def home?
|
23
|
+
request.path == '/'
|
24
|
+
end
|
25
|
+
|
26
|
+
def meta arg
|
27
|
+
arg.is_a?(Hash) ? meta_hash(arg) : meta_str(arg)
|
28
|
+
end
|
29
|
+
|
22
30
|
def css href = '/style'
|
23
31
|
render_haml "%link{rel: 'stylesheet', href: '#{href}.css'}"
|
24
32
|
end
|
@@ -27,6 +35,10 @@ module Sinatra
|
|
27
35
|
render_haml "%script{src: '#{src}.js'}"
|
28
36
|
end
|
29
37
|
|
38
|
+
def title str, prefix = "", suffix = false
|
39
|
+
render_haml "%title= '#{suffix ? str + prefix : prefix + str}'"
|
40
|
+
end
|
41
|
+
|
30
42
|
def livereload
|
31
43
|
haml "%script{src: 'http://#{request.host}:35729/livereload.js'}" if development? or test?
|
32
44
|
end
|
@@ -43,6 +55,19 @@ module Sinatra
|
|
43
55
|
def render_haml code
|
44
56
|
Haml::Engine.new(code).render
|
45
57
|
end
|
58
|
+
|
59
|
+
def meta_hash hash
|
60
|
+
a = hash.first
|
61
|
+
render_haml "%meta{name: '#{a.first}', content: '#{a.last}'}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def meta_str str
|
65
|
+
case str.to_s
|
66
|
+
when 'charset' then render_haml "%meta{charset: 'utf-8'}"
|
67
|
+
when 'edge' then render_haml "%meta{'http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge'}"
|
68
|
+
when 'viewport' then render_haml "%meta{name: 'viewport', content: 'width=device-width,initial-scale=1'}"
|
69
|
+
end
|
70
|
+
end
|
46
71
|
end
|
47
72
|
end
|
48
73
|
|
data/sinatra-cigars.gemspec
CHANGED
data/spec/helpers_spec.rb
CHANGED
@@ -233,4 +233,96 @@ describe Sinatra::Cigars::Helpers, type: :feature do
|
|
233
233
|
body.should == "<script src=\"//use.typekit.net/kitid.js\"></script>\n<script>try{Typekit.load();}catch(e){}</script>\n"
|
234
234
|
end
|
235
235
|
end
|
236
|
+
|
237
|
+
describe 'home?' do
|
238
|
+
before do
|
239
|
+
mock_app do
|
240
|
+
helpers Sinatra::Cigars::Helpers
|
241
|
+
|
242
|
+
get('/') { home?.to_s }
|
243
|
+
get('/home') { home?.to_s }
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
it do
|
248
|
+
visit '/'
|
249
|
+
body.should == 'true'
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'should == "true" with params' do
|
253
|
+
visit '/?foo=baz'
|
254
|
+
body.should == 'true'
|
255
|
+
end
|
256
|
+
|
257
|
+
it do
|
258
|
+
visit '/home'
|
259
|
+
body.should == 'false'
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe 'meta' do
|
264
|
+
before do
|
265
|
+
mock_app do
|
266
|
+
helpers Sinatra::Cigars::Helpers
|
267
|
+
|
268
|
+
get('/author') { haml '= meta author: "John Q Public"' }
|
269
|
+
get('/charset') { haml '= meta :charset' }
|
270
|
+
get('/description') { haml '= meta description: "page description"' }
|
271
|
+
get('/edge') { haml '= meta :edge' }
|
272
|
+
get('/viewport') { haml '= meta :viewport' }
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
it do
|
277
|
+
visit '/author'
|
278
|
+
body.should == "<meta content='John Q Public' name='author'>\n"
|
279
|
+
end
|
280
|
+
|
281
|
+
it do
|
282
|
+
visit '/charset'
|
283
|
+
body.should == "<meta charset='utf-8'>\n"
|
284
|
+
end
|
285
|
+
|
286
|
+
it do
|
287
|
+
visit '/description'
|
288
|
+
body.should == "<meta content='page description' name='description'>\n"
|
289
|
+
end
|
290
|
+
|
291
|
+
it do
|
292
|
+
visit '/edge'
|
293
|
+
body.should == "<meta content='IE=edge' http-equiv='X-UA-Compatible'>\n"
|
294
|
+
end
|
295
|
+
|
296
|
+
it do
|
297
|
+
visit '/viewport'
|
298
|
+
body.should == "<meta content='width=device-width,initial-scale=1' name='viewport'>\n"
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
describe 'title' do
|
303
|
+
before do
|
304
|
+
mock_app do
|
305
|
+
helpers Sinatra::Cigars::Helpers
|
306
|
+
|
307
|
+
get('/') { haml '= title "title"' }
|
308
|
+
get('/prefix') { haml '= title "title", "prefix - "' }
|
309
|
+
get('/suffix') { haml '= title "title", " - suffix", true' }
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
it do
|
314
|
+
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"
|
321
|
+
end
|
322
|
+
|
323
|
+
it do
|
324
|
+
visit '/suffix'
|
325
|
+
body.should == "<title>title - suffix</title>\n"
|
326
|
+
end
|
327
|
+
end
|
236
328
|
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.11
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: haml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
27
41
|
description: ''
|
28
42
|
email:
|
29
43
|
executables: []
|
@@ -33,8 +47,8 @@ files:
|
|
33
47
|
- ".editorconfig"
|
34
48
|
- ".gitignore"
|
35
49
|
- ".rspec"
|
50
|
+
- Changelog.md
|
36
51
|
- Gemfile
|
37
|
-
- Gemfile.lock
|
38
52
|
- Rakefile
|
39
53
|
- Readme.md
|
40
54
|
- lib/sinatra/cigars.rb
|
data/Gemfile.lock
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
sinatra-cigars (0.0.10)
|
5
|
-
sinatra (~> 1.4)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
capybara (2.2.1)
|
11
|
-
mime-types (>= 1.16)
|
12
|
-
nokogiri (>= 1.3.3)
|
13
|
-
rack (>= 1.0.0)
|
14
|
-
rack-test (>= 0.5.4)
|
15
|
-
xpath (~> 2.0)
|
16
|
-
diff-lcs (1.2.5)
|
17
|
-
mime-types (2.2)
|
18
|
-
mini_portile (0.5.3)
|
19
|
-
nokogiri (1.6.1)
|
20
|
-
mini_portile (~> 0.5.0)
|
21
|
-
rack (1.5.2)
|
22
|
-
rack-protection (1.5.3)
|
23
|
-
rack
|
24
|
-
rack-test (0.6.2)
|
25
|
-
rack (>= 1.0)
|
26
|
-
rake (10.1.0)
|
27
|
-
rspec (2.14.1)
|
28
|
-
rspec-core (~> 2.14.0)
|
29
|
-
rspec-expectations (~> 2.14.0)
|
30
|
-
rspec-mocks (~> 2.14.0)
|
31
|
-
rspec-core (2.14.8)
|
32
|
-
rspec-expectations (2.14.5)
|
33
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
34
|
-
rspec-mocks (2.14.6)
|
35
|
-
sinatra (1.4.5)
|
36
|
-
rack (~> 1.4)
|
37
|
-
rack-protection (~> 1.4)
|
38
|
-
tilt (~> 1.3, >= 1.3.4)
|
39
|
-
tilt (1.4.1)
|
40
|
-
xpath (2.0.0)
|
41
|
-
nokogiri (~> 1.3)
|
42
|
-
|
43
|
-
PLATFORMS
|
44
|
-
ruby
|
45
|
-
|
46
|
-
DEPENDENCIES
|
47
|
-
capybara
|
48
|
-
rake
|
49
|
-
rspec
|
50
|
-
sinatra-cigars!
|