README.md in bubble-wrap-1.1.3 vs README.md in bubble-wrap-1.1.4

- old
+ new

@@ -167,10 +167,11 @@ * `App.user_cache` * `App.states` * `App.frame` * `App.delegate` * `App.shared` +* `App.window` * `App.current_locale` ### Device @@ -224,11 +225,11 @@ end ``` ### JSON -`BubbleWrap::JSON` wraps `NSJSONSerialization` available in iOS5 and offers the same API as Ruby's JSON std lib. +`BW::JSON` wraps `NSJSONSerialization` available in iOS5 and offers the same API as Ruby's JSON std lib. ```ruby BW::JSON.generate({'foo => 1, 'bar' => [1,2,3], 'baz => 'awesome'}) => "{\"foo\":1,\"bar\":[1,2,3],\"baz\":\"awesome\"}" BW::JSON.parse "{\"foo\":1,\"bar\":[1,2,3],\"baz\":\"awesome\"}" @@ -397,37 +398,37 @@ end ``` ## HTTP -`BubbleWrap::HTTP` wraps `NSURLRequest`, `NSURLConnection` and friends to provide Ruby developers with a more familiar and easier to use API. +`BW::HTTP` wraps `NSURLRequest`, `NSURLConnection` and friends to provide Ruby developers with a more familiar and easier to use API. The API uses async calls and blocks to stay as simple as possible. To enable it add the following require line to your `Rakefile`: ```ruby require 'bubble-wrap/http' ``` Usage example: ```ruby -BubbleWrap::HTTP.get("https://api.github.com/users/mattetti") do |response| +BW::HTTP.get("https://api.github.com/users/mattetti") do |response| p response.body.to_str end ``` ```ruby -BubbleWrap::HTTP.get("https://api.github.com/users/mattetti", {credentials: {username: 'matt', password: 'aimonetti'}}) do |response| +BW::HTTP.get("https://api.github.com/users/mattetti", {credentials: {username: 'matt', password: 'aimonetti'}}) do |response| p response.body.to_str # prints the response's body end ``` ```ruby data = {first_name: 'Matt', last_name: 'Aimonetti'} -BubbleWrap::HTTP.post("http://foo.bar.com/", {payload: data}) do |response| +BW::HTTP.post("http://foo.bar.com/", {payload: data}) do |response| if response.ok? - json = BubbleWrap::JSON.parse(response.body.to_str) + json = BW::JSON.parse(response.body.to_str) p json['id'] elsif response.status_code.to_s =~ /40\d/ App.alert("Login failed") else App.alert(response.error_message) @@ -518,13 +519,13 @@ ## Reactor **Since: > version 1.0.0** -`BubbleWrap::Reactor` is a simplified, mostly complete implementation of +`BW::Reactor` is a simplified, mostly complete implementation of the [Event Machine](http://rubyeventmachine.com/) API. In fact -`BubbleWrap::Reactor` is aliased to `EM` in the runtime environment. +`BW::Reactor` is aliased to `EM` in the runtime environment. ### Deferables BubbleWrap provides both a `Deferrable` mixin and a `DefaultDeferrable` class, which simply mixes in deferrable behaviour if you don't want to @@ -537,11 +538,11 @@ #### Success ```ruby > d = EM::DefaultDeferrable.new -=> #<BubbleWrap::Reactor::DefaultDeferrable:0x6d859a0> +=> #<BW::Reactor::DefaultDeferrable:0x6d859a0> > d.callback { |what| puts "Great #{what}!" } => [#<Proc:0x6d8a1e0>] > d.succeed "justice" Great justice! => nil @@ -549,11 +550,11 @@ #### Failure ```ruby > d = EM::DefaultDeferrable.new -=> #<BubbleWrap::Reactor::DefaultDeferrable:0x8bf3ee0> +=> #<BW::Reactor::DefaultDeferrable:0x8bf3ee0> > d.errback { |what| puts "Great #{what}!" } => [#<Proc:0x8bf3ef0>] > d.fail "sadness" Great sadness! => nil @@ -561,15 +562,15 @@ #### Timeout ```ruby > d = EM::DefaultDeferrable.new -=> #<BubbleWrap::Reactor::DefaultDeferrable:0x8bf5910> +=> #<BW::Reactor::DefaultDeferrable:0x8bf5910> > d.errback { puts "Great scott!" } => [#<Proc:0x8bf6350>] > d.timeout 2 -=> #<BubbleWrap::Reactor::Timer:0x6d920a0 @timer=#<__NSCFTimer:0x6d91990>> +=> #<BW::Reactor::Timer:0x6d920a0 @timer=#<__NSCFTimer:0x6d91990>> # wait... > Great scott! ``` ### Timers @@ -647,10 +648,10 @@ ### Events Although not part of the EventMachine API, BubbleWrap provides an `Eventable` mixin for use instrumenting objects with simple -event triggering behaviour. `BubbleWrap::Reactor` uses this +event triggering behaviour. `BW::Reactor` uses this behind the scenes in several places, and as it's a very handy idiom it is available as a public API. ```ruby > o = Class.new { include EM::Eventable }.new