sinatra-support 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +12 -6
- data/lib/sinatra/support.rb +1 -0
- data/lib/sinatra/support/appmodule.rb +55 -0
- data/lib/sinatra/support/jssupport.rb +0 -1
- data/lib/sinatra/support/version.rb +1 -1
- data/test/helper.rb +1 -1
- data/test/test_appmodule.rb +57 -0
- data/test/test_css.rb +10 -3
- metadata +47 -23
data/HISTORY.md
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
v1.2.2 - Sep 01, 2011
|
2
|
+
---------------------
|
3
|
+
|
4
|
+
### Added:
|
5
|
+
* `Sinatra::AppModule` for writing partial applications as modules
|
6
|
+
|
7
|
+
v1.2.1 - Aug 19, 2011
|
8
|
+
---------------------
|
3
9
|
|
4
10
|
### Fixed:
|
5
11
|
* Fixed `Sinatra::CompressedJS` to link to the production version on
|
6
|
-
production
|
12
|
+
production
|
7
13
|
|
8
14
|
### Misc changes:
|
9
|
-
* Make tests more forgiving to account for different Compass/CS/etc versions
|
10
|
-
* Improve CompressedJS docs
|
11
|
-
* Updated gem dependencies to have a required version
|
15
|
+
* Make tests more forgiving to account for different Compass/CS/etc versions
|
16
|
+
* Improve CompressedJS docs
|
17
|
+
* Updated gem dependencies to have a required version
|
12
18
|
|
13
19
|
v1.2.0 - May 27, 2011
|
14
20
|
---------------------
|
data/lib/sinatra/support.rb
CHANGED
@@ -15,6 +15,7 @@ module Sinatra
|
|
15
15
|
autoload :MultiRender, File.expand_path('../support/multirender', __FILE__)
|
16
16
|
autoload :CompassSupport, File.expand_path('../support/compasssupport', __FILE__)
|
17
17
|
autoload :CompressedJS, File.expand_path('../support/compressedjs', __FILE__)
|
18
|
+
autoload :AppModule, File.expand_path('../support/appmodule', __FILE__)
|
18
19
|
|
19
20
|
module Support
|
20
21
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Allows you to write parts of an application as a module.
|
2
|
+
#
|
3
|
+
# == Usage
|
4
|
+
#
|
5
|
+
# require 'sinatra/support/module'
|
6
|
+
#
|
7
|
+
# Create a part of your application by placing the usual Sinatra directives
|
8
|
+
# (@get@, @helpers@, @configure@, etc) in a module. Be sure to @include
|
9
|
+
# Sinatra::AppModule@ first.
|
10
|
+
#
|
11
|
+
# module LoginModule
|
12
|
+
# include Sinatra::AppModule
|
13
|
+
#
|
14
|
+
# helpers do
|
15
|
+
# def logged_in?
|
16
|
+
# # ...
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# get '/login' do
|
21
|
+
# # ...
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# In your Sinatra application, simply include the module to bring those routes
|
26
|
+
# and helpers in.
|
27
|
+
#
|
28
|
+
# class MyApplication < Sinatra::Base
|
29
|
+
# include LoginModule
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
module Sinatra::AppModule
|
33
|
+
def self.included(controller)
|
34
|
+
controller.extend ClassMethods
|
35
|
+
end
|
36
|
+
|
37
|
+
module ClassMethods
|
38
|
+
def included(app)
|
39
|
+
deferred.each { |(method, args, blk)| app.send method, *args, &blk }
|
40
|
+
end
|
41
|
+
|
42
|
+
def method_missing(meth, *args, &blk)
|
43
|
+
defer meth, *args, &blk
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def defer(what, *a, &blk)
|
48
|
+
deferred << [what, a, blk]
|
49
|
+
end
|
50
|
+
|
51
|
+
def deferred
|
52
|
+
@deferred ||= Array.new
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/test/helper.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class AppModuleTest < Test::Unit::TestCase
|
4
|
+
module MyModule
|
5
|
+
include Sinatra::AppModule
|
6
|
+
|
7
|
+
module MyHelpers
|
8
|
+
def apple(); "Apple"; end
|
9
|
+
end
|
10
|
+
|
11
|
+
helpers MyHelpers
|
12
|
+
|
13
|
+
helpers do
|
14
|
+
def banana(); "Banana"; end
|
15
|
+
end
|
16
|
+
|
17
|
+
get('/') { "Hello" }
|
18
|
+
get('/apple') { apple }
|
19
|
+
get('/banana') { banana }
|
20
|
+
|
21
|
+
configure do
|
22
|
+
set :skittles, "rainbow"
|
23
|
+
end
|
24
|
+
|
25
|
+
set :saturn, 'big'
|
26
|
+
end
|
27
|
+
|
28
|
+
class App < Sinatra::Base
|
29
|
+
include MyModule
|
30
|
+
end
|
31
|
+
|
32
|
+
include Rack::Test::Methods
|
33
|
+
def app() App; end
|
34
|
+
|
35
|
+
test "hello" do
|
36
|
+
get '/'
|
37
|
+
assert last_response.body == "Hello"
|
38
|
+
end
|
39
|
+
|
40
|
+
test "helpers in a module" do
|
41
|
+
get '/apple'
|
42
|
+
assert last_response.body == 'Apple'
|
43
|
+
end
|
44
|
+
|
45
|
+
test "helpers" do
|
46
|
+
get '/banana'
|
47
|
+
assert last_response.body == 'Banana'
|
48
|
+
end
|
49
|
+
|
50
|
+
test "configure block" do
|
51
|
+
assert App.skittles == 'rainbow'
|
52
|
+
end
|
53
|
+
|
54
|
+
test "set" do
|
55
|
+
assert App.saturn == 'big'
|
56
|
+
end
|
57
|
+
end
|
data/test/test_css.rb
CHANGED
@@ -12,21 +12,28 @@ class CssAppTest < Test::Unit::TestCase
|
|
12
12
|
App.new
|
13
13
|
end
|
14
14
|
|
15
|
+
def assert_css(css)
|
16
|
+
left = last_response.body.gsub(/[ \r\n\t]+/m, '')
|
17
|
+
right = css.gsub(/[ \r\n\t]+/m, '')
|
18
|
+
|
19
|
+
assert_equal left, right
|
20
|
+
|
21
|
+
end
|
15
22
|
test "sass" do
|
16
23
|
get '/css/style-sass.css'
|
17
24
|
|
18
|
-
|
25
|
+
assert_css "body, #sass {\n color: #333333; }\n"
|
19
26
|
end
|
20
27
|
|
21
28
|
test "scss" do
|
22
29
|
get '/css/style-scss.css'
|
23
30
|
|
24
|
-
|
31
|
+
assert_css "body, #scss {\n color: #333333; }\n"
|
25
32
|
end
|
26
33
|
|
27
34
|
test "less" do
|
28
35
|
get '/css/style-less.css'
|
29
36
|
|
30
|
-
|
37
|
+
assert_css "body, #less { color: #333333; }\n"
|
31
38
|
end
|
32
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,12 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-09-01 00:00:00.000000000 +08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sinatra
|
18
|
-
requirement: &
|
18
|
+
requirement: &2164375900 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: '1.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *2164375900
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack-test
|
29
|
-
requirement: &
|
29
|
+
requirement: &2164365880 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *2164365880
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: ohm
|
40
|
-
requirement: &
|
40
|
+
requirement: &2164364860 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: 0.0.38
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *2164364860
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: haml
|
51
|
-
requirement: &
|
51
|
+
requirement: &2164364300 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ~>
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: 3.1.2
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *2164364300
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: mocha
|
62
|
-
requirement: &
|
62
|
+
requirement: &2164363520 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ~>
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: 0.9.12
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *2164363520
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: nokogiri
|
73
|
-
requirement: &
|
73
|
+
requirement: &2164362660 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ~>
|
@@ -78,10 +78,10 @@ dependencies:
|
|
78
78
|
version: 1.5.0
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
81
|
+
version_requirements: *2164362660
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: contest
|
84
|
-
requirement: &
|
84
|
+
requirement: &2164361740 !ruby/object:Gem::Requirement
|
85
85
|
none: false
|
86
86
|
requirements:
|
87
87
|
- - ~>
|
@@ -89,10 +89,10 @@ dependencies:
|
|
89
89
|
version: 0.1.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
|
-
version_requirements: *
|
92
|
+
version_requirements: *2164361740
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: compass
|
95
|
-
requirement: &
|
95
|
+
requirement: &2164360960 !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
98
98
|
- - ~>
|
@@ -100,10 +100,10 @@ dependencies:
|
|
100
100
|
version: 0.11.5
|
101
101
|
type: :development
|
102
102
|
prerelease: false
|
103
|
-
version_requirements: *
|
103
|
+
version_requirements: *2164360960
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: coffee-script
|
106
|
-
requirement: &
|
106
|
+
requirement: &2164360260 !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
109
109
|
- - ~>
|
@@ -111,10 +111,10 @@ dependencies:
|
|
111
111
|
version: 2.1.1
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
|
-
version_requirements: *
|
114
|
+
version_requirements: *2164360260
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: jsmin
|
117
|
-
requirement: &
|
117
|
+
requirement: &2164359520 !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
120
120
|
- - ~>
|
@@ -122,7 +122,29 @@ dependencies:
|
|
122
122
|
version: 1.0.1
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
|
-
version_requirements: *
|
125
|
+
version_requirements: *2164359520
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: i18n
|
128
|
+
requirement: &2164358940 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: *2164358940
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: less
|
139
|
+
requirement: &2164358120 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: *2164358120
|
126
148
|
description: Sinatra-support includes many helpers for forms, errors and many amazing
|
127
149
|
things.
|
128
150
|
email:
|
@@ -132,6 +154,7 @@ executables: []
|
|
132
154
|
extensions: []
|
133
155
|
extra_rdoc_files: []
|
134
156
|
files:
|
157
|
+
- lib/sinatra/support/appmodule.rb
|
135
158
|
- lib/sinatra/support/compasssupport.rb
|
136
159
|
- lib/sinatra/support/compat-1.8.6.rb
|
137
160
|
- lib/sinatra/support/compressedjs.rb
|
@@ -164,6 +187,7 @@ files:
|
|
164
187
|
- test/fixtures/multirender/views_2/contact.haml
|
165
188
|
- test/fixtures/multirender/views_2/home.haml
|
166
189
|
- test/helper.rb
|
190
|
+
- test/test_appmodule.rb
|
167
191
|
- test/test_compass_app.rb
|
168
192
|
- test/test_compressed_js_app.rb
|
169
193
|
- test/test_country.rb
|
@@ -181,7 +205,7 @@ files:
|
|
181
205
|
- HISTORY.md
|
182
206
|
- Rakefile
|
183
207
|
has_rdoc: true
|
184
|
-
homepage: http://
|
208
|
+
homepage: http://sinefunc.com/sinatra-support
|
185
209
|
licenses: []
|
186
210
|
post_install_message:
|
187
211
|
rdoc_options: []
|