dima-ruboss4ruby 1.0.5

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.
Files changed (78) hide show
  1. data/Generators +7 -0
  2. data/History.txt +4 -0
  3. data/Manifest.txt +116 -0
  4. data/README.rdoc +23 -0
  5. data/gpl-3.0.txt +674 -0
  6. data/lib/ruboss4ruby.rb +84 -0
  7. data/lib/ruboss4ruby/active_foo.rb +221 -0
  8. data/lib/ruboss4ruby/active_record_tasks.rb +75 -0
  9. data/lib/ruboss4ruby/configuration.rb +59 -0
  10. data/lib/ruboss4ruby/datamapper_foo.rb +25 -0
  11. data/lib/ruboss4ruby/generated_attribute.rb +61 -0
  12. data/lib/ruboss4ruby/tasks.rb +80 -0
  13. data/merb_generators/ruboss_config.rb +103 -0
  14. data/merb_generators/ruboss_controller.rb +59 -0
  15. data/merb_generators/ruboss_flex_app.rb +67 -0
  16. data/merb_generators/ruboss_resource.rb +37 -0
  17. data/merb_generators/ruboss_resource_controller.rb +80 -0
  18. data/merb_generators/ruboss_scaffold.rb +157 -0
  19. data/merb_generators/templates/ruboss_config/actionscript.properties +16 -0
  20. data/merb_generators/templates/ruboss_config/actionscriptair.properties +16 -0
  21. data/merb_generators/templates/ruboss_config/expressInstall.swf +0 -0
  22. data/merb_generators/templates/ruboss_config/flex.properties +2 -0
  23. data/merb_generators/templates/ruboss_config/html-template/AC_OETags.js +276 -0
  24. data/merb_generators/templates/ruboss_config/html-template/history/history.css +6 -0
  25. data/merb_generators/templates/ruboss_config/html-template/history/history.js +645 -0
  26. data/merb_generators/templates/ruboss_config/html-template/history/historyFrame.html +29 -0
  27. data/merb_generators/templates/ruboss_config/html-template/index.template.html +121 -0
  28. data/merb_generators/templates/ruboss_config/html-template/playerProductInstall.swf +0 -0
  29. data/merb_generators/templates/ruboss_config/index.html.erb +18 -0
  30. data/merb_generators/templates/ruboss_config/mainair-app.xml +134 -0
  31. data/merb_generators/templates/ruboss_config/project.properties +18 -0
  32. data/merb_generators/templates/ruboss_config/projectair.properties +24 -0
  33. data/merb_generators/templates/ruboss_config/ruboss.yml +16 -0
  34. data/merb_generators/templates/ruboss_config/swfobject.js +5 -0
  35. data/merb_generators/templates/ruboss_controller/controller.as.erb +40 -0
  36. data/merb_generators/templates/ruboss_flex_app/mainapp.mxml +34 -0
  37. data/merb_generators/templates/ruboss_resource_controller/controller_ar.rb.erb +49 -0
  38. data/merb_generators/templates/ruboss_resource_controller/controller_dm.rb.erb +46 -0
  39. data/merb_generators/templates/ruboss_resource_controller/spec/controllers/%file_name%_spec.rb +7 -0
  40. data/merb_generators/templates/ruboss_resource_controller/spec/requests/%file_name%_spec.rb +1 -0
  41. data/merb_generators/templates/ruboss_resource_controller/test/controllers/%file_name%_test.rb +17 -0
  42. data/rails_generators/ruboss_config/USAGE +18 -0
  43. data/rails_generators/ruboss_config/ruboss_config_generator.rb +114 -0
  44. data/rails_generators/ruboss_config/templates/actionscript.properties +16 -0
  45. data/rails_generators/ruboss_config/templates/actionscriptair.properties +16 -0
  46. data/rails_generators/ruboss_config/templates/expressInstall.swf +0 -0
  47. data/rails_generators/ruboss_config/templates/flex.properties +2 -0
  48. data/rails_generators/ruboss_config/templates/html-template/AC_OETags.js +276 -0
  49. data/rails_generators/ruboss_config/templates/html-template/history/history.css +6 -0
  50. data/rails_generators/ruboss_config/templates/html-template/history/history.js +645 -0
  51. data/rails_generators/ruboss_config/templates/html-template/history/historyFrame.html +29 -0
  52. data/rails_generators/ruboss_config/templates/html-template/index.template.html +121 -0
  53. data/rails_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  54. data/rails_generators/ruboss_config/templates/index.html.erb +18 -0
  55. data/rails_generators/ruboss_config/templates/mainair-app.xml +134 -0
  56. data/rails_generators/ruboss_config/templates/mainapp-config.xml +21 -0
  57. data/rails_generators/ruboss_config/templates/mainapp.mxml +31 -0
  58. data/rails_generators/ruboss_config/templates/project-textmate.erb +52 -0
  59. data/rails_generators/ruboss_config/templates/project.properties +18 -0
  60. data/rails_generators/ruboss_config/templates/projectair.properties +24 -0
  61. data/rails_generators/ruboss_config/templates/ruboss.yml +14 -0
  62. data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +5 -0
  63. data/rails_generators/ruboss_config/templates/swfobject.js +5 -0
  64. data/rails_generators/ruboss_controller/USAGE +11 -0
  65. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +31 -0
  66. data/rails_generators/ruboss_controller/templates/controller.as.erb +40 -0
  67. data/rails_generators/ruboss_scaffold/USAGE +35 -0
  68. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +177 -0
  69. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +149 -0
  70. data/rails_generators/ruboss_scaffold/templates/controller.rb.erb +97 -0
  71. data/rails_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
  72. data/rails_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
  73. data/rails_generators/ruboss_scaffold/templates/model.as.erb +42 -0
  74. data/rails_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
  75. data/rails_generators/ruboss_yaml_scaffold/USAGE +14 -0
  76. data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +44 -0
  77. data/rcl-1.0.txt +0 -0
  78. metadata +197 -0
@@ -0,0 +1,61 @@
1
+ module Ruboss
2
+ module Generator
3
+ class GeneratedAttribute
4
+ attr_accessor :name, :type, :flex_name
5
+
6
+ def initialize(name, type)
7
+ @name, @type = name, type.to_sym
8
+ @flex_name = name.camelcase(:lower)
9
+ end
10
+
11
+ def field_type
12
+ @field_type ||= case type
13
+ when :integer, :float, :decimal then :text_field
14
+ when :datetime, :timestamp, :time then :datetime_select
15
+ when :date then :date_select
16
+ when :string then :text_field
17
+ when :text then :text_area
18
+ when :boolean then :check_box
19
+ else
20
+ :text_field
21
+ end
22
+ end
23
+
24
+ def default(prefix = '')
25
+ @default = case type
26
+ when :integer then 1
27
+ when :float then 1.5
28
+ when :decimal then "9.99"
29
+ when :datetime, :timestamp, :time then Time.now.to_s(:db)
30
+ when :date then Date.today.to_s(:db)
31
+ when :string then prefix + name.camelize + "String"
32
+ when :text then prefix + name.camelize + "Text"
33
+ when :boolean then false
34
+ else
35
+ ""
36
+ end
37
+ end
38
+
39
+ def flex_type
40
+ @flex_type = case type
41
+ when :integer then 'int'
42
+ when :date, :datetime, :time then 'Date'
43
+ when :boolean then 'Boolean'
44
+ when :float, :decimal then 'Number'
45
+ else
46
+ 'String'
47
+ end
48
+ end
49
+
50
+ def flex_default(prefix = '')
51
+ @flex_default = case type
52
+ when :integer, :float, :decimal then '0'
53
+ when :string, :text then '""'
54
+ when :boolean then 'false'
55
+ else
56
+ 'null'
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,80 @@
1
+ require 'rake'
2
+ require 'ftools'
3
+ require 'rexml/document'
4
+ require File.join(File.dirname(__FILE__), 'configuration')
5
+
6
+ APP_ROOT = Ruboss::Configuration::APP_ROOT
7
+
8
+ namespace :ruboss do
9
+ def compile_app(executable, destination, opts = '')
10
+ app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
11
+ app_properties.elements.each("*/applications/application") do |elm|
12
+ app_path = elm.attributes['path']
13
+ project_path = File.join(APP_ROOT, "app/flex", app_path)
14
+ target_project_path = project_path.sub(/.mxml$/, '.swf')
15
+ target_project_air_descriptor = project_path.sub(/.mxml$/, '-app.xml')
16
+
17
+ libs = Dir.glob(File.join(APP_ROOT, 'lib', '*.swc')).map {|lib| lib.gsub(' ', '\ ')}
18
+
19
+ cmd = "#{executable} #{opts} -library-path+=#{libs.join(',')} " <<
20
+ "-keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored #{project_path.gsub(' ', '\ ')}"
21
+ puts "Compiling #{project_path}"
22
+ if system(cmd)
23
+ FileUtils.makedirs File.join(APP_ROOT, destination)
24
+ puts "Moving #{target_project_path} to " + File.join(APP_ROOT, destination)
25
+ FileUtils.mv target_project_path, File.join(APP_ROOT, destination), :force => true
26
+ if File.exist?(target_project_air_descriptor)
27
+ descriptor = File.read(target_project_air_descriptor)
28
+ descriptor_name = target_project_air_descriptor.split("/").last
29
+ app_swf = target_project_path.split("/").last
30
+ descriptor.gsub!("[This value will be overwritten by Flex Builder in the output app.xml]",
31
+ app_swf)
32
+
33
+ File.open("#{APP_ROOT}/#{destination}/#{descriptor_name}", "w") do |file|
34
+ file.print descriptor
35
+ end
36
+ puts "Created #{APP_ROOT}/#{destination}/#{descriptor_name} descriptor."
37
+ end
38
+ puts 'Done!'
39
+ else
40
+ puts "The application was not compiled. Check console for errors. " <<
41
+ "It is possible that '(a)mxmlc' executable was not found or there are compilation errors."
42
+ end
43
+ end
44
+ end
45
+
46
+ def get_main_application
47
+ app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
48
+ app_properties.root.attributes['mainApplicationPath'].split("/").last
49
+ end
50
+
51
+ def get_executable(executable)
52
+ if RUBY_PLATFORM =~ /mswin32/
53
+ executable << '.exe'
54
+ end
55
+ executable
56
+ end
57
+
58
+ namespace :flex do
59
+ desc "Build project swf file and move it into public/bin folder"
60
+ task :build do
61
+ compile_app(get_executable('mxmlc'), 'public/bin')
62
+ end
63
+ end
64
+
65
+ namespace :air do
66
+ desc "Build project swf file as an AIR application and move it into bin-debug folder"
67
+ task :build do
68
+ compile_app(get_executable('mxmlc'), 'bin-debug', '+configname=air')
69
+ end
70
+
71
+ desc "Run the AIR application (if this project is configured as an AIR project)"
72
+ task :run do
73
+ target = get_main_application.gsub(/.mxml$/, '-app.xml')
74
+ puts "Running AIR application with descriptor: #{target}"
75
+ if !system("#{get_executable('adl')} bin-debug/#{target}")
76
+ puts "Could not run the application with descriptor: #{target}. Check console for errors."
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,103 @@
1
+ require 'open-uri'
2
+ require 'fileutils'
3
+
4
+ module Merb::Generators
5
+ class RubossConfigGenerator < Generator
6
+ include Ruboss::Configuration
7
+
8
+ option :air, :as => :boolean, :default => false, :desc => 'Configure AIR project instead of Flex. Flex is default.'
9
+ option :skip_framework, :as => :boolean, :default => false, :desc => "Don't fetch the latest framework binary. You'll have to link/build the framework yourself."
10
+
11
+ def initialize(*args)
12
+ super
13
+ @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
14
+
15
+ framework_release = Ruboss::RUBOSS_FRAMEWORK_VERSION
16
+ framework_distribution_url = "http://ruboss.com/releases/ruboss-#{framework_release}.swc"
17
+ framework_destination_file = "lib/ruboss-#{framework_release}.swc"
18
+
19
+ if !get_option(:skip_framework) && !File.exist?(framework_destination_file)
20
+ FileUtils.mkdir('lib') unless File.directory?('lib')
21
+ puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
22
+ open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
23
+ puts "done. saved to #{framework_destination_file}"
24
+ end
25
+ end
26
+
27
+ def extract_config(config_file)
28
+ if get_option(:air)
29
+ config_file << 'air'
30
+ end
31
+ config_file
32
+ end
33
+
34
+ def project_name
35
+ @project_name
36
+ end
37
+
38
+ def flex_project_name
39
+ @flex_project_name
40
+ end
41
+
42
+ def base_folder
43
+ @base_folder
44
+ end
45
+
46
+ def self.source_root
47
+ File.join(File.dirname(__FILE__), 'templates', 'ruboss_config')
48
+ end
49
+
50
+ empty_directory :bin, File.join('public', 'bin')
51
+ empty_directory :javascripts, File.join('public', 'javascripts')
52
+ empty_directory :schema, 'schema'
53
+
54
+ file :flex_properties, 'flex.properties', '.flexProperties'
55
+
56
+ template :actionscript_properties do |t|
57
+ t.source = "#{extract_config('actionscript')}.properties"
58
+ t.destination = '.actionScriptProperties'
59
+ end
60
+
61
+ template :project_properties do |t|
62
+ t.source = "#{extract_config('project')}.properties"
63
+ t.destination = '.project'
64
+ end
65
+
66
+ %w(components controllers commands models events).each do |dir|
67
+ empty_directory dir.to_sym do |t|
68
+ t.destination = File.join('app', 'flex', base_folder, dir)
69
+ end
70
+ end
71
+
72
+ empty_directory :generated do |t|
73
+ t.destination = File.join('app', 'flex', base_folder, 'components', 'generated')
74
+ end
75
+
76
+ glob!('html-template')
77
+
78
+ file :swfoject, 'swfobject.js', File.join('public', 'javascripts', 'swfobject.js')
79
+
80
+ file :express_install, 'expressInstall.swf', File.join('public', 'expressInstall.swf')
81
+
82
+ file :ruboss_yml, 'ruboss.yml', File.join('config', 'ruboss.yml')
83
+
84
+ template :index, 'index.html.erb', File.join('app', 'views', 'layout', 'application.html.erb')
85
+
86
+ invoke :ruboss_flex_app
87
+
88
+ template :air_descriptor, :air => true do |t|
89
+ t.source = 'mainair-app.xml'
90
+ t.destination = File.join('app', 'flex', "#{project_name}-app.xml")
91
+ end
92
+
93
+ desc <<-DESC
94
+ Generates the primary Ruboss directory structure.
95
+ Sets up Flex Builder specific descriptor files and options fetches
96
+ the latest published Ruboss Framework SWC file.
97
+ DESC
98
+
99
+ invoke :ruboss_controller
100
+ end
101
+
102
+ add :ruboss_config, RubossConfigGenerator
103
+ end
@@ -0,0 +1,59 @@
1
+ module Merb::Generators
2
+ class RubossControllerGenerator < Generator
3
+ include Ruboss::Configuration
4
+
5
+ def initialize(*args)
6
+ super
7
+ @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
8
+ end
9
+
10
+ def project_name
11
+ @project_name
12
+ end
13
+
14
+ def flex_project_name
15
+ @flex_project_name
16
+ end
17
+
18
+ def base_folder
19
+ @base_folder
20
+ end
21
+
22
+ def base_package
23
+ @base_package
24
+ end
25
+
26
+ def command_controller_name
27
+ @command_controller_name
28
+ end
29
+
30
+ def model_names
31
+ list_as_files("app/flex/#{base_folder}/models")
32
+ end
33
+
34
+ def command_names
35
+ list_as_files("app/flex/#{base_folder}/commands")
36
+ end
37
+
38
+ def self.source_root
39
+ File.join(File.dirname(__FILE__), 'templates', 'ruboss_controller')
40
+ end
41
+
42
+ template :controller do |t|
43
+ t.source = 'controller.as.erb'
44
+ t.destination = File.join('app', 'flex', base_folder, 'controllers', "#{command_controller_name}.as")
45
+ end
46
+
47
+ desc <<-DESC
48
+ Generates the main Ruboss Flex application controller.
49
+ Typically app/flex/<yourappname>/controllers/ApplicationController.as,
50
+ e.g. app/flex/pomodo/controllers/ApplicationController.as
51
+
52
+ It pulls out all available models and commands from respective
53
+ folders and makes sure they'll be pulled into the Flex application
54
+ at runtime.
55
+ DESC
56
+ end
57
+
58
+ add :ruboss_controller, RubossControllerGenerator
59
+ end
@@ -0,0 +1,67 @@
1
+ require 'open-uri'
2
+ require 'fileutils'
3
+
4
+ module Merb::Generators
5
+ class RubossFlexAppGenerator < Generator
6
+ include Ruboss::Configuration
7
+
8
+ option :air, :as => :boolean, :default => false, :desc => 'Configure AIR project instead of Flex. Flex is default.'
9
+
10
+ def initialize(*args)
11
+ super
12
+ @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
13
+
14
+ @component_names = []
15
+ if File.exists?("app/flex/#{base_folder}/components/generated")
16
+ @component_names = list_mxml_files("app/flex/#{base_folder}/components/generated")
17
+ end
18
+ end
19
+
20
+ def project_name
21
+ @project_name
22
+ end
23
+
24
+ def flex_project_name
25
+ @flex_project_name
26
+ end
27
+
28
+ def base_folder
29
+ @base_folder
30
+ end
31
+
32
+ def base_package
33
+ @base_package
34
+ end
35
+
36
+ def command_controller_name
37
+ @command_controller_name
38
+ end
39
+
40
+ def component_names
41
+ @component_names
42
+ end
43
+
44
+ def application_tag
45
+ if get_option(:air)
46
+ 'WindowedApplication'
47
+ else
48
+ 'Application'
49
+ end
50
+ end
51
+
52
+ def self.source_root
53
+ File.join(File.dirname(__FILE__), 'templates', 'ruboss_flex_app')
54
+ end
55
+
56
+ desc <<-DESC
57
+ Generates main flex application file.
58
+ DESC
59
+
60
+ template :main_app do |t|
61
+ t.source = 'mainapp.mxml'
62
+ t.destination = File.join('app', 'flex', "#{project_name}.mxml")
63
+ end
64
+ end
65
+
66
+ add :ruboss_flex_app, RubossFlexAppGenerator
67
+ end
@@ -0,0 +1,37 @@
1
+ module Merb::Generators
2
+
3
+ class RubossResourceGenerator < Generator
4
+
5
+ desc <<-DESC
6
+ Generates a new ruboss resource.
7
+ DESC
8
+
9
+ first_argument :name, :required => true, :desc => "resource name (singular)"
10
+ second_argument :attributes, :as => :hash, :default => {}, :desc => "space separated resource model properties in form of name:type. Example: state:string"
11
+
12
+ option :testing_framework, :desc => 'Testing framework to use (one of: rspec, test_unit)'
13
+ option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
14
+
15
+ invoke :model do |generator|
16
+ generator.new(destination_root, options, model_name, attributes)
17
+ end
18
+
19
+ invoke :ruboss_resource_controller do |generator|
20
+ generator.new(destination_root, options, controller_name, attributes)
21
+ end
22
+
23
+ def controller_name
24
+ name.pluralize
25
+ end
26
+
27
+ def model_name
28
+ name
29
+ end
30
+
31
+ def after_generation
32
+ STDOUT << message("Don't forget to set your resource route in config/router.rb for instance: resources :#{model_name.downcase}s ")
33
+ end
34
+ end
35
+
36
+ add :ruboss_resource, RubossResourceGenerator
37
+ end
@@ -0,0 +1,80 @@
1
+ module Merb::Generators
2
+
3
+ class RubossResourceControllerGenerator < NamespacedGenerator
4
+
5
+ desc <<-DESC
6
+ Generates a new ruboss resource controller.
7
+ DESC
8
+
9
+ option :testing_framework, :desc => 'Testing framework to use (one of: rspec, test_unit)'
10
+ option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
11
+ option :template_engine, :desc => 'Template Engine to use (one of: erb, haml, markaby, etc...)'
12
+
13
+ first_argument :name, :required => true,
14
+ :desc => "model name"
15
+ second_argument :attributes, :as => :hash,
16
+ :default => {},
17
+ :desc => "space separated resource model properties in form of name:type. Example: state:string"
18
+
19
+ invoke :helper do |generator|
20
+ generator.new(destination_root, options, name)
21
+ end
22
+
23
+ # add controller and view templates for each of the four big ORM's
24
+
25
+ template :controller_activerecord, :orm => :activerecord do |t|
26
+ t.source = File.dirname(__FILE__) / "templates/ruboss_resource_controller/controller_ar.rb.erb"
27
+ t.destination = "app/controllers" / base_path / "#{file_name}.rb"
28
+ end
29
+
30
+ template :controller_datamapper, :orm => :datamapper do |t|
31
+ t.source = File.dirname(__FILE__) / "templates/ruboss_resource_controller/controller_dm.rb.erb"
32
+ t.destination = "app/controllers" / base_path / "#{file_name}.rb"
33
+ end
34
+
35
+ template :controller_spec, :testing_framework => :rspec do |template|
36
+ template.source = File.dirname(__FILE__) / 'templates/ruboss_resource_controller/spec/controllers/%file_name%_spec.rb'
37
+ template.destination = "spec/controllers" / base_path / "#{file_name}_spec.rb"
38
+ end
39
+
40
+ template :request_spec, :testing_framework => :rspec do |template|
41
+ template.source = File.dirname(__FILE__) / 'templates/ruboss_resource_controller/spec/requests/%file_name%_spec.rb'
42
+ template.destination = "spec/requests" / base_path / "#{file_name}_spec.rb"
43
+ end
44
+
45
+ template :controller_test_unit, :testing_framework => :test_unit, :orm => :none do |template|
46
+ template.source = File.dirname(__FILE__) / 'templates/ruboss_resource_controller/test/controllers/%file_name%_test.rb'
47
+ template.destination = "test/controllers" / base_path / "#{file_name}_test.rb"
48
+ end
49
+
50
+ def model_class_name
51
+ class_name.singularize
52
+ end
53
+
54
+ def plural_model
55
+ class_name.snake_case
56
+ end
57
+
58
+ def singular_model
59
+ plural_model.singularize
60
+ end
61
+
62
+ def resource_path
63
+ chunks.map{ |c| c.snake_case }.join('/')
64
+ end
65
+
66
+ # TODO: fix this for Datamapper, so that it returns the primary keys for the model
67
+ def params_for_get
68
+ "params[:id]"
69
+ end
70
+
71
+ # TODO: implement this for Datamapper so that we get the model properties
72
+ def properties
73
+ []
74
+ end
75
+
76
+ end
77
+
78
+ add :ruboss_resource_controller, RubossResourceControllerGenerator
79
+
80
+ end