rpcoder 0.2.6 → 0.3.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.3.0
@@ -97,7 +97,7 @@ package <%= name_space %>
97
97
  * @error:Function
98
98
  */
99
99
  <%-
100
- params = func.params.map{|i| [i.name, i.type].join(':') } + ['success:Function', 'error:Function']
100
+ params = func.params.map{|i| [i.name, i.type].join(':') } + ['success:Function', 'error:Function = null']
101
101
  -%>
102
102
  public function <%= func.name %>(<%= params.join(', ') %>):void
103
103
  {
@@ -128,12 +128,7 @@ package <%= name_space %>
128
128
  end
129
129
  -%>
130
130
  success(<%= args.join(', ') %>);
131
- },
132
- function(e:FaultEvent, t:Object):void {
133
- t = t; // FIXME: for removing warning
134
- error(e);
135
- }
136
- );
131
+ }, error);
137
132
  }
138
133
 
139
134
  <%- end -%>
@@ -148,10 +143,23 @@ package <%= name_space %>
148
143
  token.addResponder(new AsyncResponder(
149
144
  success,
150
145
  function(e:FaultEvent, t:Object):void {
151
- if (_errorHandler !== null && e.statusCode >= 500) {
152
- _errorHandler(e, t);
146
+ var handler : Function;
147
+ if (error !== null) {
148
+ handler = error;
153
149
  } else {
154
- error(e, t);
150
+ handler = _errorHandler;
151
+ }
152
+ switch ( handler.length )
153
+ {
154
+ case 0:
155
+ handler.call(this);
156
+ break;
157
+ case 1:
158
+ handler.call(this, e);
159
+ break;
160
+ case 2:
161
+ handler.call(this, e, t);
162
+ break;
155
163
  }
156
164
  }
157
165
  ));
@@ -6,6 +6,24 @@ package <%= name_space %>
6
6
 
7
7
  public class <%= api_class_name %>Dummy implements <%= api_class_name %>Interface
8
8
  {
9
+ private var _baseUrl:String;
10
+ private var _errorHandler : Function;
11
+
12
+ public function get baseUrl():String
13
+ {
14
+ return this._baseUrl;
15
+ }
16
+
17
+ public function set errorHandler(handler : Function):void
18
+ {
19
+ this._errorHandler = handler;
20
+ }
21
+
22
+ public function get errorHandler():Function
23
+ {
24
+ return this._errorHandler;
25
+ }
26
+
9
27
  private var _errors:Array = new Array();
10
28
  private var _dummy_success:Array = new Array();
11
29
 
@@ -40,7 +58,7 @@ package <%= name_space %>
40
58
  * @error:Function
41
59
  */
42
60
  <%-
43
- params = func.params.map{|i| [i.name, i.type].join(':') } + ['success:Function', 'error:Function']
61
+ params = func.params.map{|i| [i.name, i.type].join(':') } + ['success:Function', 'error:Function = null']
44
62
  -%>
45
63
  public function <%= func.name %>(<%= params.join(', ') %>):void
46
64
  {
@@ -52,7 +70,13 @@ package <%= name_space %>
52
70
  {
53
71
  if ( isError(function_name) )
54
72
  {
55
- error(new FaultEvent("dummy fault"));
73
+ var e:FaultEvent = new FaultEvent("dummy fault");
74
+ var t:Object = this;
75
+ if (_errorHandler !== null) {
76
+ _errorHandler(e, t);
77
+ } else {
78
+ error(e, t);
79
+ }
56
80
  }
57
81
  else
58
82
  {
@@ -4,6 +4,10 @@ package <%= name_space %>
4
4
  {
5
5
  public interface <%= api_class_name %>Interface
6
6
  {
7
+ function get baseUrl():String;
8
+ function set errorHandler(handler : Function):void;
9
+ function get errorHandler():Function;
10
+
7
11
  <%- functions.each do |func| -%>
8
12
  /**
9
13
  * <%= func.description %>
@@ -15,7 +19,7 @@ package <%= name_space %>
15
19
  * @error:Function
16
20
  */
17
21
  <%-
18
- params = func.params.map{|i| [i.name, i.type].join(':') } + ['success:Function', 'error:Function']
22
+ params = func.params.map{|i| [i.name, i.type].join(':') } + ['success:Function', 'error:Function = null']
19
23
  -%>
20
24
  function <%= func.name %>(<%= params.join(', ') %>):void;
21
25
 
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.2.6"
8
+ s.version = "0.3.0"
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-05-17}
12
+ s.date = %q{2011-05-23}
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 = [
@@ -96,7 +96,7 @@ package foo.bar
96
96
  * @success:Function
97
97
  * @error:Function
98
98
  */
99
- public function getMail(id:int, foo:String, bar:Array, baz:Boolean, success:Function, error:Function):void
99
+ public function getMail(id:int, foo:String, bar:Array, baz:Boolean, success:Function, error:Function = null):void
100
100
  {
101
101
  var params:Object = {"foo":foo, "bar":bar, "baz":baz};
102
102
  request("GET", "/mails/" + id, params,
@@ -106,12 +106,7 @@ package foo.bar
106
106
 
107
107
 
108
108
  success(new Mail(hash['mail']));
109
- },
110
- function(e:FaultEvent, t:Object):void {
111
- t = t; // FIXME: for removing warning
112
- error(e);
113
- }
114
- );
109
+ }, error);
115
110
  }
116
111
 
117
112
  /**
@@ -120,7 +115,7 @@ package foo.bar
120
115
  * @success:Function
121
116
  * @error:Function
122
117
  */
123
- public function getMails(success:Function, error:Function):void
118
+ public function getMails(success:Function, error:Function = null):void
124
119
  {
125
120
  var params:Object = {};
126
121
  request("GET", "/mails/", params,
@@ -133,12 +128,7 @@ package foo.bar
133
128
  mails_list.push(new Mail(mails));
134
129
 
135
130
  success(mails_list, hash['count']);
136
- },
137
- function(e:FaultEvent, t:Object):void {
138
- t = t; // FIXME: for removing warning
139
- error(e);
140
- }
141
- );
131
+ }, error);
142
132
  }
143
133
 
144
134
  public function request(method:String, path:String, params:Object, success:Function, error:Function):void
@@ -152,10 +142,23 @@ package foo.bar
152
142
  token.addResponder(new AsyncResponder(
153
143
  success,
154
144
  function(e:FaultEvent, t:Object):void {
155
- if (_errorHandler !== null && e.statusCode >= 500) {
156
- _errorHandler(e, t);
145
+ var handler : Function;
146
+ if (error !== null) {
147
+ handler = error;
157
148
  } else {
158
- error(e, t);
149
+ handler = _errorHandler;
150
+ }
151
+ switch ( handler.length )
152
+ {
153
+ case 0:
154
+ handler.call(this);
155
+ break;
156
+ case 1:
157
+ handler.call(this, e);
158
+ break;
159
+ case 2:
160
+ handler.call(this, e, t);
161
+ break;
159
162
  }
160
163
  }
161
164
  ));
@@ -6,6 +6,24 @@ package foo.bar
6
6
 
7
7
  public class APIDummy implements APIInterface
8
8
  {
9
+ private var _baseUrl:String;
10
+ private var _errorHandler : Function;
11
+
12
+ public function get baseUrl():String
13
+ {
14
+ return this._baseUrl;
15
+ }
16
+
17
+ public function set errorHandler(handler : Function):void
18
+ {
19
+ this._errorHandler = handler;
20
+ }
21
+
22
+ public function get errorHandler():Function
23
+ {
24
+ return this._errorHandler;
25
+ }
26
+
9
27
  private var _errors:Array = new Array();
10
28
  private var _dummy_success:Array = new Array();
11
29
 
@@ -39,7 +57,7 @@ package foo.bar
39
57
  * @success:Function
40
58
  * @error:Function
41
59
  */
42
- public function getMail(id:int, foo:String, bar:Array, baz:Boolean, success:Function, error:Function):void
60
+ public function getMail(id:int, foo:String, bar:Array, baz:Boolean, success:Function, error:Function = null):void
43
61
  {
44
62
  requestDummy('getMail', success, error);
45
63
  }
@@ -50,7 +68,7 @@ package foo.bar
50
68
  * @success:Function
51
69
  * @error:Function
52
70
  */
53
- public function getMails(success:Function, error:Function):void
71
+ public function getMails(success:Function, error:Function = null):void
54
72
  {
55
73
  requestDummy('getMails', success, error);
56
74
  }
@@ -59,7 +77,13 @@ package foo.bar
59
77
  {
60
78
  if ( isError(function_name) )
61
79
  {
62
- error(new FaultEvent("dummy fault"));
80
+ var e:FaultEvent = new FaultEvent("dummy fault");
81
+ var t:Object = this;
82
+ if (_errorHandler !== null) {
83
+ _errorHandler(e, t);
84
+ } else {
85
+ error(e, t);
86
+ }
63
87
  }
64
88
  else
65
89
  {
@@ -4,6 +4,10 @@ package foo.bar
4
4
  {
5
5
  public interface APIInterface
6
6
  {
7
+ function get baseUrl():String;
8
+ function set errorHandler(handler : Function):void;
9
+ function get errorHandler():Function;
10
+
7
11
  /**
8
12
  * get mail
9
13
  *
@@ -14,7 +18,7 @@ package foo.bar
14
18
  * @success:Function
15
19
  * @error:Function
16
20
  */
17
- function getMail(id:int, foo:String, bar:Array, baz:Boolean, success:Function, error:Function):void;
21
+ function getMail(id:int, foo:String, bar:Array, baz:Boolean, success:Function, error:Function = null):void;
18
22
 
19
23
  /**
20
24
  * get mails
@@ -22,7 +26,7 @@ package foo.bar
22
26
  * @success:Function
23
27
  * @error:Function
24
28
  */
25
- function getMails(success:Function, error:Function):void;
29
+ function getMails(success:Function, error:Function = null):void;
26
30
 
27
31
  }
28
32
  }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rpcoder
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.6
5
+ version: 0.3.0
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-05-17 00:00:00 Z
14
+ date: 2011-05-23 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- hash: 347747791840221149
131
+ hash: -647749759454709672
132
132
  segments:
133
133
  - 0
134
134
  version: "0"