bubble-wrap 0.2.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.1
2
+
3
+ * Minor fix in the way the dependencies are set (had to monkey patch
4
+ RubyMotion)
5
+
1
6
  ## 0.2.0
2
7
 
3
8
  * Added network activity notification to the HTTP wrapper.
data/Rakefile CHANGED
@@ -7,8 +7,12 @@ Motion::Project::App.setup do |app|
7
7
 
8
8
  app.development do
9
9
  app.files << './lib/tests/test_suite_delegate.rb'
10
- app.delegate_class = 'TestSuiteDelegate'
10
+ app.delegate_class = 'TestSuiteDelegate'
11
11
  end
12
12
 
13
13
  app.files += Dir.glob('./lib/bubble-wrap/**.rb')
14
+ wrapper_files = app.files.dup
15
+ pollution_file = Dir.glob('./lib/pollute.rb')[0]
16
+ app.files << pollution_file
17
+ app.files_dependencies pollution_file => wrapper_files
14
18
  end
data/lib/bubble-wrap.rb CHANGED
@@ -4,8 +4,36 @@ unless defined?(Motion::Project::Config)
4
4
  raise "This file must be required within a RubyMotion project Rakefile."
5
5
  end
6
6
 
7
+ module Motion
8
+ module Project
9
+ class Config
10
+ # HACK NEEDED since RubyMotion doesn't support full path
11
+ # dependencies.
12
+ def files_dependencies(deps_hash)
13
+ res_path = lambda do |x|
14
+ path = /^\.|\/Users\//.match(x) ? x : File.join('.', x)
15
+ unless @files.include?(path)
16
+ App.fail "Can't resolve dependency `#{x}' because #{path} is not in #{@files.inspect}"
17
+ end
18
+ path
19
+ end
20
+ deps_hash.each do |path, deps|
21
+ deps = [deps] unless deps.is_a?(Array)
22
+ @dependencies[res_path.call(path)] = deps.map(&res_path)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+
7
30
  Motion::Project::App.setup do |app|
31
+ wrapper_files = []
8
32
  Dir.glob(File.join(File.dirname(__FILE__), 'bubble-wrap/*.rb')).each do |file|
9
- app.files.unshift(file)
33
+ app.files << file
34
+ wrapper_files << file
10
35
  end
11
- end
36
+ pollution_file = File.expand_path(File.join(File.dirname(__FILE__), 'pollute.rb'))
37
+ app.files << pollution_file
38
+ app.files_dependencies pollution_file => wrapper_files
39
+ end
@@ -152,7 +152,7 @@ module BubbleWrap
152
152
  url_string = "#{url_string}?#{@payload}" if @method == "GET"
153
153
  end
154
154
 
155
- p "HTTP building a NSRequest for #{url_string}"# if SETTINGS[:debug]
155
+ p "BubbleWrap::HTTP building a NSRequest for #{url_string}"# if SETTINGS[:debug]
156
156
  @url = NSURL.URLWithString(url_string)
157
157
  @request = NSMutableURLRequest.requestWithURL(@url,
158
158
  cachePolicy:NSURLRequestUseProtocolCachePolicy,
@@ -188,7 +188,7 @@ module BubbleWrap
188
188
  end
189
189
 
190
190
  def connection(connection, willSendRequest:request, redirectResponse:redirect_response)
191
- puts "HTTP redirected #{request.description}" #if SETTINGS[:debug]
191
+ p "HTTP redirected #{request.description}" #if SETTINGS[:debug]
192
192
  new_request = request.mutableCopy
193
193
  # new_request.setValue(@credentials.inspect, forHTTPHeaderField:'Authorization') # disabled while we figure this one out
194
194
  new_request.setAllHTTPHeaderFields(@headers) if @headers
@@ -200,7 +200,7 @@ module BubbleWrap
200
200
  def connection(connection, didFailWithError: error)
201
201
  UIApplication.sharedApplication.networkActivityIndicatorVisible = false
202
202
  @request.done_loading!
203
- p "HTTP Connection failed #{error.localizedDescription}"
203
+ NSLog"HTTP Connection failed #{error.localizedDescription}"
204
204
  @response.error_message = error.localizedDescription
205
205
  if @delegator.respond_to?(:call)
206
206
  @delegator.call( @response, self )
@@ -1,4 +1,4 @@
1
- class NSIndexPath
1
+ module NSIndexPathWrap
2
2
 
3
3
  # Gives access to an index at a given position.
4
4
  # @param [Integer] position to use to fetch the index
@@ -1,7 +1,7 @@
1
- class UIButton
1
+ module UIButtonWrap
2
2
  def when(events, &block)
3
3
  @callback ||= {}
4
4
  @callback[events] = block
5
5
  addTarget(@callback[events], action:'call', forControlEvents: events)
6
6
  end
7
- end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module BubbleWrap
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
data/lib/pollute.rb ADDED
@@ -0,0 +1,6 @@
1
+ [
2
+ [NSIndexPath, NSIndexPathWrap],
3
+ [UIButton, UIButtonWrap]
4
+ ].each do |base, wrapper|
5
+ base.send(:include, wrapper)
6
+ end
@@ -0,0 +1,18 @@
1
+ describe "NSIndexPathWrap" do
2
+
3
+ it "should be able to use an array like accessor" do
4
+ index = NSIndexPath.indexPathForRow(0, inSection:3)
5
+ index[0].should == index.indexAtPosition(0)
6
+ end
7
+
8
+ it "should support the each iterator" do
9
+ index = NSIndexPath.indexPathForRow(0, inSection:2)
10
+ puts index.inspect
11
+ i = []
12
+ index.each do |idx|
13
+ i << idx
14
+ end
15
+ i.should == [2, 0]
16
+ end
17
+
18
+ end
@@ -0,0 +1,12 @@
1
+ describe "UIButton" do
2
+
3
+ it "should support the 'when' event handler" do
4
+ button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
5
+ touched = nil
6
+ button.when(UIControlEventTouchUpInside) do
7
+ touched = 'for the very first time'
8
+ end
9
+ button.sendActionsForControlEvents(UIControlEventTouchUpInside)
10
+ touched.should == 'for the very first time'
11
+ end
12
+ 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.2.0
4
+ version: 0.2.1
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-28 00:00:00.000000000 Z
13
+ date: 2012-05-29 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.
@@ -40,10 +40,13 @@ files:
40
40
  - lib/bubble-wrap/ui_button.rb
41
41
  - lib/bubble-wrap/ui_view_controller.rb
42
42
  - lib/bubble-wrap/version.rb
43
+ - lib/pollute.rb
43
44
  - lib/tests/test_suite_delegate.rb
44
45
  - spec/http_spec.rb
45
46
  - spec/json_spec.rb
47
+ - spec/ns_index_path_spec.rb
46
48
  - spec/ns_notification_center_spec.rb
49
+ - spec/ui_button_spec.rb
47
50
  - spec_helper_patch.diff
48
51
  homepage: https://github.com/mattetti/BubbleWrap
49
52
  licenses: []
@@ -73,5 +76,6 @@ summary: RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more
73
76
  test_files:
74
77
  - spec/http_spec.rb
75
78
  - spec/json_spec.rb
79
+ - spec/ns_index_path_spec.rb
76
80
  - spec/ns_notification_center_spec.rb
77
- has_rdoc:
81
+ - spec/ui_button_spec.rb