pakada-dispatch 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  require "hooked"
2
2
  require "http_router"
3
+ require "multi_json"
3
4
  require "pakada"
4
5
 
5
6
  require "pakada/dispatch/controller"
@@ -55,7 +55,7 @@ class Pakada
55
55
  options[:render] = false
56
56
  options[:layout] = false
57
57
  response.headers["Content-Type"] = "application/json"
58
- response.write data.to_json
58
+ response.write MultiJson.encode(data)
59
59
  end
60
60
 
61
61
  def json!(data)
@@ -74,25 +74,23 @@ class Pakada
74
74
  @actions ||= {}
75
75
  end
76
76
 
77
- def action(name, options = {}, &block)
77
+ def action(name, opts = {}, &block)
78
78
  if block
79
79
  actions[name] = {
80
80
  :block => block,
81
- :options => options
81
+ :options => opts
82
82
  }
83
83
  else
84
84
  unless action = actions[name]
85
85
  raise ArgumentError, "Unknown action: #{name}"
86
86
  end
87
87
 
88
- options = self.options.dup.tap {|opts|
89
- opts.merge! action[:options]
90
- opts.merge! options
91
- opts.merge! :action => name
92
- }
88
+ options = self.options.merge(action[:options]).
89
+ merge(opts).
90
+ merge(:action => name)
93
91
 
94
92
  proc {|env|
95
- self.new(env, options).process(&action[:block]).response.finish
93
+ self.new(env, options.dup).process(&action[:block]).response.finish
96
94
  }
97
95
  end
98
96
  end
@@ -1,5 +1,5 @@
1
1
  class Pakada
2
2
  class Dispatch
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.4"
4
4
  end
5
5
  end
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency "pakada"
16
16
  s.add_dependency "http_router"
17
+ s.add_dependency "multi_json"
17
18
  s.add_dependency "rack"
18
19
 
19
20
  s.add_development_dependency "rspec"
@@ -96,10 +96,13 @@ describe Pakada::Dispatch::Controller do
96
96
  end
97
97
 
98
98
  context "#json" do
99
- let(:data) { stub "data", :to_json => stub("json_data") }
99
+ let(:data) { stub "data" }
100
+ let(:json) { stub "json" }
100
101
 
101
102
  it "sets a JSON response" do
102
- response.should_receive(:write).with data.to_json
103
+ MultiJson.should_receive(:encode).with(data) { json }
104
+ response.should_receive(:write).with json
105
+
103
106
  ctrlr_obj.json data
104
107
  response.headers["Content-Type"].should == "application/json"
105
108
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakada-dispatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-18 00:00:00.000000000Z
12
+ date: 2011-10-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pakada
16
- requirement: &81086540 !ruby/object:Gem::Requirement
16
+ requirement: &79714000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *81086540
24
+ version_requirements: *79714000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: http_router
27
- requirement: &81086230 !ruby/object:Gem::Requirement
27
+ requirement: &79713730 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *81086230
35
+ version_requirements: *79713730
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &79713460 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *79713460
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rack
38
- requirement: &81085970 !ruby/object:Gem::Requirement
49
+ requirement: &79713190 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :runtime
45
56
  prerelease: false
46
- version_requirements: *81085970
57
+ version_requirements: *79713190
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rspec
49
- requirement: &81080830 !ruby/object:Gem::Requirement
60
+ requirement: &79712950 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *81080830
68
+ version_requirements: *79712950
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: yard
60
- requirement: &81080460 !ruby/object:Gem::Requirement
71
+ requirement: &79712720 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ! '>='
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: '0'
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *81080460
79
+ version_requirements: *79712720
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: rdiscount
71
- requirement: &81080100 !ruby/object:Gem::Requirement
82
+ requirement: &79712450 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,10 +87,10 @@ dependencies:
76
87
  version: '0'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *81080100
90
+ version_requirements: *79712450
80
91
  - !ruby/object:Gem::Dependency
81
92
  name: pakada-render
82
- requirement: &81079600 !ruby/object:Gem::Requirement
93
+ requirement: &79712190 !ruby/object:Gem::Requirement
83
94
  none: false
84
95
  requirements:
85
96
  - - ! '>='
@@ -87,7 +98,7 @@ dependencies:
87
98
  version: '0'
88
99
  type: :development
89
100
  prerelease: false
90
- version_requirements: *81079600
101
+ version_requirements: *79712190
91
102
  description:
92
103
  email:
93
104
  - lars.gierth@gmail.com