README.md in bubble-wrap-1.1.5 vs README.md in bubble-wrap-1.2.0.pre

- old
+ new

@@ -3,10 +3,14 @@ A collection of (tested) helpers and wrappers used to wrap CocoaTouch 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) +[![Build Status](https://travis-ci.org/rubymotion/BubbleWrap.png?branch=master)](https://travis-ci.org/rubymotion/BubbleWrap) +[![Dependency Status](https://gemnasium.com/rubymotion/BubbleWrap.png)](https://gemnasium.com/rubymotion/BubbleWrap) + ## Installation ```ruby gem install bubble-wrap ``` @@ -157,10 +161,12 @@ # Opens the url using the device's browser. (accepts a string url or an instance of `NSURL`. > App::Persistence['channels'] # application specific persistence storage # ['NBC', 'ABC', 'Fox', 'CBS', 'PBS'] > App::Persistence['channels'] = ['TF1', 'France 2', 'France 3'] # ['TF1', 'France 2', 'France 3'] +> App.environment +# 'test' ``` Other available methods: * `App.notification_center` @@ -169,10 +175,13 @@ * `App.frame` * `App.delegate` * `App.shared` * `App.window` * `App.current_locale` +* `App.release?` +* `App.test?` +* `App.development?` ### Device A collection of useful methods about the current device: @@ -283,10 +292,12 @@ ``` ruby > App::Persistence['channels'] # application specific persistence storage # ['NBC', 'ABC', 'Fox', 'CBS', 'PBS'] > App::Persistence['channels'] = ['TF1', 'France 2', 'France 3'] # ['TF1', 'France 2', 'France 3'] +> App::Persistence['something__new'] # something previously never stored +# nil ``` ### Observers **Since: > version 0.4** @@ -398,10 +409,113 @@ button.when(UIControlEventTouchUpInside) do self.view.backgroundColor = UIColor.redColor end ``` +### UIBarButtonItem + +`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. + +```ruby +BW::UIBarButtonItem.system(:save) do + # ... +end + +title = "Friends" +BW::UIBarButtonItem.styled(:plain, title) do + # ... +end + +image = UIImage.alloc.init +BW::UIBarButtonItem.styled(:bordered, image) do + # ... +end + +image = UIImage.alloc.init +landscape = UIImage.alloc.init +BW::UIBarButtonItem.styled(:bordered, image, landscape) do + # ... +end + +view = UIView.alloc.init +BW::UIBarButtonItem.custom(view) do + # ... +end +# NOTE: The block is attached to the view as a single tap gesture recognizer. +``` + +Alternatively, `BW::UIBarButtonItem` provides a flexible, builder-style syntax for dynamically instantiating `UIBarButtonItem` objects. + +```ruby +options = { :system => :save } +BW::UIBarButtonItem.build(options) do + # ... +end + +options = { :styled => :plain, :title => "Friends" } +BW::UIBarButtonItem.build(options) do + # ... +end + +options = { :styled => :bordered, :image => UIImage.alloc.init } +BW::UIBarButtonItem.build(options) do + # ... +end + +options = { + :styled => :bordered, + :image => UIImage.alloc.init, + :landscape => UIImage.alloc.init +} +BW::UIBarButtonItem.build(options) do + # ... +end + +options = { :custom => UIView.alloc.init } +BW::UIBarButtonItem.build(options) do + # ... +end +# NOTE: The block is attached to the view as a single tap gesture recognizer. +``` + +The `.styled` button types are: + +```ruby +:plain +:bordered +:done +``` + +And the `.system` button types are: + +```ruby +:done +:cancel +:edit +:save +:add +:flexible_space +:fixed_space +:compose +:reply +:action +:organize +:bookmarks +:search +:refresh +:stop +:camera +:trash +:play +:pause +:rewind +:fast_forward +:undo +:redo +:page_curl +``` + ## HTTP `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. @@ -478,11 +592,11 @@ state callbacks: ```ruby feed_parser = BW::RSSParser.new("http://feeds.feedburner.com/sdrbpodcast") feed_parser.delegate = self -feed.parse do |item| +feed_parser.parse do |item| p item.title end # Delegate method def when_parser_initializes @@ -656,18 +770,25 @@ 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 -=> #<#<Class:0x6dc1310>:0x6dc2ec0> +=> #<#<Class:0xab63f00>:0xab64430> > o.on(:november_5_1955) { puts "Ow!" } -=> [#<Proc:0x6dc6300>] -> o.on(:november_5_1955) { puts "Flux capacitor!" } -=> [#<Proc:0x6dc6300>, #<Proc:0x6dc1ba0>] +=> [#<Proc:0xad9bf00>] +> flux = proc{ puts "Flux capacitor!" } +=> #<Proc:0xab630f0> +> o.on(:november_5_1955, &flux) +=> [#<Proc:0xad9bf00>, #<Proc:0xab630f0>] > o.trigger(:november_5_1955) Ow! Flux capacitor! => [nil, nil] +> o.off(:november_5_1955, &flux) +=> #<Proc:0xab630f0> +> o.trigger(:november_5_1955) +Ow! +=> [nil] ``` # Suggestions? Do you have a suggestion for a specific wrapper? Feel free to open an