bubble-wrap 1.1.5 → 1.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWEyMmJlN2FlMjdkMmQyZDRjNjVlZmVhMGJhZGVlNjUzODYyODg5MA==
5
+ data.tar.gz: !binary |-
6
+ MTYxYTA5NTgyMWExMTk5NDIwNGY4MGEyNWVkNzFiYjViNGFmNzZhZg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjFiMzNlOTdhOWY4YzVjYTg1NzM5MjlhOTQzNjVhNjhkMWJmYzY3N2M3Yzkw
10
+ N2M0YzZiM2U2NGFhOTYyOWE0MmNkNTJiYzRiNjQ2ODZiOGYzNmEwNDM2MTAz
11
+ YTYxZDM5ZWJlNzIyNjY2N2ExYTU2MjBhODgwZWM4ZDQxZDhkMjE=
12
+ data.tar.gz: !binary |-
13
+ MjhlNDQ5YWU0MGRkODQ1Zjc3YmIyZGU4YmYyOGIzOTUyNmI1MmViZDI3NWUw
14
+ ZGUzM2Y3MzNkMTcyZGY3ZWYzNzkwMzdkNWVkOTg0Y2IyM2UwMzMxMGU2YzMy
15
+ ZTkzZjgwYzZkY2U1NGFlYTcwODI0ZTk0YTk1MDY4MTM4YWY0Y2M=
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ language: objective-c
2
+ before_install: ruby --version
data/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
1
  ## Unreleased
2
2
 
3
- [Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.1.4...master)
3
+ ## 1.2.0.pre
4
+
5
+ [Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.2...master)
6
+
7
+ * Added `BW::UIBarButtonItem`, a factory-esque wrapper for `UIBarButtonItem` ([#202](https://github.com/rubymotion/BubbleWrap/pull/202))
8
+ * Added `BW::Font`, a wrapper for creating `UIFont` objects ([#206](https://github.com/rubymotion/BubbleWrap/pull/206))
9
+ * Added `BW::Reactor::Eventable#off`, to remove `BW::Reactor` callbacks ([#205](https://github.com/rubymotion/BubbleWrap/pull/205))
10
+ * Added `BW::Constants.get`, which is a class to help wrapper creation ([#203](https://github.com/rubymotion/BubbleWrap/pull/203))
11
+ * Added `BW::Location.get_once` to grab only one location ([#197](https://github.com/rubymotion/BubbleWrap/pull/197))
12
+ * Added `App#environment`, to detect the current RubyMotion environment ([#191](https://github.com/rubymotion/BubbleWrap/pull/191))
13
+ * Added `:follow_urls` option to `BW::HTTP` ([#192](https://github.com/rubymotion/BubbleWrap/pull/192))
14
+ * Added `:common_modes` option to `BW::Reactor`to change the runloop mode (#190)
15
+ * Added `:no_redirect` option to `BW::HTTP` ([#187](https://github.com/rubymotion/BubbleWrap/pull/187))
16
+ * Added `:cookies` option to `BW::HTTP` ([#204](https://github.com/rubymotion/BubbleWrap/pull/204))
17
+
18
+ ## 1.1.5
19
+
20
+ [Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.1.4...v1.1.5)
21
+
22
+ * Fix `BW::Camera` view-controller selection process to pickup a window's `presentedViewController` ([#183](https://github.com/rubymotion/BubbleWrap/pull/183))
23
+ * Fix strings parsed in `BW::JSON` to be mutable ([#175](https://github.com/rubymotion/BubbleWrap/pull/175))
24
+ * Add option for `:credential_persistence`/`NSURLCredentialPersistence` in `BW::HTTP` ([#166](https://github.com/rubymotion/BubbleWrap/pull/166))
25
+ * Change `Device.wide_screen?` to `Device.long_screen?` ([#159](https://github.com/rubymotion/BubbleWrap/pull/159))
26
+ * String escaping fixes to `BW::HTTP` ([#160](https://github.com/rubymotion/BubbleWrap/pull/160) [#161](https://github.com/rubymotion/BubbleWrap/pull/161) [#162](https://github.com/rubymotion/BubbleWrap/pull/162))
27
+ * Add `Device.sdk_version`
4
28
 
5
29
  ## 1.1.4
6
30
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bubble-wrap (1.1.4)
4
+ bubble-wrap (1.2.0.pre)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -5,6 +5,10 @@ A collection of (tested) helpers and wrappers used to wrap CocoaTouch code and p
5
5
  [BubbleWrap website](http://bubblewrap.io)
6
6
  [BubbleWrap mailing list](https://groups.google.com/forum/#!forum/bubblewrap)
7
7
 
8
+ [![Code Climate](https://codeclimate.com/github/rubymotion/BubbleWrap.png)](https://codeclimate.com/github/rubymotion/BubbleWrap)
9
+ [![Build Status](https://travis-ci.org/rubymotion/BubbleWrap.png?branch=master)](https://travis-ci.org/rubymotion/BubbleWrap)
10
+ [![Dependency Status](https://gemnasium.com/rubymotion/BubbleWrap.png)](https://gemnasium.com/rubymotion/BubbleWrap)
11
+
8
12
  ## Installation
9
13
 
10
14
  ```ruby
@@ -159,6 +163,8 @@ A module with useful methods related to the running application
159
163
  # ['NBC', 'ABC', 'Fox', 'CBS', 'PBS']
160
164
  > App::Persistence['channels'] = ['TF1', 'France 2', 'France 3']
161
165
  # ['TF1', 'France 2', 'France 3']
166
+ > App.environment
167
+ # 'test'
162
168
  ```
163
169
 
164
170
  Other available methods:
@@ -171,6 +177,9 @@ Other available methods:
171
177
  * `App.shared`
172
178
  * `App.window`
173
179
  * `App.current_locale`
180
+ * `App.release?`
181
+ * `App.test?`
182
+ * `App.development?`
174
183
 
175
184
 
176
185
  ### Device
@@ -285,6 +294,8 @@ simple interface:
285
294
  # ['NBC', 'ABC', 'Fox', 'CBS', 'PBS']
286
295
  > App::Persistence['channels'] = ['TF1', 'France 2', 'France 3']
287
296
  # ['TF1', 'France 2', 'France 3']
297
+ > App::Persistence['something__new'] # something previously never stored
298
+ # nil
288
299
  ```
289
300
 
290
301
  ### Observers
@@ -400,6 +411,109 @@ button.when(UIControlEventTouchUpInside) do
400
411
  end
401
412
  ```
402
413
 
414
+ ### UIBarButtonItem
415
+
416
+ `BW::UIBarButtonItem` provides an idiomatic Ruby syntax for instantiating `UIBarButtonItem` objects. Instead of a target-action pair, each method accepts a block. When the button is tapped, the block is executed. As a convenience, the block is optional.
417
+
418
+ ```ruby
419
+ BW::UIBarButtonItem.system(:save) do
420
+ # ...
421
+ end
422
+
423
+ title = "Friends"
424
+ BW::UIBarButtonItem.styled(:plain, title) do
425
+ # ...
426
+ end
427
+
428
+ image = UIImage.alloc.init
429
+ BW::UIBarButtonItem.styled(:bordered, image) do
430
+ # ...
431
+ end
432
+
433
+ image = UIImage.alloc.init
434
+ landscape = UIImage.alloc.init
435
+ BW::UIBarButtonItem.styled(:bordered, image, landscape) do
436
+ # ...
437
+ end
438
+
439
+ view = UIView.alloc.init
440
+ BW::UIBarButtonItem.custom(view) do
441
+ # ...
442
+ end
443
+ # NOTE: The block is attached to the view as a single tap gesture recognizer.
444
+ ```
445
+
446
+ Alternatively, `BW::UIBarButtonItem` provides a flexible, builder-style syntax for dynamically instantiating `UIBarButtonItem` objects.
447
+
448
+ ```ruby
449
+ options = { :system => :save }
450
+ BW::UIBarButtonItem.build(options) do
451
+ # ...
452
+ end
453
+
454
+ options = { :styled => :plain, :title => "Friends" }
455
+ BW::UIBarButtonItem.build(options) do
456
+ # ...
457
+ end
458
+
459
+ options = { :styled => :bordered, :image => UIImage.alloc.init }
460
+ BW::UIBarButtonItem.build(options) do
461
+ # ...
462
+ end
463
+
464
+ options = {
465
+ :styled => :bordered,
466
+ :image => UIImage.alloc.init,
467
+ :landscape => UIImage.alloc.init
468
+ }
469
+ BW::UIBarButtonItem.build(options) do
470
+ # ...
471
+ end
472
+
473
+ options = { :custom => UIView.alloc.init }
474
+ BW::UIBarButtonItem.build(options) do
475
+ # ...
476
+ end
477
+ # NOTE: The block is attached to the view as a single tap gesture recognizer.
478
+ ```
479
+
480
+ The `.styled` button types are:
481
+
482
+ ```ruby
483
+ :plain
484
+ :bordered
485
+ :done
486
+ ```
487
+
488
+ And the `.system` button types are:
489
+
490
+ ```ruby
491
+ :done
492
+ :cancel
493
+ :edit
494
+ :save
495
+ :add
496
+ :flexible_space
497
+ :fixed_space
498
+ :compose
499
+ :reply
500
+ :action
501
+ :organize
502
+ :bookmarks
503
+ :search
504
+ :refresh
505
+ :stop
506
+ :camera
507
+ :trash
508
+ :play
509
+ :pause
510
+ :rewind
511
+ :fast_forward
512
+ :undo
513
+ :redo
514
+ :page_curl
515
+ ```
516
+
403
517
  ## HTTP
404
518
 
405
519
  `BW::HTTP` wraps `NSURLRequest`, `NSURLConnection` and friends to provide Ruby developers with a more familiar and easier to use API.
@@ -480,7 +594,7 @@ state callbacks:
480
594
  ```ruby
481
595
  feed_parser = BW::RSSParser.new("http://feeds.feedburner.com/sdrbpodcast")
482
596
  feed_parser.delegate = self
483
- feed.parse do |item|
597
+ feed_parser.parse do |item|
484
598
  p item.title
485
599
  end
486
600
 
@@ -658,15 +772,22 @@ idiom it is available as a public API.
658
772
 
659
773
  ```ruby
660
774
  > o = Class.new { include EM::Eventable }.new
661
- => #<#<Class:0x6dc1310>:0x6dc2ec0>
775
+ => #<#<Class:0xab63f00>:0xab64430>
662
776
  > o.on(:november_5_1955) { puts "Ow!" }
663
- => [#<Proc:0x6dc6300>]
664
- > o.on(:november_5_1955) { puts "Flux capacitor!" }
665
- => [#<Proc:0x6dc6300>, #<Proc:0x6dc1ba0>]
777
+ => [#<Proc:0xad9bf00>]
778
+ > flux = proc{ puts "Flux capacitor!" }
779
+ => #<Proc:0xab630f0>
780
+ > o.on(:november_5_1955, &flux)
781
+ => [#<Proc:0xad9bf00>, #<Proc:0xab630f0>]
666
782
  > o.trigger(:november_5_1955)
667
783
  Ow!
668
784
  Flux capacitor!
669
785
  => [nil, nil]
786
+ > o.off(:november_5_1955, &flux)
787
+ => #<Proc:0xab630f0>
788
+ > o.trigger(:november_5_1955)
789
+ Ow!
790
+ => [nil]
670
791
  ```
671
792
 
672
793
  # Suggestions?
@@ -1,4 +1,4 @@
1
1
  require File.expand_path('../loader', __FILE__)
2
- ['core', 'http', 'reactor', 'rss_parser', 'ui', 'location', 'media'].each { |sub|
2
+ ['core', 'http', 'reactor', 'rss_parser', 'ui', 'location', 'media', 'font'].each { |sub|
3
3
  require File.expand_path("../#{sub}", __FILE__)
4
4
  }
@@ -1,7 +1,8 @@
1
1
  require 'bubble-wrap/loader'
2
+ BubbleWrap.require('motion/util/constants.rb')
2
3
  BubbleWrap.require('motion/core/device.rb')
3
4
  BubbleWrap.require('motion/core/device/**/*.rb') do
4
5
  file('motion/core/device/camera_wrapper.rb').depends_on 'motion/core/device/camera.rb'
5
- file('motion/core/device/camera.rb').depends_on 'motion/core/device.rb'
6
+ file('motion/core/device/camera.rb').depends_on ['motion/core/device.rb', 'motion/util/constants.rb']
6
7
  file('motion/core/device/screen.rb').depends_on 'motion/core/device.rb'
7
8
  end
@@ -1,8 +1,7 @@
1
1
  require 'bubble-wrap/loader'
2
2
  BubbleWrap.require('motion/core.rb')
3
3
  BubbleWrap.require('motion/core/**/*.rb') do
4
- file('motion/core/device/camera.rb').depends_on 'motion/core/device.rb'
5
- file('motion/core/device/screen.rb').depends_on 'motion/core/device.rb'
6
4
  file('motion/core/pollute.rb').depends_on 'motion/core/ns_index_path.rb'
7
5
  end
6
+ require 'bubble-wrap/camera'
8
7
  require 'bubble-wrap/ui'
@@ -0,0 +1,2 @@
1
+ require 'bubble-wrap/loader'
2
+ BubbleWrap.require('motion/font/font.rb')
@@ -1,6 +1,8 @@
1
1
  require 'bubble-wrap/loader'
2
+ BubbleWrap.require('motion/util/constants.rb')
2
3
  BubbleWrap.require('motion/core/string.rb')
3
4
  BubbleWrap.require('motion/location/**/*.rb') do
4
5
  file('motion/location/pollute.rb').depends_on 'motion/location/location.rb'
6
+ file('motion/location/location.rb').depends_on 'motion/util/constants.rb'
5
7
  file('motion/location/location.rb').uses_framework('CoreLocation')
6
8
  end
@@ -1,5 +1,5 @@
1
1
  module BubbleWrap
2
- VERSION = '1.1.5' unless defined?(BubbleWrap::VERSION)
2
+ VERSION = '1.2.0.pre' unless defined?(BubbleWrap::VERSION)
3
3
  MIN_MOTION_VERSION = '1.24'
4
4
 
5
5
  module_function
data/motion/core/app.rb CHANGED
@@ -129,6 +129,23 @@ module BubbleWrap
129
129
  end
130
130
  end
131
131
 
132
+ # the current application environment : development, test, release
133
+ def environment
134
+ RUBYMOTION_ENV
135
+ end
136
+
137
+ def development?
138
+ environment == 'development'
139
+ end
140
+
141
+ def test?
142
+ environment == 'test'
143
+ end
144
+
145
+ def release?
146
+ environment == 'release'
147
+ end
148
+
132
149
  end
133
150
  end
134
151
  ::App = BubbleWrap::App unless defined?(::App)
@@ -12,6 +12,9 @@ module BubbleWrap
12
12
  CANCELED=1000
13
13
  end
14
14
 
15
+ Constants.register UIImagePickerControllerSourceTypePhotoLibrary, UIImagePickerControllerSourceTypeCamera,
16
+ UIImagePickerControllerSourceTypeSavedPhotosAlbum
17
+
15
18
  MEDIA_TYPE_HASH = {movie: KUTTypeMovie, image: KUTTypeImage}
16
19
 
17
20
  # The camera location; if :none, then we can't use source_type: :camera
@@ -88,7 +91,7 @@ module BubbleWrap
88
91
  end
89
92
 
90
93
  source_type_readable = options[:source_type]
91
- source_type = const_int_get("UIImagePickerControllerSourceType", @options[:source_type])
94
+ source_type = Constants.get("UIImagePickerControllerSourceType", @options[:source_type])
92
95
  if not Camera.source_type_available?(source_type)
93
96
  error(Error::SOURCE_TYPE_NOT_AVAILABLE) and return
94
97
  end
@@ -176,7 +179,7 @@ module BubbleWrap
176
179
 
177
180
  private
178
181
  def camera_device
179
- const_int_get("UIImagePickerControllerCameraDevice", self.location)
182
+ Constants.get("UIImagePickerControllerCameraDevice", self.location)
180
183
  end
181
184
 
182
185
  # ex media_type_to_symbol(KUTTypeMovie) => :movie
@@ -192,29 +195,6 @@ module BubbleWrap
192
195
  def error(type)
193
196
  @callback.call({ error: type })
194
197
  end
195
-
196
- # @param [String] base of the constant
197
- # @param [Integer, String, Symbol] the
198
- # @return [Integer] the constant for this base
199
- # Examples
200
- # const_int_get("UIReturnKey", :done) => UIReturnKeyDone == 9
201
- # const_int_get("UIReturnKey", "done") => UIReturnKeyDone == 9
202
- # const_int_get("UIReturnKey", 9) => 9
203
- def const_int_get(base, value)
204
- return value if value.is_a? Numeric
205
- value = value.to_s.camelize
206
- Kernel.const_get("#{base}#{value}")
207
- end
208
-
209
- # Looks like RubyMotion adds UIKit constants
210
- # at compile time. If you don't use these
211
- # directly in your code, they don't get added
212
- # to Kernel and const_int_get crashes.
213
- def load_constants_hack
214
- [UIImagePickerControllerSourceTypePhotoLibrary, UIImagePickerControllerSourceTypeCamera,
215
- UIImagePickerControllerSourceTypeSavedPhotosAlbum
216
- ]
217
- end
218
198
  end
219
199
  end
220
200
  end
@@ -0,0 +1,85 @@
1
+ module BubbleWrap
2
+ module Font
3
+ module_function
4
+
5
+ def bold(size = nil)
6
+ Font.new(:bold, size)
7
+ end
8
+
9
+ def system(size = nil)
10
+ Font.new(:system, size)
11
+ end
12
+
13
+ def italic(size = nil)
14
+ Font.new(:italic, size)
15
+ end
16
+
17
+ # Example
18
+ # Font.new(<# UIFont >)
19
+ # Font.new("Helvetica")
20
+ # Font.new("Helvetica", 12)
21
+ # Font.new("Helvetica", size: 12)
22
+ # Font.new(name: "Helvetica", size: 12)
23
+ def new(params = {}, *args)
24
+ if params.is_a?(UIFont)
25
+ return params
26
+ end
27
+ _font = nil
28
+
29
+ if params.is_a?(NSString)
30
+ params = {name: params}
31
+ end
32
+
33
+ if args && !args.empty?
34
+ case args[0]
35
+ when NSDictionary
36
+ params.merge!(args[0])
37
+ else
38
+ params.merge!({size: args[0]})
39
+ end
40
+ end
41
+ params[:size] ||= UIFont.systemFontSize
42
+
43
+ case params[:name].to_sym
44
+ when :system
45
+ _font = UIFont.systemFontOfSize(params[:size].to_f)
46
+ when :bold
47
+ _font = UIFont.boldSystemFontOfSize(params[:size].to_f)
48
+ when :italic
49
+ _font = UIFont.italicSystemFontOfSize(params[:size].to_f)
50
+ else
51
+ begin
52
+ _font = UIFont.fontWithName(params[:name], size: params[:size])
53
+ rescue
54
+ end
55
+ end
56
+
57
+ if !_font
58
+ raise "Invalid font for parameters: #{params.inspect} args #{args.inspect}"
59
+ end
60
+
61
+ _font
62
+ end
63
+
64
+ class << self
65
+ alias_method :named, :new
66
+ end
67
+
68
+ # I.e. for UINavigationBar#titleTextAttributes
69
+ def attributes(params = {})
70
+ _attributes = {}
71
+
72
+ _attributes[UITextAttributeFont] = Font.new(params[:font]) if params[:font]
73
+ _attributes[UITextAttributeTextColor] = params[:color].to_color if params[:color]
74
+ _attributes[UITextAttributeTextShadowColor] = params[:shadow_color].to_color if params[:shadow_color]
75
+ _attributes[UITextAttributeTextShadowOffset] = begin
76
+ x = params[:shadow_offset][:x]
77
+ y = params[:shadow_offset][:y]
78
+ offset = UIOffsetMake(x,y)
79
+ NSValue.valueWithUIOffset(offset)
80
+ end if params[:shadow_offset]
81
+
82
+ _attributes
83
+ end
84
+ end
85
+ end