README.md in bubble-wrap-1.3.0.osx vs README.md in bubble-wrap-1.3.0
- old
+ new
@@ -1,8 +1,8 @@
# BubbleWrap for RubyMotion
-A collection of (tested) helpers and wrappers used to wrap CocoaTouch code and provide more Ruby like APIs.
+A collection of (tested) helpers and wrappers used to wrap Cocoa Touch and AppKit code and provide more Ruby like APIs.
[BubbleWrap website](http://bubblewrap.io)
[BubbleWrap mailing list](https://groups.google.com/forum/#!forum/bubblewrap)
[![Code Climate](https://codeclimate.com/github/rubymotion/BubbleWrap.png)](https://codeclimate.com/github/rubymotion/BubbleWrap)
@@ -21,10 +21,16 @@
```ruby
require 'bubble-wrap'
```
+If you are requiring bubble-wrap for RubyMotion 2.0 (iOS or OS X), use Bundler and specify version greater than 1.3.0:
+
+```ruby
+gem "bubble-wrap", "~> 1.3.0"
+```
+
BubbleWrap is split into multiple modules so that you can easily choose which parts
are included at compile-time.
The above example requires the `core` and `http` modules. If you wish to only
include the core modules use the following line of code instead:
@@ -153,10 +159,12 @@
# "testSuite"
> App.identifier
# "io.bubblewrap.testSuite"
> App.alert("BubbleWrap is awesome!")
# creates and shows an alert message.
+> App.alert("BubbleWrap is awesome!", {cancel_button_title: "I know it is!", message: "Like, seriously awesome."})
+# creates and shows an alert message with optional parameters.
> App.run_after(0.5) { p "It's #{Time.now}" }
# Runs the block after 0.5 seconds.
> App.open_url("http://matt.aimonetti.net")
# Opens the url using the device's browser. (accepts a string url or an instance of `NSURL`.
> App::Persistence['channels'] # application specific persistence storage
@@ -191,13 +199,13 @@
```ruby
> Device.iphone?
# true
> Device.ipad?
# false
-> Device.front_camera?
+> Device.camera.front?
# true
-> Device.rear_camera?
+> Device.camera.rear?
# true
> Device.orientation
# :portrait
> Device.simulator?
# true
@@ -516,187 +524,9 @@
:rewind
:fast_forward
:undo
:redo
:page_curl
-```
-
-### UIAlertView
-
-`BW::UIAlertView` is a subclass of `UIAlertView` with an natural Ruby syntax.
-
-#### Default alert
-
-The `.default` constructor accepts an optional `Hash` of options and returns a `BW::UIAlertView` instance in the `UIAlertViewStyleDefault` style. The instance can then be given an `#on_click` callback to be executed when it's button is clicked. For example:
-
-![iOS Simulator Screen shot Apr 24 2013 10 54 28 AM](https://f.cloud.github.com/assets/5688/421437/59a5376c-ad08-11e2-9ccc-0df83eb360e0.png)
-
-```ruby
-options = { :title => "Are you ready?" }
-ready_alert = BW::UIAlertView.default(options).on_click do |alert|
- # ...
-end
-
-ready_alert.show
-```
-
-#### Input alerts
-
-`BW::UIAlertView` has constructors for input alerts too.
-
-`.plain_text_input` returns an instance in the `UIAlertViewStylePlainTextInput` style.
-
-![iOS Simulator Screen shot Apr 24 2013 10 58 27 AM](https://f.cloud.github.com/assets/5688/421453/a6c15698-ad08-11e2-9bef-a755732e9b91.png)
-
-```ruby
-options = { :title => "Replicator" }
-replicator_alert = BW::UIAlertView.plain_text_input(options).on_click do |alert|
- alert.plain_text_field.text #=> "Tea. Early Grey. Hot."
-end
-
-replicator_alert.show
-```
-
-`.secure_text_input` returns an instance in the `UIAlertViewStyleSecureTextInput` style.
-
-![iOS Simulator Screen shot Apr 24 2013 11 09 43 AM](https://f.cloud.github.com/assets/5688/421503/396084dc-ad0a-11e2-9e09-c778d2a6cdc4.png)
-
-```ruby
-options = { :title => "Authorization" }
-replicator_alert = BW::UIAlertView.secure_text_input(options).on_click do |alert|
- alert.secure_text_field.text #=> "Theta2997"
-end
-
-replicator_alert.show
-```
-
-And `.login_and_password_input` returns an instance in the `UIAlertViewStyleLoginAndPasswordInput` style.
-
-![iOS Simulator Screen shot Apr 24 2013 11 27 20 AM](https://f.cloud.github.com/assets/5688/421608/b26ab51c-ad0c-11e2-8356-d73fd20c8d7f.png)
-
-```ruby
-options = { :title => "Authorization" }
-auth_alert = BW::UIAlertView.login_and_password_input(options).on_click do |alert|
- alert.login_text_field.text #=> "La Forge"
- alert.password_text_field.text #=> "Theta2997"
-end
-
-auth_alert.show
-```
-
-#### Buttons
-
-Each alert style has sane, default button titles. Yet they're fully customizable by providing either a `String` to the constructor's `:buttons` argument
-
-![iOS Simulator Screen shot Apr 24 2013 11 34 12 AM](https://f.cloud.github.com/assets/5688/421633/ac364106-ad0d-11e2-9b0a-ec1692da0c7f.png)
-
-```ruby
-alert = BW::UIAlertView.default(:title => "BubbleWrap is", :buttons => "Awesome")
-
-alert.show
-```
-
-Or an `Array` of strings to the constructor's `:buttons` argument.
-
-![iOS Simulator Screen shot Apr 24 2013 11 35 36 AM](https://f.cloud.github.com/assets/5688/421640/ce9e4d9c-ad0d-11e2-96bd-ca5327570f4d.png)
-
-```ruby
-options = {
- :title => "Dinner this Friday?",
- :message => "My treat!",
- :buttons => ["No", "Maybe", "Yes"]
-}
-alert = BW::UIAlertView.default(options)
-
-alert.show
-```
-
-Inside a callback, the `#clicked_button` method contains the `index` and `title` of the clicked button.
-
-![iOS Simulator Screen shot Apr 24 2013 11 43 26 AM](https://f.cloud.github.com/assets/5688/421755/d3bf35cc-ad10-11e2-995d-ca45adaad504.png)
-
-```ruby
-options = {
- :title => "Warp Engine Online",
- :message => "Plot a course for Starbase 118. Warp 7.",
- :buttons => ["Cancel", "Engage"],
-}
-warp_alert = BW::UIAlertView.default(options).on_click do |alert|
- if alert.clicked_button.index == 0
- # ...
- else
- # ...
- end
-
- if alert.clicked_button.title == "Cancel"
- # ...
- else
- # ...
- end
-end
-
-warp_alert.show
-```
-
-When the constructor's `:cancel_button_index` argument is provided, the `clicked_button` knows whether or not it's a `cancel?` button. Conveniently, the argument is automatically set to `0` for all constructors **EXCEPT** `.default` and `.new`.
-
-![iOS Simulator Screen shot Apr 24 2013 11 43 26 AM](https://f.cloud.github.com/assets/5688/421755/d3bf35cc-ad10-11e2-995d-ca45adaad504.png)
-
-```ruby
-options = {
- :title => "Warp Engine Online",
- :message => "Plot a course for Starbase 118. Warp 7.",
- :buttons => ["Cancel", "Engage"],
- :cancel_button_index => 0 # set for all constructors EXCEPT `.default` and `.new`
-}
-warp_alert = BW::UIAlertView.default(options).on_click do |alert|
- # NOTE: uses the :cancel_button_index argument
- if alert.clicked_button.cancel?
- # ...
- else
- # ...
- end
-end
-
-warp_alert.show
-```
-
-#### Callbacks
-
-`BW::UIAlertView` instances are their own delegate. The complete `UIAlertViewDelegte` protocol is available via callbacks.
-
-```ruby
-alert = BW::UIAlertView.default
-
-alert.will_present do |alert|
- # aka willPresentAlertView:
-end
-
-alert.did_present do |alert|
- # aka didPresentAlertView:
-end
-
-alert.on_click do |alert|
- # aka alertView:clickedButtonAtIndex:
-end
-
-alert.will_dismiss do |alert|
- # aka alertView:willDismissWithButtonIndex:
-end
-
-alert.did_dismiss do |alert|
- # aka alertView:didDismissWithButtonIndex:
-end
-
-alert.on_system_cancel do |alert|
- # aka alertViewCancel:
-end
-
-alert.enable_first_other_button? do |alert|
- # aka alertViewShouldEnableFirstOtherButton:
- # NOTE: must return a boolean
- true
-end
```
## HTTP
`BW::HTTP` wraps `NSURLRequest`, `NSURLConnection` and friends to provide Ruby developers with a more familiar and easier to use API.