bubble-wrap 0.1.2 → 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.
- data/CHANGELOG.md +8 -0
- data/lib/bubble-wrap/http.rb +3 -0
- data/lib/bubble-wrap/ns_notification_center.rb +8 -7
- data/lib/bubble-wrap/version.rb +2 -2
- data/spec/json_spec.rb +13 -3
- metadata +5 -3
data/CHANGELOG.md
ADDED
data/lib/bubble-wrap/http.rb
CHANGED
@@ -122,6 +122,7 @@ module BubbleWrap
|
|
122
122
|
@response = HTTP::Response.new
|
123
123
|
initiate_request(url)
|
124
124
|
connection.start
|
125
|
+
UIApplication.sharedApplication.networkActivityIndicatorVisible = true
|
125
126
|
connection
|
126
127
|
end
|
127
128
|
|
@@ -197,6 +198,7 @@ module BubbleWrap
|
|
197
198
|
end
|
198
199
|
|
199
200
|
def connection(connection, didFailWithError: error)
|
201
|
+
UIApplication.sharedApplication.networkActivityIndicatorVisible = false
|
200
202
|
@request.done_loading!
|
201
203
|
p "HTTP Connection failed #{error.localizedDescription}"
|
202
204
|
@response.error_message = error.localizedDescription
|
@@ -207,6 +209,7 @@ module BubbleWrap
|
|
207
209
|
|
208
210
|
# The transfer is done and everything went well
|
209
211
|
def connectionDidFinishLoading(connection)
|
212
|
+
UIApplication.sharedApplication.networkActivityIndicatorVisible = false
|
210
213
|
@request.done_loading!
|
211
214
|
|
212
215
|
# copy the data in a local var that we will attach to the response object
|
@@ -1,19 +1,20 @@
|
|
1
1
|
class NSNotificationCenter
|
2
|
-
|
2
|
+
def observers
|
3
|
+
@observers ||= {}
|
4
|
+
end
|
3
5
|
|
4
6
|
def observe(observer, name, object=nil, &proc)
|
5
|
-
|
6
|
-
|
7
|
-
@observers[observer] << proc
|
7
|
+
observers[observer] ||= []
|
8
|
+
observers[observer] << proc
|
8
9
|
self.addObserver(proc, selector:'call', name:name, object:object)
|
9
10
|
end
|
10
11
|
|
11
12
|
def unobserve(observer)
|
12
|
-
return unless
|
13
|
-
|
13
|
+
return unless observers[observer]
|
14
|
+
observers[observer].each do |proc|
|
14
15
|
removeObserver(proc)
|
15
16
|
end
|
16
|
-
|
17
|
+
observers.delete(observer)
|
17
18
|
end
|
18
19
|
|
19
20
|
def post(name, object=nil, info=nil)
|
data/lib/bubble-wrap/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module BubbleWrap
|
2
|
-
VERSION = '0.
|
3
|
-
end
|
2
|
+
VERSION = '0.2.0'
|
3
|
+
end
|
data/spec/json_spec.rb
CHANGED
@@ -93,7 +93,7 @@ EOS
|
|
93
93
|
'bar' => 'baz',
|
94
94
|
baz: 123,
|
95
95
|
foobar: [1,2,3],
|
96
|
-
foobaz: {a
|
96
|
+
foobaz: {'a' => 1, 'b' => 2}
|
97
97
|
}
|
98
98
|
end
|
99
99
|
|
@@ -106,8 +106,18 @@ EOS
|
|
106
106
|
it "should encode and decode and object losslessly" do
|
107
107
|
json = BubbleWrap::JSON.generate(@obj)
|
108
108
|
obj = BubbleWrap::JSON.parse(json)
|
109
|
-
|
110
|
-
obj.
|
109
|
+
|
110
|
+
obj["foo"].should == 'bar'
|
111
|
+
obj["bar"].should == 'baz'
|
112
|
+
obj["baz"].should == 123
|
113
|
+
obj["foobar"].should == [1,2,3]
|
114
|
+
obj["foobaz"].should == {"a" => 1, "b" => 2}
|
115
|
+
|
116
|
+
# TODO Find out why following line cause runtime error
|
117
|
+
# obj.keys.sort.should == @obj.keys.sort
|
118
|
+
# obj.values.sort.should == @obj.values.sort
|
119
|
+
obj.keys.sort { |a, b| a.to_s <=> b.to_s }.should == @obj.keys.sort { |a, b| a.to_s <=> b.to_s }
|
120
|
+
obj.values.sort { |a, b| a.to_s <=> b.to_s }.should == @obj.values.sort { |a, b| a.to_s <=> b.to_s }
|
111
121
|
end
|
112
122
|
|
113
123
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bubble-wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-28 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more
|
16
16
|
Ruby like, one API at a time. Fork away and send your pull request.
|
@@ -22,6 +22,7 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
files:
|
24
24
|
- .gitignore
|
25
|
+
- CHANGELOG.md
|
25
26
|
- Gemfile
|
26
27
|
- LICENSE
|
27
28
|
- README.md
|
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
65
|
version: '0'
|
65
66
|
requirements: []
|
66
67
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.8.
|
68
|
+
rubygems_version: 1.8.16
|
68
69
|
signing_key:
|
69
70
|
specification_version: 3
|
70
71
|
summary: RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more Ruby
|
@@ -73,3 +74,4 @@ test_files:
|
|
73
74
|
- spec/http_spec.rb
|
74
75
|
- spec/json_spec.rb
|
75
76
|
- spec/ns_notification_center_spec.rb
|
77
|
+
has_rdoc:
|