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.
- data/lib/pakada/dispatch.rb +1 -0
- data/lib/pakada/dispatch/controller.rb +7 -9
- data/lib/pakada/dispatch/version.rb +1 -1
- data/pakada-dispatch.gemspec +1 -0
- data/spec/controller_spec.rb +5 -2
- metadata +27 -16
data/lib/pakada/dispatch.rb
CHANGED
@@ -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
|
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,
|
77
|
+
def action(name, opts = {}, &block)
|
78
78
|
if block
|
79
79
|
actions[name] = {
|
80
80
|
:block => block,
|
81
|
-
: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.
|
89
|
-
|
90
|
-
|
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
|
data/pakada-dispatch.gemspec
CHANGED
data/spec/controller_spec.rb
CHANGED
@@ -96,10 +96,13 @@ describe Pakada::Dispatch::Controller do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
context "#json" do
|
99
|
-
let(:data) { stub "data"
|
99
|
+
let(:data) { stub "data" }
|
100
|
+
let(:json) { stub "json" }
|
100
101
|
|
101
102
|
it "sets a JSON response" do
|
102
|
-
|
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.
|
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-
|
12
|
+
date: 2011-10-19 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pakada
|
16
|
-
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: *
|
24
|
+
version_requirements: *79714000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: http_router
|
27
|
-
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: *
|
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: &
|
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: *
|
57
|
+
version_requirements: *79713190
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: rspec
|
49
|
-
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: *
|
68
|
+
version_requirements: *79712950
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: yard
|
60
|
-
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: *
|
79
|
+
version_requirements: *79712720
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: rdiscount
|
71
|
-
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: *
|
90
|
+
version_requirements: *79712450
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: pakada-render
|
82
|
-
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: *
|
101
|
+
version_requirements: *79712190
|
91
102
|
description:
|
92
103
|
email:
|
93
104
|
- lars.gierth@gmail.com
|