ti 0.1.5 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ti (0.1.3)
4
+ ti (0.1.5)
5
5
  coffee-script (~> 2.2.0)
6
6
  colored (~> 1.2)
7
7
  erubis (~> 2.7.0)
data/lib/ti.rb CHANGED
@@ -8,7 +8,6 @@ require 'colored'
8
8
  require 'rocco'
9
9
  require 'thor'
10
10
  require 'erubis'
11
- require 'rbconfig'
12
11
  require 'nokogiri'
13
12
 
14
13
  module Ti
@@ -20,12 +19,18 @@ module Ti
20
19
  OSX_TITANIUM = "/Library/Application\\ Support/Titanium/mobilesdk/osx/#{::Ti::TITANIUM_VERSION}/titanium.py"
21
20
  LINUX_TITANIUM = "$HOME/.titanium/mobilesdk/linux/#{::Ti::TITANIUM_VERSION}/titanium.py"
22
21
 
22
+ autoload :VERSION, 'ti/version.rb'
23
23
  autoload :CLI, 'ti/cli.rb'
24
24
  autoload :Logger, "ti/logger.rb"
25
25
  autoload :Utils, "ti/utils.rb"
26
26
 
27
27
  module Compiler
28
28
  autoload :CoffeeScripts, 'ti/compiler/coffee_scripts.rb'
29
+ autoload :SASSScripts, 'ti/compiler/sass_scripts.rb'
30
+ end
31
+
32
+ module Builder
33
+ autoload :Titanium, "ti/builder/titanium.rb"
29
34
  end
30
35
 
31
36
  module Generate
@@ -35,4 +40,8 @@ module Ti
35
40
  autoload :Controller, "ti/generate/controller.rb"
36
41
  end
37
42
 
43
+ def self.root
44
+ @root ||= Pathname(__FILE__).dirname.expand_path
45
+ end
46
+
38
47
  end
@@ -0,0 +1,19 @@
1
+ module Ti
2
+ module Builder
3
+ class Titanium
4
+ class << self
5
+ require 'rake'
6
+ include ::Ti::Utils
7
+
8
+ # TODO: This should be loaded properly
9
+ load 'config/config.rb'
10
+ include Config
11
+
12
+ def build(platform)
13
+ log "Building with Titanium... DEVICE_TYPE: #{platform}"
14
+ sh %Q{bash -c "#{TI_BUILD} run #{PROJECT_ROOT}/ #{IPHONE_SDK_VERSION} #{APP_ID} #{APP_NAME} #{APP_DEVICE}" | 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;'}
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -24,6 +24,7 @@ module Ti
24
24
  say "Version #{::Ti::VERSION}"
25
25
  end
26
26
 
27
+ map %(n) => 'new'
27
28
  desc "new <name> <id> <platform>", "generates a new Titanium project."
28
29
  long_desc "Generates a new Titanium project. See 'ti help new' for more information.
29
30
  \n\nExamples:
@@ -67,9 +68,23 @@ module Ti
67
68
  :name => name })
68
69
  end
69
70
 
70
- desc "compile", "compiles all CoffeeScripts"
71
- def compile
72
- ::Ti::Compiler::CoffeeScripts.compile_all!
71
+ desc "compile <all/coffee/sass>", "compiles all CoffeeScripts"
72
+ def compile(type)
73
+ case
74
+ when type =~ /all/i
75
+ ::Ti::Compiler::CoffeeScripts.compile_all!
76
+ ::Ti::Compiler::SASSScripts.compile
77
+ when type =~ /coffee/i
78
+ ::Ti::Compiler::CoffeeScripts.compile_all!
79
+ when type =~ /sass/i
80
+ ::Ti::Compiler::SASSScripts.compile
81
+ end
82
+ end
83
+
84
+ map %w(b) => 'build'
85
+ desc "build <all/iphone/android/ipad/desktop/>", "Build the project using Titanium"
86
+ def build(platform)
87
+ ::Ti::Builder::Titanium.build platform
73
88
  end
74
89
 
75
90
  end
@@ -7,21 +7,26 @@ module Ti
7
7
 
8
8
  def compile_all!
9
9
  coffeefile = File.read(base_location.join('Coffeefile')).split("\n").compact.delete_if { |l| l.include?("#") }
10
- files = coffeefile.collect { |a| Dir.glob(coffeefile) }.flatten!
10
+ files = coffeefile.collect { |a| Dir.glob(coffeefile) }.flatten!.uniq
11
11
  if files.nil?
12
12
  log "There are no files to compile."
13
13
  exit(0)
14
14
  end
15
- @contents = ''
16
- files.uniq!.each { |f| @contents << File.read(f) }
15
+
16
+ compile_main
17
17
  compile_location = "Resources/#{underscore(get_app_name).downcase}.js"
18
- compile(@contents, base_location.join(compile_location))
19
- log "Your CoffeeScripts have been compiled to: #{compile_location}"
18
+ compile(files.join(' '), base_location.join(compile_location), :join => true, :bare => true)
19
+ end
20
+
21
+ def compile_main
22
+ compile("app/app.coffee", base_location.join("Resources/app.js"), :bare => true)
20
23
  end
21
24
 
22
- def compile(contents, compile_to_location)
23
- coffeescript = ::CoffeeScript.compile(contents, :no_wrap => false)
24
- File.open(compile_to_location, 'w') { |f| f.write(coffeescript) }
25
+ def compile(files, compile_to_location, options={})
26
+ coffee_options = []
27
+ options.each { |k,v| coffee_options << "--#{k.to_s}" if v} unless options.empty?
28
+ system("coffee -p #{coffee_options.join(' ')} #{files} > #{compile_to_location}")
29
+ log "Your CoffeeScripts have been compiled to: #{compile_to_location}"
25
30
  end
26
31
 
27
32
  end
@@ -0,0 +1,16 @@
1
+ require 'sass'
2
+ module Ti
3
+ module Compiler
4
+ class SASSScripts
5
+ class << self
6
+ include ::Ti::Utils
7
+
8
+ # def compile(contents, compile_to_location)
9
+ def compile
10
+ system "sass --compass -C -t expand app/#{underscore(get_app_name)}/stylesheets/app.sass > Resources/app.jss"
11
+ log "Your SASS have been compiled to: Resources/app.jss"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -27,6 +27,7 @@ module Ti
27
27
  File.open(location.join(filename), 'w') { |f| f.write(contents) }
28
28
 
29
29
  create_new_file("spec/controllers/#{name}_spec.coffee", templates("specs/app_spec.coffee"))
30
+ append_to_router(name, 'controllers')
30
31
  end
31
32
 
32
33
 
@@ -17,6 +17,8 @@ module Ti
17
17
 
18
18
  create_new_file("#{model_directory}/#{name}.coffee")
19
19
  create_new_file("spec/models/#{name}_spec.coffee", templates("specs/app_spec.coffee"))
20
+
21
+ append_to_router(name, 'models')
20
22
  end
21
23
 
22
24
  end
@@ -31,9 +31,10 @@ module Ti
31
31
  def generate_files
32
32
  create_project_directory
33
33
  touch('Readme.mkd')
34
- full_app_hash = {:app_name => @project_name, :app_name_underscore => underscore(@project_name)}
34
+ full_app_hash = {:app_name => @project_name.capitalize, :app_name_underscore => underscore(@project_name), :platform => @device_platform}
35
35
  create_with_template('app/app.coffee', 'app/app.coffee', full_app_hash)
36
36
  create_with_template("app/#{underscore(@project_name)}/app.coffee", 'app/app_project.coffee', full_app_hash)
37
+ create_with_template("app/#{underscore(@project_name)}/api.coffee", 'app/api.coffee', full_app_hash)
37
38
 
38
39
  create_new_file(".gitignore", templates('gitignore'))
39
40
  create_new_file("spec/app_spec.coffee", templates('specs/app_spec.coffee'))
@@ -58,9 +59,11 @@ module Ti
58
59
  'config',
59
60
  'docs',
60
61
  "app/#{underscore(@project_name)}/models",
62
+ "app/#{underscore(@project_name)}/helpers",
61
63
  "app/#{underscore(@project_name)}/views",
62
64
  "app/#{underscore(@project_name)}/stylesheets",
63
- 'spec/models', 'spec/views')
65
+ "app/#{underscore(@project_name)}/stylesheets/partials",
66
+ 'spec/models', 'spec/views', 'spec/helpers')
64
67
  end
65
68
 
66
69
  def remove_old_files
@@ -37,6 +37,7 @@ module Ti
37
37
 
38
38
  create_new_file("spec/views/#{name}_spec.coffee", templates("specs/app_spec.coffee"))
39
39
  create_new_file("app/#{underscore(app_name)}/stylesheets/_#{(context[:domain] || '').downcase}.sass", templates("app/stylesheets/sample.sass"))
40
+ append_to_router(context[:domain].capitalize, 'views')
40
41
  end
41
42
 
42
43
  end
@@ -0,0 +1,61 @@
1
+ class <%= app_name %>.API
2
+
3
+ constructor: (@login, @password) ->
4
+
5
+ requestURI: (path, query={}) ->
6
+ # NOTE: Setup your own API endpoint, as below
7
+ <%= app_name %>.API_ENDPOINT = "http://<%= app_name.downcase %>.com/api/v1"
8
+
9
+ uri = "#{<%= app_name %>.API_ENDPOINT}#{path}.json?"
10
+ for own key, value of query
11
+ uri += "#{ key }=#{ escape(value) }&"
12
+
13
+ uri = uri.replace(/^(&)/g, '')
14
+ uri
15
+
16
+ request: (path, options, authenticated=true) ->
17
+ options.method ?= 'GET'
18
+ options.query ?= {}
19
+ options.success ?= -> Ti.API.info
20
+ options.error ?= -> Ti.API.error
21
+
22
+ xhr = Ti.Network.createHTTPClient()
23
+ xhr.onreadystatechange = (e) ->
24
+ if this.readyState == 4
25
+ try
26
+ data = JSON.parse(this.responseText)
27
+ if data.error?
28
+ options.error(data)
29
+ else
30
+ options.success(data)
31
+ catch exception
32
+ options.error(exception)
33
+ uri = @requestURI(path, options.query)
34
+ xhr.open(options.method, uri)
35
+ xhr.setRequestHeader 'Authorization', 'Basic ' + Ti.Utils.base64encode(@login+':'+@password) if authenticated
36
+
37
+ message = "Executing "
38
+ message += if authenticated then "Authenticated " else "Unauthenticated "
39
+ message += "#{options.method} #{uri}"
40
+ Ti.API.debug(message) if options.debug
41
+
42
+ if options.body?
43
+ xhr.setRequestHeader('Accept', 'application/json')
44
+ xhr.setRequestHeader('Content-Type', 'application/json')
45
+ data = JSON.stringify(options.body)
46
+ Ti.API.debug(data) if options.debug
47
+ xhr.send(data)
48
+ else
49
+ xhr.send()
50
+
51
+ # High level method for GET requests
52
+ get: (path, options, authenticated=true) ->
53
+ options.method = 'GET'
54
+ @request path, options, authenticated
55
+
56
+ # High level method for POST requests
57
+ post: (path, options, authenticated=true) ->
58
+ options.method = 'POST'
59
+ @request path, options, authenticated
60
+
61
+ # Add your API endpoints below
@@ -2,10 +2,22 @@
2
2
  # tab windows.
3
3
  # The `<%= app_name %>` object provides common access to app data, API wrapper and UI utilities
4
4
 
5
- # ## ShwinkersMobile ##
5
+ # ## <%= app_name %> ##
6
6
  <%= app_name %> =
7
- Views:
7
+ Models: {}
8
+ Helpers: {}
9
+ Views: {}
10
+
11
+ # Include your libraries like:
12
+ # Ti.include('vendor/date.js')
13
+ # Ti.include('vendor/underscore.js')
14
+ # Ti.include('vendor/backbone.js')
8
15
 
9
16
  Ti.include('<%= app_name_underscore %>.js')
10
17
 
11
- <%= app_name %>.App.init()
18
+ # Alias, so you could do $.App.init() below. If you have an API class,
19
+ # make sure to either use the full app name or declare the below at the top
20
+ # and use $.API for the class name. Uncomment to use.
21
+ # $ = <%= app_name %>
22
+
23
+ <%= app_name %>.App.init()
@@ -1,111 +1,111 @@
1
1
  <%= app_name %>.App =
2
- init: ->
3
- # This sets the background color of the master UIView
4
- Ti.UI.iPhone.statusBarStyle = Titanium.UI.iPhone.StatusBar.OPAQUE_BLACK
5
-
6
- # Return the currently logged in user from App persisted properties
7
- currentUser: ->
8
- userData = Ti.App.Properties.getString('user')
9
- if userData?
10
- user = JSON.parse(userData)
11
- return user
12
- else
13
- null
14
2
 
15
- # Authenticate a user
16
- authenticate: (login, password) ->
17
- Ti.API.debug('<%= app_name %>.App.authenticate')
3
+ currentUser: ->
4
+ userData = Ti.App.Properties.getString('user')
5
+ if userData?
6
+ user = JSON.parse(userData)
7
+ return user
8
+ else
9
+ null
10
+
11
+ # Attempt to log in with saved creds
12
+ hasCurrentSession: ->
13
+ login = Ti.App.Properties.getString 'login'
14
+ password = Ti.App.Properties.getString 'password'
15
+ if login? and password?
16
+ Ti.API.debug "Found current session with login: #{login} and password: #{password}"
18
17
  this.api = new <%= app_name %>.API(login, password)
19
- this.api.authenticate
20
- success: (user) ->
21
- # Stash the user for `.currentUser()`
22
- Ti.App.Properties.setString('user', JSON.stringify(user))
23
- # Stash the username/password for the user later
24
- Ti.App.Properties.setString 'login', login
25
- Ti.App.Properties.setString 'password', password
26
- # Call any other callbacks
27
- Ti.App.fireEvent 'login:success', user.username
28
- error: (e) ->
29
- Ti.API.error(e)
18
+ else
19
+ Ti.API.debug "No current session found", login, password
20
+ login? and password?
21
+
22
+ getCurrentLocation: (options) ->
23
+ options.success ?= ->
24
+ options.error ?= ->
25
+ Ti.Geolocation.purpose = "Find something near you"
26
+ Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_KILOMETER
27
+ Ti.Geolocation.getCurrentPosition (e) ->
28
+ if !e.success || e.error
29
+ Ti.API.error e.error
30
+ options.error e.error
31
+ options.success e.coords if e.success
32
+
33
+
34
+ # Authenticate a user
35
+ authenticate: (login, password) ->
36
+ Ti.API.debug('<%= app_name %>.App.authenticate')
37
+ @api = new <%= app_name %>.API(login, password)
38
+ @api.authenticate
39
+ success: (user) ->
40
+ Ti.App.Properties.setString('user', JSON.stringify(user))
41
+ Ti.App.Properties.setString('login', login)
42
+ Ti.App.Properties.setString('password', password)
43
+ Ti.App.fireEvent 'login:success', user.username
44
+ error: (e) ->
45
+ Ti.API.error(e)
46
+
47
+ # Registers a new user
48
+ register: (options) ->
49
+ api = new <%= app_name %>.API
50
+ api.register options
51
+
52
+ signOut: ->
53
+ Ti.App.Properties.removeProperty 'user'
54
+ Ti.App.Properties.removeProperty 'login'
55
+ Ti.App.Properties.removeProperty 'password'
56
+ Ti.App.fireEvent 'logout'
30
57
 
31
- # Attempt to login with saved credentials
32
- hasCurrentSession: ->
33
- login = Ti.App.Properties.getString 'login'
34
- password = Ti.App.Properties.getString 'password'
35
- if login? and password?
36
- Ti.API.debug "Found current session with login: #{login}"
37
- this.api = new <%= app_name %>.API(login, password)
38
- else
39
- Ti.API.debug "No current session found", login, password
40
- login? and password?
41
-
42
- # Clears the current session by removing the persisted property for user
43
- signOut: ->
44
- Ti.App.Properties.removeProperty 'user'
45
- Ti.App.Properties.removeProperty 'login'
46
- Ti.App.Properties.removeProperty 'password'
47
- Ti.App.fireEvent 'logout'
58
+ init: ->
59
+ Ti.UI.setBackgroundColor '#000'
60
+ Ti.UI.iPhone.statusBarStyle = Ti.UI.iPhone.StatusBar.OPAQUE_BLACK
48
61
 
49
- # A function to open the login window
50
62
  showLogin = () ->
51
- login = <%= app_name %>.Views.createLoginWindow
52
- title: 'Login'
53
- id: 'loginWindow'
54
-
55
- # Open the login window modally with no nav bar
56
- login.open
57
- modal: true
58
- navBarHidden: true
59
-
60
- <%= app_name %>.App.initTabGroup()
63
+ rootWindow = Ti.UI.createWindow()
64
+ login = <%= app_name %>.Views.Account.createLoginWindow
65
+ title: 'Login'
66
+ id: 'loginWindow'
67
+ <%= app_name %>.App.sessionNavGroup = Ti.UI.iPhone.createNavigationGroup
68
+ window: login
69
+ rootWindow.add <%= app_name %>.App.sessionNavGroup
70
+ Ti.App.addEventListener 'login:success', (e) ->
71
+ rootWindow.close()
72
+ rootWindow.open()
73
+
74
+ loggedIn = <%= app_name %>.App.hasCurrentSession()
75
+
76
+ if loggedIn
77
+ <%= app_name %>.App.initTabGroup()
78
+ else
79
+ showLogin() unless loggedIn
80
+
81
+ # Listen to an app-wide `logout` event and show the login again
82
+ Ti.App.addEventListener 'logout', (e) ->
83
+ showLogin()
84
+
85
+ Ti.App.addEventListener 'login:success', (e) ->
86
+ <%= app_name %>.App.initTabGroup()
61
87
 
62
88
  initTabGroup: ->
63
- # # Create a new TabGroup to manage tabs
64
89
  <%= app_name %>.App.tabGroup = Ti.UI.createTabGroup()
65
90
 
66
- # ### Set up the **sampleWindow**
91
+ # Sample Tab
67
92
  sampleWindow = <%= app_name %>.Views.Sample.createMainWindow
68
- title: 'Sample'
69
- id: 'sampleWindow'
70
-
71
- # Titanium magic to handle orientation changes
72
- orientationModes: [
73
- Ti.UI.PORTRAIT
74
- Ti.UI.UPSIDE_PORTRAIT
75
- Ti.UI.LANDSCAPE_LEFT
76
- Ti.UI.LANDSCAPE_RIGHT
77
- ]
78
-
79
- # ### Set up the Sample Window
80
- <%= app_name %>.App.sampleTab = Ti.UI.createTab
81
- id: 'sampleTab'
82
- className: 'tabElement'
83
- title: 'sample'
84
- window: sampleWindow
85
-
86
- <%= app_name %>.App.tabGroup.addTab <%= app_name %>.App.sampleTab
87
-
88
- # ### Set up the ***Settings Window***
89
- settingsWindow = <%= app_name %>.Views.Settings.createMainWindow
90
- title: 'Settings'
91
- id: 'settingsWindow'
92
-
93
- # Titanium magic to handle orientation changes
94
- orientationModes: [
95
- Ti.UI.PORTRAIT
96
- Ti.UI.UPSIDE_PORTRAIT
97
- Ti.UI.LANDSCAPE_LEFT
98
- Ti.UI.LANDSCAPE_RIGHT
99
- ]
100
-
101
- <%= app_name %>.App.settingsTab = Ti.UI.createTab
102
- id: 'settingsTab'
103
- className: 'tabElement'
104
- title: 'settings'
105
- window: settingsWindow
106
-
107
- <%= app_name %>.App.tabGroup.addTab <%= app_name %>.App.settingsTab
108
-
109
- # Open the TabGroup and first window via selecte tab
110
- <%= app_name %>.App.tabGroup.open()
111
-
93
+ title: 'Sample'
94
+ id: 'sampleWindow'
95
+ orientationModes: <%= app_name %>.Helpers.Application.createOrientiationModes
96
+ <%= app_name %>.App.sampleWindow = Ti.UI.createTab
97
+ id: 'sampleTab'
98
+ className: 'tabElement'
99
+ title: 'Sample'
100
+ window: sampleWindow
101
+
102
+
103
+ # Bottom Tab Loader
104
+ <%= app_name %>.App.tabGroup.addTab <%= app_name %>.App.sampleWindow
105
+
106
+ <%= app_name %>.App.tabGroup.addEventListener 'focus', (e) ->
107
+ <%= app_name %>.App.currentTab = e.tab
108
+ Ti.API.info(<%= app_name %>.App.currentTab)
109
+
110
+ # Open Tabs
111
+ <%= app_name %>.App.tabGroup.open()
@@ -0,0 +1,10 @@
1
+ <%= app_name %>.Helpers.Application =
2
+
3
+ createOrientiationModes: ->
4
+ modes = [
5
+ Titanium.UI.PORTRAIT
6
+ Titanium.UI.UPSIDE_PORTRAIT
7
+ Titanium.UI.LANDSCAPE_LEFT
8
+ Titanium.UI.LANDSCAPE_RIGHT
9
+ ]
10
+ modes
@@ -0,0 +1,22 @@
1
+ <%= app_name %>.DateFormat =
2
+
3
+ relativeDate: (olderDate, newerDate) ->
4
+ olderDate = new Date(olderDate) if (typeof olderDate == "string")
5
+ newerDate = new Date(newerDate) if (typeof newerDate == "string")
6
+
7
+ milliseconds = newerDate - olderDate
8
+
9
+ conversions = [
10
+ ["years", 31518720000]
11
+ ["months", 2626560000]
12
+ ["days", 86400000]
13
+ ["hours", 3600000]
14
+ ["minutes", 60000]
15
+ ["seconds", 1000]
16
+ ]
17
+
18
+ for conversion in conversions
19
+ result = Math.floor(milliseconds / conversion[1])
20
+ return result + " " + conversion[0] + " ago" if result >= 2
21
+
22
+ return "1 second ago"
@@ -1,16 +1,19 @@
1
1
  # Coffeefile for Compiling CoffeeScripts
2
2
  #
3
3
  # Compiled top down. First listed is the first to be added for compiling. You can
4
- # specify specific files to be loaded first and then use the generic wildcard to
4
+ # specify which files to be loaded first and then use a wildcard to
5
5
  # add the rest of the files that don't require specific loading.
6
6
  #
7
7
  # Example
8
+ # app/dailyfocus/app.coffee
8
9
  # app/dailyfocus/models/user.coffee
9
10
  # app/dailyfocus/models/task.coffee
10
11
  # app/dailyfocus/models/**/*.coffee
11
12
  # app/dailyfocus/controllers/**/*.coffee
12
13
  # app/dailyfocus/views/**/*.coffee
13
14
  #
14
- app/<%= app_name %>/models/**/*.coffee
15
- app/<%= app_name %>/controllers/**/*.coffee
16
- app/<%= app_name %>/views/**/*.coffee
15
+ app/<%= app_name_underscore %>/app.coffee
16
+ app/<%= app_name_underscore %>/models/**/*.coffee
17
+ app/<%= app_name_underscore %>/helpers/*.coffee
18
+ app/<%= app_name_underscore %>/controllers/**/*.coffee
19
+ app/<%= app_name_underscore %>/views/**/*.coffee
@@ -3,23 +3,8 @@ require 'nokogiri'
3
3
  require 'colored'
4
4
  require 'betabuilder'
5
5
 
6
- PROJECT_NAME = "<%= app_name %>"
7
- PROJECT_ROOT = File.dirname(__FILE__)
8
-
9
- IPHONE_SDK_VERSION = "4.3"
10
- TI_SDK_VERSION = "1.6.2"
11
- TI_DIR = '/Library/Application\ Support/Titanium'
12
- TI_ASSET_DIR = "#{TI_DIR}/mobilesdk/osx/#{TI_SDK_VERSION}"
13
- TI_IPHONE_DIR = "#{TI_ASSET_DIR}/iphone"
14
- TI_BUILD = "#{TI_IPHONE_DIR}/builder.py"
15
- APP_DEVICE = "iphone"
16
-
17
- # Get APP parameters from current tiapp.xml
18
- config = File.open("tiapp.xml")
19
- doc = Nokogiri::XML(config)
20
- config.close
21
- APP_ID = doc.xpath('ti:app/id').text
22
- APP_NAME = doc.xpath('ti:app/name').text
6
+ require File.expand_path(File.join(Dir.pwd, 'config/config.rb'))
7
+ include Config
23
8
 
24
9
  BetaBuilder::Tasks.new do |config|
25
10
  # App Name
@@ -1 +1 @@
1
- # <%= app_name %> - Generated by Ti
1
+ # <%= app_name %> - Created with Ti, the rapid development framework.
@@ -1,17 +1,24 @@
1
+ require 'fileutils'
2
+ # TODO: remove
1
3
  require 'nokogiri'
2
4
 
3
5
  module Config
6
+ # TODO: These need to be removed.
4
7
  config = File.open('tiapp.xml')
5
8
  doc = Nokogiri::XML(config)
6
9
  config.close
7
10
 
11
+ # TODO: Project name and root don't have any meaning once building of the devise is within ti core.
8
12
  PROJECT_NAME = "<%= app_name %>"
9
- PROJECT_ROOT = File.dirname(__FILE__)
13
+ PROJECT_ROOT = FileUtils.pwd()
10
14
  PROJECT_VERSION = "0.0.1"
11
15
 
12
16
  IPHONE_SDK_VERSION = "4.3"
13
17
  ANDROID_SDK_VERSION = ""
14
18
 
19
+ # TODO: In Ti itself, we have the sdk version and the ti directory locations. We should use this configuration instead of
20
+ # the one within Ti itself. This will allow the user to decide if they're building on a different version or have
21
+ # Titanium in a different location.
15
22
  TI_SDK_VERSION = "1.6.2"
16
23
  TI_DIR = "/Library/Application\\ Support/Titanium"
17
24
 
@@ -21,7 +28,8 @@ module Config
21
28
  TI_BUILD = "#{TI_IPHONE_DIR}/builder.py"
22
29
 
23
30
  # Application
31
+ # TODO: No reason for having APP_ID or APP_NAME. Still thinking through APP_DEVISE.
24
32
  APP_ID = doc.xpath('ti:app/id').text
25
33
  APP_NAME = doc.xpath('ti:app/name').text
26
- APP_DEVICE = "iphone"
34
+ APP_DEVICE = "<%= platform %>"
27
35
  end
@@ -4,7 +4,9 @@ module Ti
4
4
  def create_new_file(name, file=nil)
5
5
  log "Creating #{name}"
6
6
  contents = file.nil? ? '' : File.read(file)
7
- File.open(location.join(name), 'w') { |f| f.write(contents) }
7
+ unless File.file?(location.join(name))
8
+ File.open(location.join(name), 'w') { |f| f.write(contents) }
9
+ end
8
10
  end
9
11
 
10
12
  def get_app_name
@@ -52,9 +54,20 @@ module Ti
52
54
  File.open(location.join(name.gsub(/^\//, '')), 'w') { |f| f.write(eruby.result(contents))}
53
55
  end
54
56
 
57
+ def append_to_router(name, type)
58
+ router_contents = File.read(location.join("app/app.coffee"))
59
+
60
+ if router_contents.include?(type.capitalize)
61
+ contents = router_contents.sub( "#{type.capitalize}:", "#{type.capitalize}:\n #{name.capitalize}: {}" )
62
+ else
63
+ contents = router_contents.sub("#{get_app_name} =", "#{get_app_name} =\n\t#{type.capitalize}:\n #{name.capitalize}: {}\n")
64
+ end
65
+ File.open(location.join("app/app.coffee"), 'w') { |f| f.write(contents) }
66
+ end
67
+
55
68
 
56
69
  def templates(path)
57
- ::Ti::ROOT_PATH.join('ti/templates').join(path)
70
+ ::Ti.root.join('ti/templates').join(path)
58
71
  end
59
72
 
60
73
 
@@ -1,3 +1,3 @@
1
1
  module Ti
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ date: 2011-05-23 00:00:00.000000000Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: sass
19
- requirement: &2158422720 !ruby/object:Gem::Requirement
19
+ requirement: &2153826940 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ~>
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 3.1.1
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2158422720
27
+ version_requirements: *2153826940
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: guard-sass
30
- requirement: &2158422200 !ruby/object:Gem::Requirement
30
+ requirement: &2153826380 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ~>
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: 0.0.6
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *2158422200
38
+ version_requirements: *2153826380
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: guard
41
- requirement: &2158421720 !ruby/object:Gem::Requirement
41
+ requirement: &2153825860 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ~>
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: 0.3.4
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *2158421720
49
+ version_requirements: *2153825860
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: guard-coffeescript
52
- requirement: &2158421240 !ruby/object:Gem::Requirement
52
+ requirement: &2153825340 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: 0.2.0
58
58
  type: :runtime
59
59
  prerelease: false
60
- version_requirements: *2158421240
60
+ version_requirements: *2153825340
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: guard-livereload
63
- requirement: &2158420760 !ruby/object:Gem::Requirement
63
+ requirement: &2153824840 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ~>
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: 0.1.10
69
69
  type: :runtime
70
70
  prerelease: false
71
- version_requirements: *2158420760
71
+ version_requirements: *2153824840
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: jasmine
74
- requirement: &2158420280 !ruby/object:Gem::Requirement
74
+ requirement: &2153824320 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ~>
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: 1.0.2.0
80
80
  type: :runtime
81
81
  prerelease: false
82
- version_requirements: *2158420280
82
+ version_requirements: *2153824320
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: coffee-script
85
- requirement: &2158419800 !ruby/object:Gem::Requirement
85
+ requirement: &2153823800 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ~>
@@ -90,10 +90,10 @@ dependencies:
90
90
  version: 2.2.0
91
91
  type: :runtime
92
92
  prerelease: false
93
- version_requirements: *2158419800
93
+ version_requirements: *2153823800
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: colored
96
- requirement: &2158419320 !ruby/object:Gem::Requirement
96
+ requirement: &2153823300 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ~>
@@ -101,10 +101,10 @@ dependencies:
101
101
  version: '1.2'
102
102
  type: :runtime
103
103
  prerelease: false
104
- version_requirements: *2158419320
104
+ version_requirements: *2153823300
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: rake
107
- requirement: &2158418840 !ruby/object:Gem::Requirement
107
+ requirement: &2153822780 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
110
  - - ~>
@@ -112,10 +112,10 @@ dependencies:
112
112
  version: 0.8.7
113
113
  type: :runtime
114
114
  prerelease: false
115
- version_requirements: *2158418840
115
+ version_requirements: *2153822780
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: nokogiri
118
- requirement: &2158412200 !ruby/object:Gem::Requirement
118
+ requirement: &2153822260 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ~>
@@ -123,10 +123,10 @@ dependencies:
123
123
  version: 1.4.4
124
124
  type: :runtime
125
125
  prerelease: false
126
- version_requirements: *2158412200
126
+ version_requirements: *2153822260
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: erubis
129
- requirement: &2158411700 !ruby/object:Gem::Requirement
129
+ requirement: &2153821740 !ruby/object:Gem::Requirement
130
130
  none: false
131
131
  requirements:
132
132
  - - ~>
@@ -134,10 +134,10 @@ dependencies:
134
134
  version: 2.7.0
135
135
  type: :runtime
136
136
  prerelease: false
137
- version_requirements: *2158411700
137
+ version_requirements: *2153821740
138
138
  - !ruby/object:Gem::Dependency
139
139
  name: bundler
140
- requirement: &2158411180 !ruby/object:Gem::Requirement
140
+ requirement: &2153821240 !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
143
143
  - - ~>
@@ -145,10 +145,10 @@ dependencies:
145
145
  version: 1.0.10
146
146
  type: :development
147
147
  prerelease: false
148
- version_requirements: *2158411180
148
+ version_requirements: *2153821240
149
149
  - !ruby/object:Gem::Dependency
150
150
  name: rspec
151
- requirement: &2158410660 !ruby/object:Gem::Requirement
151
+ requirement: &2153820720 !ruby/object:Gem::Requirement
152
152
  none: false
153
153
  requirements:
154
154
  - - ~>
@@ -156,10 +156,10 @@ dependencies:
156
156
  version: 2.5.0
157
157
  type: :development
158
158
  prerelease: false
159
- version_requirements: *2158410660
159
+ version_requirements: *2153820720
160
160
  - !ruby/object:Gem::Dependency
161
161
  name: rocco
162
- requirement: &2158410160 !ruby/object:Gem::Requirement
162
+ requirement: &2153820200 !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements:
165
165
  - - ~>
@@ -167,7 +167,7 @@ dependencies:
167
167
  version: '0.6'
168
168
  type: :development
169
169
  prerelease: false
170
- version_requirements: *2158410160
170
+ version_requirements: *2153820200
171
171
  description: Titanium Rapid Development Framework
172
172
  email: robert@codewranglers.org
173
173
  executables:
@@ -187,19 +187,24 @@ files:
187
187
  - TODO.mkd
188
188
  - bin/ti
189
189
  - lib/ti.rb
190
+ - lib/ti/builder/titanium.rb
190
191
  - lib/ti/cli.rb
191
192
  - lib/ti/compiler/coffee_scripts.rb
193
+ - lib/ti/compiler/sass_scripts.rb
192
194
  - lib/ti/config.rb
193
195
  - lib/ti/generate/controller.rb
194
196
  - lib/ti/generate/model.rb
195
197
  - lib/ti/generate/project.rb
196
198
  - lib/ti/generate/view.rb
197
199
  - lib/ti/logger.rb
200
+ - lib/ti/templates/app/api.coffee.erb
198
201
  - lib/ti/templates/app/app.coffee
199
202
  - lib/ti/templates/app/app.coffee.erb
200
203
  - lib/ti/templates/app/app_project.coffee.erb
201
204
  - lib/ti/templates/app/controllers/controller.erb
202
205
  - lib/ti/templates/app/controllers/window.erb
206
+ - lib/ti/templates/app/helpers/application.coffee.erb
207
+ - lib/ti/templates/app/helpers/date_format.coffee.erb
203
208
  - lib/ti/templates/app/stylesheets/app.sass
204
209
  - lib/ti/templates/app/stylesheets/sample.sass
205
210
  - lib/ti/templates/app/views/generic.erb