ext_direct 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ext_direct.gemspec +2 -2
- data/lib/ext_direct/request.rb +14 -0
- data/lib/ext_direct/response.rb +1 -3
- data/lib/ext_direct/router.rb +0 -6
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/ext_direct.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ext_direct}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcin Lewandowski"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-06-03}
|
13
13
|
s.description = %q{The Ext Direct plugin is a simple implementation of Ext Direct router to call server-side methods on the client-side.}
|
14
14
|
s.email = %q{marcin.martio.lewandowski@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/ext_direct/request.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
module ExtDirect
|
2
2
|
class Request < Rack::Request
|
3
|
+
def initialize(env)
|
4
|
+
update_env(env)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
3
8
|
def action
|
4
9
|
params.fetch("extAction", params.fetch("action", "unknown"))
|
5
10
|
end
|
@@ -44,5 +49,14 @@ module ExtDirect
|
|
44
49
|
def upload?
|
45
50
|
params.include? "extUpload"
|
46
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def update_env(env)
|
56
|
+
if env["CONTENT_TYPE"] and env["CONTENT_TYPE"].match("^application/json")
|
57
|
+
env["rack.input"].rewind
|
58
|
+
env.update("rack.request.form_hash" => JSON.parse(env["rack.input"].read), "rack.request.form_input" => env["rack.input"])
|
59
|
+
end
|
60
|
+
end
|
47
61
|
end
|
48
62
|
end
|
data/lib/ext_direct/response.rb
CHANGED
data/lib/ext_direct/router.rb
CHANGED
@@ -8,12 +8,6 @@ module ExtDirect
|
|
8
8
|
|
9
9
|
def call(env)
|
10
10
|
if env["PATH_INFO"].match("^#{@route_path}")
|
11
|
-
if env["CONTENT_TYPE"] and env["CONTENT_TYPE"].match("^application/json")
|
12
|
-
# support for parsing a POST body data in a JSON format
|
13
|
-
env["rack.input"].rewind
|
14
|
-
env.update("rack.request.form_hash" => JSON.parse(env["rack.input"].read), "rack.request.form_input" => env["rack.input"])
|
15
|
-
end
|
16
|
-
|
17
11
|
request = ExtDirect::Request.new(env)
|
18
12
|
response = ExtDirect::Response.new("", 200, {"Content-Type" => "application/json"})
|
19
13
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Marcin Lewandowski
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-03 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|