afmotion 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2NjOGE1NWZjMWQzYzRmZjQ2MTRiOTc5N2QwZThlYTZiNTM1OGZhMg==
4
+ OTdiNzU4ZDY0OTM0YWM1MTEwOGE0OWExYjE3ZTcyYTA0YzA0MmMxZg==
5
5
  data.tar.gz: !binary |-
6
- MjBhOTAxMmNkNjJhMWIwMDJkNjkwZWQ4MmNlM2E3ZTk1ZTY3MjIxMg==
6
+ ODZlZmFlNzBlMjNmMWMzZjMyNTE1MDc1OWQ3YTUzMjhmMGI3MzA1Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzFhNDEyMmI0NTZlNjY0YWQ4MzVhZTYzZjVlMWJiMDRhYWI0ZGRhOWU4MThj
10
- NDZlMDJjM2YyNzNmNzQ1ODZhNTBhZDVmNzYxNDY1ZjRhOTdlYmRkMTU3Njcw
11
- ZjQxMGMwZTBhYTZlZTVkZDZhOWY1MzgyZTA1YmRiN2VjMmU3OGQ=
9
+ ZTkyYTM2ZjcxODc4OTkzYmEwZWQ4NGYyOWM1YjAwNTRlYmY5MTJmNThjY2Ey
10
+ Yjk3OTFiZjBhM2I5YmIxYjFlY2EzMzc2OGYyOTkyOGRhYTc5ZDQxZTQ4OGZj
11
+ NDhiNjQ5M2U1YTRjNGYyN2U0MzhiZTU0OTI3NWY1YTUzZmNmNmY=
12
12
  data.tar.gz: !binary |-
13
- YmQwNTI3ZWUxYmI5ZDZkMjFjMzJkNGRmOTU0YTc5OGY3YTcyOWVmMDlhNTg0
14
- OWZjNmUzODMxNGRjOWYyNDFjY2EwMWVjYTZlMWNmYzY1ZmI2ZTUwNTkxMmIx
15
- ZmFmZDJkOGYyOTNiMmI3NmE2MzAyYWI4ZmM1NDRlYzM2NTcyMWU=
13
+ YjA5YTRkODQ5MGJkYjI5NjEyOWJhMmZjYzE1NTAzZWNmNTEwOTU0ZDc3Y2E0
14
+ OWM5ZDUwZTgyMjE5MmQ1NmJmZTY2ZTQzMmRmMzczZDU5ZmYxYzdkOTQzYWJl
15
+ ODVhNTYxMDRjZjI3NWZjZjE4ZmZjODdmMDQ5M2JlZmEyODA2Mjg=
data/AFMotion.gemspec CHANGED
@@ -14,6 +14,6 @@ Gem::Specification.new do |s|
14
14
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
15
  s.require_paths = ["lib"]
16
16
 
17
- s.add_dependency "motion-cocoapods", ">= 1.2.1"
17
+ s.add_dependency "motion-cocoapods", "~> 1.3.6"
18
18
  s.add_development_dependency 'rake'
19
19
  end
data/Gemfile.lock CHANGED
@@ -1,42 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afmotion (0.7)
5
- motion-cocoapods (>= 1.2.1)
4
+ afmotion (0.8)
5
+ motion-cocoapods (~> 1.3.6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (3.2.13)
11
- i18n (= 0.6.1)
10
+ activesupport (3.2.14)
11
+ i18n (~> 0.6, >= 0.6.4)
12
12
  multi_json (~> 1.0)
13
13
  claide (0.3.2)
14
- cocoapods (0.22.1)
14
+ cocoapods (0.23.0)
15
15
  activesupport (~> 3.2.13)
16
16
  claide (~> 0.3.2)
17
- cocoapods-core (= 0.22.1)
18
- cocoapods-downloader (~> 0.1.1)
17
+ cocoapods-core (= 0.23.0)
18
+ cocoapods-downloader (~> 0.1.2)
19
19
  colored (~> 1.2)
20
20
  escape (~> 0.0.4)
21
21
  json (~> 1.8.0)
22
22
  open4 (~> 1.3.0)
23
- xcodeproj (~> 0.8.0)
24
- cocoapods-core (0.22.1)
23
+ xcodeproj (~> 0.9.0)
24
+ cocoapods-core (0.23.0)
25
25
  activesupport (~> 3.2.13)
26
26
  json (~> 1.8.0)
27
27
  nap (~> 0.5.1)
28
- cocoapods-downloader (0.1.1)
28
+ cocoapods-downloader (0.1.2)
29
29
  colored (1.2)
30
30
  escape (0.0.4)
31
- i18n (0.6.1)
31
+ i18n (0.6.5)
32
32
  json (1.8.0)
33
- motion-cocoapods (1.3.5)
33
+ motion-cocoapods (1.3.6)
34
34
  cocoapods (>= 0.17.0)
35
- multi_json (1.7.7)
35
+ multi_json (1.7.9)
36
36
  nap (0.5.1)
37
37
  open4 (1.3.0)
38
38
  rake (0.9.2.2)
39
- xcodeproj (0.8.0)
39
+ xcodeproj (0.9.0)
40
40
  activesupport (~> 3.2.13)
41
41
  colored (~> 1.2)
42
42
 
data/README.md CHANGED
@@ -211,6 +211,21 @@ client.multipart.post("avatars") do |result, form_data, progress|
211
211
  end
212
212
  ```
213
213
 
214
+ #### Client Operations
215
+
216
+ If you want to grab an `AFURLConnectionOperation` from your client instance, use `create_operation` or `create_multipart_operation`:
217
+
218
+ ```ruby
219
+ operation = client.create_operation(:get, "http://google.com", {q: "hello"}) do |result|
220
+ end
221
+
222
+ multipart_operation = client.create_multipart_operation(:get, "http://google.com", {q: "hello"}) do |result, form_data, progress|
223
+ end
224
+
225
+ # elsewhere
226
+ client.enqueueHTTPRequestOperation(operation)
227
+ ```
228
+
214
229
  #### Client Building DSL
215
230
 
216
231
  The `AFMotion::Client` DSL allows the following properties:
@@ -81,64 +81,72 @@ class AFHTTPClient
81
81
  # EX client.get('my/resource.json')
82
82
  define_method "#{method}", -> (path, parameters = {}, &callback) do
83
83
  if @multipart
84
- multipart_callback = callback.arity == 1 ? nil : lambda { |formData|
85
- callback.call(nil, formData)
86
- }
87
- upload_callback = callback.arity > 2 ? lambda { |bytes_written_now, total_bytes_written, total_bytes_expect|
88
- case callback.arity
89
- when 3
90
- callback.call(nil, nil, total_bytes_written.to_f / total_bytes_expect.to_f)
91
- when 5
92
- callback.call(nil, nil, bytes_written_now, total_bytes_written, total_bytes_expect)
93
- end
94
- } : nil
95
- request = self.multipartFormRequestWithMethod(method, path: path,
96
- parameters: parameters,constructingBodyWithBlock: multipart_callback)
97
- operation = self.HTTPRequestOperationWithRequest(request,
98
- success: lambda {|operation, responseObject|
99
- result = AFMotion::HTTPResult.new(operation, responseObject, nil)
100
- case callback.arity
101
- when 1
102
- callback.call(result)
103
- when 2
104
- callback.call(result, nil)
105
- when 3
106
- callback.call(result, nil, nil)
107
- when 5
108
- callback.call(result, nil, nil, nil, nil)
109
- end
110
- }, failure: lambda {|operation, error|
111
- result = AFMotion::HTTPResult.new(operation, nil, error)
112
- case callback.arity
113
- when 1
114
- callback.call(result)
115
- when 2
116
- callback.call(result, nil)
117
- when 3
118
- callback.call(result, nil, nil)
119
- when 5
120
- callback.call(result, nil, nil, nil, nil)
121
- end
122
- })
123
- if upload_callback
124
- operation.setUploadProgressBlock(upload_callback)
125
- end
126
- self.enqueueHTTPRequestOperation(operation)
84
+ @operation = create_multipart_operation(method, path, parameters, &callback)
85
+ self.enqueueHTTPRequestOperation(@operation)
127
86
  @multipart = nil
128
- @operation = operation
129
87
  else
130
- request = self.requestWithMethod(method.upcase, path:path, parameters:parameters)
131
- @operation = self.HTTPRequestOperationWithRequest(request, success: lambda {|operation, responseObject|
88
+ @operation = create_operation(method, path, parameters, &callback)
89
+ self.enqueueHTTPRequestOperation(@operation)
90
+ end
91
+ @operation
92
+ end
93
+ end
94
+
95
+ def create_multipart_operation(method, path, parameters = {}, &callback)
96
+ multipart_callback = callback.arity == 1 ? nil : lambda { |formData|
97
+ callback.call(nil, formData)
98
+ }
99
+ upload_callback = callback.arity > 2 ? lambda { |bytes_written_now, total_bytes_written, total_bytes_expect|
100
+ case callback.arity
101
+ when 3
102
+ callback.call(nil, nil, total_bytes_written.to_f / total_bytes_expect.to_f)
103
+ when 5
104
+ callback.call(nil, nil, bytes_written_now, total_bytes_written, total_bytes_expect)
105
+ end
106
+ } : nil
107
+ request = self.multipartFormRequestWithMethod(method, path: path,
108
+ parameters: parameters,constructingBodyWithBlock: multipart_callback)
109
+ operation = self.HTTPRequestOperationWithRequest(request,
110
+ success: lambda {|operation, responseObject|
111
+ result = AFMotion::HTTPResult.new(operation, responseObject, nil)
112
+ case callback.arity
113
+ when 1
114
+ callback.call(result)
115
+ when 2
116
+ callback.call(result, nil)
117
+ when 3
118
+ callback.call(result, nil, nil)
119
+ when 5
120
+ callback.call(result, nil, nil, nil, nil)
121
+ end
122
+ }, failure: lambda {|operation, error|
123
+ result = AFMotion::HTTPResult.new(operation, nil, error)
124
+ case callback.arity
125
+ when 1
126
+ callback.call(result)
127
+ when 2
128
+ callback.call(result, nil)
129
+ when 3
130
+ callback.call(result, nil, nil)
131
+ when 5
132
+ callback.call(result, nil, nil, nil, nil)
133
+ end
134
+ })
135
+ if upload_callback
136
+ operation.setUploadProgressBlock(upload_callback)
137
+ end
138
+ operation
139
+ end
140
+
141
+ def create_operation(method, path, parameters = {}, &callback)
142
+ request = self.requestWithMethod(method.upcase, path:path, parameters:parameters)
143
+ self.HTTPRequestOperationWithRequest(request, success: lambda {|operation, responseObject|
132
144
  result = AFMotion::HTTPResult.new(operation, responseObject, nil)
133
145
  callback.call(result)
134
146
  }, failure: lambda {|operation, error|
135
147
  result = AFMotion::HTTPResult.new(operation, nil, error)
136
148
  callback.call(result)
137
149
  })
138
- self.enqueueHTTPRequestOperation(@operation)
139
- @operation
140
- end
141
- end
142
150
  end
143
151
 
144
152
  def multipart
@@ -1,5 +1,5 @@
1
1
  module AFMotion
2
- VERSION = "0.7"
2
+ VERSION = "0.8"
3
3
 
4
4
  HTTP_METHODS = [:get, :post, :put, :delete, :patch, :head]
5
5
  end
data/vendor/Podfile.lock CHANGED
@@ -1,11 +1,10 @@
1
-
2
1
  PODS:
3
- - AFNetworking (1.0.1)
2
+ - AFNetworking (1.0.1)
4
3
 
5
4
  DEPENDENCIES:
6
- - AFNetworking
5
+ - AFNetworking
7
6
 
8
7
  SPEC CHECKSUMS:
9
8
  AFNetworking: 0bce3ae41023e080e96b8a2e0d07c94709f72a81
10
9
 
11
- COCOAPODS: 0.15.2
10
+ COCOAPODS: 0.23.0
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afmotion
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clay Allsopp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-26 00:00:00.000000000 Z
11
+ date: 2013-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: motion-cocoapods
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.1
19
+ version: 1.3.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.1
26
+ version: 1.3.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement