bubble-wrap 1.1.1 → 1.1.2
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 +33 -4
- data/Gemfile.lock +3 -2
- data/README.md +5 -5
- data/bubble-wrap.gemspec +2 -1
- data/lib/bubble-wrap/requirement/path_manipulation.rb +11 -7
- data/lib/bubble-wrap/version.rb +1 -1
- data/motion/http.rb +35 -20
- data/samples/gesture/.gitignore +5 -0
- data/samples/gesture/Gemfile +4 -0
- data/samples/gesture/Gemfile.lock +12 -0
- data/samples/gesture/README.md +5 -0
- data/samples/gesture/Rakefile +9 -0
- data/samples/gesture/app/app_delegate.rb +16 -0
- data/samples/gesture/app/controllers/drawing_view_controller.rb +12 -0
- data/samples/gesture/app/helpers/drawing_helper.rb +2 -0
- data/samples/gesture/app/views/drawing/gesture_view.rb +92 -0
- data/samples/gesture/app/views/drawing/rect_view.rb +13 -0
- data/samples/gesture/spec/main_spec.rb +9 -0
- data/spec/lib/bubble-wrap/requirement/path_manipulation_spec.rb +6 -1
- data/spec/motion/http_spec.rb +44 -14
- metadata +34 -12
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,32 @@
|
|
1
|
+
## 1.1.2
|
2
|
+
|
3
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.1.0...v1.1.1)
|
4
|
+
|
5
|
+
* Fixed a problem with the load path.
|
6
|
+
* Added `format:` to the HTTP wrapper with [5 supported formats supported](https://github.com/rubymotion/BubbleWrap/pull/109) that sets the content type accordingly.
|
7
|
+
* Default HTTP Content-Type for `POST` like requests is back to being
|
8
|
+
form url encoded.
|
9
|
+
|
1
10
|
## 1.1.1
|
2
11
|
|
12
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.1.0...v1.1.1)
|
13
|
+
|
14
|
+
### Enhancements
|
15
|
+
|
16
|
+
* Added support for symbols as selectors to the KVO module.
|
17
|
+
* Improved the RSSParser by providing a delegate to handle errors.
|
18
|
+
|
19
|
+
### Bug Fixes
|
20
|
+
|
3
21
|
* Fixed a bug with the way JSON payloads were handled in the HTTP
|
4
22
|
wrapper.
|
5
|
-
* Improved the RSSParser by providing a delegate to handle errors.
|
6
|
-
* Added support for symbols as selectors to the KVO module.
|
7
23
|
* Fixed a bug with the way the headers and content types were handled in
|
8
24
|
the HTTP wrapper.
|
9
25
|
|
10
26
|
## 1.1.0
|
11
27
|
|
12
|
-
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/
|
28
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.0.0...v1.1.0)
|
29
|
+
|
13
30
|
* Added `BubbleWrap::Reactor`, a simplified implementation of the Event Machine API on top of GCD.
|
14
31
|
* Added upload support to the HTTP wrapper.
|
15
32
|
* Added `BubbleWrap.create_uuid` to generate a uuid string.
|
@@ -24,6 +41,8 @@
|
|
24
41
|
|
25
42
|
## 1.0.0
|
26
43
|
|
44
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v0.4.0...v1.0.0)
|
45
|
+
|
27
46
|
* Improved the integration with RubyMotion build system.
|
28
47
|
* Improved test suite.
|
29
48
|
* Added better documentation, including on how to work on the internals.
|
@@ -33,25 +52,35 @@
|
|
33
52
|
|
34
53
|
## 0.4.0
|
35
54
|
|
55
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v0.3.1...v0.4.0)
|
56
|
+
|
36
57
|
* Refactored the code and test suite to be more modular and to handle
|
37
58
|
dependencies. One can now require only a subset of BW such as `require 'bubble-wrap/core'` or 'bubble-wrap/http'
|
38
59
|
|
39
60
|
## 0.3.1
|
40
61
|
|
62
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v0.3.0...v0.3.1)
|
63
|
+
|
41
64
|
* Added App.run_after(delay){ }
|
42
65
|
* HTTP responses return true to ok? when the status code is 20x.
|
43
66
|
|
44
67
|
## 0.3.0
|
45
68
|
|
46
|
-
|
69
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v0.2.1...v0.3.0)
|
70
|
+
|
71
|
+
* Major refactoring preparing for 1.0
|
47
72
|
|
48
73
|
## 0.2.1
|
49
74
|
|
75
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v0.2.0...v0.2.1)
|
76
|
+
|
50
77
|
* Minor fix in the way the dependencies are set (had to monkey patch
|
51
78
|
RubyMotion)
|
52
79
|
|
53
80
|
## 0.2.0
|
54
81
|
|
82
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v0.1.2...v0.2.0)
|
83
|
+
|
55
84
|
* Added network activity notification to the HTTP wrapper.
|
56
85
|
* fixed a bug in the `NSNotificationCenter` wrapper.
|
57
86
|
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bubble-wrap (1.1.
|
4
|
+
bubble-wrap (1.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
bacon (1.1.0)
|
10
10
|
metaclass (0.0.1)
|
11
|
-
mocha (0.
|
11
|
+
mocha (0.11.4)
|
12
12
|
metaclass (~> 0.0.1)
|
13
13
|
mocha-on-bacon (0.2.0)
|
14
14
|
mocha (>= 0.9.8)
|
@@ -20,5 +20,6 @@ PLATFORMS
|
|
20
20
|
DEPENDENCIES
|
21
21
|
bacon
|
22
22
|
bubble-wrap!
|
23
|
+
mocha (= 0.11.4)
|
23
24
|
mocha-on-bacon
|
24
25
|
rake
|
data/README.md
CHANGED
@@ -240,22 +240,22 @@ Helper methods to give NSNotificationCenter a Ruby-like interface:
|
|
240
240
|
|
241
241
|
```ruby
|
242
242
|
def viewWillAppear(animated)
|
243
|
-
@foreground_observer = notification_center.observe UIApplicationWillEnterForegroundNotification do |notification|
|
243
|
+
@foreground_observer = App.notification_center.observe UIApplicationWillEnterForegroundNotification do |notification|
|
244
244
|
loadAndRefresh
|
245
245
|
end
|
246
246
|
|
247
|
-
@reload_observer = notification_center.observe ReloadNotification do |notification|
|
247
|
+
@reload_observer = App.notification_center.observe ReloadNotification do |notification|
|
248
248
|
loadAndRefresh
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
252
|
def viewWillDisappear(animated)
|
253
|
-
notification_center.unobserve @foreground_observer
|
254
|
-
notification_center.unobserve @reload_observer
|
253
|
+
App.notification_center.unobserve @foreground_observer
|
254
|
+
App.notification_center.unobserve @reload_observer
|
255
255
|
end
|
256
256
|
|
257
257
|
def reload
|
258
|
-
notification_center.post ReloadNotification
|
258
|
+
App.notification_center.post ReloadNotification
|
259
259
|
end
|
260
260
|
```
|
261
261
|
|
data/bubble-wrap.gemspec
CHANGED
@@ -16,7 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
|
17
17
|
gem.extra_rdoc_files = gem.files.grep(%r{motion})
|
18
18
|
|
19
|
-
gem.add_development_dependency '
|
19
|
+
gem.add_development_dependency 'mocha', '0.11.4'
|
20
20
|
gem.add_development_dependency 'mocha-on-bacon'
|
21
|
+
gem.add_development_dependency 'bacon'
|
21
22
|
gem.add_development_dependency 'rake'
|
22
23
|
end
|
@@ -22,13 +22,17 @@ module BubbleWrap
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def strip_up_to_last_lib(path)
|
25
|
-
path
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
if path =~ /\/lib$/
|
26
|
+
path = path.gsub(/\/lib$/, "")
|
27
|
+
else
|
28
|
+
path = path.split('lib')
|
29
|
+
path = if path.size > 1
|
30
|
+
path[0..-2].join('lib')
|
31
|
+
else
|
32
|
+
path[0]
|
33
|
+
end
|
34
|
+
path = path[0..-2] if path[-1] == '/'
|
35
|
+
end
|
32
36
|
path
|
33
37
|
end
|
34
38
|
|
data/lib/bubble-wrap/version.rb
CHANGED
data/motion/http.rb
CHANGED
@@ -119,6 +119,7 @@ module BubbleWrap
|
|
119
119
|
@credentials = {:username => '', :password => ''}.merge(@credentials)
|
120
120
|
@timeout = options.delete(:timeout) || 30.0
|
121
121
|
@headers = escape_line_feeds(options.delete :headers)
|
122
|
+
@format = options.delete(:format)
|
122
123
|
@cache_policy = options.delete(:cache_policy) || NSURLRequestUseProtocolCachePolicy
|
123
124
|
@options = options
|
124
125
|
@response = HTTP::Response.new
|
@@ -126,6 +127,7 @@ module BubbleWrap
|
|
126
127
|
@url = create_url(url_string)
|
127
128
|
@body = create_request_body
|
128
129
|
@request = create_request
|
130
|
+
set_content_type
|
129
131
|
@connection = create_connection(request, self)
|
130
132
|
@connection.start
|
131
133
|
|
@@ -221,16 +223,6 @@ Cache policy: #{@cache_policy}, response: #{@response.inspect} >"
|
|
221
223
|
return nil if (@method == "GET" || @method == "HEAD")
|
222
224
|
return nil unless (@payload || @files)
|
223
225
|
|
224
|
-
# if no headers provided, set content-type automatically
|
225
|
-
if @headers.nil?
|
226
|
-
@headers = {"Content-Type" => "multipart/form-data; boundary=#{@boundary}"}
|
227
|
-
# else set content type unless it is specified
|
228
|
-
# if content-type is specified, you should probably also specify
|
229
|
-
# the :boundary key
|
230
|
-
else
|
231
|
-
@headers['Content-Type'] = "multipart/form-data; boundary=#{@boundary}" unless @headers.keys.find {|k| k.downcase == 'content-type'}
|
232
|
-
end
|
233
|
-
|
234
226
|
body = NSMutableData.data
|
235
227
|
|
236
228
|
append_payload(body) if @payload
|
@@ -241,6 +233,27 @@ Cache policy: #{@cache_policy}, response: #{@response.inspect} >"
|
|
241
233
|
body
|
242
234
|
end
|
243
235
|
|
236
|
+
def set_content_type
|
237
|
+
# if no headers provided, set content-type automatically
|
238
|
+
if @headers.nil? || !@headers.keys.find {|k| k.downcase == 'content-type'}
|
239
|
+
@headers ||= {}
|
240
|
+
@headers["Content-Type"] = case @format
|
241
|
+
when :json
|
242
|
+
"application/json"
|
243
|
+
when :xml
|
244
|
+
"application/xml"
|
245
|
+
when :text
|
246
|
+
"text/plain"
|
247
|
+
else
|
248
|
+
if @format == :form_data || @set_body_to_close_boundary
|
249
|
+
"multipart/form-data; boundary=#{@boundary}"
|
250
|
+
else
|
251
|
+
"application/x-www-form-urlencoded"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
244
257
|
def append_payload(body)
|
245
258
|
if @payload.is_a?(NSData)
|
246
259
|
body.appendData(@payload)
|
@@ -255,7 +268,8 @@ Cache policy: #{@cache_policy}, response: #{@response.inspect} >"
|
|
255
268
|
if @payload.is_a?(String)
|
256
269
|
body.appendData(@payload.dataUsingEncoding NSUTF8StringEncoding)
|
257
270
|
else
|
258
|
-
@payload
|
271
|
+
list = process_payload_hash(@payload)
|
272
|
+
list.each do |key, value|
|
259
273
|
form_data = NSMutableData.new
|
260
274
|
s = "\r\n--#{@boundary}\r\n"
|
261
275
|
s += "Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n"
|
@@ -295,28 +309,29 @@ Cache policy: #{@cache_policy}, response: #{@response.inspect} >"
|
|
295
309
|
end
|
296
310
|
|
297
311
|
def convert_payload_to_url
|
298
|
-
params_array =
|
312
|
+
params_array = process_payload_hash(@payload)
|
313
|
+
params_array.map! { |key, value| "#{key}=#{value}" }
|
299
314
|
@payload = params_array.join("&")
|
300
315
|
end
|
301
316
|
|
302
|
-
def
|
317
|
+
def process_payload_hash(payload, prefix=nil)
|
303
318
|
list = []
|
304
319
|
payload.each do |k,v|
|
305
320
|
if v.is_a?(Hash)
|
306
321
|
new_prefix = prefix ? "#{prefix}[#{k.to_s}]" : k.to_s
|
307
|
-
param =
|
308
|
-
list
|
322
|
+
param = process_payload_hash(v, new_prefix)
|
323
|
+
list += param
|
309
324
|
elsif v.is_a?(Array)
|
310
325
|
v.each do |val|
|
311
|
-
param = prefix ? "#{prefix}[#{k}][]
|
312
|
-
list << param
|
326
|
+
param = prefix ? "#{prefix}[#{k.to_s}][]" : "#{k.to_s}[]"
|
327
|
+
list << [param, val]
|
313
328
|
end
|
314
329
|
else
|
315
|
-
param = prefix ? "#{prefix}[#{k}]
|
316
|
-
list << param
|
330
|
+
param = prefix ? "#{prefix}[#{k.to_s}]" : k.to_s
|
331
|
+
list << [param, v]
|
317
332
|
end
|
318
333
|
end
|
319
|
-
|
334
|
+
list
|
320
335
|
end
|
321
336
|
|
322
337
|
def log(message)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
attr_reader :window
|
3
|
+
|
4
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
5
|
+
setup_window
|
6
|
+
true
|
7
|
+
end
|
8
|
+
|
9
|
+
# setup UI
|
10
|
+
def setup_window
|
11
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
12
|
+
@window.rootViewController = DrawingViewController.alloc.init
|
13
|
+
@window.rootViewController.wantsFullScreenLayout = true
|
14
|
+
@window.makeKeyAndVisible
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class DrawingViewController < UIViewController
|
2
|
+
attr_reader :drawing_view
|
3
|
+
|
4
|
+
def loadView
|
5
|
+
screen = UIScreen.mainScreen.bounds
|
6
|
+
self.view = UIView.alloc.initWithFrame screen
|
7
|
+
self.view.backgroundColor = UIColor.whiteColor
|
8
|
+
|
9
|
+
@drawing_view = RectView.alloc.initWithFrame [[screen.size.width/2-50,screen.size.height/2-50], [100,100]]
|
10
|
+
self.view.addSubview @drawing_view
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class GestureView < UIView
|
2
|
+
attr_accessor :rotation, :scale, :translation
|
3
|
+
|
4
|
+
def initWithCoder(coder)
|
5
|
+
super
|
6
|
+
setup
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
def initWithFrame(coder)
|
11
|
+
super
|
12
|
+
setup
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
## UIGestureRecognizerDelegate
|
17
|
+
|
18
|
+
# Note: this method allow rotate and pinch gesture happen at the same time
|
19
|
+
def gestureRecognizer(recognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer:other_recognizer)
|
20
|
+
case recognizer
|
21
|
+
when @rotated_recognizer
|
22
|
+
if other_recognizer == @pinch_recognizer
|
23
|
+
return true
|
24
|
+
end
|
25
|
+
when @pinch_recognizer
|
26
|
+
if other_recognizer == @rotated_recognizer
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def setup
|
36
|
+
self.layer.shouldRasterize = true
|
37
|
+
self.rotation = 0
|
38
|
+
self.scale = 1
|
39
|
+
setup_gesture
|
40
|
+
end
|
41
|
+
|
42
|
+
def setup_gesture
|
43
|
+
@panned_recognizer = self.whenPanned do |recognizer|
|
44
|
+
case(recognizer.state)
|
45
|
+
when UIGestureRecognizerStateBegan
|
46
|
+
@last_position = self.position
|
47
|
+
when UIGestureRecognizerStateChanged
|
48
|
+
self.translation = recognizer.translationInView(self.superview)
|
49
|
+
self.position = [@last_position.x + self.translation.x, @last_position.y + self.translation.y]
|
50
|
+
when UIGestureRecognizerStateEnded
|
51
|
+
@last_position = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
@panned_recognizer.maximumNumberOfTouches = 1
|
55
|
+
@panned_recognizer.minimumNumberOfTouches = 1
|
56
|
+
@panned_recognizer.delegate = self
|
57
|
+
|
58
|
+
@rotated_recognizer = self.whenRotated do |recognizer|
|
59
|
+
case(recognizer.state)
|
60
|
+
when UIGestureRecognizerStateBegan
|
61
|
+
@last_rotation = self.rotation
|
62
|
+
when UIGestureRecognizerStateChanged
|
63
|
+
self.rotation = @last_rotation + recognizer.rotation
|
64
|
+
reset_transformation
|
65
|
+
when UIGestureRecognizerStateEnded
|
66
|
+
@last_rotation = nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
@rotated_recognizer.delegate = self
|
70
|
+
|
71
|
+
@pinch_recognizer = self.whenPinched do |recognizer|
|
72
|
+
case(recognizer.state)
|
73
|
+
when UIGestureRecognizerStateBegan
|
74
|
+
@last_scale = self.scale
|
75
|
+
when UIGestureRecognizerStateChanged
|
76
|
+
self.scale = @last_scale * recognizer.scale
|
77
|
+
reset_transformation
|
78
|
+
when UIGestureRecognizerStateEnded
|
79
|
+
@last_scale = nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
@pinch_recognizer.delegate = self
|
83
|
+
end
|
84
|
+
|
85
|
+
def reset_transformation
|
86
|
+
transform = CATransform3DIdentity
|
87
|
+
transform = CATransform3DRotate(transform, -1 * self.rotation, 0.0, 0.0, -1.0)
|
88
|
+
transform = CATransform3DScale(transform, self.scale, self.scale, 1.0)
|
89
|
+
self.layer.transform = transform
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class RectView < GestureView
|
2
|
+
def drawRect(rect)
|
3
|
+
super(rect)
|
4
|
+
|
5
|
+
context = UIGraphicsGetCurrentContext()
|
6
|
+
CGContextSetAllowsAntialiasing(context, true);
|
7
|
+
CGContextSetShouldAntialias(context, true);
|
8
|
+
CGContextSetFillColorWithColor(context, UIColor.redColor.CGColor)
|
9
|
+
CGContextSetLineWidth(context, 10.0)
|
10
|
+
CGContextAddRect(context, [[0,0], [self.frame.size.width,self.frame.size.height]])
|
11
|
+
CGContextFillPath(context)
|
12
|
+
end
|
13
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path('../../../../../lib/bubble-wrap/requirement/path_manipulation', __FILE__)
|
2
2
|
|
3
3
|
describe BubbleWrap::Requirement::PathManipulation do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
@subject = Object.new
|
7
7
|
@subject.extend BubbleWrap::Requirement::PathManipulation
|
@@ -35,6 +35,11 @@ describe BubbleWrap::Requirement::PathManipulation do
|
|
35
35
|
should == '/fake/lib/dir'
|
36
36
|
end
|
37
37
|
|
38
|
+
it "strips off only a trailing lib" do
|
39
|
+
@subject.strip_up_to_last_lib('/fake/lib/dir/lib').
|
40
|
+
should == '/fake/lib/dir'
|
41
|
+
end
|
42
|
+
|
38
43
|
it "doesn't modify the path otherwise" do
|
39
44
|
@subject.strip_up_to_last_lib('/fake/path').
|
40
45
|
should == '/fake/path'
|
data/spec/motion/http_spec.rb
CHANGED
@@ -108,6 +108,7 @@ describe "HTTP" do
|
|
108
108
|
credentials: @credentials
|
109
109
|
}
|
110
110
|
@action = lambda{|fa, ke|}
|
111
|
+
@format = "application/x-www-form-urlencoded"
|
111
112
|
@cache_policy = 24234
|
112
113
|
@leftover_option = 'trololo'
|
113
114
|
@headers = { 'User-Agent' => "Mozilla/5.0 (X11; Linux x86_64; rv:12.0) \n Gecko/20100101 Firefox/12.0" }
|
@@ -122,7 +123,8 @@ describe "HTTP" do
|
|
122
123
|
credentials: @credentials,
|
123
124
|
headers: @headers,
|
124
125
|
cache_policy: @cache_policy,
|
125
|
-
leftover_option: @leftover_option
|
126
|
+
leftover_option: @leftover_option,
|
127
|
+
format: @format
|
126
128
|
}
|
127
129
|
@query = BubbleWrap::HTTP::Query.new( @localhost_url , :get, @options )
|
128
130
|
end
|
@@ -158,6 +160,11 @@ describe "HTTP" do
|
|
158
160
|
@options.should.not.has_key? :files
|
159
161
|
end
|
160
162
|
|
163
|
+
it "sets the format from options" do
|
164
|
+
@query.instance_variable_get(:@format).should.equal @format
|
165
|
+
@options.should.not.has_key? :format
|
166
|
+
end
|
167
|
+
|
161
168
|
it "should set self as the delegator if action was not passed in" do
|
162
169
|
new_query = BubbleWrap::HTTP::Query.new( 'http://localhost', :get, {})
|
163
170
|
new_query.instance_variable_get(:@delegator).should.equal new_query
|
@@ -241,7 +248,7 @@ describe "HTTP" do
|
|
241
248
|
lambda { query = create_query(data, nil) }.should.not.raise NoMethodError
|
242
249
|
end
|
243
250
|
|
244
|
-
it "sets the payload as a string if JSON" do
|
251
|
+
it "sets the payload as a string if JSON" do
|
245
252
|
json = BW::JSON.generate({foo:42, bar:'BubbleWrap'})
|
246
253
|
puts "\n"
|
247
254
|
[:put, :post, :delete, :patch].each do |method|
|
@@ -252,6 +259,14 @@ describe "HTTP" do
|
|
252
259
|
end
|
253
260
|
end
|
254
261
|
|
262
|
+
it "sets the payload for a nested hash to multiple form-data parts" do
|
263
|
+
payload = { computer: { name: 'apple', model: 'macbook'} }
|
264
|
+
query = BubbleWrap::HTTP::Query.new( 'nil', :post, { payload: payload } )
|
265
|
+
uuid = query.instance_variable_get(:@boundary)
|
266
|
+
real_payload = NSString.alloc.initWithData(query.request.HTTPBody, encoding:NSUTF8StringEncoding)
|
267
|
+
real_payload.should.equal "\r\n--#{uuid}\r\nContent-Disposition: form-data; name=\"computer[name]\"\r\n\r\napple\r\n--#{uuid}\r\nContent-Disposition: form-data; name=\"computer[model]\"\r\n\r\nmacbook\r\n--#{uuid}--\r\n"
|
268
|
+
end
|
269
|
+
|
255
270
|
end
|
256
271
|
|
257
272
|
it "should set default timeout to 30s or the one from hash" do
|
@@ -351,6 +366,21 @@ describe "HTTP" do
|
|
351
366
|
@post_query.request.allHTTPHeaderFields.should.include?('Content-Type')
|
352
367
|
end
|
353
368
|
|
369
|
+
it "should use the format parameter to decide the Content-Type" do
|
370
|
+
json_query = BubbleWrap::HTTP::Query.new(@url_string, :post, {headers: @headers, format: :json, payload: "{\"key\":\"abc1234\"}"})
|
371
|
+
json_query.request.allHTTPHeaderFields['Content-Type'].should.equal "application/json"
|
372
|
+
end
|
373
|
+
|
374
|
+
it "should default to multipart/form-data for payloads with a hash" do
|
375
|
+
uuid = @post_query.instance_variable_get(:@boundary)
|
376
|
+
@post_query.request.allHTTPHeaderFields['Content-Type'].should.equal "multipart/form-data; boundary=#{uuid}"
|
377
|
+
end
|
378
|
+
|
379
|
+
it "should default to application/x-www-form-urlencoded for non-hash payloads" do
|
380
|
+
string_query = BubbleWrap::HTTP::Query.new(@url_string, :post, {headers: @headers, payload: "{\"key\":\"abc1234\"}"})
|
381
|
+
string_query.request.allHTTPHeaderFields['Content-Type'].should.equal "application/x-www-form-urlencoded"
|
382
|
+
end
|
383
|
+
|
354
384
|
it "should not add Content-Type if you provide one yourself" do
|
355
385
|
# also ensures check is case insenstive
|
356
386
|
@headers = { fake: 'headers', 'CONTENT-TYPE' => 'x-banana' }
|
@@ -365,21 +395,21 @@ describe "HTTP" do
|
|
365
395
|
|
366
396
|
end
|
367
397
|
|
368
|
-
describe "Generating
|
398
|
+
describe "Generating payloads" do
|
369
399
|
|
370
|
-
it "should create
|
400
|
+
it "should create payload key/value pairs from nested hashes with prefix[key]=value" do
|
371
401
|
expected_params = [
|
372
|
-
'user[name]
|
373
|
-
'user[surname]
|
374
|
-
'twitter
|
375
|
-
'website
|
376
|
-
'values[]
|
377
|
-
'values[]
|
378
|
-
'values[]
|
379
|
-
|
380
|
-
|
402
|
+
['user[name]', 'marin'],
|
403
|
+
['user[surname]', 'usalj'],
|
404
|
+
['twitter', '@mneorr'],
|
405
|
+
['website', 'mneorr.com'],
|
406
|
+
['values[]', 'apple'],
|
407
|
+
['values[]', 'orange'],
|
408
|
+
['values[]', 'peach'],
|
409
|
+
['credentials[username]', 'mneorr'],
|
410
|
+
['credentials[password]', '123456xx!@crazy']
|
381
411
|
]
|
382
|
-
@query.send(:
|
412
|
+
@query.send(:process_payload_hash, @payload).should.equal expected_params
|
383
413
|
end
|
384
414
|
|
385
415
|
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: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,22 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-07-
|
14
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
18
|
-
requirement: &
|
17
|
+
name: mocha
|
18
|
+
requirement: &70216781507520 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - =
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.11.4
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *70216781507520
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocha-on-bacon
|
29
|
+
requirement: &70216781507100 !ruby/object:Gem::Requirement
|
19
30
|
none: false
|
20
31
|
requirements:
|
21
32
|
- - ! '>='
|
@@ -23,10 +34,10 @@ dependencies:
|
|
23
34
|
version: '0'
|
24
35
|
type: :development
|
25
36
|
prerelease: false
|
26
|
-
version_requirements: *
|
37
|
+
version_requirements: *70216781507100
|
27
38
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: &
|
39
|
+
name: bacon
|
40
|
+
requirement: &70216781506640 !ruby/object:Gem::Requirement
|
30
41
|
none: false
|
31
42
|
requirements:
|
32
43
|
- - ! '>='
|
@@ -34,10 +45,10 @@ dependencies:
|
|
34
45
|
version: '0'
|
35
46
|
type: :development
|
36
47
|
prerelease: false
|
37
|
-
version_requirements: *
|
48
|
+
version_requirements: *70216781506640
|
38
49
|
- !ruby/object:Gem::Dependency
|
39
50
|
name: rake
|
40
|
-
requirement: &
|
51
|
+
requirement: &70216781506220 !ruby/object:Gem::Requirement
|
41
52
|
none: false
|
42
53
|
requirements:
|
43
54
|
- - ! '>='
|
@@ -45,7 +56,7 @@ dependencies:
|
|
45
56
|
version: '0'
|
46
57
|
type: :development
|
47
58
|
prerelease: false
|
48
|
-
version_requirements: *
|
59
|
+
version_requirements: *70216781506220
|
49
60
|
description: RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more
|
50
61
|
Ruby like, one API at a time. Fork away and send your pull request.
|
51
62
|
email:
|
@@ -179,6 +190,17 @@ files:
|
|
179
190
|
- motion/ui/ui_control.rb
|
180
191
|
- motion/ui/ui_view_controller.rb
|
181
192
|
- resources/atom.xml
|
193
|
+
- samples/gesture/.gitignore
|
194
|
+
- samples/gesture/Gemfile
|
195
|
+
- samples/gesture/Gemfile.lock
|
196
|
+
- samples/gesture/README.md
|
197
|
+
- samples/gesture/Rakefile
|
198
|
+
- samples/gesture/app/app_delegate.rb
|
199
|
+
- samples/gesture/app/controllers/drawing_view_controller.rb
|
200
|
+
- samples/gesture/app/helpers/drawing_helper.rb
|
201
|
+
- samples/gesture/app/views/drawing/gesture_view.rb
|
202
|
+
- samples/gesture/app/views/drawing/rect_view.rb
|
203
|
+
- samples/gesture/spec/main_spec.rb
|
182
204
|
- spec/lib/bubble-wrap/ext/motion_project_app_spec.rb
|
183
205
|
- spec/lib/bubble-wrap/ext/motion_project_config_spec.rb
|
184
206
|
- spec/lib/bubble-wrap/requirement/path_manipulation_spec.rb
|
@@ -219,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
241
|
version: '0'
|
220
242
|
segments:
|
221
243
|
- 0
|
222
|
-
hash:
|
244
|
+
hash: 4073507284193479358
|
223
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
246
|
none: false
|
225
247
|
requirements:
|
@@ -228,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
250
|
version: '0'
|
229
251
|
segments:
|
230
252
|
- 0
|
231
|
-
hash:
|
253
|
+
hash: 4073507284193479358
|
232
254
|
requirements: []
|
233
255
|
rubyforge_project:
|
234
256
|
rubygems_version: 1.8.16
|