motion-bundler 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,12 @@
1
1
  = MotionBundler CHANGELOG
2
2
 
3
+ == Version 0.1.2 (May 20, 2013)
4
+
5
+ * Updated mocked HTTParty module:
6
+
7
+ * Support passing block when sending request
8
+ * Support asynchronous requests
9
+
3
10
  == Version 0.1.1 (May 15, 2013)
4
11
 
5
12
  * Fixed device/core_ext.rb when running `rake device`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -18,24 +18,24 @@ module HTTParty
18
18
  end
19
19
 
20
20
  def get(path, options = {}, &block)
21
- send_request path, :get
21
+ send_request path, :get, options, &block
22
22
  end
23
23
 
24
24
  def post(path, options = {}, &block)
25
- send_request path, :post
25
+ send_request path, :post, options, &block
26
26
  end
27
27
 
28
28
  def put(path, options = {}, &block)
29
- send_request path, :put
29
+ send_request path, :put, options, &block
30
30
  end
31
31
 
32
32
  def delete(path, options = {}, &block)
33
- send_request path, :delete
33
+ send_request path, :delete, options, &block
34
34
  end
35
35
 
36
36
  private
37
37
 
38
- def send_request(path, method, options = {})
38
+ def send_request(path, method, options = {}, &block)
39
39
  path = "#{@base_uri}/#{path}" if @base_uri && !path.match(/^\w+:\/\//)
40
40
  path = path.stringByAddingPercentEscapesUsingEncoding NSUTF8StringEncoding
41
41
  method = method.to_s.upcase
@@ -63,9 +63,17 @@ private
63
63
 
64
64
  response = Pointer.new :object
65
65
  error = Pointer.new :object
66
- data = NSURLConnection.sendSynchronousRequest request, returningResponse: response, error: error
67
66
 
68
- HTTParty::Response.new response, data, {:format => @format, :error => error}
67
+ if options[:async]
68
+ queue = NSOperationQueue.alloc.init
69
+ NSURLConnection.sendAsynchronousRequest request, queue: queue, completionHandler: proc { |response, data, error|
70
+ block.call HTTParty::Response.new(response, data, {:format => @format || options[:format], :error => error})
71
+ }
72
+ else
73
+ data = NSURLConnection.sendSynchronousRequest request, returningResponse: response, error: error
74
+ response = HTTParty::Response.new(response.value, data, {:format => @format || options[:format], :error => error})
75
+ block_given? ? block.call(response) : response
76
+ end
69
77
  end
70
78
 
71
79
  def payload_to_query_string(payload_hash)
@@ -98,7 +106,7 @@ module HTTParty
98
106
  class Response
99
107
 
100
108
  def initialize(response, data, options = {})
101
- @cached_response = NSCachedURLResponse.alloc.initWithResponse response.value, data: data
109
+ @cached_response = NSCachedURLResponse.alloc.initWithResponse response, data: data
102
110
  @options = options
103
111
  end
104
112
 
@@ -1,7 +1,7 @@
1
1
  module MotionBundler #:nodoc:
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 1
4
+ TINY = 2
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
@@ -36,8 +36,8 @@ module MotionBundler
36
36
  argv.include? "device"
37
37
  end
38
38
 
39
- def default_files
40
- [File.expand_path("../motion-bundler/#{simulator? ? "simulator" : "device"}/boot.rb", __FILE__)]
39
+ def boot_file
40
+ File.expand_path "../motion-bundler/#{simulator? ? "simulator" : "device"}/boot.rb", __FILE__
41
41
  end
42
42
 
43
43
  private
@@ -67,9 +67,7 @@ private
67
67
  def tracer_require(files, files_dependencies, required)
68
68
  Require.trace do
69
69
  require MOTION_BUNDLER_FILE
70
- default_files.each do |file|
71
- require file
72
- end
70
+ require boot_file
73
71
  Bundler.require :motion
74
72
  app_requires.delete_if do |file|
75
73
  require file, "APP"
@@ -88,8 +86,7 @@ private
88
86
  files_dependencies.merge!(
89
87
  Require.files_dependencies.tap do |dependencies|
90
88
  (dependencies.delete("BUNDLER") || []).each do |file|
91
- dependencies[file] ||= []
92
- dependencies[file] = default_files + dependencies[file]
89
+ (dependencies[file] ||= []).unshift boot_file
93
90
  end
94
91
  dependencies.delete("APP")
95
92
  dependencies.delete(__FILE__)
data/sample_app/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  $:.unshift "/Library/RubyMotion/lib"
3
- require "motion/project"
3
+ require "motion/project/template/ios"
4
4
 
5
5
  # Require and prepare Bundler
6
6
  require "bundler"
@@ -20,6 +20,7 @@ class AppController < UIViewController
20
20
  p s.read(17)
21
21
 
22
22
  # Testing StringScanner
23
+
23
24
  s = StringScanner.new "ab"
24
25
  p s.getch
25
26
  p s.getch
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/paulengel/Sources/motion-bundler
3
3
  specs:
4
- motion-bundler (0.1.0)
4
+ motion-bundler (0.1.1)
5
5
  colorize
6
6
 
7
7
  PATH
@@ -14,9 +14,7 @@ module Motion
14
14
  last_loaded_feature = nil
15
15
 
16
16
  assert_output "" do
17
- MotionBundler.default_files.each do |default_file|
18
- require default_file
19
- end
17
+ require MotionBundler.boot_file
20
18
  last_loaded_feature = $LOADED_FEATURES.last
21
19
 
22
20
  assert_nil require("a")
@@ -17,10 +17,7 @@ module Motion
17
17
  last_loaded_feature = nil
18
18
  fu = Fu.new
19
19
 
20
- MotionBundler.default_files.each do |default_file|
21
- require default_file
22
- end
23
-
20
+ require MotionBundler.boot_file
24
21
  last_loaded_feature = $LOADED_FEATURES.last
25
22
 
26
23
  assert_nil require("a")
@@ -19,10 +19,10 @@ module Unit
19
19
 
20
20
  it "should determine Motion::Project::App default files" do
21
21
  MotionBundler.expects(:simulator?).returns(true)
22
- assert_equal [motion_bundler_file("motion-bundler/simulator/boot.rb")], MotionBundler.default_files
22
+ assert_equal motion_bundler_file("motion-bundler/simulator/boot.rb"), MotionBundler.boot_file
23
23
 
24
24
  MotionBundler.expects(:simulator?).returns(false)
25
- assert_equal [motion_bundler_file("motion-bundler/device/boot.rb")], MotionBundler.default_files
25
+ assert_equal motion_bundler_file("motion-bundler/device/boot.rb"), MotionBundler.boot_file
26
26
  end
27
27
 
28
28
  it "should be able to touch MotionBundler::MOTION_BUNDLER_FILE" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-05-15 00:00:00.000000000 Z
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -199,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  segments:
201
201
  - 0
202
- hash: -4515734510727804082
202
+ hash: 3167972286108752732
203
203
  required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  segments:
210
210
  - 0
211
- hash: -4515734510727804082
211
+ hash: 3167972286108752732
212
212
  requirements: []
213
213
  rubyforge_project:
214
214
  rubygems_version: 1.8.25