sinatra-cigars 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +9 -0
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +50 -0
- data/Rakefile +6 -0
- data/Readme.md +1 -0
- data/lib/sinatra/cigars.rb +2 -0
- data/lib/sinatra/cigars/helpers.rb +50 -0
- data/lib/sinatra/cigars/version.rb +5 -0
- data/sinatra-cigars.gemspec +15 -0
- data/spec/cigars_spec.rb +15 -0
- data/spec/helpers_spec.rb +236 -0
- data/spec/spec_helper.rb +15 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d72bf5d42d37ed3d556fb11b6c5d0bd1f71ff3b
|
4
|
+
data.tar.gz: 1a2549eb9a7446bd8b408549c55f6deb65e8766c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eed942a38e225beefa557fe0f8adc581a5bd7cb9b0070bcd52ac1e6a5a198d2074b3d90aa82180f4258416c6950bc275c297ed1f0390948abd36b8f31c316c7a
|
7
|
+
data.tar.gz: d667609ce6fe843ff277e39b5254ff4c3e81724d7c055fab825b13151b8455417ae82dffeb6a186cbd572dee7d2a7746afb9ab7b3ea6dfbe63f346f952c81dc6
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
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!
|
data/Rakefile
ADDED
data/Readme.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Sinatra::Cigars
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module Sinatra
|
4
|
+
module Cigars
|
5
|
+
module Helpers
|
6
|
+
def development?
|
7
|
+
ENV['RACK_ENV'] == 'development'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test?
|
11
|
+
ENV['RACK_ENV'] == 'test'
|
12
|
+
end
|
13
|
+
|
14
|
+
def staging?
|
15
|
+
ENV['RACK_ENV'] == 'staging'
|
16
|
+
end
|
17
|
+
|
18
|
+
def production?
|
19
|
+
ENV['RACK_ENV'] == 'production'
|
20
|
+
end
|
21
|
+
|
22
|
+
def css href = '/style'
|
23
|
+
render_haml "%link{rel: 'stylesheet', href: '#{href}.css'}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def js src
|
27
|
+
render_haml "%script{src: '#{src}.js'}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def livereload
|
31
|
+
haml "%script{src: 'http://#{request.host}:35729/livereload.js'}" if development? or test?
|
32
|
+
end
|
33
|
+
|
34
|
+
def typekit id
|
35
|
+
src = <<-EOF.gsub(/^ {8}/, '')
|
36
|
+
<script src="//use.typekit.net/#{id}.js"></script>
|
37
|
+
<script>try{Typekit.load();}catch(e){}</script>
|
38
|
+
EOF
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def render_haml code
|
44
|
+
Haml::Engine.new(code).render
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
helpers Cigars::Helpers
|
50
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path '../lib/sinatra/cigars/version', __FILE__
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.author = 'Seiichi Yonezawa'
|
5
|
+
spec.description = ''
|
6
|
+
spec.homepage = 'http://sinatra-cigars.nzwsch.com'
|
7
|
+
spec.name = 'sinatra-cigars'
|
8
|
+
spec.summary = spec.description
|
9
|
+
spec.version = Sinatra::Cigars::VERSION
|
10
|
+
|
11
|
+
spec.files = `git ls-files -z`.split("\x0")
|
12
|
+
spec.require_paths = ["lib"]
|
13
|
+
|
14
|
+
spec.add_dependency "sinatra", "~> 1.4"
|
15
|
+
end
|
data/spec/cigars_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sinatra::Cigars do
|
4
|
+
context 'VERSION' do
|
5
|
+
it do
|
6
|
+
Sinatra::Cigars::VERSION.should match /^\d+\.\d+\.\d+/
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'Helpers' do
|
11
|
+
it 'included automatically' do
|
12
|
+
defined?(Sinatra::Cigars::Helpers).should be_true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,236 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sinatra::Cigars::Helpers, type: :feature do
|
4
|
+
include Sinatra::TestHelpers
|
5
|
+
|
6
|
+
describe 'development?' do
|
7
|
+
before do
|
8
|
+
ENV['RACK_ENV'] = 'development'
|
9
|
+
|
10
|
+
mock_app do
|
11
|
+
helpers Sinatra::Cigars::Helpers
|
12
|
+
|
13
|
+
get('/development') { development?.to_s }
|
14
|
+
get('/test') { test?.to_s }
|
15
|
+
get('/staging') { staging?.to_s }
|
16
|
+
get('/production') { production?.to_s }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it do
|
21
|
+
visit '/development'
|
22
|
+
body.should == 'true'
|
23
|
+
end
|
24
|
+
|
25
|
+
it do
|
26
|
+
visit '/test'
|
27
|
+
body.should == 'false'
|
28
|
+
end
|
29
|
+
|
30
|
+
it do
|
31
|
+
visit '/staging'
|
32
|
+
body.should == 'false'
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
visit '/production'
|
37
|
+
body.should == 'false'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'test?' do
|
42
|
+
before do
|
43
|
+
ENV['RACK_ENV'] = 'test'
|
44
|
+
|
45
|
+
mock_app do
|
46
|
+
helpers Sinatra::Cigars::Helpers
|
47
|
+
|
48
|
+
get('/development') { development?.to_s }
|
49
|
+
get('/test') { test?.to_s }
|
50
|
+
get('/staging') { staging?.to_s }
|
51
|
+
get('/production') { production?.to_s }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it do
|
56
|
+
visit '/development'
|
57
|
+
body.should == 'false'
|
58
|
+
end
|
59
|
+
|
60
|
+
it do
|
61
|
+
visit '/test'
|
62
|
+
body.should == 'true'
|
63
|
+
end
|
64
|
+
|
65
|
+
it do
|
66
|
+
visit '/staging'
|
67
|
+
body.should == 'false'
|
68
|
+
end
|
69
|
+
|
70
|
+
it do
|
71
|
+
visit '/production'
|
72
|
+
body.should == 'false'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'staging?' do
|
77
|
+
before do
|
78
|
+
ENV['RACK_ENV'] = 'staging'
|
79
|
+
|
80
|
+
mock_app do
|
81
|
+
helpers Sinatra::Cigars::Helpers
|
82
|
+
|
83
|
+
get('/development') { development?.to_s }
|
84
|
+
get('/test') { test?.to_s }
|
85
|
+
get('/staging') { staging?.to_s }
|
86
|
+
get('/production') { production?.to_s }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it do
|
91
|
+
visit '/development'
|
92
|
+
body.should == 'false'
|
93
|
+
end
|
94
|
+
|
95
|
+
it do
|
96
|
+
visit '/test'
|
97
|
+
body.should == 'false'
|
98
|
+
end
|
99
|
+
|
100
|
+
it do
|
101
|
+
visit '/staging'
|
102
|
+
body.should == 'true'
|
103
|
+
end
|
104
|
+
|
105
|
+
it do
|
106
|
+
visit '/production'
|
107
|
+
body.should == 'false'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'production?' do
|
112
|
+
before do
|
113
|
+
ENV['RACK_ENV'] = 'production'
|
114
|
+
|
115
|
+
mock_app do
|
116
|
+
helpers Sinatra::Cigars::Helpers
|
117
|
+
|
118
|
+
get('/development') { development?.to_s }
|
119
|
+
get('/test') { test?.to_s }
|
120
|
+
get('/staging') { staging?.to_s }
|
121
|
+
get('/production') { production?.to_s }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it do
|
126
|
+
visit '/development'
|
127
|
+
body.should == 'false'
|
128
|
+
end
|
129
|
+
|
130
|
+
it do
|
131
|
+
visit '/test'
|
132
|
+
body.should == 'false'
|
133
|
+
end
|
134
|
+
|
135
|
+
it do
|
136
|
+
visit '/staging'
|
137
|
+
body.should == 'false'
|
138
|
+
end
|
139
|
+
|
140
|
+
it do
|
141
|
+
visit '/production'
|
142
|
+
body.should == 'true'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe 'css' do
|
147
|
+
before do
|
148
|
+
mock_app do
|
149
|
+
helpers Sinatra::Cigars::Helpers
|
150
|
+
|
151
|
+
get('/') { haml '= css' }
|
152
|
+
|
153
|
+
get('/custom') { haml '= css :custom' }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it do
|
158
|
+
visit '/'
|
159
|
+
body.should == "<link href='/style.css' rel='stylesheet'>\n"
|
160
|
+
end
|
161
|
+
|
162
|
+
it do
|
163
|
+
visit '/custom'
|
164
|
+
body.should == "<link href='custom.css' rel='stylesheet'>\n"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe 'js' do
|
169
|
+
before do
|
170
|
+
mock_app do
|
171
|
+
helpers Sinatra::Cigars::Helpers
|
172
|
+
|
173
|
+
get('/') { haml '= js "/script"' }
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
it do
|
178
|
+
visit '/'
|
179
|
+
body.should == "<script src='/script.js'></script>\n"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe 'livereload' do
|
184
|
+
before do
|
185
|
+
mock_app do
|
186
|
+
helpers Sinatra::Cigars::Helpers
|
187
|
+
|
188
|
+
get('/development') { haml '= livereload' }
|
189
|
+
get('/test') { haml '= livereload' }
|
190
|
+
get('/staging') { haml '= livereload' }
|
191
|
+
get('/production') { haml '= livereload' }
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
it do
|
196
|
+
ENV['RACK_ENV'] = 'development'
|
197
|
+
visit '/development'
|
198
|
+
body.should == "<script src='http://www.example.com:35729/livereload.js'></script>\n"
|
199
|
+
end
|
200
|
+
|
201
|
+
it do
|
202
|
+
ENV['RACK_ENV'] = 'test'
|
203
|
+
visit '/test'
|
204
|
+
body.should == "<script src='http://www.example.com:35729/livereload.js'></script>\n"
|
205
|
+
end
|
206
|
+
|
207
|
+
it do
|
208
|
+
ENV['RACK_ENV'] = 'staging'
|
209
|
+
visit '/staging'
|
210
|
+
body.should == "\n"
|
211
|
+
end
|
212
|
+
|
213
|
+
it do
|
214
|
+
ENV['RACK_ENV'] = 'production'
|
215
|
+
visit '/production'
|
216
|
+
body.should == "\n"
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe 'typekit' do
|
221
|
+
before do
|
222
|
+
ENV['RACK_ENV'] = 'test'
|
223
|
+
|
224
|
+
mock_app do
|
225
|
+
helpers Sinatra::Cigars::Helpers
|
226
|
+
|
227
|
+
get('/') { haml '= typekit :kitid' }
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
it do
|
232
|
+
visit '/'
|
233
|
+
body.should == "<script src=\"//use.typekit.net/kitid.js\"></script>\n<script>try{Typekit.load();}catch(e){}</script>\n"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
2
|
+
|
3
|
+
require 'capybara/rspec'
|
4
|
+
require 'sinatra/cigars'
|
5
|
+
|
6
|
+
module Sinatra
|
7
|
+
module TestHelpers
|
8
|
+
def mock_app &block
|
9
|
+
@app = Sinatra.new Sinatra::Application do
|
10
|
+
class_eval &block
|
11
|
+
end
|
12
|
+
Capybara.app = @app
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-cigars
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Seiichi Yonezawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
description: ''
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".editorconfig"
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- Gemfile
|
37
|
+
- Gemfile.lock
|
38
|
+
- Rakefile
|
39
|
+
- Readme.md
|
40
|
+
- lib/sinatra/cigars.rb
|
41
|
+
- lib/sinatra/cigars/helpers.rb
|
42
|
+
- lib/sinatra/cigars/version.rb
|
43
|
+
- sinatra-cigars.gemspec
|
44
|
+
- spec/cigars_spec.rb
|
45
|
+
- spec/helpers_spec.rb
|
46
|
+
- spec/spec_helper.rb
|
47
|
+
homepage: http://sinatra-cigars.nzwsch.com
|
48
|
+
licenses: []
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.2.2
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: ''
|
70
|
+
test_files: []
|