ti 0.0.6 → 0.1.0
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/.gitignore +43 -0
- data/Gemfile +2 -19
- data/Gemfile.lock +27 -27
- data/LICENSE.txt +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +0 -28
- data/TODO.mkd +1 -2
- data/lib/ti.rb +10 -10
- data/lib/ti/cli.rb +39 -6
- data/lib/ti/config.rb +22 -0
- data/lib/ti/generate/controller.rb +38 -0
- data/lib/ti/generate/model.rb +13 -7
- data/lib/ti/generate/project.rb +59 -13
- data/lib/ti/generate/view.rb +30 -9
- data/lib/ti/templates/app/controllers/controller.erb +0 -0
- data/lib/ti/templates/app/controllers/window.erb +3 -0
- data/lib/ti/templates/app/views/tabgroup.erb +0 -0
- data/lib/ti/templates/app/views/view.erb +0 -0
- data/lib/ti/templates/app/views/window.erb +3 -0
- data/lib/ti/templates/{guardfile → defaults/Guardfile.erb} +3 -3
- data/lib/ti/templates/defaults/Rakefile.erb +148 -0
- data/lib/ti/templates/defaults/Readme.mkd.erb +1 -0
- data/lib/ti/templates/{config → defaults/config.erb} +1 -1
- data/lib/ti/templates/gitignore +1 -1
- data/lib/ti/templates/specs/app_spec.coffee +2 -2
- data/lib/ti/utils.rb +70 -41
- data/lib/ti/version.rb +3 -0
- data/spec/cli/command_spec.rb +7 -11
- data/spec/fixtures/configs/tiapp.xml +34 -0
- data/spec/lib/config_spec.rb +34 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/ti/generators/model_spec.rb +25 -0
- data/spec/ti/generators/project_spec.rb +121 -0
- data/spec/ti/generators/view_spec.rb +25 -0
- data/spec/ti/logger_spec.rb +25 -0
- data/spec/ti/utils_spec.rb +120 -0
- data/ti.gemspec +32 -103
- metadata +75 -47
- data/VERSION +0 -1
- data/lib/ti/options.rb +0 -64
- data/lib/ti/parse_options.rb +0 -48
- data/lib/ti/templates/readme +0 -1
data/.gitignore
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
*.gem
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
|
15
|
+
# jeweler generated
|
16
|
+
pkg
|
17
|
+
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
+
#
|
20
|
+
# * Create a file at ~/.gitignore
|
21
|
+
# * Include files you want ignored
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
+
#
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
26
|
+
#
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
+
#
|
29
|
+
# For MacOS:
|
30
|
+
#
|
31
|
+
.DS_Store
|
32
|
+
#
|
33
|
+
# For TextMate
|
34
|
+
*.tmproj
|
35
|
+
#tmtags
|
36
|
+
#
|
37
|
+
# For emacs:
|
38
|
+
*~
|
39
|
+
\#*
|
40
|
+
.\#*
|
41
|
+
#
|
42
|
+
# For vim:
|
43
|
+
*.swp
|
data/Gemfile
CHANGED
@@ -1,21 +1,4 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
|
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"
|
15
|
-
end
|
16
|
-
|
17
|
-
group :development do
|
18
|
-
gem "bundler", "~> 1.0.10"
|
19
|
-
gem "jeweler", "~> 1.5.2"
|
20
|
-
gem "rspec", "~> 2.5.0"
|
21
|
-
end
|
3
|
+
# Specify your gem's dependencies in ti.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
|
2
|
-
remote:
|
3
|
-
revision: 6bcf5f4de45d1b994468ad51cec68298ed3d9c5e
|
1
|
+
PATH
|
2
|
+
remote: .
|
4
3
|
specs:
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
ti (0.1.0)
|
5
|
+
coffee-script (~> 2.2.0)
|
6
|
+
colored (~> 1.2)
|
7
|
+
erubis (~> 2.7.0)
|
8
|
+
guard (~> 0.3.4)
|
9
|
+
guard-coffeescript (~> 0.2.0)
|
10
|
+
guard-livereload (~> 0.1.10)
|
11
|
+
guard-sass (~> 0.0.6)
|
12
|
+
jasmine (~> 1.0.2.0)
|
13
|
+
nokogiri (~> 1.4.4)
|
14
|
+
rake (~> 0.8.7)
|
15
|
+
rocco (~> 0.6)
|
16
|
+
sass (~> 3.1.1)
|
8
17
|
|
9
18
|
GEM
|
10
19
|
remote: http://rubygems.org/
|
@@ -15,40 +24,41 @@ GEM
|
|
15
24
|
coffee-script (2.2.0)
|
16
25
|
coffee-script-source
|
17
26
|
execjs
|
18
|
-
coffee-script-source (1.0
|
27
|
+
coffee-script-source (1.1.0)
|
19
28
|
colored (1.2)
|
20
29
|
diff-lcs (1.1.2)
|
21
30
|
em-websocket (0.2.1)
|
22
31
|
addressable (>= 2.1.1)
|
23
32
|
eventmachine (>= 0.12.9)
|
33
|
+
erubis (2.7.0)
|
24
34
|
eventmachine (0.12.10)
|
25
|
-
execjs (0.3.
|
35
|
+
execjs (0.3.3)
|
26
36
|
multi_json (~> 1.0)
|
27
37
|
ffi (1.0.7)
|
28
38
|
rake (>= 0.8.7)
|
29
|
-
git (1.2.5)
|
30
39
|
guard (0.3.4)
|
31
40
|
thor (~> 0.14.6)
|
32
41
|
guard-coffeescript (0.2.0)
|
33
42
|
coffee-script (~> 2.2.0)
|
34
43
|
guard (~> 0.3.0)
|
35
|
-
guard-livereload (0.1.
|
44
|
+
guard-livereload (0.1.11)
|
36
45
|
em-websocket (~> 0.2.0)
|
37
46
|
guard (>= 0.2.2)
|
38
47
|
json (~> 1.5.1)
|
48
|
+
guard-sass (0.0.6)
|
49
|
+
guard (>= 0.2.1)
|
50
|
+
haml (~> 3.0.0)
|
51
|
+
haml (3.0.25)
|
39
52
|
jasmine (1.0.2.0)
|
40
53
|
json_pure (>= 1.4.3)
|
41
54
|
rack (>= 1.1)
|
42
55
|
rspec (>= 1.3.1)
|
43
56
|
selenium-webdriver (>= 0.1.3)
|
44
|
-
jeweler (1.5.2)
|
45
|
-
bundler (~> 1.0.0)
|
46
|
-
git (>= 1.2.5)
|
47
|
-
rake
|
48
57
|
json (1.5.1)
|
49
58
|
json_pure (1.5.1)
|
50
|
-
multi_json (1.0.
|
59
|
+
multi_json (1.0.1)
|
51
60
|
mustache (0.99.3)
|
61
|
+
nokogiri (1.4.4)
|
52
62
|
rack (1.2.2)
|
53
63
|
rake (0.8.7)
|
54
64
|
rdiscount (1.6.8)
|
@@ -59,7 +69,7 @@ GEM
|
|
59
69
|
rspec-core (~> 2.5.0)
|
60
70
|
rspec-expectations (~> 2.5.0)
|
61
71
|
rspec-mocks (~> 2.5.0)
|
62
|
-
rspec-core (2.5.
|
72
|
+
rspec-core (2.5.2)
|
63
73
|
rspec-expectations (2.5.0)
|
64
74
|
diff-lcs (~> 1.1.2)
|
65
75
|
rspec-mocks (2.5.0)
|
@@ -77,15 +87,5 @@ PLATFORMS
|
|
77
87
|
|
78
88
|
DEPENDENCIES
|
79
89
|
bundler (~> 1.0.10)
|
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)
|
87
|
-
jeweler (~> 1.5.2)
|
88
|
-
rake (~> 0.8.7)
|
89
|
-
rocco (~> 0.6)
|
90
90
|
rspec (~> 2.5.0)
|
91
|
-
|
91
|
+
ti!
|
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -11,23 +11,6 @@ end
|
|
11
11
|
require 'rake'
|
12
12
|
require 'time'
|
13
13
|
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "ti"
|
18
|
-
gem.homepage = "http://github.com/revans/ti"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Ti}
|
21
|
-
gem.description = %Q{Titanium Project Generator}
|
22
|
-
gem.email = "robert@codewranglers.org"
|
23
|
-
gem.authors = ["Robert R Evans", "Julius Francisco", 'Wynn Netherland', 'Rupak Ganguly']
|
24
|
-
gem.date = Time.now.strftime("%Y-%m-%d")
|
25
|
-
gem.executables = ["ti"]
|
26
|
-
gem.version = File.read(File.join(File.dirname(__FILE__), 'VERSION')).chomp
|
27
|
-
|
28
|
-
end
|
29
|
-
Jeweler::RubygemsDotOrgTasks.new
|
30
|
-
|
31
14
|
require 'rake/testtask'
|
32
15
|
Rake::TestTask.new(:test) do |test|
|
33
16
|
test.libs << 'lib' << 'test'
|
@@ -37,17 +20,6 @@ end
|
|
37
20
|
|
38
21
|
task :default => :test
|
39
22
|
|
40
|
-
require 'rake/rdoctask'
|
41
|
-
Rake::RDocTask.new do |rdoc|
|
42
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
-
|
44
|
-
rdoc.rdoc_dir = 'rdoc'
|
45
|
-
rdoc.title = "ti #{version}"
|
46
|
-
rdoc.rdoc_files.include('README*')
|
47
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
23
|
require 'rspec/core'
|
52
24
|
require 'rspec/core/rake_task'
|
53
25
|
|
data/TODO.mkd
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
* CoffeeScript Compiling doesn't work because "path" needs to be implemented. The idea is to make this a dynamic lookup.
|
4
4
|
* Need to remove the perl script in the rakefile
|
5
5
|
* Documentation.
|
6
|
-
* Currently, using a home-brewed option parser, which works. Once I figure out why Thor is error-ing out on my system, I'll re implement with Thor.
|
7
6
|
* Need to write a guard-jasmine gem.
|
8
7
|
|
9
8
|
## Ideas
|
@@ -20,4 +19,4 @@ I love autotest for rails. I'd like to have the coffee-scripts auto compiling, s
|
|
20
19
|
|
21
20
|
When doing small upgrades/changes, use patch versioning.
|
22
21
|
Once everything is in this, and it's well tested, we can go to version
|
23
|
-
1.0
|
22
|
+
1.0
|
data/lib/ti.rb
CHANGED
@@ -3,32 +3,32 @@ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) ||
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'pathname'
|
5
5
|
require 'fileutils'
|
6
|
+
require 'rbconfig'
|
6
7
|
require 'colored'
|
7
8
|
require 'rocco'
|
8
9
|
require 'thor'
|
9
|
-
|
10
|
-
require '
|
10
|
+
require 'erubis'
|
11
|
+
require 'rbconfig'
|
12
|
+
require 'nokogiri'
|
11
13
|
|
12
14
|
module Ti
|
13
|
-
VERSION = File.read(File.join(File.dirname(__FILE__), '../VERSION')).chomp
|
14
15
|
ROOT_PATH = Pathname(__FILE__).dirname.expand_path
|
15
16
|
TITANIUM_VERSION = '1.6.2'
|
16
17
|
|
17
18
|
# TODO: Need to support those how have install Titanium in their $HOME dir.
|
18
|
-
|
19
|
-
OSX_TITANIUM
|
20
|
-
LINUX_TITANIUM
|
19
|
+
OSX_TITANIUM_HOME = "$HOME/Library/Application\\ Support/Titanium/mobilesdk/osx/#{::Ti::TITANIUM_VERSION}/titanium.py"
|
20
|
+
OSX_TITANIUM = "/Library/Application\\ Support/Titanium/mobilesdk/osx/#{::Ti::TITANIUM_VERSION}/titanium.py"
|
21
|
+
LINUX_TITANIUM = "$HOME/.titanium/mobilesdk/linux/#{::Ti::TITANIUM_VERSION}/titanium.py"
|
21
22
|
|
22
23
|
autoload :CLI, 'ti/cli.rb'
|
23
|
-
autoload :Options, 'ti/options.rb'
|
24
|
-
autoload :ParseOptions, 'ti/parse_options.rb'
|
25
24
|
autoload :Logger, "ti/logger.rb"
|
26
25
|
autoload :Utils, "ti/utils.rb"
|
27
|
-
|
26
|
+
|
28
27
|
module Generate
|
29
28
|
autoload :Project, "ti/generate/project.rb"
|
30
29
|
autoload :Model, "ti/generate/model.rb"
|
31
|
-
autoload :View,
|
30
|
+
autoload :View, "ti/generate/view.rb"
|
31
|
+
autoload :Controller, "ti/generate/controller.rb"
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
data/lib/ti/cli.rb
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
module Ti
|
2
2
|
class CLI < Thor
|
3
|
-
|
3
|
+
include Utils
|
4
|
+
|
4
5
|
STATUS_TYPES = {:success => 0,
|
5
6
|
:general_error => 1,
|
6
7
|
:not_supported => 3,
|
7
8
|
:not_found => 4,
|
8
9
|
:incorrect_usage => 64,
|
9
10
|
}
|
10
|
-
|
11
|
+
|
12
|
+
no_tasks {
|
13
|
+
def cli_error(message, exit_status=nil)
|
14
|
+
$stderr.puts message
|
15
|
+
exit_status = STATUS_TYPES[exit_status] if exit_status.is_a?(Symbol)
|
16
|
+
exit exit_status || 1
|
17
|
+
end
|
18
|
+
}
|
19
|
+
|
20
|
+
### TODO: When these commands list grows big, we need to move them into a seperate commands.rb file
|
11
21
|
map %w(--version -v) => 'info'
|
12
22
|
desc "info", "information about Ti."
|
13
23
|
def info
|
@@ -15,7 +25,7 @@ module Ti
|
|
15
25
|
end
|
16
26
|
|
17
27
|
desc "new <name> <id> <platform>", "generates a new Titanium project."
|
18
|
-
long_desc "Generates a new Titanium project. See 'ti help
|
28
|
+
long_desc "Generates a new Titanium project. See 'ti help new' for more information.
|
19
29
|
\n\nExamples:
|
20
30
|
\n\nti new demo ==> Creates a new project with a default id (org.mycompany.demo) and sets the project platform to iphone.
|
21
31
|
\n\nti new demo com.youwantit.dontyou ==> Creates a new project 'demo' with the id of 'com.youwantit.dontyou' to be used on the iphone.
|
@@ -25,15 +35,38 @@ module Ti
|
|
25
35
|
end
|
26
36
|
|
27
37
|
map %w(g) => 'generate'
|
28
|
-
desc "generate <model/view> <name>", "generate a new model or view with jasmine specs."
|
38
|
+
desc "generate <model/controller/view> <name>", "generate a new model or view with jasmine specs."
|
29
39
|
def generate(type, name)
|
30
40
|
case
|
31
41
|
when type =~ /model/i
|
32
42
|
::Ti::Generate::Model.create(name)
|
33
43
|
when type =~ /view/i
|
34
44
|
::Ti::Generate::View.create(name)
|
45
|
+
when type =~ /controller/i
|
46
|
+
::Ti::Generate::Controller.create(name)
|
35
47
|
end
|
36
48
|
end
|
37
|
-
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
map %w(s) => 'scaffold'
|
53
|
+
desc "scaffold <window/tabgroup/view> <domain> <name>", "generate a scaffold for Titanium elements."
|
54
|
+
def scaffold(ti_type, domain, name)
|
55
|
+
::Ti::Generate::View.create(name, {
|
56
|
+
:domain => domain,
|
57
|
+
:ti_type => ti_type,
|
58
|
+
:app_name => get_app_name,
|
59
|
+
:name => name })
|
60
|
+
end
|
61
|
+
|
62
|
+
map %w(c) => 'controller'
|
63
|
+
desc "controller <window> <name>", "generate a controller for Titanium"
|
64
|
+
def controller(ti_type, name)
|
65
|
+
::Ti::Generate::Controller.create(name, {
|
66
|
+
:ti_type => ti_type,
|
67
|
+
:app_name => get_app_name,
|
68
|
+
:name => name })
|
69
|
+
end
|
70
|
+
|
38
71
|
end
|
39
|
-
end
|
72
|
+
end
|
data/lib/ti/config.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Ti
|
4
|
+
class Config
|
5
|
+
attr_accessor :id, :name, :version, :publisher, :url, :description, :copyright
|
6
|
+
|
7
|
+
def parse(filename)
|
8
|
+
xml = File.open(filename)
|
9
|
+
doc = Nokogiri::XML(xml)
|
10
|
+
xml.close
|
11
|
+
# parse into properties
|
12
|
+
@id = doc.xpath('ti:app/id').text
|
13
|
+
@name = doc.xpath('ti:app/name').text
|
14
|
+
@version = doc.xpath('ti:app/version').text
|
15
|
+
@publisher = doc.xpath('ti:app/publisher').text
|
16
|
+
@url = doc.xpath('ti:app/url').text
|
17
|
+
@description = doc.xpath('ti:app/description').text
|
18
|
+
@copyright = doc.xpath('ti:app/copyright').text
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Ti
|
2
|
+
module Generate
|
3
|
+
class Controller
|
4
|
+
class << self
|
5
|
+
include Utils
|
6
|
+
|
7
|
+
def create(name, context={})
|
8
|
+
create_controller_file(name, context)
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def create_controller_file(name, context)
|
13
|
+
log "Creating #{name} controller using a template."
|
14
|
+
controller_directory = "app/#{underscore(get_app_name)}/controllers"
|
15
|
+
|
16
|
+
case context[:ti_type]
|
17
|
+
when 'window'
|
18
|
+
template = templates("app/controllers/window.erb")
|
19
|
+
else
|
20
|
+
template = templates("app/controllers/controller.erb")
|
21
|
+
end
|
22
|
+
|
23
|
+
payload = Pathname.new("#{controller_directory}/#{context[:domain].downcase}")
|
24
|
+
contents = Erubis::Eruby.new(File.read(template)).result(context) if template
|
25
|
+
create_directories(payload) unless File.directory?(payload)
|
26
|
+
create_directories("spec/controllers") unless File.directory?("spec/controllers")
|
27
|
+
|
28
|
+
filename = payload.join("#{name.downcase}.coffee")
|
29
|
+
File.open(location.join(filename), 'w') { |f| f.write(contents) }
|
30
|
+
|
31
|
+
create_new_file("spec/controllers/#{name}_spec.coffee", templates("specs/app_spec.coffee"))
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/ti/generate/model.rb
CHANGED
@@ -2,18 +2,24 @@ module Ti
|
|
2
2
|
module Generate
|
3
3
|
class Model
|
4
4
|
class << self
|
5
|
-
include Utils
|
5
|
+
include ::Ti::Utils
|
6
6
|
|
7
|
-
def create(name
|
8
|
-
|
9
|
-
create_new_file("specs/models/#{name}_spec.coffee", File.read(::Ti::ROOT_PATH.join("ti/templates/specs/app_spec.coffee")))
|
7
|
+
def create(name)
|
8
|
+
create_model_file(name)
|
10
9
|
end
|
11
10
|
|
12
|
-
def
|
13
|
-
|
11
|
+
def create_model_file(name)
|
12
|
+
log "Creating a new model file named #{name}."
|
13
|
+
model_directory = "app/#{underscore(get_app_name)}/models"
|
14
|
+
|
15
|
+
create_directories(model_directory) unless File.directory?(model_directory)
|
16
|
+
create_directories("spec/models") unless File.directory?("spec/models")
|
17
|
+
|
18
|
+
create_new_file("#{model_directory}/#{name}.coffee")
|
19
|
+
create_new_file("spec/models/#{name}_spec.coffee", templates("specs/app_spec.coffee"))
|
14
20
|
end
|
15
21
|
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
19
|
-
end
|
25
|
+
end
|