rpcoder 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  $ gem install rpcoder
6
6
 
7
- == generating AS3 RPC code
7
+ == code for AS3 RPC
8
8
 
9
9
  #!/usr/bin/env ruby
10
10
 
@@ -22,15 +22,22 @@
22
22
  RPCoder.function "getMail" do |f|
23
23
  f.path = "/mails/:id" # => ("/mails/" + id)
24
24
  f.method = "GET"
25
- f.return_type = "Mail"
25
+ f.set_return_type "Mail"
26
26
  f.add_param :id, "int"
27
27
  f.description = 'メールを取得'
28
28
  end
29
29
 
30
+ RPCoder.function "getMails" do |f|
31
+ f.path = "/mails"
32
+ f.method = "GET"
33
+ f.set_return_type "Array", {:array_type => "Mail"}
34
+ f.description = 'メールを送信'
35
+ end
36
+
30
37
  RPCoder.function "sendMail" do |f|
31
- f.path = "/mails" # => ("/mails/" + id)
38
+ f.path = "/mails/create"
32
39
  f.method = "POST"
33
- f.return_type = "void"
40
+ f.set_return_type "void"
34
41
  f.add_param :subject, "String"
35
42
  f.add_param :body, "String"
36
43
  f.description = 'メールを送信'
@@ -39,3 +46,13 @@
39
46
  # output codes
40
47
  dir = File.expand_path('src', File.dirname(__FILE__))
41
48
  RPCoder.export(dir)
49
+
50
+ == code for using RPC
51
+
52
+ var rpc:RPC = new RPC('http://localhost:3000');
53
+ rpc.getMail(1, function(mail:Mail):void {
54
+ // success
55
+ }, function():void {
56
+ // failure
57
+ })
58
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -108,8 +108,12 @@ package <%= name_space %>
108
108
  <%- if func.return_type && func.return_type == 'Array' -%>
109
109
  var hash:Object = JSON.decode(e.result as String);
110
110
  var array:Array = new Array();
111
- for each (var elem:Object in hash)
112
- array.push(<%= func.return_type_instance_creator('elem') %>);
111
+ <%-
112
+ @elem_count ||= 0
113
+ @elem_count += 1
114
+ -%>
115
+ for each (var elem<%= @elem_count %>:Object in hash)
116
+ array.push(<%= func.return_type_instance_creator("elem#{@elem_count}") %>);
113
117
  success(array);
114
118
  <%- elsif func.return_type != 'void' -%>
115
119
  success(<%= func.return_type_instance_creator('JSON.decode(e.result as String)') %>);
data/rpcoder.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rpcoder}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jugyo", "Toshiyuki Hirooka"]
12
- s.date = %q{2011-04-27}
12
+ s.date = %q{2011-05-09}
13
13
  s.description = %q{Simple JSON HTTP RPC generator for as3}
14
14
  s.email = %q{toshi.hirooka@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -125,8 +125,8 @@ package foo.bar
125
125
  t = t; // FIXME: for removing warning
126
126
  var hash:Object = JSON.decode(e.result as String);
127
127
  var array:Array = new Array();
128
- for each (var elem:Object in hash)
129
- array.push(new Mail(elem));
128
+ for each (var elem1:Object in hash)
129
+ array.push(new Mail(elem1));
130
130
  success(array);
131
131
  },
132
132
  function(e:FaultEvent, t:Object):void {
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rpcoder
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - jugyo
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-27 00:00:00 Z
14
+ date: 2011-05-09 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- hash: -4034393724026610595
122
+ hash: 3871653312860039459
123
123
  segments:
124
124
  - 0
125
125
  version: "0"