ti 0.0.2 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,19 +1,21 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+
3
4
  group :runtime do
4
- gem 'guard'
5
- gem 'guard-coffeescript'
6
- gem 'guard-livereload'
7
- gem 'jasmine'
8
- gem 'coffee-script'
9
- gem 'colored'
10
- gem 'rocco'
11
- gem 'rake'
12
- gem 'choice'
5
+ gem "sass", "~> 3.1.1"
6
+ gem "guard-sass", :git => "https://github.com/pengwynn/guard-sass"
7
+ gem 'guard', "~> 0.3.4"
8
+ gem 'guard-coffeescript', "~> 0.2.0"
9
+ gem 'guard-livereload', "~> 0.1.10"
10
+ gem 'jasmine', "~> 1.0.2.0"
11
+ gem 'coffee-script', "~> 2.2.0"
12
+ gem 'colored', "~> 1.2"
13
+ gem 'rocco', "~> 0.6"
14
+ gem 'rake', "~> 0.8.7"
13
15
  end
14
16
 
15
17
  group :development do
16
- gem "bundler", "~> 1.0.10"
17
- gem "jeweler", "~> 1.5.2"
18
- gem "rcov", ">= 0"
18
+ gem "bundler", "~> 1.0.10"
19
+ gem "jeweler", "~> 1.5.2"
20
+ gem "rspec", "~> 2.5.0"
19
21
  end
@@ -1,10 +1,17 @@
1
+ GIT
2
+ remote: https://github.com/pengwynn/guard-sass
3
+ revision: 6bcf5f4de45d1b994468ad51cec68298ed3d9c5e
4
+ specs:
5
+ guard-sass (0.0.5)
6
+ guard (>= 0.2.1)
7
+ sass (~> 3.1.0)
8
+
1
9
  GEM
2
10
  remote: http://rubygems.org/
3
11
  specs:
4
12
  addressable (2.2.5)
5
13
  childprocess (0.1.8)
6
14
  ffi (~> 1.0.6)
7
- choice (0.1.4)
8
15
  coffee-script (2.2.0)
9
16
  coffee-script-source
10
17
  execjs
@@ -15,11 +22,12 @@ GEM
15
22
  addressable (>= 2.1.1)
16
23
  eventmachine (>= 0.12.9)
17
24
  eventmachine (0.12.10)
18
- execjs (0.2.0)
25
+ execjs (0.3.0)
26
+ multi_json (~> 1.0)
19
27
  ffi (1.0.7)
20
28
  rake (>= 0.8.7)
21
29
  git (1.2.5)
22
- guard (0.3.3)
30
+ guard (0.3.4)
23
31
  thor (~> 0.14.6)
24
32
  guard-coffeescript (0.2.0)
25
33
  coffee-script (~> 2.2.0)
@@ -39,10 +47,10 @@ GEM
39
47
  rake
40
48
  json (1.5.1)
41
49
  json_pure (1.5.1)
50
+ multi_json (1.0.0)
42
51
  mustache (0.99.3)
43
52
  rack (1.2.2)
44
53
  rake (0.8.7)
45
- rcov (0.9.9)
46
54
  rdiscount (1.6.8)
47
55
  rocco (0.6)
48
56
  mustache
@@ -56,7 +64,8 @@ GEM
56
64
  diff-lcs (~> 1.1.2)
57
65
  rspec-mocks (2.5.0)
58
66
  rubyzip (0.9.4)
59
- selenium-webdriver (0.1.4)
67
+ sass (3.1.1)
68
+ selenium-webdriver (0.2.0)
60
69
  childprocess (>= 0.1.7)
61
70
  ffi (>= 1.0.7)
62
71
  json_pure
@@ -68,14 +77,15 @@ PLATFORMS
68
77
 
69
78
  DEPENDENCIES
70
79
  bundler (~> 1.0.10)
71
- choice
72
- coffee-script
73
- colored
74
- guard
75
- guard-coffeescript
76
- guard-livereload
77
- jasmine
80
+ coffee-script (~> 2.2.0)
81
+ colored (~> 1.2)
82
+ guard (~> 0.3.4)
83
+ guard-coffeescript (~> 0.2.0)
84
+ guard-livereload (~> 0.1.10)
85
+ guard-sass!
86
+ jasmine (~> 1.0.2.0)
78
87
  jeweler (~> 1.5.2)
79
- rake
80
- rcov
81
- rocco
88
+ rake (~> 0.8.7)
89
+ rocco (~> 0.6)
90
+ rspec (~> 2.5.0)
91
+ sass (~> 3.1.1)
data/Rakefile CHANGED
@@ -7,8 +7,10 @@ rescue Bundler::BundlerError => e
7
7
  $stderr.puts "Run `bundle install` to install missing gems"
8
8
  exit e.status_code
9
9
  end
10
+
10
11
  require 'rake'
11
12
 
13
+
12
14
  require 'jeweler'
13
15
  Jeweler::Tasks.new do |gem|
14
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
@@ -16,15 +18,13 @@ Jeweler::Tasks.new do |gem|
16
18
  gem.homepage = "http://github.com/revans/ti"
17
19
  gem.license = "MIT"
18
20
  gem.summary = %Q{Ti}
19
- gem.description = %Q{Titanium Commandline Helper}
21
+ gem.description = %Q{Titanium Project Generator}
20
22
  gem.email = "robert@codewranglers.org"
21
- gem.authors = ["Robert R Evans"]
23
+ gem.authors = ["Robert R Evans", "Julius Francisco", 'Wynn Netherland']
22
24
  gem.date = "2011-04-16"
23
25
  gem.executables = ["ti"]
24
- # Include your dependencies below. Runtime dependencies are required when using your gem,
25
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
26
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
27
- # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ gem.version = File.read(File.join(File.dirname(__FILE__), 'VERSION')).chomp
27
+
28
28
  end
29
29
  Jeweler::RubygemsDotOrgTasks.new
30
30
 
@@ -35,13 +35,6 @@ Rake::TestTask.new(:test) do |test|
35
35
  test.verbose = true
36
36
  end
37
37
 
38
- require 'rcov/rcovtask'
39
- Rcov::RcovTask.new do |test|
40
- test.libs << 'test'
41
- test.pattern = 'test/**/test_*.rb'
42
- test.verbose = true
43
- end
44
-
45
38
  task :default => :test
46
39
 
47
40
  require 'rake/rdoctask'
@@ -0,0 +1,17 @@
1
+ # TODO
2
+
3
+ * CoffeeScript Compiling doesn't work because "path" needs to be implemented. The idea is to make this a dynamic lookup.
4
+ * File creation, moving, replacing, etc should be moved to a module that can be included in other classes.
5
+ * Config, gitignore, rakefile, readme need to be moved to an appropriately named folder inside of the ti directory.
6
+ * Jasmine needs to be added.
7
+ * Guard needs to be added
8
+ * SASS needs to be added.
9
+ * Need to remove the perl script in the rakefile
10
+ * Use Thor instead of the choice gem.
11
+ * Documentation.
12
+
13
+ ## Versioning
14
+
15
+ When doing small upgrades/changes, use patch versioning.
16
+ Once everything is in this, and it's well tested, we can go to version
17
+ 1.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.0.5
data/bin/ti CHANGED
@@ -1,50 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.expand_path(File.join(File.dirname(__FILE__), %w[ .. lib ti ]))
4
- require "choice"
3
+ require 'ti'
4
+ options = ::Ti::Options.parse(ARGV)
5
5
 
6
- PROGRAM_VERSION = "0.0.1"
7
-
8
- Choice.options do
9
- header ''
10
- header 'Specific options:'
11
-
12
- option :name do
13
- short '-n'
14
- long '--name=demo'
15
- desc 'Titanium Project Name'
16
- default 'HelloWorld'
17
- end
18
-
19
- option :id do
20
- short '-i'
21
- long '--id=com.codewranglers.demo'
22
- desc 'Your Project id'
23
- default 'org.company.demo'
24
- end
25
-
26
- option :platform do
27
- short '-p'
28
- long '--platform=iphone'
29
- desc 'Project Platform where you want to run your application'
30
- default 'iphone'
31
- end
32
-
33
- separator ''
34
- separator 'Common options:'
35
-
36
- option :help do
37
- long '--help'
38
- desc 'Show this message'
39
- end
6
+ # Create a new project
7
+ if options.name
8
+ puts "Generating a new Ti Project named #{options.name}"
9
+ Ti::Generate::Project.create(options.name, options.device_id, (options.platform || 'iphone'))
10
+ end
40
11
 
41
- option :version do
42
- short 'v'
43
- long '--version'
44
- desc 'Show version'
45
- end
46
12
 
13
+ if options.model
14
+ Ti::Generate::Model.create(options.model)
47
15
  end
48
16
 
49
- # Main entry point for the application
50
- Ti::Generate.new_project(Choice.choices[:name], Choice.choices[:id], Choice.choices[:platform])
17
+
18
+ if options.view
19
+ Ti::Generate::View.create(options.view)
20
+ end
data/lib/ti.rb CHANGED
@@ -1,108 +1,31 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
2
2
 
3
+ require 'rubygems'
3
4
  require 'pathname'
4
5
  require 'fileutils'
5
6
  require 'colored'
6
7
  require 'rocco'
7
-
8
- @@ti = Pathname(__FILE__).dirname.expand_path
9
-
8
+ require 'ostruct'
10
9
 
11
10
  module Ti
12
- VERSION = '1.6.0'
11
+ VERSION = File.read(File.join(File.dirname(__FILE__), '../VERSION')).chomp
12
+ ROOT_PATH = Pathname(__FILE__).dirname.expand_path
13
+ TITANIUM_VERSION = '1.6.0'
14
+
13
15
  # TODO: Need to support those how have install Titanium in their $HOME dir.
14
- OSX_TITANIUM = "/Library/Application\\ Support/Titanium/mobilesdk/osx/#{VERSION}/titanium.py"
15
- LINUX_TITANIUM = "$HOME/.titanium/mobilesdk/linux/#{VERSION}/titanium.py"
16
-
17
- class Generate
18
- class << self
19
- attr_accessor :project_name, :devise_platform, :app_id
20
-
21
-
22
- # Ti::Generate.new_project('demo', 'org.codewranglers.demo', 'ipad')
23
- def new_project(name, id, platform='iphone')
24
- @project_name = name
25
- @devise_platform = platform
26
- @app_id = id
27
- if `#{generate_titanium_project}`
28
- remove_old_files
29
- generate_files
30
- log "Your Titanium project is ready for you to get rockin!"
31
- else
32
- error "There was an error generating your Titanium project."
33
- end
34
- end
35
-
36
-
37
- def create_new_file(name, contents)
38
- log "Creating #{name}"
39
- File.open(location.join(name), 'w') { |f| f.write(contents) }
40
- end
41
-
42
- def touch(*filenames)
43
- filenames.each do |filename|
44
- log "Creating #{filename} file."
45
- FileUtils.touch(location.join(filename))
46
- end
47
- end
48
-
49
- def create_directories(*dirs)
50
- dirs.each do |dir|
51
- log "Creating the #{dir} directory."
52
- FileUtils.mkdir_p(location.join(dir))
53
- end
54
- end
55
-
56
-
57
- def remove_directories(*names)
58
- names.each do |name|
59
- log "Removing #{name} directory."
60
- FileUtils.rm_rf(location.join(name))
61
- end
62
- end
63
-
64
- def remove_files(*files)
65
- files.each do |file|
66
- log "Removing #{file} file."
67
- FileUtils.rm(location.join(file))
68
- end
69
- end
16
+
17
+ OSX_TITANIUM = "/Library/Application\\ Support/Titanium/mobilesdk/osx/#{::Ti::TITANIUM_VERSION}/titanium.py"
18
+ LINUX_TITANIUM = "$HOME/.titanium/mobilesdk/linux/#{::Ti::TITANIUM_VERSION}/titanium.py"
70
19
 
71
-
72
- def remove_old_files
73
- remove_files('README')
74
- remove_directories('Resources')
75
- end
76
-
77
-
78
- def generate_files
79
- create_directories('Resources', 'src', 'docs', 'specs', 'Resources/images', 'Resources/stylesheets', 'Resources/vendor')
80
- touch('Readme.mkd')
81
- create_new_file("src/app.coffee", '')
82
- create_new_file(".gitignore", File.read(@@ti.join('ti/gitignore')))
83
- create_new_file("config.rb", File.read(@@ti.join('ti/config')))
84
- create_new_file("Rakefile", File.read(@@ti.join('ti/rakefile')))
85
- end
86
-
87
-
88
- def location
89
- @location ||= Pathname.new(Dir.pwd).join(@project_name)
90
- end
91
-
92
-
93
- def generate_titanium_project
94
- "#{OSX_TITANIUM} create --name=#{@project_name} --platform=#{@devise_platform} --id=#{@app_id}"
95
- end
96
-
97
-
98
- def log(msg)
99
- $stdout.puts(msg.green.bold)
100
- end
101
-
102
- def error(msg)
103
- $stderr.puts(msg.red.bold)
104
- end
105
-
106
- end
20
+ autoload :Options, 'ti/options.rb'
21
+ autoload :ParseOptions, 'ti/parse_options.rb'
22
+ autoload :Logger, "ti/logger.rb"
23
+ autoload :Utils, "ti/utils.rb"
24
+
25
+ module Generate
26
+ autoload :Project, "ti/generate/project.rb"
27
+ autoload :Model, "ti/generate/model.rb"
28
+ autoload :View, "ti/generate/view.rb"
107
29
  end
30
+
108
31
  end
@@ -0,0 +1,19 @@
1
+ module Ti
2
+ module Generate
3
+ class Model
4
+ class << self
5
+ include Utils
6
+
7
+ def create(name, options={})
8
+ create_new_file("app/models/#{name}.coffee")
9
+ create_new_file("specs/models/#{name}_spec.coffee", File.read(::Ti::ROOT_PATH.join("ti/templates/specs/app_spec.coffee")))
10
+ end
11
+
12
+ def location
13
+ base_location
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,74 @@
1
+ module Ti
2
+ module Generate
3
+ class Project
4
+ class << self
5
+ attr_accessor :project_name, :device_platform, :app_id
6
+ include Utils
7
+
8
+ # Ti::Generate::Project.create('demo', 'org.codewranglers.demo', 'ipad')
9
+ def create(name, id, platform='iphone')
10
+ @project_name = name
11
+ @device_platform = platform
12
+ @app_id = id
13
+ if system(generate_titanium_project)
14
+ create_directories('tmp')
15
+ copy_defaults
16
+ remove_old_files
17
+ generate_files
18
+ log "Your Titanium project is ready for you to get rockin!"
19
+ else
20
+ error "There was an error generating your Titanium project."
21
+ end
22
+ end
23
+
24
+
25
+ def copy_defaults
26
+ FileUtils.cp(location.join("Resources/KS_nav_ui.png"), "/tmp/")
27
+ FileUtils.cp(location.join("Resources/KS_nav_views.png"), "/tmp/")
28
+ end
29
+
30
+
31
+ def generate_files
32
+ create_project_directory
33
+ touch('Readme.mkd')
34
+ # touch('specs/spec_helper.coffee') # TODO: Necessary? If so, what is in it?
35
+
36
+ create_new_file("app/app.coffee", File.read(::Ti::ROOT_PATH.join('ti/templates/app/app.coffee')))
37
+ create_new_file(".gitignore", File.read(::Ti::ROOT_PATH.join('ti/templates/gitignore')))
38
+ create_new_file("config/config.rb", File.read(::Ti::ROOT_PATH.join('ti/templates/config')))
39
+ create_new_file("Rakefile", File.read(::Ti::ROOT_PATH.join('ti/templates/rakefile')))
40
+ create_new_file("Readme.mkd", File.read(::Ti::ROOT_PATH.join('ti/templates/readme')))
41
+ create_new_file("Guardfile", File.read(::Ti::ROOT_PATH.join('ti/templates/guardfile')))
42
+ create_new_file("specs/app_spec.coffee", File.read(::Ti::ROOT_PATH.join('ti/templates/specs/app_spec.coffee')))
43
+
44
+ # load default images
45
+ FileUtils.cp("/tmp/KS_nav_ui.png", location.join("Resources/images/"))
46
+ FileUtils.cp("/tmp/KS_nav_views.png", location.join("Resources/images/"))
47
+ end
48
+
49
+ def create_project_directory
50
+ create_directories('Resources', 'Resources/images', 'Resources/vendor',
51
+ 'config',
52
+ 'docs',
53
+ 'app/models', 'app/views', 'app/stylesheets',
54
+ 'specs/models', 'specs/views')
55
+ end
56
+
57
+ def remove_old_files
58
+ remove_files('README')
59
+ remove_directories('Resources')
60
+ end
61
+
62
+ def location
63
+ base_location.join(@project_name)
64
+ end
65
+
66
+ # TODO: Need to look at what system this is being ran on. If OSX check if titanium was installed in the $HOME dir.
67
+ def generate_titanium_project
68
+ "#{::Ti::OSX_TITANIUM} create --name=#{@project_name} --platform=#{@device_platform} --id=#{@app_id}"
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,19 @@
1
+ module Ti
2
+ module Generate
3
+ class View
4
+ class << self
5
+ include Utils
6
+
7
+ def create(name, options={})
8
+ create_new_file("app/views/#{name}.coffee")
9
+ create_new_file("specs/views/#{name}_spec.coffee", File.read(::Ti::ROOT_PATH.join("ti/templates/specs/app_spec.coffee")))
10
+ end
11
+
12
+ def location
13
+ base_location
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ module Ti
2
+ class Logger
3
+
4
+ def self.report(msg)
5
+ $stdout.puts(msg.green.bold)
6
+ end
7
+
8
+ def self.error(msg)
9
+ $stderr.puts(msg.red.bold)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,64 @@
1
+ module Ti
2
+ class Options
3
+
4
+ def self.parse(args)
5
+ options = OpenStruct.new
6
+
7
+ ParseOptions.new(args) do |opts|
8
+
9
+ opts.value('new') do |name|
10
+ options.name = name
11
+ end
12
+
13
+ opts.value('-i', '--id') do |id|
14
+ options.device_id = id
15
+ end
16
+
17
+ opts.value('-p', '--platform') do |platform|
18
+ options.platform = platform
19
+ end
20
+
21
+ opts.value('generate') do |generate|
22
+ options.generate = !!generate
23
+ end
24
+
25
+ opts.value('g') do |g|
26
+ options.generate = !!g
27
+ end
28
+
29
+ opts.value('model') do |model|
30
+ options.model = model
31
+ end
32
+
33
+ opts.value('view') do |view|
34
+ options.view = view
35
+ end
36
+
37
+ opts.help('help', '-h') do
38
+ puts "
39
+
40
+ Usage: ti new name
41
+
42
+ Ti Options:
43
+
44
+ new: The name of the ti project.
45
+ e.g. ti new cool_iphone_app
46
+ generate Generate a specific file type:
47
+ e.g. ti generate model user
48
+ g Shortcut for generate
49
+ help View the Help Screen
50
+ version View the current version of Ti
51
+
52
+ "
53
+ exit(0)
54
+ end
55
+
56
+ opts.version('-v', 'version') do
57
+ puts "Ti's current version is #{Ti::VERSION}"
58
+ exit(0)
59
+ end
60
+ end
61
+ options
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,48 @@
1
+ class ParseOptions
2
+
3
+ ##
4
+ # Initialize
5
+ #
6
+ def initialize(args, &block)
7
+ @args = args
8
+ instance_eval(&block) if block_given?
9
+ end
10
+
11
+
12
+ ##
13
+ # Help Menu
14
+ #
15
+ def help(value, value2='', &block)
16
+ puts yield(block) if display_message?(value, value2)
17
+ end
18
+ alias_method :version, :help
19
+
20
+
21
+ ##
22
+ # Scan for values
23
+ #
24
+ def scan_for_value(v1, v2='', &block)
25
+ found = nil
26
+ @args.each_with_index do |value, index|
27
+ next if found
28
+ found = @args[index + 1] if (v1.to_s == value.to_s || v2.to_s == value.to_s)
29
+ end
30
+ yield found
31
+ end
32
+ alias_method :value, :scan_for_value
33
+
34
+
35
+ ##
36
+ # Boolean
37
+ #
38
+ def boolean(v1, v2='', &block)
39
+ found = false
40
+ @args.each do |value|
41
+ next if found
42
+ found = true if (v1.to_s == value.to_s || v2.to_s == value.to_s)
43
+ end
44
+ block_given? ? yield(found) : found
45
+ end
46
+ alias_method :display_message?, :boolean
47
+
48
+ end
@@ -0,0 +1,54 @@
1
+ # ## This sets the background color of the master UIView (when there are no windows)
2
+ Titanium.UI.setBackgroundColor('#000')
3
+
4
+ # ## Create tab Group
5
+ tabGroup = Titanium.UI.createTabGroup({ barColor:'#336699' })
6
+
7
+ # ## Create base UI tab and root window
8
+ win1 = Titanium.UI.createWindow
9
+ title: 'Tab 1'
10
+ backgroundColor: '#fff'
11
+
12
+ tab1 = Titanium.UI.createTab
13
+ icon: '/images/KS_nav_views.png'
14
+ title: 'Tab 1'
15
+ window: win1
16
+
17
+ label1 = Titanium.UI.createLabel
18
+ color: '#999'
19
+ text: 'I am Window 1'
20
+ font:
21
+ fontSize: 20
22
+ fontFamily: 'Helvetica Neue'
23
+ textAlign: 'center'
24
+ width: 'auto'
25
+
26
+ win1.add label1
27
+
28
+ # ## Create controls tab and root window
29
+ win2 = Titanium.UI.createWindow
30
+ title: 'Tab 2'
31
+ backgroundColor: '#fff'
32
+
33
+ tab2 = Titanium.UI.createTab
34
+ icon: '/images/KS_nav_ui.png'
35
+ title: 'Tab 2'
36
+ window: win2
37
+
38
+ label2 = Titanium.UI.createLabel
39
+ color: '#999'
40
+ text: 'I am Window 2'
41
+ font:
42
+ fontSize: 20
43
+ fontFamily: 'Helvetica Neue'
44
+ textAlign: 'center'
45
+ width: 'auto'
46
+
47
+ win2.add label2
48
+
49
+ # ## Add tabs
50
+ tabGroup.addTab tab1
51
+ tabGroup.addTab tab2
52
+
53
+ # ## Open tab group
54
+ tabGroup.open()
@@ -13,7 +13,7 @@ module Config
13
13
  ANDROID_SDK_VERSION = ""
14
14
 
15
15
  TI_SDK_VERSION = "1.6.0"
16
- TI_DIR = "/Library/Application\ Support/Titanium"
16
+ TI_DIR = "/Library/Application\\ Support/Titanium"
17
17
 
18
18
  TI_ASSETS_DIR = "#{TI_DIR}/mobilesdk/osx/#{TI_SDK_VERSION}"
19
19
  TI_IPHONE_DIR = "#{TI_ASSETS_DIR}/iphone"
@@ -22,6 +22,6 @@ module Config
22
22
 
23
23
  # Application
24
24
  APP_ID = doc.xpath('ti:app/id').text
25
- APP_NAME = doc.xpath('ti:app/id').text
26
- APP_DEVISE = "iphone"
25
+ APP_NAME = doc.xpath('ti:app/name').text
26
+ APP_DEVICE = "iphone"
27
27
  end
@@ -0,0 +1,15 @@
1
+ group 'styles' do
2
+ guard 'sass', :output => 'Resources', :output_format => 'jss' do
3
+ watch(%r{^stylesheets/.+\.sass}) { puts 'compiling sass' }
4
+ watch(%r{^stylesheets/.+\.scss}) { puts 'compiling scss' }
5
+ end
6
+ end
7
+
8
+ group 'coffee' do
9
+ guard 'shell' do
10
+ watch(%r{src/(.+\.coffee)}) do
11
+ puts 'compiling coffeescript'
12
+ `coffee -p --bare src > Resources/app_name.js`
13
+ end
14
+ end
15
+ end
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'colored'
2
3
  require File.join(File.dirname(__FILE__), 'config.rb')
3
4
  include Config
4
5
 
@@ -10,17 +11,28 @@ namespace :project do
10
11
  puts "#{PROJECT_NAME} at version #{PROJECT_VERSION}."
11
12
  puts " App ID: #{APP_ID}."
12
13
  puts " App Name: #{APP_NAME}."
13
- puts " Building for: #{APP_DEVISE}."
14
+ puts " Building for: #{APP_DEVICE}."
14
15
  puts " Using iOS SDK Version #{IPHONE_SDK_VERSION}."
15
16
  puts " Using Android Version #{ANDROID_SDK_VERSION}."
16
17
  puts " Titanium Build Version #{TI_SDK_VERSION}."
17
18
  end
18
19
  end
19
20
 
21
+ namespace :compile do
22
+ desc "Compile all"
23
+ task :all do
24
+ compile
25
+ end
20
26
 
21
- desc "Compile Coffee files"
22
- task :compile do
23
- compile
27
+ desc "Compile coffee"
28
+ task :coffee do
29
+ compile_coffee
30
+ end
31
+
32
+ desc "Compile sass"
33
+ task :styles do
34
+ compile_sass
35
+ end
24
36
  end
25
37
 
26
38
  namespace :build do
@@ -31,9 +43,25 @@ namespace :build do
31
43
  end
32
44
 
33
45
  def compile
34
- puts "Compiling CoffeeScript"
35
-
36
- # TODO: APP_NAME needs to be changed to the real name, but set dynamically.
46
+ compile_coffee && compile_sass
47
+ end
48
+
49
+ def compile_sass
50
+ puts "Compiling stylesheets".blue
51
+ `sass --compass -C -t expanded stylesheets/app.sass > Resources/app.jss`
52
+ puts "Done".green
53
+ end
54
+
55
+ def compile_coffee
56
+ puts "Compiling CoffeeScript".blue
57
+ paths = [
58
+ "app/#{APP_NAME}.coffee",
59
+ "app/models/*.coffee",
60
+ "app/views/*.coffee"
61
+ ]
62
+
63
+ puts "PATHS: #{paths.join(' ')} ".yellow
64
+
37
65
  `coffee -p --join --bare #{paths.join(' ')} > Resources/#{APP_NAME}.js`
38
66
  `coffee -p --bare src/app.coffee > Resources/app.js`
39
67
  end
@@ -41,7 +69,7 @@ end
41
69
  def build(options={})
42
70
  compile
43
71
  options[:device] ||= 'iphone'
44
- puts "Building with Titanium... (DEVICE_TYPE:#{options[:device]})"
72
+ puts "Building with Titanium with Ti... (DEVICE_TYPE:#{options[:device]})"
45
73
  FileUtils.mkdir_p "#{PROJECT_ROOT}/#{PROJECT_NAME}/build/iphone/"
46
74
  sh %Q{bash -c "#{TI_BUILD} run #{PROJECT_ROOT}/ #{IPHONE_SDK_VERSION} #{APP_ID} #{APP_NAME} #{APP_DEVICE}" \
47
75
  | 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;'}
@@ -0,0 +1 @@
1
+ # My Titanium Project - Generated by Ti
@@ -0,0 +1,3 @@
1
+ describe 'Jasmine', ->
2
+ it 'should require your to write your tests', ->
3
+ expect(yourCode).toBeLotsBetter()
@@ -0,0 +1,48 @@
1
+ module Utils
2
+ def create_new_file(name, contents='')
3
+ log "Creating #{name}"
4
+ File.open(location.join(name), 'w') { |f| f.write(contents) }
5
+ end
6
+
7
+ def touch(*filenames)
8
+ filenames.each do |filename|
9
+ log "Creating #{filename} file."
10
+ FileUtils.touch(location.join(filename))
11
+ end
12
+ end
13
+
14
+ def create_directories(*dirs)
15
+ dirs.each do |dir|
16
+ log "Creating the #{dir} directory."
17
+ FileUtils.mkdir_p(location.join(dir))
18
+ end
19
+ end
20
+
21
+
22
+ def remove_directories(*names)
23
+ names.each do |name|
24
+ log "Removing #{name} directory."
25
+ FileUtils.rm_rf(location.join(name))
26
+ end
27
+ end
28
+
29
+ def remove_files(*files)
30
+ files.each do |file|
31
+ log "Removing #{file} file."
32
+ FileUtils.rm(location.join(file))
33
+ end
34
+ end
35
+
36
+ def log(msg)
37
+ ::Ti::Logger.report(msg)
38
+ end
39
+
40
+ def error(msg)
41
+ ::Ti::Logger.error(msg)
42
+ end
43
+
44
+ def base_location
45
+ @location ||= Pathname.new(Dir.pwd)
46
+ end
47
+
48
+ end
data/ti.gemspec CHANGED
@@ -5,13 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ti}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Robert R Evans"]
11
+ s.authors = ["Robert R Evans", "Julius Francisco", "Wynn Netherland"]
12
12
  s.date = %q{2011-04-16}
13
- s.default_executable = %q{ti}
14
- s.description = %q{Titanium Commandline Helper}
13
+ s.description = %q{Titanium Project Generator}
15
14
  s.email = %q{robert@codewranglers.org}
16
15
  s.executables = ["ti"]
17
16
  s.extra_rdoc_files = [
@@ -26,12 +25,24 @@ Gem::Specification.new do |s|
26
25
  "LICENSE.txt",
27
26
  "README.rdoc",
28
27
  "Rakefile",
28
+ "TODO.mkd",
29
29
  "VERSION",
30
30
  "bin/ti",
31
31
  "lib/ti.rb",
32
- "lib/ti/config",
33
- "lib/ti/gitignore",
34
- "lib/ti/rakefile",
32
+ "lib/ti/generate/model.rb",
33
+ "lib/ti/generate/project.rb",
34
+ "lib/ti/generate/view.rb",
35
+ "lib/ti/logger.rb",
36
+ "lib/ti/options.rb",
37
+ "lib/ti/parse_options.rb",
38
+ "lib/ti/templates/app/app.coffee",
39
+ "lib/ti/templates/config",
40
+ "lib/ti/templates/gitignore",
41
+ "lib/ti/templates/guardfile",
42
+ "lib/ti/templates/rakefile",
43
+ "lib/ti/templates/readme",
44
+ "lib/ti/templates/specs/app_spec.coffee",
45
+ "lib/ti/utils.rb",
35
46
  "test/helper.rb",
36
47
  "test/test_ti.rb",
37
48
  "ti.gemspec"
@@ -39,7 +50,7 @@ Gem::Specification.new do |s|
39
50
  s.homepage = %q{http://github.com/revans/ti}
40
51
  s.licenses = ["MIT"]
41
52
  s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.6.2}
53
+ s.rubygems_version = %q{1.7.2}
43
54
  s.summary = %q{Ti}
44
55
  s.test_files = [
45
56
  "test/helper.rb",
@@ -50,45 +61,48 @@ Gem::Specification.new do |s|
50
61
  s.specification_version = 3
51
62
 
52
63
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<guard>, [">= 0"])
54
- s.add_runtime_dependency(%q<guard-coffeescript>, [">= 0"])
55
- s.add_runtime_dependency(%q<guard-livereload>, [">= 0"])
56
- s.add_runtime_dependency(%q<jasmine>, [">= 0"])
57
- s.add_runtime_dependency(%q<coffee-script>, [">= 0"])
58
- s.add_runtime_dependency(%q<colored>, [">= 0"])
59
- s.add_runtime_dependency(%q<rocco>, [">= 0"])
60
- s.add_runtime_dependency(%q<rake>, [">= 0"])
61
- s.add_runtime_dependency(%q<choice>, [">= 0"])
64
+ s.add_runtime_dependency(%q<sass>, ["~> 3.1.1"])
65
+ s.add_runtime_dependency(%q<guard-sass>, [">= 0"])
66
+ s.add_runtime_dependency(%q<guard>, ["~> 0.3.4"])
67
+ s.add_runtime_dependency(%q<guard-coffeescript>, ["~> 0.2.0"])
68
+ s.add_runtime_dependency(%q<guard-livereload>, ["~> 0.1.10"])
69
+ s.add_runtime_dependency(%q<jasmine>, ["~> 1.0.2.0"])
70
+ s.add_runtime_dependency(%q<coffee-script>, ["~> 2.2.0"])
71
+ s.add_runtime_dependency(%q<colored>, ["~> 1.2"])
72
+ s.add_runtime_dependency(%q<rocco>, ["~> 0.6"])
73
+ s.add_runtime_dependency(%q<rake>, ["~> 0.8.7"])
62
74
  s.add_development_dependency(%q<bundler>, ["~> 1.0.10"])
63
75
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
64
- s.add_development_dependency(%q<rcov>, [">= 0"])
76
+ s.add_development_dependency(%q<rspec>, ["~> 2.5.0"])
65
77
  else
66
- s.add_dependency(%q<guard>, [">= 0"])
67
- s.add_dependency(%q<guard-coffeescript>, [">= 0"])
68
- s.add_dependency(%q<guard-livereload>, [">= 0"])
69
- s.add_dependency(%q<jasmine>, [">= 0"])
70
- s.add_dependency(%q<coffee-script>, [">= 0"])
71
- s.add_dependency(%q<colored>, [">= 0"])
72
- s.add_dependency(%q<rocco>, [">= 0"])
73
- s.add_dependency(%q<rake>, [">= 0"])
74
- s.add_dependency(%q<choice>, [">= 0"])
78
+ s.add_dependency(%q<sass>, ["~> 3.1.1"])
79
+ s.add_dependency(%q<guard-sass>, [">= 0"])
80
+ s.add_dependency(%q<guard>, ["~> 0.3.4"])
81
+ s.add_dependency(%q<guard-coffeescript>, ["~> 0.2.0"])
82
+ s.add_dependency(%q<guard-livereload>, ["~> 0.1.10"])
83
+ s.add_dependency(%q<jasmine>, ["~> 1.0.2.0"])
84
+ s.add_dependency(%q<coffee-script>, ["~> 2.2.0"])
85
+ s.add_dependency(%q<colored>, ["~> 1.2"])
86
+ s.add_dependency(%q<rocco>, ["~> 0.6"])
87
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
75
88
  s.add_dependency(%q<bundler>, ["~> 1.0.10"])
76
89
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
77
- s.add_dependency(%q<rcov>, [">= 0"])
90
+ s.add_dependency(%q<rspec>, ["~> 2.5.0"])
78
91
  end
79
92
  else
80
- s.add_dependency(%q<guard>, [">= 0"])
81
- s.add_dependency(%q<guard-coffeescript>, [">= 0"])
82
- s.add_dependency(%q<guard-livereload>, [">= 0"])
83
- s.add_dependency(%q<jasmine>, [">= 0"])
84
- s.add_dependency(%q<coffee-script>, [">= 0"])
85
- s.add_dependency(%q<colored>, [">= 0"])
86
- s.add_dependency(%q<rocco>, [">= 0"])
87
- s.add_dependency(%q<rake>, [">= 0"])
88
- s.add_dependency(%q<choice>, [">= 0"])
93
+ s.add_dependency(%q<sass>, ["~> 3.1.1"])
94
+ s.add_dependency(%q<guard-sass>, [">= 0"])
95
+ s.add_dependency(%q<guard>, ["~> 0.3.4"])
96
+ s.add_dependency(%q<guard-coffeescript>, ["~> 0.2.0"])
97
+ s.add_dependency(%q<guard-livereload>, ["~> 0.1.10"])
98
+ s.add_dependency(%q<jasmine>, ["~> 1.0.2.0"])
99
+ s.add_dependency(%q<coffee-script>, ["~> 2.2.0"])
100
+ s.add_dependency(%q<colored>, ["~> 1.2"])
101
+ s.add_dependency(%q<rocco>, ["~> 0.6"])
102
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
89
103
  s.add_dependency(%q<bundler>, ["~> 1.0.10"])
90
104
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
91
- s.add_dependency(%q<rcov>, [">= 0"])
105
+ s.add_dependency(%q<rspec>, ["~> 2.5.0"])
92
106
  end
93
107
  end
94
108
 
metadata CHANGED
@@ -1,19 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Robert R Evans
9
+ - Julius Francisco
10
+ - Wynn Netherland
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
14
  date: 2011-04-16 00:00:00.000000000Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
- name: guard
16
- requirement: &2164294940 !ruby/object:Gem::Requirement
17
+ name: sass
18
+ requirement: &2152171360 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 3.1.1
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *2152171360
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard-sass
29
+ requirement: &2152170760 !ruby/object:Gem::Requirement
17
30
  none: false
18
31
  requirements:
19
32
  - - ! '>='
@@ -21,98 +34,98 @@ dependencies:
21
34
  version: '0'
22
35
  type: :runtime
23
36
  prerelease: false
24
- version_requirements: *2164294940
37
+ version_requirements: *2152170760
38
+ - !ruby/object:Gem::Dependency
39
+ name: guard
40
+ requirement: &2152166100 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.4
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *2152166100
25
49
  - !ruby/object:Gem::Dependency
26
50
  name: guard-coffeescript
27
- requirement: &2164294340 !ruby/object:Gem::Requirement
51
+ requirement: &2152165540 !ruby/object:Gem::Requirement
28
52
  none: false
29
53
  requirements:
30
- - - ! '>='
54
+ - - ~>
31
55
  - !ruby/object:Gem::Version
32
- version: '0'
56
+ version: 0.2.0
33
57
  type: :runtime
34
58
  prerelease: false
35
- version_requirements: *2164294340
59
+ version_requirements: *2152165540
36
60
  - !ruby/object:Gem::Dependency
37
61
  name: guard-livereload
38
- requirement: &2164293740 !ruby/object:Gem::Requirement
62
+ requirement: &2152164820 !ruby/object:Gem::Requirement
39
63
  none: false
40
64
  requirements:
41
- - - ! '>='
65
+ - - ~>
42
66
  - !ruby/object:Gem::Version
43
- version: '0'
67
+ version: 0.1.10
44
68
  type: :runtime
45
69
  prerelease: false
46
- version_requirements: *2164293740
70
+ version_requirements: *2152164820
47
71
  - !ruby/object:Gem::Dependency
48
72
  name: jasmine
49
- requirement: &2164293140 !ruby/object:Gem::Requirement
73
+ requirement: &2152163720 !ruby/object:Gem::Requirement
50
74
  none: false
51
75
  requirements:
52
- - - ! '>='
76
+ - - ~>
53
77
  - !ruby/object:Gem::Version
54
- version: '0'
78
+ version: 1.0.2.0
55
79
  type: :runtime
56
80
  prerelease: false
57
- version_requirements: *2164293140
81
+ version_requirements: *2152163720
58
82
  - !ruby/object:Gem::Dependency
59
83
  name: coffee-script
60
- requirement: &2164292540 !ruby/object:Gem::Requirement
84
+ requirement: &2152163080 !ruby/object:Gem::Requirement
61
85
  none: false
62
86
  requirements:
63
- - - ! '>='
87
+ - - ~>
64
88
  - !ruby/object:Gem::Version
65
- version: '0'
89
+ version: 2.2.0
66
90
  type: :runtime
67
91
  prerelease: false
68
- version_requirements: *2164292540
92
+ version_requirements: *2152163080
69
93
  - !ruby/object:Gem::Dependency
70
94
  name: colored
71
- requirement: &2164291940 !ruby/object:Gem::Requirement
95
+ requirement: &2152162520 !ruby/object:Gem::Requirement
72
96
  none: false
73
97
  requirements:
74
- - - ! '>='
98
+ - - ~>
75
99
  - !ruby/object:Gem::Version
76
- version: '0'
100
+ version: '1.2'
77
101
  type: :runtime
78
102
  prerelease: false
79
- version_requirements: *2164291940
103
+ version_requirements: *2152162520
80
104
  - !ruby/object:Gem::Dependency
81
105
  name: rocco
82
- requirement: &2164291340 !ruby/object:Gem::Requirement
106
+ requirement: &2152162000 !ruby/object:Gem::Requirement
83
107
  none: false
84
108
  requirements:
85
- - - ! '>='
109
+ - - ~>
86
110
  - !ruby/object:Gem::Version
87
- version: '0'
111
+ version: '0.6'
88
112
  type: :runtime
89
113
  prerelease: false
90
- version_requirements: *2164291340
114
+ version_requirements: *2152162000
91
115
  - !ruby/object:Gem::Dependency
92
116
  name: rake
93
- requirement: &2164290740 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- type: :runtime
100
- prerelease: false
101
- version_requirements: *2164290740
102
- - !ruby/object:Gem::Dependency
103
- name: choice
104
- requirement: &2164290120 !ruby/object:Gem::Requirement
117
+ requirement: &2152158600 !ruby/object:Gem::Requirement
105
118
  none: false
106
119
  requirements:
107
- - - ! '>='
120
+ - - ~>
108
121
  - !ruby/object:Gem::Version
109
- version: '0'
122
+ version: 0.8.7
110
123
  type: :runtime
111
124
  prerelease: false
112
- version_requirements: *2164290120
125
+ version_requirements: *2152158600
113
126
  - !ruby/object:Gem::Dependency
114
127
  name: bundler
115
- requirement: &2164289560 !ruby/object:Gem::Requirement
128
+ requirement: &2152158120 !ruby/object:Gem::Requirement
116
129
  none: false
117
130
  requirements:
118
131
  - - ~>
@@ -120,10 +133,10 @@ dependencies:
120
133
  version: 1.0.10
121
134
  type: :development
122
135
  prerelease: false
123
- version_requirements: *2164289560
136
+ version_requirements: *2152158120
124
137
  - !ruby/object:Gem::Dependency
125
138
  name: jeweler
126
- requirement: &2164287600 !ruby/object:Gem::Requirement
139
+ requirement: &2152157620 !ruby/object:Gem::Requirement
127
140
  none: false
128
141
  requirements:
129
142
  - - ~>
@@ -131,19 +144,19 @@ dependencies:
131
144
  version: 1.5.2
132
145
  type: :development
133
146
  prerelease: false
134
- version_requirements: *2164287600
147
+ version_requirements: *2152157620
135
148
  - !ruby/object:Gem::Dependency
136
- name: rcov
137
- requirement: &2164285000 !ruby/object:Gem::Requirement
149
+ name: rspec
150
+ requirement: &2152156920 !ruby/object:Gem::Requirement
138
151
  none: false
139
152
  requirements:
140
- - - ! '>='
153
+ - - ~>
141
154
  - !ruby/object:Gem::Version
142
- version: '0'
155
+ version: 2.5.0
143
156
  type: :development
144
157
  prerelease: false
145
- version_requirements: *2164285000
146
- description: Titanium Commandline Helper
158
+ version_requirements: *2152156920
159
+ description: Titanium Project Generator
147
160
  email: robert@codewranglers.org
148
161
  executables:
149
162
  - ti
@@ -159,12 +172,24 @@ files:
159
172
  - LICENSE.txt
160
173
  - README.rdoc
161
174
  - Rakefile
175
+ - TODO.mkd
162
176
  - VERSION
163
177
  - bin/ti
164
178
  - lib/ti.rb
165
- - lib/ti/config
166
- - lib/ti/gitignore
167
- - lib/ti/rakefile
179
+ - lib/ti/generate/model.rb
180
+ - lib/ti/generate/project.rb
181
+ - lib/ti/generate/view.rb
182
+ - lib/ti/logger.rb
183
+ - lib/ti/options.rb
184
+ - lib/ti/parse_options.rb
185
+ - lib/ti/templates/app/app.coffee
186
+ - lib/ti/templates/config
187
+ - lib/ti/templates/gitignore
188
+ - lib/ti/templates/guardfile
189
+ - lib/ti/templates/rakefile
190
+ - lib/ti/templates/readme
191
+ - lib/ti/templates/specs/app_spec.coffee
192
+ - lib/ti/utils.rb
168
193
  - test/helper.rb
169
194
  - test/test_ti.rb
170
195
  - ti.gemspec
@@ -181,6 +206,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
206
  - - ! '>='
182
207
  - !ruby/object:Gem::Version
183
208
  version: '0'
209
+ segments:
210
+ - 0
211
+ hash: 3838389161754621473
184
212
  required_rubygems_version: !ruby/object:Gem::Requirement
185
213
  none: false
186
214
  requirements:
@@ -196,4 +224,3 @@ summary: Ti
196
224
  test_files:
197
225
  - test/helper.rb
198
226
  - test/test_ti.rb
199
- has_rdoc: