gin 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.rdoc +8 -0
- data/TODO.rdoc +0 -3
- data/lib/gin.rb +2 -1
- data/lib/gin/app.rb +1 -1
- data/lib/gin/config.rb +1 -1
- data/lib/gin/rw_lock.rb +18 -15
- data/lib/gin/test.rb +1 -6
- data/test/test_cache.rb +8 -3
- metadata +14 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e20fe42824dc7458a51fe9ea96b09f99c679529a
|
4
|
+
data.tar.gz: f44971595636a3b44b0a5d0c8c53b29b85b10506
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf9d2e7fd479e59041b0ff4da58526b5e6e9ea95d9b2ab93eb2a824f99a2bcf87894d030d8e2fc382e21961bf2b154309793ced6afca92881d209a5c672423b6
|
7
|
+
data.tar.gz: 6ce807b68799d40b56c41c3ca4fa4681e6271dcca623e3fbf22b47533492cd82def91f95139b6ed2cc93e9442f4e1ec94b854884be1e35668fbbb4d9d1a11dca
|
data/History.rdoc
CHANGED
data/TODO.rdoc
CHANGED
data/lib/gin.rb
CHANGED
data/lib/gin/app.rb
CHANGED
@@ -52,7 +52,7 @@ class Gin::App
|
|
52
52
|
@options[:environment] = ENV['RACK_ENV'] || ENV_DEV
|
53
53
|
@options[:error_delegate] = Gin::Controller
|
54
54
|
@options[:middleware] = []
|
55
|
-
@options[:logger] = $stdout
|
55
|
+
@options[:logger] = Logger.new($stdout)
|
56
56
|
@options[:router] = Gin::Router.new
|
57
57
|
@options[:session_secret] = SESSION_SECRET
|
58
58
|
@options[:protection] = false
|
data/lib/gin/config.rb
CHANGED
data/lib/gin/rw_lock.rb
CHANGED
@@ -34,7 +34,7 @@ class Gin::RWLock
|
|
34
34
|
class WriteTimeout < StandardError; end
|
35
35
|
|
36
36
|
TIMEOUT_MSG = "Took too long to lock all config mutexes. \
|
37
|
-
Try increasing the value of
|
37
|
+
Try increasing the value of write_timeout."
|
38
38
|
|
39
39
|
# The amount of time to wait for writer threads to get all the read locks.
|
40
40
|
attr_accessor :write_timeout
|
@@ -45,30 +45,24 @@ Try increasing the value of Config#write_timeout."
|
|
45
45
|
@write_timeout = write_timeout || 0.05
|
46
46
|
@mutex_id = :"rwlock_#{self.object_id}"
|
47
47
|
@mutex_owned_id = :"#{@mutex_id}_owned"
|
48
|
+
@rmutex_owned_id = :"#{@mutex_id}_r_owned"
|
48
49
|
end
|
49
50
|
|
50
51
|
|
51
52
|
def write_sync
|
52
53
|
lock_mutexes = []
|
53
|
-
relock_curr = false
|
54
54
|
was_locked = Thread.current[@mutex_owned_id]
|
55
55
|
|
56
|
-
curr_mutex = read_mutex
|
57
|
-
|
58
56
|
write_mutex.lock unless was_locked
|
59
57
|
Thread.current[@mutex_owned_id] = true
|
60
58
|
|
61
|
-
# Protect against same-thread deadlocks
|
62
|
-
if curr_mutex && curr_mutex.locked?
|
63
|
-
relock_curr = curr_mutex.unlock rescue false
|
64
|
-
end
|
65
|
-
|
66
59
|
start = Time.now
|
67
60
|
|
68
61
|
Thread.list.each do |t|
|
69
62
|
mutex = t[@mutex_id]
|
70
|
-
next if !mutex ||
|
63
|
+
next if !mutex || t == Thread.current
|
71
64
|
until mutex.try_lock
|
65
|
+
Thread.pass
|
72
66
|
raise WriteTimeout, TIMEOUT_MSG if Time.now - start > @write_timeout
|
73
67
|
end
|
74
68
|
lock_mutexes << mutex
|
@@ -77,7 +71,6 @@ Try increasing the value of Config#write_timeout."
|
|
77
71
|
yield
|
78
72
|
ensure
|
79
73
|
lock_mutexes.each(&:unlock)
|
80
|
-
curr_mutex.try_lock if relock_curr
|
81
74
|
unless was_locked
|
82
75
|
Thread.current[@mutex_owned_id] = false
|
83
76
|
write_mutex.unlock
|
@@ -86,11 +79,17 @@ Try increasing the value of Config#write_timeout."
|
|
86
79
|
|
87
80
|
|
88
81
|
def read_sync
|
89
|
-
was_locked =
|
90
|
-
|
82
|
+
was_locked = Thread.current[@rmutex_owned_id]
|
83
|
+
unless was_locked
|
84
|
+
read_mutex.lock
|
85
|
+
Thread.current[@rmutex_owned_id] = true
|
86
|
+
end
|
91
87
|
yield
|
92
88
|
ensure
|
93
|
-
|
89
|
+
if !was_locked
|
90
|
+
Thread.current[@rmutex_owned_id] = false
|
91
|
+
read_mutex.unlock
|
92
|
+
end
|
94
93
|
end
|
95
94
|
|
96
95
|
|
@@ -104,6 +103,10 @@ Try increasing the value of Config#write_timeout."
|
|
104
103
|
|
105
104
|
def read_mutex
|
106
105
|
return Thread.current[@mutex_id] if Thread.current[@mutex_id]
|
107
|
-
|
106
|
+
if Thread.current[@mutex_owned_id]
|
107
|
+
Thread.current[@mutex_id] = Mutex.new
|
108
|
+
else
|
109
|
+
@wmutex.synchronize{ Thread.current[@mutex_id] = Mutex.new }
|
110
|
+
end
|
108
111
|
end
|
109
112
|
end
|
data/lib/gin/test.rb
CHANGED
@@ -210,7 +210,7 @@ module Gin::Test::Assertions
|
|
210
210
|
|
211
211
|
|
212
212
|
##
|
213
|
-
# Checks that a specific layout was
|
213
|
+
# Checks that a specific layout was used to render the response.
|
214
214
|
|
215
215
|
def assert_layout layout, msg=nil
|
216
216
|
path = @controller.template_path(layout, true)
|
@@ -314,11 +314,6 @@ Run the following command and try again: gem install #{gemname}"
|
|
314
314
|
end
|
315
315
|
|
316
316
|
|
317
|
-
def correct_302_redirect?
|
318
|
-
self.class.correct_302_redirect?
|
319
|
-
end
|
320
|
-
|
321
|
-
|
322
317
|
##
|
323
318
|
# The App instance being used for the requests.
|
324
319
|
|
data/test/test_cache.rb
CHANGED
@@ -17,13 +17,18 @@ class CacheTest < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def test_write_thread_safe
|
19
19
|
@cache[:num] = 0
|
20
|
+
@mutex = Mutex.new
|
21
|
+
@num = 0
|
22
|
+
|
20
23
|
threads = []
|
21
|
-
|
24
|
+
30.times do
|
22
25
|
threads << Thread.new{ @cache[:num] += 1 }
|
23
26
|
end
|
24
|
-
threads.each
|
27
|
+
threads.each do |t|
|
28
|
+
t.join
|
29
|
+
end
|
25
30
|
|
26
|
-
assert_equal
|
31
|
+
assert_equal 30, @cache[:num]
|
27
32
|
end
|
28
33
|
|
29
34
|
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jeremie Castagna
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rack-protection
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: tilt
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,23 +55,20 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rdoc
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
61
|
+
version: '4.0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
68
|
+
version: '4.0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: nokogiri
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: plist
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: bson
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,7 +104,6 @@ dependencies:
|
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ~>
|
124
109
|
- !ruby/object:Gem::Version
|
@@ -126,22 +111,20 @@ dependencies:
|
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: hoe
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
115
|
- - ~>
|
132
116
|
- !ruby/object:Gem::Version
|
133
|
-
version: '3.
|
117
|
+
version: '3.6'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
122
|
- - ~>
|
140
123
|
- !ruby/object:Gem::Version
|
141
|
-
version: '3.
|
142
|
-
description:
|
143
|
-
|
144
|
-
Sinatra expressiveness, and targets larger applications.
|
124
|
+
version: '3.6'
|
125
|
+
description: |-
|
126
|
+
Gin is a small Ruby web framework, built on Rack, which borrows from
|
127
|
+
Sinatra expressiveness, and targets larger applications.
|
145
128
|
email:
|
146
129
|
- yaksnrainbows@gmail.com
|
147
130
|
executables:
|
@@ -211,6 +194,7 @@ files:
|
|
211
194
|
- .gemtest
|
212
195
|
homepage: http://yaks.me/gin
|
213
196
|
licenses: []
|
197
|
+
metadata: {}
|
214
198
|
post_install_message:
|
215
199
|
rdoc_options:
|
216
200
|
- --main
|
@@ -218,25 +202,20 @@ rdoc_options:
|
|
218
202
|
require_paths:
|
219
203
|
- lib
|
220
204
|
required_ruby_version: !ruby/object:Gem::Requirement
|
221
|
-
none: false
|
222
205
|
requirements:
|
223
|
-
- -
|
206
|
+
- - '>='
|
224
207
|
- !ruby/object:Gem::Version
|
225
208
|
version: '0'
|
226
|
-
segments:
|
227
|
-
- 0
|
228
|
-
hash: 3379788584365895606
|
229
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
|
-
none: false
|
231
210
|
requirements:
|
232
|
-
- -
|
211
|
+
- - '>='
|
233
212
|
- !ruby/object:Gem::Version
|
234
213
|
version: '0'
|
235
214
|
requirements: []
|
236
215
|
rubyforge_project: gin
|
237
|
-
rubygems_version:
|
216
|
+
rubygems_version: 2.0.2
|
238
217
|
signing_key:
|
239
|
-
specification_version:
|
218
|
+
specification_version: 4
|
240
219
|
summary: Gin is a small Ruby web framework, built on Rack, which borrows from Sinatra
|
241
220
|
expressiveness, and targets larger applications.
|
242
221
|
test_files:
|