titanium_cli 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -22,10 +22,14 @@ command line.
22
22
  Run iPhone project:
23
23
  titanium run --platform=iphone
24
24
 
25
- Run iPhone project:
25
+ Run Android project:
26
26
  titanium run --platform=android
27
27
 
28
28
 
29
+ ## Installation
30
+
31
+ gem install titanium_cli
32
+
29
33
 
30
34
  ## TODO
31
35
 
data/bin/titanium CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require 'titanium_cli/base'
4
+ require 'titanium_cli'
5
5
  rescue LoadError
6
6
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '/../lib'))
7
7
  begin
8
- require 'titanium_cli/base'
8
+ require 'titanium_cli'
9
9
  rescue LoadError
10
- warn "Can't find titanium_cli/base"
10
+ warn "Can't find titanium_cli"
11
11
  exit -1
12
12
  end
13
13
  end
14
14
 
15
- TitaniumCLI::Base.run(ARGV)
15
+ TitaniumCLI.run(ARGV)
data/lib/titanium_cli.rb CHANGED
@@ -1,4 +1,104 @@
1
1
  module TitaniumCLI
2
- autoload :Version, "titanium_cli/version"
3
- autoload :Base, "titanium_cli/base"
2
+
3
+ VERSION = Version = '0.0.2'
4
+
5
+ extend self
6
+
7
+ attr_accessor :log, :sdk_root, :sdk_version
8
+
9
+ # Copy Titanium logs to this file
10
+ def log
11
+ @log ||= ENV['LOG'] || 'log/development.log'
12
+ end
13
+
14
+ # Titanium SDK version
15
+ def sdk_version
16
+ @sdk_version ||= ENV['SDK_VERSION'] || '1.4.2'
17
+ end
18
+
19
+ # Titanium SDK root
20
+ def sdk_root
21
+ return @sdk_root if @sdk_root
22
+ case RUBY_PLATFORM
23
+ when /darwin/
24
+ system_root = "/Library/Application Support/Titanium/mobilesdk/osx/#{sdk_version}"
25
+ local_root = "#{ENV['HOME']}#{system_root}"
26
+
27
+ if File.exists?(local_root)
28
+ @sdk_root = local_root
29
+ elsif File.exists?(system_root)
30
+ @sdk_root = system_root
31
+ end
32
+ end
33
+
34
+ unless @sdk_root
35
+ raise "Can't find Titanium SDK root"
36
+ end
37
+ @sdk_root
38
+ end
39
+
40
+ # Run titanium.py command
41
+ def run(argv)
42
+ if action = argv.shift
43
+ case action.to_sym
44
+ when :create
45
+ create_project(argv)
46
+ when :run
47
+ run_project(argv)
48
+ else
49
+ raise "Invalid action #{action}"
50
+ end
51
+ return
52
+ end
53
+ puts usage.gsub(/^ /, '')
54
+ end
55
+
56
+ # Print usage for this script
57
+ def usage; <<-USAGE
58
+ Creating projects:
59
+ Create iPhone project:
60
+ titanium create --platform=iphone --name=FooMobile --id=com.foo.mobile
61
+
62
+ Create Android project
63
+ titanium create --platform=android --name=FooMobile \\
64
+ --id=com.foo.mobile --android=/opt/android-sdk
65
+
66
+ Create iPhone and Android project
67
+ titanium create --platform=iphone,android --name=FooMobile \\
68
+ --id=com.foo.mobile --android=/opt/android-sdk
69
+
70
+ Running projects:
71
+ Run iPhone project:
72
+ titanium run --platform=iphone
73
+
74
+ Run iPhone project:
75
+ titanium run --platform=android
76
+
77
+ USAGE
78
+ end
79
+
80
+ # Create project
81
+ # (directory optional)
82
+ #
83
+ # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py create --platform=iphone --name=FooBar --id=com.foobar.baz --directory=.
84
+ # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py create --platform=iphone,android --name=FooBar --id=com.foobar.baz --android=/opt/android-sdk
85
+ def create_project(args)
86
+ system %{#{bin} create #{args.join(' ')}}
87
+ end
88
+
89
+ # Run project
90
+ #
91
+ # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py run --platform=iphone
92
+ # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py run --platform=android
93
+ def run_project(args)
94
+ cmd = "run #{args.join(' ')} 2>&1 | tee -a #{log}"
95
+ system %{trap 'killall -9 "iPhone Simulator"' INT ; #{bin} #{cmd}}
96
+ end
97
+
98
+ private
99
+
100
+ # Path to titanium.py
101
+ def bin
102
+ %{"#{sdk_root}/titanium.py"}
103
+ end
4
104
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joshua Priddle
@@ -30,8 +30,6 @@ files:
30
30
  - Rakefile
31
31
  - README.markdown
32
32
  - bin/titanium
33
- - lib/titanium_cli/base.rb
34
- - lib/titanium_cli/version.rb
35
33
  - lib/titanium_cli.rb
36
34
  has_rdoc: true
37
35
  homepage: http://github.com/itspriddle/titanium_cli
@@ -1,102 +0,0 @@
1
- module TitaniumCLI
2
- module Base
3
- extend self
4
-
5
- attr_accessor :log, :sdk_root, :sdk_version
6
-
7
- # Copy Titanium logs to this file
8
- def log
9
- @log ||= ENV['LOG'] || 'log/development.log'
10
- end
11
-
12
- # Titanium SDK version
13
- def sdk_version
14
- @sdk_version ||= ENV['SDK_VERSION'] || '1.4.2'
15
- end
16
-
17
- # Titanium SDK root
18
- def sdk_root
19
- return @sdk_root if @sdk_root
20
- case RUBY_PLATFORM
21
- when /darwin/
22
- system_root = "/Library/Application Support/Titanium/mobilesdk/osx/#{sdk_version}"
23
- local_root = "#{ENV['HOME']}#{system_root}"
24
-
25
- if File.exists?(local_root)
26
- @sdk_root = local_root
27
- elsif File.exists?(system_root)
28
- @sdk_root = system_root
29
- end
30
- end
31
-
32
- unless @sdk_root
33
- raise "Can't find Titanium SDK root"
34
- end
35
- @sdk_root
36
- end
37
-
38
- # Run titanium.py command
39
- def run(argv)
40
- if action = argv.shift
41
- case action.to_sym
42
- when :create
43
- create_project(argv) and return
44
- when :run
45
- run_project(argv) and return
46
- else
47
- raise "Invalid action #{action}" and return
48
- end
49
- end
50
- puts usage.gsub(/^ /, '')
51
- end
52
-
53
- # Print usage for this script
54
- def usage; <<-USAGE
55
- Creating projects:
56
- Create iPhone project:
57
- titanium create --platform=iphone --name=FooMobile --id=com.foo.mobile
58
-
59
- Create Android project
60
- titanium create --platform=android --name=FooMobile \\
61
- --id=com.foo.mobile --android=/opt/android-sdk
62
-
63
- Create iPhone and Android project
64
- titanium create --platform=iphone,android --name=FooMobile \\
65
- --id=com.foo.mobile --android=/opt/android-sdk
66
-
67
- Running projects:
68
- Run iPhone project:
69
- titanium run --platform=iphone
70
-
71
- Run iPhone project:
72
- titanium run --platform=android
73
-
74
- USAGE
75
- end
76
-
77
- # Create project
78
- # (directory optional)
79
- #
80
- # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py create --platform=iphone --name=FooBar --id=com.foobar.baz --directory=.
81
- # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py create --platform=iphone,android --name=FooBar --id=com.foobar.baz --android=/opt/android-sdk
82
- def create_project(args)
83
- bin "create #{args.join(' ')}"
84
- end
85
-
86
- # Run project
87
- #
88
- # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py run --platform=iphone
89
- # python /Library/Application\ Support/Titanium/mobilesdk/osx/1.4.2/titanium.py run --platform=android
90
- def run_project(args)
91
- bin "run #{args.join(' ')} 2>&1 | tee -a #{log}"
92
- end
93
-
94
- private
95
-
96
- # Runs the titanium.py command
97
- def bin(command)
98
- system %{"#{sdk_root}/titanium.py" #{command}}
99
- end
100
-
101
- end
102
- end
@@ -1,3 +0,0 @@
1
- module TitaniumCLI
2
- VERSION = Version = '0.0.1'
3
- end