BubbleWrap

Cocoa wrappers and helpers for RubyMotion.

View the Project on GitHub rubymotion/BubbleWrap Read the RDocrdoc.info Get the Ruby Gemgem 'bubble-wrap' Join the discussionbubblewrap@googlegroups.com Using BubbleWrapA guide to getting started with BubbleWrap Hacking BubbleWrapA guide to working on BubbleWrap Gem HowtoBuilding RubyMotion gems with BW

Hacking on BubbleWrap

A library in two parts

RubyMotion forces a certain background-radiation of schizophrenia due to the fact that it's build tools run using the system ruby via Rake. BubbleWrap manipulates the build environment in order to make it possible to include itself (and other code) into the build process from outside the project hierarchy.

Part the first: lib/

This is where RubyGems goes looking for code when you call

require 'bubble-wrap'

When bubble-wrap is required it immediately requires bubble-wrap/loader which sets up the infrastructure needed to manipulate the Rakefile build process. Once that is done we can freely call

BubbleWrap.require 'motion/core/**/*.rb'

BubbleWrap.require (or simply BW.require) is used to include library code into the Rake build process used by RubyMotion. BW.require is similar to ruby's standard require method with two major changes:

If a block is passed to BW.require it is evaluated in the context of BW::Requirement and thus has access to all it's class methods. The most common use cases are setting file dependencies:

BW.require('motion/core/**/*.rb') do
  file('motion/core/device/screen.rb').depends_on 'motion/core/device.rb'
end

and specifying frameworks that need to be included at build time:

BW.require('motion/**/*.rb') do
  file('motion/address_book.rb').uses_framework 'Addressbook'
end

Part the second: motion/

Inside the motion directory you'll see the actual implementation code which is compiled into RubyMotion projects that are using BubbleWrap.

Your project here

If you think that your project would be of interest to the large number of RubyMotion users that use BubbleWrap in their daily development then feel free to fork the repository on GitHub and send us a pull request.

You should place your implementation files in a subdirectory of motion (eg motion/my_awesome_project), your tests in a subdirectory of spec (eg spec/my_awesome_project) and you can create a require file in lib/bubble-wrap for example lib/bubble-wrap/my_awesome_project.rb:

require 'bubble-wrap/loader'
BW.require 'motion/my_awesome_project.rb'

People will then be able to use it by adding:

require 'bubble-wrap/my_awesome_project'

to their project's Rakefile

Go forth and conquer!

The developers wish to thank you so much for taking the time to improve BubbleWrap and by extension the RubyMotion ecosystem. You're awesome!