Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

186 lines (150 sloc) 9.462 kB
<!doctype html>
<html>
<head>
<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="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30927742-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="wrapper">
<header>
<h1>BubbleWrap</h1>
<p>
Cocoa wrappers and helpers for <a href="http://www.rubymotion.com/">RubyMotion</a>.
</p>
<p class="view">
<a href="https://github.com/rubymotion/BubbleWrap">View the Project on GitHub <small>mattetti/BubbleWrap</small></a>
<a href="http://rdoc.info/github/rubymotion/BubbleWrap/master/frames">Read the RDoc<small>rdoc.info</small></a>
<a href="http://rubygems.org/gems/bubble-wrap">Get the Ruby Gem<small>gem 'bubble-wrap'</small></a>
<a href="https://groups.google.com/d/forum/bubblewrap">Join the discussion<small>bubblewrap@googlegroups.com</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>
</p>
</header>
<section>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<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>
</h3>
<p>This is where <a href="http://rubygems.org">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>
</pre>
</div>
<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>
</pre>
</div>
<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>
<ul>
<li>it can take a file pattern as used by <a href="http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob"><code>Dir.glob</code></a>.</li>
<li>it can be passed a block to manipulate dependencies.</li>
</ul>
<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>
</pre>
</div>
<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>
</pre>
</div>
<h3>Part the second: <code>motion/</code>
</h3>
<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>
<ul>
<li>
<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>
<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>
<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>
</ul>
<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="https://github.com/mattetti/BubbleWrap">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>
</pre>
</div>
<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>
</pre>
</div>
<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>
</body></html>
</section>
<footer>
<p>This project is maintained by:</p>
<ul>
<li><a href="https://github.com/mattetti"><img src="https://secure.gravatar.com/avatar/c69521d6e22fc0bbd69337ec8b1698df?s=24&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-24.png">Matt Aimonetti</a><a href="http://twitter.com/merbist"><small>@merbist</small></a></li>
<li><a href="https://github.com/siuying"><img src="https://secure.gravatar.com/avatar/ecdf9a83234e21743d77b75fd308b929?s=24&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-24.png">Francis Chong</a><a href="http://twitter.com/siuying"><small>@siuying</small></a></li>
<li><a href="https://github.com/mneorr"><img src="https://secure.gravatar.com/avatar/9ee164729035736549e4ae6e6e2d7cfc?s=24&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-24.png">Marin Usalj</a><a href="http://twitter.com/mneorr"><small>@mneorr</small></a></li>
<li><a href="https://github.com/jamesotron"><img src="https://secure.gravatar.com/avatar/d468b182b11cdee834dd1f9777645b79?s=24&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-24.png">James Harton</a><a href="http://twitter.com/jamesotron"><small>@jamesotron</small></a></li>
<li><a href="https://github.com/janweinkauff"><img src="https://secure.gravatar.com/avatar/89a1b3da3c51c9028598e4c703c6acbf?s=24&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-24.png">Jan Weinkauff</a><a href="http://twitter.com/janweinkauff"><small>@janweinkauff</small></a></li>
</ul>
</footer>
</div>
<script src="javascripts/scale.fix.js"></script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.