Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
186 lines (150 sloc) 9.24 KB
<!doctype html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>BubbleWrap - A Cocoa wrapper by Matt Aimonetti</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30927742-1']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
<div class="wrapper">
Cocoa wrappers and helpers for <a href="">RubyMotion</a>.
<p class="view">
<a href="">View the Project on GitHub <small>mattetti/BubbleWrap</small></a>
<a href="">Read the RDoc<small></small></a>
<a href="">Get the Ruby Gem<small>gem 'bubble-wrap'</small></a>
<a href="">Join the discussion<small></small></a>
<a href="getting_started.html">Using BubbleWrap<small>A guide to getting started with BubbleWrap</small></a>
<a href="hacking.html">Hacking BubbleWrap<small>A guide to working on BubbleWrap</small></a>
<a href="gem.html">Gem Howto<small>Building RubyMotion gems with BW</small></a>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">
<h1>Hacking on BubbleWrap</h1>
<h2>A library in two parts</h2>
<p>RubyMotion forces a certain background-radiation of schitzophrenia
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 outsite the project heirarchy.</p>
<h3>Part the first: <code>lib/</code>
<p>This is where <a href="">RubyGems</a> goes looking for
code when you call</p>
<div class="highlight">
<pre><span class="nb">require</span> <span class="s1">'bubble-wrap'</span>
<p>When <code>bubble-wrap</code> is required it immediately requires <code>bubble-wrap/loader</code> which sets up the infrastructure needed to manipulate the <code>Rakefile</code> build process. Once that is done we can freely call</p>
<div class="highlight">
<pre><span class="no">BubbleWrap</span><span class="o">.</span><span class="n">require</span> <span class="s1">'motion/core**/*.rb'</span>
<p><code>BubbleWrap.require</code> (or simply <code>BW.require</code>) is used to include
library code into the Rake build process used by RubyMotion.
<code>BW.require</code> is similar to ruby's standard <code>require</code> method with
two major changes:</p>
<li>it can take a file pattern as used by <a href=""><code>Dir.glob</code></a>.</li>
<li>it can be passed a block to manipulate dependencies.</li>
<p>If a block is passed to <code>BW.require</code> it is evaluated in the context
of <code>BW::Requirement</code> and thus has access to all it's class methods.
The most common use cases are setting file dependencies:</p>
<div class="highlight">
<pre><span class="no">BW</span><span class="o">.</span><span class="n">require</span><span class="p">(</span><span class="s1">'motion/core**/*.rb'</span><span class="p">)</span> <span class="k">do</span>
<span class="n">file</span><span class="p">(</span><span class="s1">'motion/core/device/screen.rb'</span><span class="p">)</span><span class="o">.</span><span class="n">depends_on</span> <span class="s1">'motion/core/device.rb'</span>
<span class="k">end</span>
<p>and specifying frameworks that need to be included at build time:</p>
<div class="highlight">
<pre><span class="no">BW</span><span class="o">.</span><span class="n">require</span><span class="p">(</span><span class="s1">'motion/**/*.rb'</span><span class="p">)</span> <span class="k">do</span>
<span class="n">file</span><span class="p">(</span><span class="s1">'motion/address_book.rb'</span><span class="p">)</span><span class="o">.</span><span class="n">uses_framework</span> <span class="s1">'Addressbook'</span>
<span class="k">end</span>
<h3>Part the second: <code>motion/</code>
<p>Inside the <code>motion</code> directory you'll see the actual implementation code
which is compiled into RubyMotion projects that are using BubbleWrap.</p>
<code>motion/core</code> contains "core" extension, things that the developers
reasonably think should be included in every BubbleWrap using project.
Careful consideration should be taken when making changes to the
contents and test coverage (in <code>spec/core</code>) must be updated to match.
This can be included in your project by requiring <code>bubble-wrap</code> or
<code>bubble-wrap/core</code> in your project <code>Rakefile</code>.</li>
<code>motion/http</code> contains the "http" extension. This can be included
by requiring <code>bubble-wrap/http</code> in your project <code>Rakefile</code>.</li>
<code>motion/test_suite_delegate</code> contains a simple <code>AppDelegate</code> which
can be used to enable the <code>rake spec</code> to run when developing a
BubbleWrap gem. Using <code>require 'bubble-wrap/test'</code> will include
it in the build process and also configure the app delegate to point
to <code>TestSuiteDelegate</code>. See the <a href="gem.html">BubbleWrap gem guide</a> for
more information.</li>
<h4>Your project here</h4>
<p>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 <a href="">the repository on GitHub</a>
and send us a pull request.</p>
<p>You should place your implemenation files in a subdirectory of <code>motion</code>
(eg <code>motion/my_awesome_project</code>), your tests in a subdirectory of <code>spec</code>
(eg <code>spec/my_awesome_project</code>) and you can create a require file in
<code>lib/bubble-wrap</code> for example <code>lib/bubble-wrap/my_awesome_project.rb</code>:</p>
<div class="highlight">
<pre><span class="nb">require</span> <span class="s1">'bubble-wrap/loader'</span>
<span class="no">BW</span><span class="o">.</span><span class="n">require</span> <span class="s1">'motion/my_awesome_project.rb'</span>
<p>People will then be able to use it by adding:</p>
<div class="highlight">
<pre><span class="nb">require</span> <span class="s1">'bubble-wrap/my_awesome_project'</span>
<p>to their project's <code>Rakefile</code></p>
<h2>Go forth and conquer!</h2>
<p>The developers wish to thank you so much for taking the time
to improve BubbleWrap and by extension the RubyMotion
ecosystem. You're awesome!</p>
<p>This project is maintained by:</p>
<li><a href=""><img src="">Matt Aimonetti</a><a href=""><small>@merbist</small></a></li>
<li><a href=""><img src="">Francis Chong</a><a href=""><small>@siuying</small></a></li>
<li><a href=""><img src="">Marin Usalj</a><a href=""><small>@mneorr</small></a></li>
<li><a href=""><img src="">James Harton</a><a href=""><small>@jamesotron</small></a></li>
<li><a href=""><img src="">Jan Weinkauff</a><a href=""><small>@janweinkauff</small></a></li>
<script src="javascripts/scale.fix.js"></script>
Jump to Line
Something went wrong with that request. Please try again.