aries 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a721b5050b0c0d62fac4c082a6999db9b0b7fd32
4
- data.tar.gz: 83c31100b9aa075a09bad91bfa6215edf82fd5b6
3
+ metadata.gz: 3e6227534776e0c86fd9d60f9cd995b05e2d183c
4
+ data.tar.gz: d1b03be5e483fa2875381fb19d0d24189bd708fc
5
5
  SHA512:
6
- metadata.gz: abbab34967cf7e96b9552886c2f777aeffefd67eca7295e180f871fc468065649a91faf586f58ff56325c5f10962e8ee48d055861b821f320242ceb67d5885aa
7
- data.tar.gz: c7fa32042565cc17e52379d51d5c53d7497d228cf7781ef0872d80b3278635dabc6764c0ac320189f969c19abbcb16fb1d527a96659d0e9e5e62ed4b525a1cf2
6
+ metadata.gz: 64e02c38a77a72588d62ef6dec0af77dae2b0c558c4e08d496d1dc6f84ff2cbd50ab1d00b5490e1cea4bf345ee221234ed316a06e6a91c7dcaebaffd180f34f7
7
+ data.tar.gz: 7b82b2f2db6c42afaa07517d1525c2568a2edd9c6f0d5ee5e9259ab6858368212f44890767a3eae5f90f78f6443fe5ae11ead985dac004e8d08fbdf1005a3532
data/README.md CHANGED
@@ -34,9 +34,9 @@ Aries can setup costom config for api client class name, base url, output path.
34
34
  --url http://api.myapp.com \
35
35
  --output /path/to/dir
36
36
 
37
- ### Swift(v1,1)
37
+ ### Swift(v1.2)
38
38
 
39
- Dependent on [SwiftTask](https://github.com/ReactKit/SwiftTask), [Alamofire](https://github.com/Alamofire/Alamofire), [URITemplate](https://github.com/kylef/URITemplate.swift).
39
+ Dependent on [SwiftTask](https://github.com/ReactKit/SwiftTask), [Alamofire](https://github.com/Alamofire/Alamofire),
40
40
  Aries api client should be used with these libraries, and works like promise style.
41
41
 
42
42
  Aries api client behaves use the following.
@@ -1,23 +1,22 @@
1
1
  //
2
- // RackJsonSchemaApi.swift
2
+ // RackJSONSchemaApi.swift
3
3
  //
4
- // Auto generated by Aries on 2015/04/11.
4
+ // Auto generated by Aries on 2015/04/30.
5
5
  // Do not modify this file directory
6
6
  //
7
7
 
8
8
  import Alamofire
9
9
  import SwiftTask
10
- import URITemplate
11
10
 
12
- typealias RackJsonSchemaApiResponse = Task<Int,AnyObject,NSError>
11
+ typealias RackJSONSchemaApiResponse = Task<Int,AnyObject,NSError>
13
12
 
14
- protocol RackJsonSchemaApiDelegate {
13
+ protocol RackJSONSchemaApiDelegate {
15
14
  func customReqeust(request: NSMutableURLRequest) -> NSMutableURLRequest
16
15
  func onDefaultSuccess(response: AnyObject) -> AnyObject
17
16
  func onDefaultFailure(err: NSError) -> NSError
18
17
  }
19
18
 
20
- class RackJsonSchemaApi {
19
+ class RackJSONSchemaApi {
21
20
 
22
21
  private struct BaseUrlStringStruct{ static var url = "http://localhost:5000" }
23
22
  class var BaseUrlString: String {
@@ -27,21 +26,21 @@ class RackJsonSchemaApi {
27
26
 
28
27
  // workaround tips
29
28
  // After updated swift 1.2, use ( static var someVariable: Int = 0 ) instead
30
- private struct delegateStruct{ static var detegator: RackJsonSchemaApiDelegate? }
31
- class var delegate: RackJsonSchemaApiDelegate? {
29
+ private struct delegateStruct{ static var detegator: RackJSONSchemaApiDelegate? }
30
+ class var delegate: RackJSONSchemaApiDelegate? {
32
31
  get{ return delegateStruct.detegator }
33
32
  set{ delegateStruct.detegator = newValue }
34
33
  }
35
34
 
36
35
  private class func defaultURLRequest(let path: String, let method: Alamofire.Method) -> NSMutableURLRequest {
37
- let URL = NSURL(string: RackJsonSchemaApi.BaseUrlString)!
36
+ let URL = NSURL(string: RackJSONSchemaApi.BaseUrlString)!
38
37
  let mutableURLRequest = NSMutableURLRequest(URL: URL.URLByAppendingPathComponent(path))
39
38
 
40
39
  mutableURLRequest.HTTPMethod = method.rawValue
41
40
  mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
42
41
  mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Accept")
43
42
 
44
- if let delegate = self.delegate?{
43
+ if let delegate = self.delegate{
45
44
  return delegate.customReqeust(mutableURLRequest)
46
45
  }
47
46
 
@@ -49,34 +48,39 @@ class RackJsonSchemaApi {
49
48
  }
50
49
 
51
50
  private class func generateURI(template: String, params: [String: AnyObject]?) -> String {
51
+ var uri = template
52
52
  if let params = params {
53
- return URITemplate(template: template).expand(params)
53
+ for (key, value) in params {
54
+ if let value = value as? String {
55
+ uri = uri.stringByReplacingOccurrencesOfString("{\(key)}", withString: value)
56
+ }
57
+ }
54
58
  }
55
- return template
59
+ return uri
56
60
  }
57
61
 
58
62
  class Base {
59
63
 
60
- private class func request(URLRequest: URLRequestConvertible) -> RackJsonSchemaApiResponse {
61
- return RackJsonSchemaApiResponse {(progress, fulfill, reject, configure) in
64
+ private class func request(URLRequest: URLRequestConvertible) -> RackJSONSchemaApiResponse {
65
+ return RackJSONSchemaApiResponse {(progress, fulfill, reject, configure) in
62
66
  let alam = Alamofire.request(URLRequest)
63
67
  .validate()
64
- .responseJSON({ (req, res, data, err) -> Void in
68
+ .responseJSON { (req, res, data, err) -> Void in
65
69
 
66
70
  if let err = err {
67
71
  reject(self.buildErr(res, data: data, err: err))
68
72
  return
69
73
  }
70
74
  fulfill(data!)
71
- })
75
+ }
72
76
  debugPrintln(alam)
73
77
  configure.pause = { [weak alam] in if let alam = alam { alam.suspend() } }
74
78
  configure.resume = { [weak alam] in if let alam = alam { alam.resume() } }
75
79
  configure.cancel = { [weak alam] in if let alam = alam { alam.cancel() } }
76
- }.then({ (data, errorInfo) -> RackJsonSchemaApiResponse in
77
- return RackJsonSchemaApiResponse { (progress, fulfill, reject, configure) in
80
+ }.then({ (data, errorInfo) -> RackJSONSchemaApiResponse in
81
+ return RackJSONSchemaApiResponse { (progress, fulfill, reject, configure) in
78
82
  if(errorInfo == nil){
79
- if let delegate = RackJsonSchemaApi.delegate {
83
+ if let delegate = RackJSONSchemaApi.delegate {
80
84
  let newData: AnyObject = delegate.onDefaultSuccess(data!)
81
85
  fulfill(newData)
82
86
  return
@@ -86,7 +90,7 @@ class RackJsonSchemaApi {
86
90
  }else{
87
91
  let (err, isCancelled) = errorInfo!
88
92
  if let err = err {
89
- if let delegate = RackJsonSchemaApi.delegate{
93
+ if let delegate = RackJSONSchemaApi.delegate{
90
94
  let newErr = delegate.onDefaultFailure(err)
91
95
  reject(newErr)
92
96
  return
@@ -123,7 +127,7 @@ class RackJsonSchemaApi {
123
127
  class App: Base {
124
128
 
125
129
 
126
- class func Create(name: String? = nil) -> RackJsonSchemaApiResponse {
130
+ class func Create(name: String? = nil) -> RackJSONSchemaApiResponse {
127
131
  var params = [String: AnyObject]()
128
132
 
129
133
 
@@ -135,7 +139,7 @@ class RackJsonSchemaApi {
135
139
  }
136
140
 
137
141
 
138
- class func Delete(appId: String) -> RackJsonSchemaApiResponse {
142
+ class func Delete(appId: String) -> RackJSONSchemaApiResponse {
139
143
  var params = [String: AnyObject]()
140
144
 
141
145
  params["appId"] = appId
@@ -145,7 +149,7 @@ class RackJsonSchemaApi {
145
149
  }
146
150
 
147
151
 
148
- class func Info(appId: String) -> RackJsonSchemaApiResponse {
152
+ class func Info(appId: String) -> RackJSONSchemaApiResponse {
149
153
  var params = [String: AnyObject]()
150
154
 
151
155
  params["appId"] = appId
@@ -155,17 +159,17 @@ class RackJsonSchemaApi {
155
159
  }
156
160
 
157
161
 
158
- class func Info(appId: String) -> RackJsonSchemaApiResponse {
162
+ class func InfoText(appId: String) -> RackJSONSchemaApiResponse {
159
163
  var params = [String: AnyObject]()
160
164
 
161
165
  params["appId"] = appId
162
166
 
163
167
 
164
- return request(Router.Info(params))
168
+ return request(Router.InfoText(params))
165
169
  }
166
170
 
167
171
 
168
- class func List() -> RackJsonSchemaApiResponse {
172
+ class func List() -> RackJSONSchemaApiResponse {
169
173
  var params: [String: AnyObject]? = nil
170
174
 
171
175
 
@@ -174,7 +178,7 @@ class RackJsonSchemaApi {
174
178
  }
175
179
 
176
180
 
177
- class func Update(appId: String, name: String? = nil) -> RackJsonSchemaApiResponse {
181
+ class func Update(appId: String, name: String? = nil) -> RackJSONSchemaApiResponse {
178
182
  var params = [String: AnyObject]()
179
183
 
180
184
  params["appId"] = appId
@@ -187,7 +191,7 @@ class RackJsonSchemaApi {
187
191
  }
188
192
 
189
193
 
190
- class func Create(appId: String, file: String? = nil) -> RackJsonSchemaApiResponse {
194
+ class func CreateFile(appId: String, file: String? = nil) -> RackJSONSchemaApiResponse {
191
195
  var params = [String: AnyObject]()
192
196
 
193
197
  params["appId"] = appId
@@ -196,7 +200,7 @@ class RackJsonSchemaApi {
196
200
  params["file"] = file
197
201
  }
198
202
 
199
- return request(Router.Create(params))
203
+ return request(Router.CreateFile(params))
200
204
  }
201
205
 
202
206
 
@@ -205,10 +209,10 @@ class RackJsonSchemaApi {
205
209
  case Create([String: AnyObject]?)
206
210
  case Delete([String: AnyObject]?)
207
211
  case Info([String: AnyObject]?)
208
- case Info([String: AnyObject]?)
212
+ case InfoText([String: AnyObject]?)
209
213
  case List([String: AnyObject]?)
210
214
  case Update([String: AnyObject]?)
211
- case Create([String: AnyObject]?)
215
+ case CreateFile([String: AnyObject]?)
212
216
  var method: Alamofire.Method {
213
217
  switch self {
214
218
  case .Create:
@@ -217,13 +221,13 @@ class RackJsonSchemaApi {
217
221
  return .DELETE
218
222
  case .Info:
219
223
  return .GET
220
- case .Info:
224
+ case .InfoText:
221
225
  return .GET
222
226
  case .List:
223
227
  return .GET
224
228
  case .Update:
225
229
  return .PATCH
226
- case .Create:
230
+ case .CreateFile:
227
231
  return .POST
228
232
  }
229
233
  }
@@ -231,19 +235,19 @@ class RackJsonSchemaApi {
231
235
  var path: String {
232
236
  switch self {
233
237
  case .Create(let params):
234
- return RackJsonSchemaApi.generateURI("/apps", params: params)
238
+ return RackJSONSchemaApi.generateURI("/apps", params: params)
235
239
  case .Delete(let params):
236
- return RackJsonSchemaApi.generateURI("/apps/{appId}", params: params)
237
- case .Info(let params):
238
- return RackJsonSchemaApi.generateURI("/apps/{appId}", params: params)
240
+ return RackJSONSchemaApi.generateURI("/apps/{appId}", params: params)
239
241
  case .Info(let params):
240
- return RackJsonSchemaApi.generateURI("/apps/{appId}/text", params: params)
242
+ return RackJSONSchemaApi.generateURI("/apps/{appId}", params: params)
243
+ case .InfoText(let params):
244
+ return RackJSONSchemaApi.generateURI("/apps/{appId}/text", params: params)
241
245
  case .List(let params):
242
- return RackJsonSchemaApi.generateURI("/apps", params: params)
246
+ return RackJSONSchemaApi.generateURI("/apps", params: params)
243
247
  case .Update(let params):
244
- return RackJsonSchemaApi.generateURI("/apps/{appId}", params: params)
245
- case .Create(let params):
246
- return RackJsonSchemaApi.generateURI("/apps/{appId}/files", params: params)
248
+ return RackJSONSchemaApi.generateURI("/apps/{appId}", params: params)
249
+ case .CreateFile(let params):
250
+ return RackJSONSchemaApi.generateURI("/apps/{appId}/files", params: params)
247
251
  }
248
252
  }
249
253
 
@@ -252,19 +256,19 @@ class RackJsonSchemaApi {
252
256
  var URLRequest: NSURLRequest {
253
257
  switch self{
254
258
  case .Create(let parameters):
255
- return Alamofire.ParameterEncoding.JSON.encode(RackJsonSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
259
+ return Alamofire.ParameterEncoding.JSON.encode(RackJSONSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
256
260
  case .Delete(let parameters):
257
- return Alamofire.ParameterEncoding.JSON.encode(RackJsonSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
258
- case .Info(let parameters):
259
- return Alamofire.ParameterEncoding.URL.encode(RackJsonSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
261
+ return Alamofire.ParameterEncoding.JSON.encode(RackJSONSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
260
262
  case .Info(let parameters):
261
- return Alamofire.ParameterEncoding.URL.encode(RackJsonSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
263
+ return Alamofire.ParameterEncoding.URL.encode(RackJSONSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
264
+ case .InfoText(let parameters):
265
+ return Alamofire.ParameterEncoding.URL.encode(RackJSONSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
262
266
  case .List(let parameters):
263
- return Alamofire.ParameterEncoding.URL.encode(RackJsonSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
267
+ return Alamofire.ParameterEncoding.URL.encode(RackJSONSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
264
268
  case .Update(let parameters):
265
- return Alamofire.ParameterEncoding.JSON.encode(RackJsonSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
266
- case .Create(let parameters):
267
- return Alamofire.ParameterEncoding.JSON.encode(RackJsonSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
269
+ return Alamofire.ParameterEncoding.JSON.encode(RackJSONSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
270
+ case .CreateFile(let parameters):
271
+ return Alamofire.ParameterEncoding.JSON.encode(RackJSONSchemaApi.defaultURLRequest(path, method: method), parameters: parameters).0
268
272
  }
269
273
  }
270
274
 
@@ -73,7 +73,7 @@
73
73
  "href": "/apps/{(%23%2Fdefinitions%2Fapp%2Fdefinitions%2Fid)}/text",
74
74
  "method": "GET",
75
75
  "rel": "self",
76
- "title": "Info",
76
+ "title": "InfoText",
77
77
  "mediaType": "text/plain"
78
78
  },
79
79
  {
@@ -116,7 +116,7 @@
116
116
  "object"
117
117
  ]
118
118
  },
119
- "title": "Create"
119
+ "title": "CreateFile"
120
120
  }
121
121
  ],
122
122
  "properties": {
@@ -7,7 +7,6 @@
7
7
 
8
8
  import Alamofire
9
9
  import SwiftTask
10
- import URITemplate
11
10
 
12
11
  typealias <%= class_name %>Response = Task<Int,AnyObject,NSError>
13
12
 
@@ -41,7 +40,7 @@ class <%= class_name %> {
41
40
  mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
42
41
  mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Accept")
43
42
 
44
- if let delegate = self.delegate?{
43
+ if let delegate = self.delegate{
45
44
  return delegate.customReqeust(mutableURLRequest)
46
45
  }
47
46
 
@@ -49,10 +48,15 @@ class <%= class_name %> {
49
48
  }
50
49
 
51
50
  private class func generateURI(template: String, params: [String: AnyObject]?) -> String {
51
+ var uri = template
52
52
  if let params = params {
53
- return URITemplate(template: template).expand(params)
53
+ for (key, value) in params {
54
+ if let value = value as? String {
55
+ uri = uri.stringByReplacingOccurrencesOfString("{\(key)}", withString: value)
56
+ }
57
+ }
54
58
  }
55
- return template
59
+ return uri
56
60
  }
57
61
 
58
62
  class Base {
@@ -61,14 +65,14 @@ class <%= class_name %> {
61
65
  return <%= class_name %>Response {(progress, fulfill, reject, configure) in
62
66
  let alam = Alamofire.request(URLRequest)
63
67
  .validate()
64
- .responseJSON({ (req, res, data, err) -> Void in
68
+ .responseJSON { (req, res, data, err) -> Void in
65
69
 
66
70
  if let err = err {
67
71
  reject(self.buildErr(res, data: data, err: err))
68
72
  return
69
73
  }
70
74
  fulfill(data!)
71
- })
75
+ }
72
76
  debugPrintln(alam)
73
77
  configure.pause = { [weak alam] in if let alam = alam { alam.suspend() } }
74
78
  configure.resume = { [weak alam] in if let alam = alam { alam.resume() } }
@@ -1,3 +1,3 @@
1
1
  module Aries
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yss44
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable