jellyfish 0.9.0 → 0.9.1

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: 1bbff880b25384a19ae38417f6318fa77b8bbc4b
4
- data.tar.gz: 391a9abc638194dfb1ac7f662b57659ccba104bd
3
+ metadata.gz: fbbc428cd07afe7548eb82457f5f01f092198fd8
4
+ data.tar.gz: 5f669713f1f3bd5b1a69868116c776739cbaeb37
5
5
  SHA512:
6
- metadata.gz: e1ce357a54f83f8e3f28d28e49b493ef15e7702cc28198b8d6a75d29e7983d062b8685dcdee5bb3f61d8c05b2fa3af833c656c9a24f4f8d11b1e4aa9f2f9254f
7
- data.tar.gz: cbeb51d8505790c6cd404a1f3e464afbcfe5e1e8077af069a1896eb4f77a33578aadcf30d2d73708c4d9fd724a394667038e0623304f49800d78e55db454a4ed
6
+ metadata.gz: d3fabf40031fcf2eee773f38d4fc0a021d9d749d69e47aad0e322aa0744e611f3e1e8b69dc85a0f1a39b7bf96d5a7c629cdd2564e1b9ce992f05c557044d22ec
7
+ data.tar.gz: 12247188a14f764dba3e66dbf81a31ee6e5162434a376f32d29013c5a3b5910d4fef3fbaec3256d191b7179bd790fb217c7a3f581dda342da01e50a77bb43d1c
data/CHANGES.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # CHANGES
2
2
 
3
- ## Jellyfish 0.9.0
3
+ ## Jellyfish 0.9.1 -- 2013-08-23
4
+
5
+ * Fixed a thread safety bug for initializing exception handlers.
6
+
7
+ ## Jellyfish 0.9.0 -- 2013-07-11
4
8
 
5
9
  ### Enhancements for Jellyfish core
6
10
 
@@ -15,7 +19,7 @@
15
19
  it would no longer forward the request but show a 404 page. Always
16
20
  use `forward` if you intend to forward the request.
17
21
 
18
- ## Jellyfish 0.8.0
22
+ ## Jellyfish 0.8.0 -- 2013-06-15
19
23
 
20
24
  ### Incompatible changes
21
25
 
data/README.md CHANGED
@@ -53,6 +53,10 @@ Because Sinatra is too complex and inconsistent for me.
53
53
 
54
54
  ## SYNOPSIS:
55
55
 
56
+ You could also take a look at [Saya][] as an example Jellyfish application.
57
+
58
+ [Saya]: https://github.com/godfat/saya
59
+
56
60
  ### Hello Jellyfish, your lovely config.ru
57
61
 
58
62
  ``` ruby
@@ -701,7 +705,7 @@ class Tank
701
705
  end
702
706
  end
703
707
 
704
- HugeTank = Rack::Builder.new do
708
+ HugeTank = Rack::Builder.app do
705
709
  use Rack::ContentLength
706
710
  use Rack::ContentType, 'text/plain'
707
711
  use Heater
data/Rakefile CHANGED
@@ -3,8 +3,8 @@
3
3
  begin
4
4
  require "#{dir = File.dirname(__FILE__)}/task/gemgem"
5
5
  rescue LoadError
6
- sh "git submodule update --init"
7
- exec Gem.ruby, "-S", "rake", *ARGV
6
+ sh 'git submodule update --init'
7
+ exec Gem.ruby, '-S', 'rake', *ARGV
8
8
  end
9
9
 
10
10
  Gemgem.dir = dir
@@ -16,7 +16,7 @@ task 'gem:spec' do
16
16
  require 'jellyfish/version'
17
17
  s.name = 'jellyfish'
18
18
  s.version = Jellyfish::VERSION
19
- %w[rack bacon].each{ |g| s.add_development_dependency(g) }
19
+ %w[rack bacon muack].each{ |g| s.add_development_dependency(g) }
20
20
  end
21
21
 
22
22
  Gemgem.write
data/jellyfish.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "jellyfish"
5
- s.version = "0.9.0"
5
+ s.version = "0.9.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Lin Jen-Shin (godfat)"]
9
- s.date = "2013-07-11"
9
+ s.date = "2013-08-23"
10
10
  s.description = "Pico web framework for building API-centric web applications.\nFor Rack applications or Rack middlewares. Around 250 lines of code."
11
11
  s.email = ["godfat (XD) godfat.org"]
12
12
  s.files = [
@@ -41,11 +41,12 @@ Gem::Specification.new do |s|
41
41
  "test/sinatra/test_multi_actions.rb",
42
42
  "test/sinatra/test_routing.rb",
43
43
  "test/test_from_readme.rb",
44
- "test/test_inheritance.rb"]
44
+ "test/test_inheritance.rb",
45
+ "test/test_threads.rb"]
45
46
  s.homepage = "https://github.com/godfat/jellyfish"
46
47
  s.licenses = ["Apache License 2.0"]
47
48
  s.require_paths = ["lib"]
48
- s.rubygems_version = "2.0.4"
49
+ s.rubygems_version = "2.0.6"
49
50
  s.summary = "Pico web framework for building API-centric web applications."
50
51
  s.test_files = [
51
52
  "test/sinatra/test_base.rb",
@@ -54,7 +55,8 @@ Gem::Specification.new do |s|
54
55
  "test/sinatra/test_multi_actions.rb",
55
56
  "test/sinatra/test_routing.rb",
56
57
  "test/test_from_readme.rb",
57
- "test/test_inheritance.rb"]
58
+ "test/test_inheritance.rb",
59
+ "test/test_threads.rb"]
58
60
 
59
61
  if s.respond_to? :specification_version then
60
62
  s.specification_version = 4
@@ -62,12 +64,15 @@ Gem::Specification.new do |s|
62
64
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
65
  s.add_development_dependency(%q<rack>, [">= 0"])
64
66
  s.add_development_dependency(%q<bacon>, [">= 0"])
67
+ s.add_development_dependency(%q<muack>, [">= 0"])
65
68
  else
66
69
  s.add_dependency(%q<rack>, [">= 0"])
67
70
  s.add_dependency(%q<bacon>, [">= 0"])
71
+ s.add_dependency(%q<muack>, [">= 0"])
68
72
  end
69
73
  else
70
74
  s.add_dependency(%q<rack>, [">= 0"])
71
75
  s.add_dependency(%q<bacon>, [">= 0"])
76
+ s.add_dependency(%q<muack>, [">= 0"])
72
77
  end
73
78
  end
data/lib/jellyfish.rb CHANGED
@@ -223,7 +223,7 @@ module Jellyfish
223
223
  handlers[e.class]
224
224
  else # or find the nearest match and cache it
225
225
  ancestors = e.class.ancestors
226
- handlers[e.class] = handlers.
226
+ handlers[e.class] = handlers.dup. # thread safe iteration
227
227
  inject([nil, Float::INFINITY]){ |(handler, val), (klass, block)|
228
228
  idx = ancestors.index(klass) || Float::INFINITY # lower is better
229
229
  if idx < val then [block, idx] else [handler, val] end }.first
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Jellyfish
3
- VERSION = '0.9.0'
3
+ VERSION = '0.9.1'
4
4
  end
@@ -411,12 +411,12 @@ describe 'Sinatra routing_test.rb' do
411
411
  should 'play well with other routing middleware' do
412
412
  middleware = Class.new{include Jellyfish}
413
413
  inner_app = Class.new{include Jellyfish; get('/foo'){ 'hello' } }
414
- builder = Rack::Builder.new do
414
+ app = Rack::Builder.app do
415
415
  use middleware
416
416
  map('/test'){ run inner_app.new }
417
417
  end
418
418
 
419
- status, _, body = get('/test/foo', builder.to_app)
419
+ status, _, body = get('/test/foo', app)
420
420
  status.should.eq 200
421
421
  body .should.eq ['hello']
422
422
  end
@@ -27,7 +27,7 @@ describe 'from README.md' do
27
27
  pinfo, query = uri.path, uri.query
28
28
 
29
29
  status, headers, body = File.open(File::NULL) do |input|
30
- Rack::Builder.new{ eval(code) }.call(
30
+ Rack::Builder.app{ eval(code) }.call(
31
31
  'REQUEST_METHOD' => method, 'PATH_INFO' => pinfo,
32
32
  'QUERY_STRING' => query , 'rack.input' => input)
33
33
  end
@@ -0,0 +1,40 @@
1
+
2
+ require 'jellyfish/test'
3
+ require 'muack'
4
+
5
+ include Muack::API
6
+
7
+ describe Jellyfish do
8
+ after do
9
+ Muack.verify
10
+ end
11
+
12
+ app = Class.new{
13
+ include Jellyfish
14
+ handle(Exception){ |env| 0 }
15
+ }.new
16
+
17
+ exp = RuntimeError.new
18
+
19
+ should "no RuntimeError: can't add a new key into hash during iteration" do
20
+ # make static ancestors so that we could stub it
21
+ ancestors = RuntimeError.ancestors
22
+ stub(RuntimeError).ancestors{ancestors}
23
+ flip = true
24
+ stub(ancestors).index(anything).proxy.returns do |i|
25
+ if flip
26
+ flip = false
27
+ sleep 0.0001
28
+ end
29
+ i
30
+ end
31
+
32
+ 2.times.map{
33
+ Thread.new do
34
+ app.send(:best_handler, exp).call({}).should.eq 0
35
+ end
36
+ }.each(&:join)
37
+
38
+ flip.should.eq false
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jellyfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-11 00:00:00.000000000 Z
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: muack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: |-
42
56
  Pico web framework for building API-centric web applications.
43
57
  For Rack applications or Rack middlewares. Around 250 lines of code.
@@ -79,6 +93,7 @@ files:
79
93
  - test/sinatra/test_routing.rb
80
94
  - test/test_from_readme.rb
81
95
  - test/test_inheritance.rb
96
+ - test/test_threads.rb
82
97
  homepage: https://github.com/godfat/jellyfish
83
98
  licenses:
84
99
  - Apache License 2.0
@@ -99,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
114
  version: '0'
100
115
  requirements: []
101
116
  rubyforge_project:
102
- rubygems_version: 2.0.4
117
+ rubygems_version: 2.0.6
103
118
  signing_key:
104
119
  specification_version: 4
105
120
  summary: Pico web framework for building API-centric web applications.
@@ -111,3 +126,4 @@ test_files:
111
126
  - test/sinatra/test_routing.rb
112
127
  - test/test_from_readme.rb
113
128
  - test/test_inheritance.rb
129
+ - test/test_threads.rb