afmotion 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afmotion (0.0.2)
4
+ afmotion (0.0.3)
5
5
  motion-cocoapods (>= 1.2.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -52,6 +52,12 @@ Loading images from the internet is pretty common. AFNetworking's existing metho
52
52
  image_view.url = {url: "http://i.imgur.com/r4uwx.jpg", placeholder: placeholder}
53
53
  ```
54
54
 
55
+ ## Install
56
+
57
+ 1. `gem install afmotion`
58
+
59
+ 2. `require 'afmotion'` or add to your `Gemfile`
60
+
55
61
  ## Overview
56
62
 
57
63
  ### Results
data/lib/afmotion/http.rb CHANGED
@@ -2,9 +2,12 @@ module AFMotion
2
2
  module HTTPBuilder
3
3
  def self.included(base)
4
4
  AFMotion::HTTP_METHODS.each do |method|
5
- base.send(:define_singleton_method, method, -> (url, parameters = {}, &callback) do
6
- request = NSMutableURLRequest.requestWithURL(url.to_url)
7
- request.HTTPMethod = method.upcase
5
+ base.send(:define_singleton_method, method, -> (request_or_url, parameters = {}, &callback) do
6
+ request = request_or_url
7
+ if !request.is_a?(NSURLRequest)
8
+ request = NSMutableURLRequest.requestWithURL(request_or_url.to_url)
9
+ request.HTTPMethod = method.upcase
10
+ end
8
11
 
9
12
  operation = (self.request_module.for_request(request) do |result|
10
13
  callback.call(result)
@@ -1,5 +1,5 @@
1
1
  module AFMotion
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
 
4
4
  HTTP_METHODS = [:get, :post, :put, :delete, :patch]
5
5
  end
Binary file
data/spec/http_spec.rb CHANGED
@@ -11,7 +11,11 @@ describe "AFMotion" do
11
11
  end
12
12
 
13
13
  describe ".get" do
14
- it "should work" do
14
+ before do
15
+ @result = nil
16
+ end
17
+
18
+ it "should work with string" do
15
19
  _module.get("http://google.com") do |result|
16
20
  @result = result
17
21
  resume
@@ -20,6 +24,17 @@ describe "AFMotion" do
20
24
  @result.nil?.should == false
21
25
  end
22
26
  end
27
+
28
+ it "should work with request" do
29
+ request = NSURLRequest.requestWithURL(NSURL.URLWithString("http://google.com"))
30
+ _module.get(request) do |result|
31
+ @result = result
32
+ resume
33
+ end
34
+ wait_max(10) do
35
+ @result.nil?.should == false
36
+ end
37
+ end
23
38
  end
24
39
  end
25
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afmotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -65,6 +65,7 @@ files:
65
65
  - lib/afmotion/operation.rb
66
66
  - lib/afmotion/patch/NSString_NSUrl.rb
67
67
  - lib/afmotion/version.rb
68
+ - pkg/afmotion-0.0.2.gem
68
69
  - spec/http_client_spec.rb
69
70
  - spec/http_spec.rb
70
71
  - spec/operation_spec.rb
@@ -132,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
133
  version: '0'
133
134
  segments:
134
135
  - 0
135
- hash: 2603590834289563556
136
+ hash: -2112569163746405091
136
137
  required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  none: false
138
139
  requirements:
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  version: '0'
142
143
  segments:
143
144
  - 0
144
- hash: 2603590834289563556
145
+ hash: -2112569163746405091
145
146
  requirements: []
146
147
  rubyforge_project:
147
148
  rubygems_version: 1.8.23