Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

Add support for #github in javascript. Fixes #29 #48

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ rdoc
spec/reports
tmp
bundler_bin
/.bundle/install.log
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-1.9.3-p392
2.0.0
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: ruby
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.0
script: 'bundle exec rspec spec'
12 changes: 12 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 2.0.0 2013-12-30 Brad Grzesiak <[email protected]>

* Use `bwoken` at the command line instead of `rake`.
* Allow spaces in the pwd of your project.
* Allow much more configuration of the builder and test runner.
* Deprecate Ruby 1.x. You must now use Ruby 2.x. (2.0.0 comes standard with Mavericks; other versions installable via RVM or rbenv)
* Deprecate invocation via `rake`.

Version 1.3.0

Version 1.2.0

Version 1.1.0 2012-7-5 Brad Grzesiak <[email protected]> and Jaymes Waters <[email protected]>

* Add device support.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bwoken (2.0.0.beta.2)
bwoken (2.0.0)
coffee-script-source
colorful
execjs
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ $ bwoken test -h
--focus Specify particular tests to run
--clobber Remove any generated file
--skip-build Do not build the iOS binary
--configuration The build configruation to use (e.g., --configuration=Release)
--sdk-version The SDK version to use (e.g., --sdk-version=6.1)
--verbose Be verbose
-h, --help Display this help message.
</code></pre>
Expand Down Expand Up @@ -159,9 +161,11 @@ Install rvm via <a href="https://rvm.io/rvm/install/">the instructions</a>. Ensu

### Install

**NOTE:** Do **NOT** use `sudo` to install or run bwoken. It will almost definitely fail you.

In the terminal, inside the directory of your project (e.g., you should see a <code>ProjectName.xcodeproj</code> file), create <code>.ruby-version</code> and <code>.ruby-gemset</code> files and trigger their use:

<pre><code>$ echo '2.0.0' &gt; .ruby-version
<pre><code>$ echo '2.1.0' &gt; .ruby-version
$ echo 'my_project' &gt; .ruby-gemset
$ cd .
</code></pre>
Expand All @@ -174,7 +178,7 @@ $ bundle init

This will create a <code>Gemfile</code>. Add bwoken to it and bundle:

<pre><code>$ echo "gem 'bwoken', '2.0.0.beta.1'" &gt;&gt; Gemfile
<pre><code>$ echo "gem 'bwoken', '2.0.0.beta.3'" &gt;&gt; Gemfile
$ bundle
</code></pre>

Expand All @@ -187,7 +191,7 @@ Now, you can start <a href="#usage">using it!</a>

#### The Dirty Little Installation Method

Technically, you can skip this entire Installation section and just run `sudo gem install bwoken && bwoken init`. This is listed here for completeness, but you really shouldn't install gems this way.
Technically, you can skip this entire Installation section and just run `sudo gem install bwoken && bwoken init`. This is listed here for completeness, but you really shouldn't install gems this way. This installation method will almost certainly not work with versions of OS X prior to Mavericks.

## Contributors

Expand Down
4 changes: 2 additions & 2 deletions lib/bwoken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def workspace_or_project
def workspace_or_project_flag
ws = xcworkspace
if ws && File.exists?(ws)
"-workspace #{ws}"
"-workspace \"#{ws}\""
else
"-project #{xcodeproj}"
"-project \"#{xcodeproj}\""
end
end

Expand Down
21 changes: 6 additions & 15 deletions lib/bwoken/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def app_dir simulator
attr_accessor :scheme
attr_accessor :simulator
attr_accessor :configuration
attr_accessor :sdk_version
attr_accessor :verbose

def initialize
Expand All @@ -50,7 +51,7 @@ def sdk

def env_variables
{
'BWOKEN_CONFIGURATION_BUILD_DIR' => self.class.configuration_build_dir(simulator)
'BWOKEN_CONFIGURATION_BUILD_DIR' => %Q|"#{self.class.configuration_build_dir(simulator)}"|
}
end

Expand All @@ -59,24 +60,24 @@ def variables_for_cli
end

def scheme_string
Bwoken.xcworkspace ? "-scheme #{scheme}" : ''
Bwoken.xcworkspace ? %Q|-scheme "#{scheme}"| : ''
end

def cmd
"xcodebuild \
#{Bwoken.workspace_or_project_flag} \
#{scheme_string} \
-configuration #{configuration} \
-sdk #{sdk} \
-xcconfig #{self.class.xcconfig} \
-sdk #{sdk}#{sdk_version} \
-xcconfig \"#{self.class.xcconfig}\" \
#{variables_for_cli} \
clean build"
end

def compile
formatter.before_build_start

succeeded, out_string, err_string = RUBY_VERSION == '1.8.7' ? compile_18 : compile_19_plus
succeeded, out_string, err_string = compile_19_plus

if succeeded
formatter.build_successful out_string
Expand All @@ -86,16 +87,6 @@ def compile
end
end

def compile_18
out_string, err_string = '', ''
a, b, c = Open3.popen3(cmd) do |stdin, stdout, stderr|
out_string = formatter.format_build stdout
err_string = stderr.read
end

[a.to_s !~ /BUILD FAILED/, out_string, err_string]
end

def compile_19_plus
ret = nil
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
Expand Down
3 changes: 2 additions & 1 deletion lib/bwoken/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
on :focus=, 'Specify particular tests to run', :as => Array, :default => []
on :clobber, 'Remove any generated file'
on :'skip-build', 'Do not build the iOS binary'
on :verbose, 'Be verbose'
on :configuration=, 'The build configruation to use (e.g., --configuration=Release)', :default => 'Debug'
on :'sdk-version=', 'The SDK version to use (e.g., --sdk-version=6.1)'
on :verbose, 'Be verbose'

run { ran_command = 'test' }
end
Expand Down
8 changes: 5 additions & 3 deletions lib/bwoken/cli/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

require 'bwoken'
require 'bwoken/build'
require 'bwoken/coffeescript'
require 'bwoken/device'
#TODO: make formatters dynamically loadable during runtime
require 'bwoken/formatter'
require 'bwoken/formatters/passthru_formatter'
require 'bwoken/formatters/colorful_formatter'
require 'bwoken/input'
require 'bwoken/script_runner'

module Bwoken
Expand Down Expand Up @@ -50,6 +50,7 @@ def self.help_banner
# :integration-path - the base directory for all the integration files
# :product-name - the name of the generated .app file if it is different from the name of the project/workspace
# :configuration - typically "Debug" or "Release"
# :sdk-version - the version of the sdk to use when building
def initialize opts
opts = opts.to_hash if opts.is_a?(Slop)
self.options = opts.to_hash.tap do |o|
Expand Down Expand Up @@ -78,6 +79,7 @@ def compile
b.scheme = options[:scheme] if options[:scheme]
b.simulator = options[:simulator]
b.configuration = options[:configuration]
b.sdk_version = options[:'sdk-version']
end.compile
end

Expand All @@ -91,13 +93,13 @@ def transpile
compiled_coffee.zip(coffeescripts).each do |target, source|
containing_dir = target.pathmap('%d')
ensure_directory containing_dir
Bwoken::Coffeescript.compile source, target
Bwoken::Input.process source, target
end

copied_javascripts.zip(javascripts).each do |target, source|
containing_dir = target.pathmap('%d')
ensure_directory containing_dir
FileUtils.cp source, target
Bwoken::Input.process source, target
end
end

Expand Down
28 changes: 18 additions & 10 deletions lib/bwoken/coffeescript.rb → lib/bwoken/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
require 'json'
require 'execjs'

require File.expand_path('../coffeescript/import_string', __FILE__)
require File.expand_path('../coffeescript/github_import_string', __FILE__)
require File.expand_path('../input/import_string', __FILE__)
require File.expand_path('../input/github_import_string', __FILE__)

module Bwoken
class Coffeescript
class Input
class << self

def coffee_script? source
source.downcase.end_with?('.coffee')
end

def coffee_script_source
return @coffeescript if @coffeescript

Expand All @@ -24,21 +28,25 @@ def context
@context ||= ExecJS.compile(coffee_script_source)
end

def precompile coffeescript
coffeescript.lines.partition {|line| line =~ /^#(?:github|import) .*$/}
def preprocess script
script.lines.partition {|line| line =~ /^#(?:github|import) .*$/}
end

def compile source, target
githubs_and_imports, sans_imports = precompile(IO.read source)
def process source, target
githubs_and_imports, sans_imports = preprocess(IO.read source)

javascript = coffeescript_to_javascript sans_imports.join
javascript = compile_to_javascript(source, sans_imports.join)
import_strings = githubs_to_imports(githubs_and_imports)

write import_strings, javascript, :to => target
end

def coffeescript_to_javascript coffee
self.context.call 'CoffeeScript.compile', coffee, :bare => true
def compile_to_javascript source, script
if coffee_script? source
self.context.call 'CoffeeScript.compile', script, :bare => true
else
script
end
end

def githubs_to_imports strings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require File.expand_path('../import_string', __FILE__)

module Bwoken
class Coffeescript
class Input
class GithubImportString < ImportString
attr_reader :repo_name, :file_path

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Bwoken
class Coffeescript
class Input
class ImportString

def initialize string
Expand Down
2 changes: 1 addition & 1 deletion lib/bwoken/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bwoken
VERSION = "2.0.0.beta.2" unless defined?(::Bwoken::VERSION)
VERSION = "2.0.0" unless defined?(::Bwoken::VERSION)
end
5 changes: 3 additions & 2 deletions spec/lib/bwoken/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
scheme_regex = scheme.gsub(/ /, '\s+')
configuration = stub_out(subject, :configuration, :baz)
sdk = stub_out(subject, :sdk, :qux)
sdk_version = stub_out(subject, :sdk_version, 123)
xcconfig = stub_out(subject.class, :xcconfig, :quz)
variables_for_cli = stub_out(subject, :variables_for_cli, :quux)

Expand All @@ -38,8 +39,8 @@
#{workspace_regex}\s+
#{scheme_regex}\s+
-configuration\s+#{configuration}\s+
-sdk\s+#{sdk}\s+
-xcconfig\s+#{xcconfig}\s+
-sdk\s+#{sdk}#{sdk_version}\s+
-xcconfig\s+"#{xcconfig}"\s+
#{variables_for_cli}\s+
clean\s+build
/x
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'bwoken/coffeescript/github_import_string'
require 'bwoken/input/github_import_string'

describe Bwoken::Coffeescript::GithubImportString do
describe Bwoken::Input::GithubImportString do
let(:string) { '#github alexvollmer/tuneup_js/tuneup.js' }
subject { Bwoken::Coffeescript::GithubImportString.new(string) }
subject { Bwoken::Input::GithubImportString.new(string) }

describe '#parse' do
it 'ensures the github repo is pulled' do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'bwoken/coffeescript/import_string'
require 'bwoken/input/import_string'

describe Bwoken::Coffeescript::ImportString do
describe Bwoken::Input::ImportString do
let(:string) { '#import foo.js' }
subject { Bwoken::Coffeescript::ImportString.new(string) }
subject { Bwoken::Input::ImportString.new(string) }

describe '#parse' do
it 'does not affect @string' do
Expand Down
Loading