elevate 0.3.2 → 0.3.3

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elevate (0.3.2)
4
+ elevate (0.3.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -0,0 +1,44 @@
1
+ module Elevate
2
+ module HTTP
3
+ class ActivityIndicator
4
+ def self.instance
5
+ Dispatch.once { @instance = new }
6
+
7
+ @instance
8
+ end
9
+
10
+ def initialize
11
+ @lock = NSLock.alloc.init
12
+ @count = 0
13
+ end
14
+
15
+ def hide
16
+ toggled = false
17
+
18
+ @lock.lock
19
+ @count -= 1 if @count > 0
20
+ toggled = @count == 0
21
+ @lock.unlock
22
+
23
+ update_indicator(false) if toggled
24
+ end
25
+
26
+ def show
27
+ toggled = false
28
+
29
+ @lock.lock
30
+ toggled = @count == 0
31
+ @count += 1
32
+ @lock.unlock
33
+
34
+ update_indicator(true) if toggled
35
+ end
36
+
37
+ private
38
+
39
+ def update_indicator(visible)
40
+ UIApplication.sharedApplication.networkActivityIndicatorVisible = visible
41
+ end
42
+ end
43
+ end
44
+ end
@@ -39,6 +39,8 @@ module HTTP
39
39
  return unless started?
40
40
 
41
41
  NetworkThread.cancel(@connection)
42
+ ActivityIndicator.instance.hide
43
+
42
44
  @promise.fulfill(nil)
43
45
  end
44
46
 
@@ -54,6 +56,7 @@ module HTTP
54
56
  @connection = NSURLConnection.alloc.initWithRequest(@request, delegate:self, startImmediately:false)
55
57
 
56
58
  NetworkThread.start(@connection)
59
+ ActivityIndicator.instance.show
57
60
  end
58
61
 
59
62
  def started?
@@ -77,18 +80,22 @@ module HTTP
77
80
  @response.error = error
78
81
  @response.freeze
79
82
 
83
+ ActivityIndicator.instance.hide
84
+
80
85
  @promise.fulfill(@response)
81
86
  end
82
87
 
83
88
  def connectionDidFinishLoading(connection)
84
89
  @response.freeze
85
90
 
91
+ ActivityIndicator.instance.hide
92
+
86
93
  @promise.fulfill(@response)
87
94
  end
88
95
 
89
96
  def get_authorization_header(credentials)
90
97
  "Basic " + Base64.encode("#{credentials[:username]}:#{credentials[:password]}")
91
- end
98
+ end
92
99
  end
93
100
  end
94
101
  end
@@ -1,3 +1,3 @@
1
1
  module Elevate
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
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: 0.3.2
4
+ version: 0.3.3
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-20 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -97,6 +97,7 @@ files:
97
97
  - lib/elevate/callback.rb
98
98
  - lib/elevate/dispatcher.rb
99
99
  - lib/elevate/dsl.rb
100
+ - lib/elevate/http/activity_indicator.rb
100
101
  - lib/elevate/http/base64.rb
101
102
  - lib/elevate/http/errors.rb
102
103
  - lib/elevate/http/http_client.rb
@@ -131,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
132
  version: '0'
132
133
  segments:
133
134
  - 0
134
- hash: 3623850089933404602
135
+ hash: 13511162272098335
135
136
  required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  none: false
137
138
  requirements:
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  version: '0'
141
142
  segments:
142
143
  - 0
143
- hash: 3623850089933404602
144
+ hash: 13511162272098335
144
145
  requirements: []
145
146
  rubyforge_project:
146
147
  rubygems_version: 1.8.24