alloy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alloy.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Junya Ogura, QNYP, LLC.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,158 @@
1
+ # alloy
2
+
3
+ CLI Toolbelt for Titanium Mobile development on Mac OS X.
4
+
5
+ ## Prerequisite
6
+
7
+ * Mac OS X 10.7
8
+ * Titanium Studio 2.0
9
+ * Ruby 1.9.3
10
+ * CoffeeScript
11
+
12
+ ## Usage
13
+
14
+ ### Setup
15
+
16
+ $ cd /path/to/titanium-workspace/HelloWorld
17
+ $ alloy init
18
+ create alloy.json
19
+
20
+ ### Compiling CoffeeScript into JavaScript
21
+
22
+ You should place `*.coffee` files under the directory named `app`.
23
+
24
+ $ mkdir app
25
+ $ echo "Ti.API.console 'Hello'" > app/hello.coffee
26
+
27
+ Then, run `coffee` task.
28
+
29
+ $ alloy coffee
30
+ Compiling CoffeeScript
31
+ Successfully compiled CoffeeScript
32
+
33
+ JavaScript files generated under the `Resources` directory.
34
+
35
+ $ cat Resources/hello.js
36
+ // Generated by CoffeeScript 1.3.1
37
+
38
+ Ti.API.console('Hello');
39
+
40
+ ### Cleaning up build directory
41
+
42
+ Run `clean` task to clean up intermediate files (`build/iphone/*` or `build/android/*`).
43
+
44
+ $ alloy clean iphone
45
+ $ alloy clean android
46
+
47
+ ### Building app and run in iPhone simulator
48
+
49
+ $ alloy build iphone
50
+
51
+ ### Building app and run in Android emulator
52
+
53
+ Before using alloy, you need to create and setup a [AVD (Android Virtual Devices)](http://developer.android.com/intl/en/guide/developing/devices/index.html) for rapid development process.
54
+
55
+ #### AVD setup
56
+
57
+ 1. Launch Android SDK Manager and install `SDK Platform` and `Google APIs` of `Android 2.2 (API 8)`
58
+
59
+ $ ANDROID_SDK_HOME/tools/android &
60
+
61
+ 2. Check what Android target availables
62
+
63
+ $ ANDROID_SDK_HOME/tools/android list targets
64
+ Available Android targets:
65
+ ----------
66
+ id: 1 or "android-15"
67
+ Name: Android 4.0.3
68
+ Type: Platform
69
+ API level: 15
70
+ Revision: 3
71
+ Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800
72
+ ABIs : armeabi-v7a, x86
73
+ ----------
74
+ id: 2 or "Google Inc.:Google APIs:15"
75
+ Name: Google APIs
76
+ Type: Add-On
77
+ Vendor: Google Inc.
78
+ Revision: 2
79
+ Description: Android + Google APIs
80
+ Based on Android 4.0.3 (API level 15)
81
+ Libraries:
82
+ * com.google.android.media.effects (effects.jar)
83
+ Collection of video effects
84
+ * com.android.future.usb.accessory (usb.jar)
85
+ API for USB Accessories
86
+ * com.google.android.maps (maps.jar)
87
+ API for Google Maps
88
+ Skins: WVGA854, WQVGA400, WSVGA, WXGA720, HVGA, WQVGA432, WVGA800 (default), QVGA, WXGA800
89
+ ABIs : armeabi-v7a
90
+
91
+ 3. Create a new AVD
92
+
93
+ $ ANDROID_SDK_HOME/tools/android create avd \
94
+ -n my_android-4.0.3 \
95
+ -t 1 \
96
+ --abi armeabi-v7a \
97
+ --skin WVGA800
98
+
99
+ `my_android-4.0.3` is AVD name, `1` is ID of Android target.
100
+
101
+ AVD created under `~/.android/avd`.
102
+
103
+ $ ls -la ~/.android/avd
104
+ total 8
105
+ drwxr-xr-x 4 juno staff 136 6 1 00:56 .
106
+ drwxr-xr-x 6 juno staff 204 6 1 00:51 ..
107
+ drwxr-xr-x 4 juno staff 136 6 1 00:56 my_android-4.0.3.avd
108
+ -rw-r--r-- 1 juno staff 69 6 1 00:56 my_android-4.0.3.ini
109
+
110
+ $ ANDROID_SDK_HOME/tools/android list avd
111
+ Available Android Virtual Devices:
112
+ Name: my_android-4.0.3
113
+ Path: /Users/juno/.android/avd/my_android-4.0.3.avd
114
+ Target: Android 4.0.3 (API level 15)
115
+ ABI: armeabi-v7a
116
+ Skin: WVGA800
117
+
118
+ Yay!
119
+
120
+ 4. Enable SD Card support to install application
121
+
122
+ $ echo "sdcard.size=256M" >> ~/.android/avd/my_android-4.0.3.avd/config.ini
123
+
124
+ #### Running Android emulator
125
+
126
+ 1. Start adb server
127
+
128
+ $ ANDROID_SDK_HOME/platform-tools/adb start-server
129
+
130
+ 2. Launch Android emulator
131
+
132
+ $ ANDROID_SDK_HOME/tools/emulator -avd my_android-4.0.3
133
+
134
+ After Android launch, emulator instance appears as a device.
135
+
136
+ $ ANDROID_SDK_HOME/platform-tools/adb devices
137
+ List of devices attached
138
+ emulator-5554 device
139
+
140
+ #### Build and install application to emulator
141
+
142
+ $ alloy build android
143
+
144
+ #### Shutting down Android emulator
145
+
146
+ 1. Exit Android emulator app
147
+
148
+ 2. Kill adb server
149
+
150
+ $ ANDROID_SDK_HOME/platform-tools/adb kill-server
151
+
152
+ ## Contributing
153
+
154
+ 1. Fork it
155
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
156
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
157
+ 4. Push to the branch (`git push origin my-new-feature`)
158
+ 5. Create new Pull Request
@@ -0,0 +1,44 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ #############################################################################
4
+ #
5
+ # Helper functions
6
+ #
7
+ #############################################################################
8
+
9
+ def name
10
+ @name ||= Dir['*.gemspec'].first.split('.').first
11
+ end
12
+
13
+ def version
14
+ line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
15
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
16
+ end
17
+
18
+ #############################################################################
19
+ #
20
+ # Standard tasks
21
+ #
22
+ #############################################################################
23
+
24
+ task :default => :spec
25
+
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new do |t|
28
+ t.rspec_opts = ['--color']
29
+ t.pattern = 'spec/**/*_spec.rb'
30
+ end
31
+
32
+ require 'rdoc/task'
33
+ RDoc::Task.new do |t|
34
+ t.rdoc_dir = 'rdoc'
35
+ t.title = "#{name} #{version}"
36
+ t.rdoc_files.include('README*')
37
+ t.rdoc_files.include('lib/**/*.rb')
38
+ t.markup = 'tomdoc'
39
+ end
40
+
41
+ desc 'Open an irb session preloaded with this library'
42
+ task :console do
43
+ sh "irb -rubygems -r ./lib/#{name}.rb"
44
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/alloy/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Junya Ogura"]
6
+ gem.email = ["junyaogura@gmail.com"]
7
+ gem.description = %q{CLI Toolbelt for Titanium Mobile development on Mac OS X.}
8
+ gem.summary = %q{CLI Toolbelt for Titanium Mobile development on Mac OS X.}
9
+ gem.homepage = "https://github.com/qnyp/alloy"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "alloy"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Alloy::VERSION
17
+
18
+ gem.add_development_dependency 'rake', '~> 0.9.0'
19
+ gem.add_development_dependency 'rdoc', '~> 3.0'
20
+ gem.add_development_dependency 'rspec', '~> 2.10.0'
21
+ gem.add_development_dependency 'simplecov', '~> 0.6.0'
22
+
23
+ gem.add_dependency 'colored', '~> 1.2'
24
+ gem.add_dependency 'json', '~> 1.6.6'
25
+ gem.add_dependency 'nokogiri', '~> 1.5.2'
26
+ gem.add_dependency 'thor', '~> 0.14.6'
27
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path("../../lib", __FILE__)
3
+ require 'alloy'
4
+
5
+ Alloy::CLI.start
@@ -0,0 +1,14 @@
1
+ module Alloy
2
+ autoload :CLI, 'alloy/cli'
3
+ autoload :Config, 'alloy/config'
4
+ autoload :VERSION, 'alloy/version'
5
+
6
+ module Chore
7
+ autoload :CoffeeScript, 'alloy/chore/coffee_script'
8
+ end
9
+
10
+ module Task
11
+ autoload :Build, 'alloy/task/build'
12
+ autoload :Clean, 'alloy/task/clean'
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ require 'colored'
2
+
3
+ module Alloy::Chore
4
+
5
+ class CoffeeScript
6
+ def self.run
7
+ puts "Compiling CoffeeScript".blue
8
+
9
+ failed = false
10
+ paths = `find app -name '*.coffee'`.split("\n")
11
+
12
+ paths.each do |path|
13
+ out_dir = path.gsub(/^app/, 'Resources').gsub(/\/[\w-]*\.coffee$/,"")
14
+ unless system "coffee -c -b -o #{out_dir} #{path}"
15
+ puts "Compilation failed: #{path}".red
16
+ failed = true
17
+ end
18
+ end
19
+
20
+ puts "Successfully compiled CoffeeScript".green unless failed
21
+ not failed
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'alloy'
2
+ require 'thor'
3
+
4
+ module Alloy
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+
8
+ Alloy::CLI.source_root(File.expand_path('../../templates', __FILE__))
9
+
10
+ desc 'build SUBCOMMAND', 'Build the app and run in simulator or emulator'
11
+ subcommand 'build', Task::Build
12
+
13
+ desc 'clean SUBCOMMAND', 'Clean up build directory'
14
+ subcommand 'clean', Task::Clean
15
+
16
+ desc 'coffee', 'Compile CoffeeScript into JavaScript'
17
+ def coffee
18
+ Chore::CoffeeScript.run
19
+ end
20
+
21
+ desc 'init', 'Generate alloy.json'
22
+ def init
23
+ template('alloy.json.erb', 'alloy.json')
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,196 @@
1
+ require 'json'
2
+ require 'nokogiri'
3
+
4
+ module Alloy
5
+
6
+ class Config
7
+ # Public: Creates a new config instance.
8
+ #
9
+ # Examples
10
+ #
11
+ # config = Alloy::Config.new('alloy.json')
12
+ #
13
+ # path - The String represents path to alloy.json
14
+ def initialize(path)
15
+ load_alloy_json(path)
16
+ load_tiapp_xml
17
+ end
18
+
19
+ # Public: Returns Application ID
20
+ #
21
+ # Examples
22
+ #
23
+ # app_id
24
+ # # => 'com.example.helloworld'
25
+ #
26
+ # Returns the Application ID String.
27
+ def app_id
28
+ @app_id
29
+ end
30
+
31
+ # Public: Returns Application Name
32
+ #
33
+ # Examples
34
+ #
35
+ # app_name
36
+ # # => 'HelloWorld'
37
+ #
38
+ # Returns the Application Name String.
39
+ def app_name
40
+ @app_name
41
+ end
42
+
43
+ # Public: Returns path to Titanium Mobile SDK installation.
44
+ #
45
+ # Examples
46
+ #
47
+ # titanium_sdk_path
48
+ # # => '/Library/Application Support/Titanium'
49
+ #
50
+ # Returns the path String.
51
+ def titanium_sdk_path
52
+ @json['titanium']['sdk_path']
53
+ end
54
+
55
+ # Public: Returns Titanium Mobile SDK version string.
56
+ #
57
+ # Examples
58
+ #
59
+ # titanium_sdk_version
60
+ # # => '1.8.2'
61
+ #
62
+ # Returns the version String.
63
+ def titanium_sdk_version
64
+ @titanium_sdk_version
65
+ end
66
+
67
+ # Public: Returns iPhone SDK version string.
68
+ #
69
+ # Examples
70
+ #
71
+ # iphone_sdk_version
72
+ # # => '5.0'
73
+ #
74
+ # Returns the version String.
75
+ def iphone_sdk_version
76
+ @json['iphone']['sdk_version']
77
+ end
78
+
79
+ # Public: Returns path string to Android SDK installation.
80
+ #
81
+ # Examples
82
+ #
83
+ # android_sdk_path
84
+ # # => ''
85
+ #
86
+ # Returns the path String.
87
+ def android_sdk_path
88
+ @json['android']['sdk_path']
89
+ end
90
+
91
+ # Public: Returns AVD ID string.
92
+ #
93
+ # Examples
94
+ #
95
+ # android_avd_id
96
+ # # => '1'
97
+ #
98
+ # Returns the AVD ID String.
99
+ def android_avd_id
100
+ @json['android']['avd_id']
101
+ end
102
+
103
+ # Public: Returns Titanium assets directory path string.
104
+ #
105
+ # Examples
106
+ #
107
+ # titanium_assets_path
108
+ # # => '/Library/Application Support/Titanium/mobilesdk/osx/2.0.2.GA'
109
+ #
110
+ # Returns the AVD ID String.
111
+ def titanium_assets_path
112
+ titanium_sdk_path + '/mobilesdk/osx/' + titanium_sdk_version
113
+ end
114
+
115
+ # Public: Returns Titanium iPhone assets directory path string.
116
+ #
117
+ # Examples
118
+ #
119
+ # titanium_iphone_path
120
+ # # => '/Library/Application Support/Titanium/mobilesdk/osx/2.0.2.GA/iphone'
121
+ #
122
+ # Returns the AVD ID String.
123
+ def titanium_iphone_path
124
+ titanium_assets_path + '/iphone'
125
+ end
126
+
127
+ # Public: Returns Titanium Android assets directory path string.
128
+ #
129
+ # Examples
130
+ #
131
+ # titanium_android_path
132
+ # # => '/Library/Application Support/Titanium/mobilesdk/osx/2.0.2.GA/android'
133
+ #
134
+ # Returns the AVD ID String.
135
+ def titanium_android_path
136
+ titanium_assets_path + '/android'
137
+ end
138
+
139
+ # Public: Returns Titanium iPhone builder.py path string.
140
+ #
141
+ # Examples
142
+ #
143
+ # titanium_iphone_builder
144
+ # # => '/Library/Application Support/Titanium/mobilesdk/osx/2.0.2.GA/iphone/builder.py'
145
+ #
146
+ # Returns the AVD ID String.
147
+ def titanium_iphone_builder
148
+ titanium_iphone_path + '/builder.py'
149
+ end
150
+
151
+ # Public: Returns Titanium Android builder.py path string.
152
+ #
153
+ # Examples
154
+ #
155
+ # titanium_android_builder
156
+ # # => '/Library/Application Support/Titanium/mobilesdk/osx/2.0.2.GA/android/builder.py'
157
+ #
158
+ # Returns the AVD ID String.
159
+ def titanium_android_builder
160
+ titanium_android_path + '/builder.py'
161
+ end
162
+
163
+ # Public: Returns project root directory path string.
164
+ #
165
+ # Examples
166
+ #
167
+ # project_root
168
+ # # => '/path/to/titanium-project-root'
169
+ #
170
+ # Returns the AVD ID String.
171
+ def project_root
172
+ @json['project_root']
173
+ end
174
+
175
+
176
+ private
177
+
178
+ def load_alloy_json(path)
179
+ @json = {}
180
+ open(path) do |file|
181
+ @json = JSON.parse(file.read)
182
+ end
183
+ end
184
+
185
+ def load_tiapp_xml(filename = 'tiapp.xml')
186
+ path = @json['project_root'] + '/' + filename
187
+ open(path) do |f|
188
+ doc = Nokogiri::XML(f)
189
+ @app_id = doc.xpath('ti:app/id').text
190
+ @app_name = doc.xpath('ti:app/name').text
191
+ @titanium_sdk_version = doc.xpath('ti:app/sdk-version').text
192
+ end
193
+ end
194
+ end
195
+
196
+ end
@@ -0,0 +1,63 @@
1
+ require 'alloy'
2
+ require 'colored'
3
+ require 'shellwords'
4
+ require 'thor'
5
+
6
+ module Alloy::Task
7
+ class Build < Thor
8
+ desc 'iphone', 'Build the iPhone app and run in simulator'
9
+ def iphone
10
+ Chore::build_and_run_iphone
11
+ end
12
+
13
+ desc 'android', 'Build the Android app and run in emulator'
14
+ def android
15
+ Chore::build_and_run_android
16
+ end
17
+ end
18
+
19
+ class Build::Chore
20
+ PERL_COLOR_FILTER = %Q{| perl -pe 's/^\\[DEBUG\\].*$/\\e[35m$&\\e[0m/g;s/^\\[INFO\\].*$/\\e[36m$&\\e[0m/g;s/^\\[WARN\\].*$/\\e[33m$&\\e[0m/g;s/^\\[ERROR\\].*$/\\e[31m$&\\e[0m/g;'}
21
+
22
+ def self.build_and_run_iphone
23
+ config = Alloy::Config.new('./alloy.json')
24
+ puts "Building with Titanium... (DEVICE_TYPE: iphone)".blue
25
+ bash_arg = [config.titanium_iphone_builder,
26
+ 'run',
27
+ config.project_root + '/',
28
+ config.iphone_sdk_version,
29
+ config.app_id,
30
+ config.app_name,
31
+ 'iphone'].map{|i|Shellwords.escape(i)}.join(' ')
32
+ cmd = %Q{bash -c "#{bash_arg}" #{PERL_COLOR_FILTER}}
33
+ begin
34
+ system cmd
35
+ rescue => e
36
+ puts e.backtrace.join("\n")
37
+ puts e.message.red
38
+ system %Q{killall "iPhone Simulator"}
39
+ end
40
+ end
41
+
42
+ def self.build_and_run_android
43
+ config = Alloy::Config.new('./alloy.json')
44
+ puts "Building with Titanium... (DEVICE_TYPE: android)".blue
45
+ command = 'simulator'
46
+ project_name = config.app_name
47
+ sdk_dir = config.android_sdk_path
48
+ project_dir = config.project_root + '/'
49
+ app_id = config.app_id
50
+ avd_id = config.android_avd_id
51
+ bash_arg = [config.titanium_android_builder,
52
+ command,
53
+ project_name,
54
+ sdk_dir,
55
+ project_dir,
56
+ app_id,
57
+ avd_id].map{|i|Shellwords.escape(i)}.join(' ')
58
+ cmd = %Q{bash -c "#{bash_arg}" #{PERL_COLOR_FILTER}}
59
+ puts cmd
60
+ system cmd
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,36 @@
1
+ require 'colored'
2
+ require 'fileutils'
3
+ require 'thor'
4
+
5
+ module Alloy::Task
6
+ class Clean < Thor
7
+ desc 'iphone', 'Clean up iPhone build directory'
8
+ def iphone
9
+ Chore::clean_up_iphone
10
+ end
11
+
12
+ desc 'android', 'Clean up Android build directory'
13
+ def android
14
+ Chore::clean_up_android
15
+ end
16
+ end
17
+
18
+ class Clean::Chore
19
+ def self.clean_up_iphone
20
+ clean_up('build/iphone')
21
+ end
22
+
23
+ def self.clean_up_android
24
+ clean_up('build/android')
25
+ end
26
+
27
+ def self.clean_up(path)
28
+ if Dir.exist?(path)
29
+ FileUtils.rm_r Dir.glob("#{path}/*"), :force => true
30
+ puts "Cleaned #{path}".blue
31
+ else
32
+ puts "Directory '#{path}' not found".red
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Alloy
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,24 @@
1
+ <%
2
+ project_root = Dir.pwd
3
+
4
+ candidates = ['/Library/Application Support/Titanium',
5
+ '~/Library/Application Support/Titanium']
6
+ titanium_sdk_path = candidates.find { |i| Dir.exist?(File.expand_path(i)) }
7
+
8
+ candidates = [ENV['ANDROID_SDK'],
9
+ ENV['ANDROID_SDK_HOME']]
10
+ android_sdk_path = candidates.find { |i| i != nil }
11
+ -%>
12
+ {
13
+ "project_root": "<%= project_root %>",
14
+ "titanium": {
15
+ "sdk_path": "<%= titanium_sdk_path %>"
16
+ },
17
+ "iphone": {
18
+ "sdk_version": "5.1"
19
+ },
20
+ "android": {
21
+ "sdk_path": "<%= android_sdk_path %>",
22
+ "avd_id": "1"
23
+ }
24
+ }
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Alloy::Config do
4
+ let(:tiapp_xml_path) {
5
+ File.join(File.dirname(__FILE__), '..', 'fixtures', 'tiapp.xml')
6
+ }
7
+ let(:json_path) {
8
+ File.join(File.dirname(__FILE__), '..', 'fixtures', 'config.json')
9
+ }
10
+
11
+ describe ".load(path)" do
12
+ let(:config) { nil }
13
+
14
+ before { config = Alloy::Config.load(json_path) }
15
+ end
16
+
17
+ context "Default values" do
18
+ let(:config) { Alloy::Config.new(tiapp_xml_path) }
19
+
20
+ before do
21
+ ENV.stub(:[]).with('ANDROID_SDK') { '' }
22
+ end
23
+
24
+ describe "#titanium_sdk_path" do
25
+ subject { config.titanium_sdk_path }
26
+ xit { should eq('/Library/Application\\ Support/Titanium') }
27
+ end
28
+
29
+ describe "#titanium_sdk_version" do
30
+ subject { config.titanium_sdk_version }
31
+ xit { should eq('1.8.2') }
32
+ end
33
+
34
+ describe "#iphone_sdk_version" do
35
+ subject { config.iphone_sdk_version }
36
+ xit { should eq('5.0') }
37
+ end
38
+
39
+ describe "#android_sdk_id" do
40
+ subject { config.android_sdk_id }
41
+ xit { should eq('6') }
42
+ end
43
+
44
+ describe "#android_sdk_path" do
45
+ subject { config.android_sdk_path }
46
+ xit { should eq('') }
47
+ end
48
+ end
49
+
50
+ context "Environment variable ANDROID_SDK exists" do
51
+ let(:config) { Alloy::Config.new(tiapp_xml_path) }
52
+
53
+ before do
54
+ ENV.stub(:[]).with('ANDROID_SDK') { '/path/to/android-sdk' }
55
+ end
56
+
57
+ describe "#android_sdk_path" do
58
+ subject { config.android_sdk_path }
59
+ xit { should eq('/path/to/android-sdk') }
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,12 @@
1
+ {
2
+ "titanium": {
3
+ "sdk_version": "1.8.1",
4
+ },
5
+ "iphone": {
6
+ "sdk_version": "4.3"
7
+ },
8
+ "android": {
9
+ "sdk_dir": "/Users/juno/apps/android-sdk",
10
+ "sdk_id": "6"
11
+ }
12
+ }
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ti:app xmlns:ti="http://ti.appcelerator.org">
3
+ <deployment-targets>
4
+ <target device="mobileweb">false</target>
5
+ <target device="iphone">true</target>
6
+ <target device="ipad">false</target>
7
+ <target device="android">false</target>
8
+ <target device="blackberry">false</target>
9
+ </deployment-targets>
10
+ <sdk-version>2.0.1.GA2</sdk-version>
11
+ <id>com.example.hello</id>
12
+ <name>hello</name>
13
+ <version>1.0</version>
14
+ <publisher>foo</publisher>
15
+ <url>http://example.com/</url>
16
+ <description>not specified</description>
17
+ <copyright>2012 by foo</copyright>
18
+ <icon>appicon.png</icon>
19
+ <persistent-wifi>false</persistent-wifi>
20
+ <prerendered-icon>false</prerendered-icon>
21
+ <statusbar-style>default</statusbar-style>
22
+ <statusbar-hidden>false</statusbar-hidden>
23
+ <fullscreen>false</fullscreen>
24
+ <navbar-hidden>false</navbar-hidden>
25
+ <analytics>true</analytics>
26
+ <guid>249e2249-9394-4f99-ae0d-c33b6a83794f</guid>
27
+ <property name="ti.ui.defaultunit">system</property>
28
+ <iphone>
29
+ <orientations device="iphone">
30
+ <orientation>Ti.UI.PORTRAIT</orientation>
31
+ </orientations>
32
+ <orientations device="ipad">
33
+ <orientation>Ti.UI.PORTRAIT</orientation>
34
+ <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
35
+ <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
36
+ <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
37
+ </orientations>
38
+ </iphone>
39
+ <android xmlns:android="http://schemas.android.com/apk/res/android"/>
40
+ <mobileweb>
41
+ <precache/>
42
+ <splash>
43
+ <enabled>true</enabled>
44
+ <inline-css-images>true</inline-css-images>
45
+ </splash>
46
+ <theme>default</theme>
47
+ </mobileweb>
48
+ <modules/>
49
+ </ti:app>
@@ -0,0 +1,15 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter '.bundle/'
4
+ add_filter 'spec/'
5
+ end
6
+
7
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+
9
+ require 'rspec'
10
+
11
+ require 'alloy'
12
+
13
+ RSpec.configure do |config|
14
+ config.mock_with :rspec
15
+ end
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alloy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Junya Ogura
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.10.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.10.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: simplecov
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.6.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.6.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: colored
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.2'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.2'
94
+ - !ruby/object:Gem::Dependency
95
+ name: json
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.6.6
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.6.6
110
+ - !ruby/object:Gem::Dependency
111
+ name: nokogiri
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.5.2
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.5.2
126
+ - !ruby/object:Gem::Dependency
127
+ name: thor
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.14.6
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.14.6
142
+ description: CLI Toolbelt for Titanium Mobile development on Mac OS X.
143
+ email:
144
+ - junyaogura@gmail.com
145
+ executables:
146
+ - alloy
147
+ extensions: []
148
+ extra_rdoc_files: []
149
+ files:
150
+ - .gitignore
151
+ - Gemfile
152
+ - LICENSE
153
+ - README.md
154
+ - Rakefile
155
+ - alloy.gemspec
156
+ - bin/alloy
157
+ - lib/alloy.rb
158
+ - lib/alloy/chore/coffee_script.rb
159
+ - lib/alloy/cli.rb
160
+ - lib/alloy/config.rb
161
+ - lib/alloy/task/build.rb
162
+ - lib/alloy/task/clean.rb
163
+ - lib/alloy/version.rb
164
+ - lib/templates/alloy.json.erb
165
+ - spec/alloy/config_spec.rb
166
+ - spec/fixtures/config.json
167
+ - spec/fixtures/tiapp.xml
168
+ - spec/spec_helper.rb
169
+ homepage: https://github.com/qnyp/alloy
170
+ licenses: []
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ none: false
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ segments:
182
+ - 0
183
+ hash: 1436312249168359088
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ segments:
191
+ - 0
192
+ hash: 1436312249168359088
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 1.8.23
196
+ signing_key:
197
+ specification_version: 3
198
+ summary: CLI Toolbelt for Titanium Mobile development on Mac OS X.
199
+ test_files:
200
+ - spec/alloy/config_spec.rb
201
+ - spec/fixtures/config.json
202
+ - spec/fixtures/tiapp.xml
203
+ - spec/spec_helper.rb