elevate 0.3 → 0.3.1
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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/elevate/http/request.rb +3 -4
- data/lib/elevate/http/thread.rb +30 -0
- data/lib/elevate/version.rb +1 -1
- metadata +5 -4
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -2,6 +2,11 @@ Elevate
|
|
|
2
2
|
======
|
|
3
3
|
How do we convey the intent of our application?
|
|
4
4
|
|
|
5
|
+
**Status:** beta quality. Feedback desired!
|
|
6
|
+
|
|
7
|
+
[](https://codeclimate.com/github/mattgreen/elevate)
|
|
8
|
+
|
|
9
|
+
|
|
5
10
|
Background
|
|
6
11
|
-----------
|
|
7
12
|
iOS applications employ the MVC architecture to delineate responsibilities:
|
data/lib/elevate/http/request.rb
CHANGED
|
@@ -3,7 +3,6 @@ module HTTP
|
|
|
3
3
|
# TODO: redirects
|
|
4
4
|
class HTTPRequest
|
|
5
5
|
METHODS = [:get, :post, :put, :delete, :patch, :head, :options].freeze
|
|
6
|
-
QUEUE = NSOperationQueue.alloc.init
|
|
7
6
|
|
|
8
7
|
def initialize(method, url, options={})
|
|
9
8
|
raise ArgumentError, "invalid HTTP method" unless METHODS.include? method.downcase
|
|
@@ -39,7 +38,7 @@ module HTTP
|
|
|
39
38
|
def cancel
|
|
40
39
|
return unless started?
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
NetworkThread.cancel(@connection)
|
|
43
42
|
@promise.set(nil)
|
|
44
43
|
end
|
|
45
44
|
|
|
@@ -53,8 +52,8 @@ module HTTP
|
|
|
53
52
|
|
|
54
53
|
def start
|
|
55
54
|
@connection = NSURLConnection.alloc.initWithRequest(@request, delegate:self, startImmediately:false)
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
|
|
56
|
+
NetworkThread.start(@connection)
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
def started?
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Elevate
|
|
2
|
+
module HTTP
|
|
3
|
+
class NetworkThread
|
|
4
|
+
def self.cancel(connection)
|
|
5
|
+
connection.performSelector(:cancel, onThread:thread, withObject:nil, waitUntilDone:false)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.start(connection)
|
|
9
|
+
connection.performSelector(:start, onThread:thread, withObject:nil, waitUntilDone:false)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def self.main(_)
|
|
15
|
+
while true
|
|
16
|
+
NSRunLoop.currentRunLoop.run
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.thread
|
|
21
|
+
Dispatch.once do
|
|
22
|
+
@thread = NSThread.alloc.initWithTarget(self, selector: :"main:", object: nil)
|
|
23
|
+
@thread.start
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
@thread
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/elevate/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: elevate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-02-
|
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -101,6 +101,7 @@ files:
|
|
|
101
101
|
- lib/elevate/http/http_client.rb
|
|
102
102
|
- lib/elevate/http/request.rb
|
|
103
103
|
- lib/elevate/http/response.rb
|
|
104
|
+
- lib/elevate/http/thread.rb
|
|
104
105
|
- lib/elevate/http/uri.rb
|
|
105
106
|
- lib/elevate/io_coordinator.rb
|
|
106
107
|
- lib/elevate/operation.rb
|
|
@@ -129,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
129
130
|
version: '0'
|
|
130
131
|
segments:
|
|
131
132
|
- 0
|
|
132
|
-
hash:
|
|
133
|
+
hash: 421563326578819591
|
|
133
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
none: false
|
|
135
136
|
requirements:
|
|
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
139
|
version: '0'
|
|
139
140
|
segments:
|
|
140
141
|
- 0
|
|
141
|
-
hash:
|
|
142
|
+
hash: 421563326578819591
|
|
142
143
|
requirements: []
|
|
143
144
|
rubyforge_project:
|
|
144
145
|
rubygems_version: 1.8.24
|