res/generators/rhogen.rb in rhodes-5.5.0.3 vs res/generators/rhogen.rb in rhodes-5.5.0.7
- old
+ new
@@ -58,18 +58,18 @@
end
alias_method :module_name, :class_name
end
- class AppGenerator < BaseGenerator
+ class RubyAppGenerator < BaseGenerator
def self.source_root
File.join(File.dirname(__FILE__), 'templates', 'application')
end
desc <<-DESC
- Generates a new rhodes application.
+ Generates a new ruby-based rhodes application.
Options:
--rhoconnect - include rhoconnect-client in application
Required:
@@ -284,17 +284,209 @@
template.source = 'Rakefile'
template.destination = "#{name}/Rakefile"
end
end
- class ModelGenerator < BaseGenerator
+ class JavascriptAppGenerator < BaseGenerator
+
def self.source_root
+ File.join(File.dirname(__FILE__), 'templates', 'application')
+ end
+
+ desc <<-DESC
+ Generates a new javascript-based rhodes application.
+
+ Options:
+ --rhoconnect - include rhoconnect-client in application
+
+ Required:
+ name - application name
+
+ Optional:
+ syncserver - url to the rhosync application (i.e. "http://localhost:9292")
+ zip_url - optional url to zipfile download of bundle (this can be your RhoHub Bundle URL)
+ DESC
+
+ #option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
+
+ option :rhoconnect, :desc => '', :as => :boolean, :default => false
+
+ first_argument :name, :required => true, :desc => 'application name'
+ second_argument :syncserver, :required => false, :desc => 'url to the source adapter (i.e. "" or "http://rhosync.rhohub.com/apps/myapp/sources/")'
+ third_argument :zip_url, :required => false, :desc => 'optional url to zipfile download of bundle'
+
+ invoke :appResources
+
+ template :config do |template|
+ zip_url ||= ''
+ syncserver ||= ''
+ template.source = 'javascript_rhoconfig.txt'
+ template.destination = "#{name}/rhoconfig.txt"
+ end
+
+ template :buildyml do |template|
+ @sdk_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
+ @sdk_path.gsub!('\\', '/')
+ @app_name = name
+ @app_name_cleared = name.downcase.split(/[^a-zA-Z0-9\.\-]/).map { |w| w.downcase }.join("")
+ puuid = UUID.new
+ generated_uuid = puuid.generate
+ @productid = generated_uuid
+ @uid = '0x'+(0xE0000000 + rand(0xFFFFFFF)).to_s(16)
+ @rhoconnectclient_ext = '"rhoconnect-client"' if rhoconnect
+ template.source = 'javascript_build.yml'
+ template.destination = "#{name}/build.yml"
+ end
+
+ template :gitignore do |template|
+ template.source = 'gitignore'
+ template.destination = "#{name}/.gitignore"
+ end
+
+ template :rubyversion do |template|
+ template.source = 'ruby-version'
+ template.destination = "#{name}/.ruby-version"
+ end
+
+ template :gemfile do |template|
+ template.source = 'Gemfile'
+ template.destination = "#{name}/Gemfile"
+ end
+
+ template :application do |template|
+ template.source = 'app/javascript_index.html'
+ template.destination = "#{name}/app/index.html"
+ end
+
+ file :applicationScript do |file|
+ file.source = 'app/javascript_index.js'
+ file.destination = "#{name}/app/index.js"
+ end
+
+ template :options do |template|
+ template.source = 'app/Settings/javascript_index.html'
+ template.destination = "#{name}/app/Settings/index.html"
+ end
+
+ template :login do |template|
+ template.source = 'app/Settings/javascript_login.html'
+ template.destination = "#{name}/app/Settings/login.html"
+ end
+
+ template :loading do |template|
+ template.source = 'app/loading.html'
+ template.destination = "#{name}/app/loading.html"
+ end
+
+ file :loadingpng do |file|
+ file.source = 'app/loading.png'
+ file.destination = "#{name}/app/loading.png"
+ end
+
+ file :loadingpng5 do |file|
+ file.source = 'app/loading-568h@2x.png'
+ file.destination = "#{name}/app/loading-568h@2x.png"
+ end
+
+ file :loadingpng51 do |file|
+ file.source = 'app/loading-667h@2x.png'
+ file.destination = "#{name}/app/loading-667h@2x.png"
+ end
+
+ file :loadingpng52 do |file|
+ file.source = 'app/loading-736h@3x.png'
+ file.destination = "#{name}/app/loading-736h@3x.png"
+ end
+
+ file :loadingpngl do |file|
+ file.source = 'app/loading-Landscape.png'
+ file.destination = "#{name}/app/loading-Landscape.png"
+ end
+
+ file :loadingpngll do |file|
+ file.source = 'app/loading-LandscapeLeft.png'
+ file.destination = "#{name}/app/loading-LandscapeLeft.png"
+ end
+
+ file :loadingpnglr do |file|
+ file.source = 'app/loading-LandscapeRight.png'
+ file.destination = "#{name}/app/loading-LandscapeRight.png"
+ end
+
+ file :loadingpngp do |file|
+ file.source = 'app/loading-Portrait.png'
+ file.destination = "#{name}/app/loading-Portrait.png"
+ end
+
+ file :loadingpngpud do |file|
+ file.source = 'app/loading-PortraitUpsideDown.png'
+ file.destination = "#{name}/app/loading-PortraitUpsideDown.png"
+ end
+
+ file :loadingpngl2 do |file|
+ file.source = 'app/loading-Landscape@2x.png'
+ file.destination = "#{name}/app/loading-Landscape@2x.png"
+ end
+
+ file :loadingpngll2 do |file|
+ file.source = 'app/loading-LandscapeLeft@2x.png'
+ file.destination = "#{name}/app/loading-LandscapeLeft@2x.png"
+ end
+
+ file :loadingpnglr2 do |file|
+ file.source = 'app/loading-LandscapeRight@2x.png'
+ file.destination = "#{name}/app/loading-LandscapeRight@2x.png"
+ end
+
+ file :loadingpngp2 do |file|
+ file.source = 'app/loading-Portrait@2x.png'
+ file.destination = "#{name}/app/loading-Portrait@2x.png"
+ end
+
+ file :loadingpngpud2 do |file|
+ file.source = 'app/loading-PortraitUpsideDown@2x.png'
+ file.destination = "#{name}/app/loading-PortraitUpsideDown@2x.png"
+ end
+
+ file :loadingpngx do |file|
+ file.source = 'app/loading@2x.png'
+ file.destination = "#{name}/app/loading@2x.png"
+ end
+
+ directory :icon do |directory|
+ directory.source = 'icon'
+ directory.destination = "#{name}/icon"
+ end
+
+ directory :production do |directory|
+ directory.source = 'production'
+ directory.destination = "#{name}/production"
+ end
+
+ file :androidmanifesterb do |file|
+ file.source = 'AndroidManifest.erb'
+ file.destination = "#{name}/AndroidManifest.erb"
+ end
+
+ directory :public do |directory|
+ directory.source = 'public'
+ directory.destination = "#{name}/public/"
+ end
+
+ template :rakefile do |template|
+ template.source = 'Rakefile'
+ template.destination = "#{name}/Rakefile"
+ end
+ end
+
+ class RubyModelGenerator < BaseGenerator
+ def self.source_root
File.join(File.dirname(__FILE__), 'templates', 'model')
end
desc <<-DESC
- Generates a new model for a rhodes application.
+ Generates a new ruby model for a ruby-based rhodes application.
Required:
name - model name
attributes - list of one or more string attributes (i.e. name,industry,progress), NO spaces between attributes
@@ -366,10 +558,117 @@
end
found
end
end
+ class JavascriptModelGenerator < BaseGenerator
+ def self.source_root
+ File.join(File.dirname(__FILE__), 'templates', 'model')
+ end
+
+ desc <<-DESC
+ Generates a new javascript model for a javascript-based rhodes application.
+
+ Required:
+ name - model name
+ attributes - list of one or more string attributes (i.e. name,industry,progress), NO spaces between attributes
+
+ Optional:
+ priority - sync priority (i.e. 100)
+ type - DEPRECATED: type of model (i.e. "ask" for an ask model). This will be removed in 1.5, instead use
+ search method.
+ DESC
+
+ #option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
+
+ first_argument :name, :required => true, :desc => 'model name'
+ second_argument :attributes, :as => :array, :required => true, :desc => "list of one or more string attributes (i.e. name,industry,progress), NO spaces between attributes"
+ third_argument :priority, :required => false, :desc => "optional sync priority (i.e. 100)"
+ fourth_argument :type, :required => false, :desc => "optional type (i.e. \"ask\" for an ask model)"
+
+ template :javascript_index do |template|
+ template.source = "javascript_index.html"
+ template.destination = "app/#{name.modulize}/index.html"
+ end
+
+ template :javascript_index_script do |template|
+ template.source = "javascript_index.js"
+ template.destination = "app/#{name.modulize}/index.js"
+ end
+
+ template :javascript_model_script do |template|
+ template.source = "javascript_model.js"
+ template.destination = "app/#{name.modulize}/model.js"
+ end
+
+ template :javascript_new do |template|
+ template.source = "javascript_new.html"
+ template.destination = "app/#{name.modulize}/new.html"
+ end
+
+ template :javascript_show do |template|
+ template.source = "javascript_show.html"
+ template.destination = "app/#{name.modulize}/show.html"
+ end
+
+ template :javascript_edit do |template|
+ template.source = "javascript_edit.html"
+ template.destination = "app/#{name.modulize}/edit.html"
+ end
+
+
+ # template :index do |template|
+ # template.source = 'index.erb'
+ # template.destination = "app/#{name.modulize}/index.erb"
+ # end
+ #
+ # template :edit do |template|
+ # template.source = 'edit.erb'
+ # template.destination = "app/#{name.modulize}/edit.erb"
+ # end
+ #
+ # template :new do |template|
+ # template.source = 'new.erb'
+ # template.destination = "app/#{name.modulize}/new.erb"
+ # end
+ #
+ # template :new do |template|
+ # template.source = 'show.erb'
+ # template.destination = "app/#{name.modulize}/show.erb"
+ # end
+ #
+ # template :controller do |template|
+ # underscore_name = name.modulize.split(/(?=[A-Z])/).map { |w| w.downcase }.join('_')
+ # template.source = 'controller.rb'
+ # template.destination = "app/#{name.modulize}/#{underscore_name}_controller.rb"
+ # end
+ #
+ # template :model do |template|
+ # underscore_name = name.modulize.split(/(?=[A-Z])/).map { |w| w.downcase }.join('_')
+ # template.source = 'model.rb'
+ # template.destination = "app/#{name.modulize}/#{underscore_name}.rb"
+ # end
+ #
+ # template :spec do |template|
+ # underscore_name = name.modulize.split(/(?=[A-Z])/).map { |w| w.downcase }.join('_')
+ # template.source = 'spec.rb'
+ # template.destination = "app/test/#{underscore_name}_spec.rb"
+ # end
+
+ def attributes?
+ self.attributes && !self.attributes.empty?
+ end
+
+ def syncserver_exists?
+ found = true
+ File.open('rhoconfig.txt').each do |line|
+ found = false if line.match("syncserver\ =\ ''") or line.match("syncserver\ =\ \"\"") or line.match("syncserver\ =\ nil")
+ end
+ found
+ end
+ end
+
class SpecGenerator < BaseGenerator
def self.source_root
File.join(File.dirname(__FILE__), 'templates', 'spec')
end
@@ -410,13 +709,10 @@
template.destination = 'app/spec_runner.rb'
end
end
-
-
-
class IphoneProjectGenerator < BaseGenerator
@@noapp = false
def self.source_root
@@ -679,16 +975,10 @@
end
-
-
-
-
-
-
class ExtensionGenerator < BaseGenerator
@@noapp = false
def self.source_root
@@ -1346,11 +1636,13 @@
self.attributes && !self.attributes.empty?
end
end
- add :app, AppGenerator
- add :model, ModelGenerator
+ add :app, RubyAppGenerator
+ add :jsapp, JavascriptAppGenerator
+ add :model, RubyModelGenerator
+ add :jsmodel, JavascriptModelGenerator
add :spec, SpecGenerator
add :extension, ExtensionGenerator
add :api, ApiGenerator
add :api_test, ApiMegatestGenerator
add :iphone_project, IphoneProjectGenerator