dima-ruboss4ruby 1.0.5 → 1.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.
Files changed (106) hide show
  1. data/History.txt +2 -3
  2. data/Manifest.txt +46 -37
  3. data/README.rdoc +12 -10
  4. data/Rakefile +37 -0
  5. data/app_generators/ruboss_app/USAGE +13 -0
  6. data/app_generators/ruboss_app/ruboss_app_generator.rb +88 -0
  7. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/actionscript.properties +1 -1
  8. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/actionscriptair.properties +0 -0
  9. data/app_generators/ruboss_app/templates/default_tasks.rake +51 -0
  10. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/expressInstall.swf +0 -0
  11. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/flex.properties +0 -0
  12. data/app_generators/ruboss_app/templates/generate.rb +21 -0
  13. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/AC_OETags.js +0 -0
  14. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/history.css +0 -0
  15. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/history.js +0 -0
  16. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/historyFrame.html +0 -0
  17. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/index.template.html +0 -0
  18. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/playerProductInstall.swf +0 -0
  19. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/index.html.erb +2 -2
  20. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/mainair-app.xml +3 -3
  21. data/app_generators/ruboss_app/templates/mainapp-config.xml +21 -0
  22. data/{merb_generators/templates/ruboss_flex_app → app_generators/ruboss_app/templates}/mainapp.mxml +6 -9
  23. data/app_generators/ruboss_app/templates/project-textmate.erb +52 -0
  24. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/project.properties +0 -0
  25. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/projectair.properties +0 -0
  26. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/swfobject.js +0 -0
  27. data/bin/ruboss-gen +17 -0
  28. data/generators/ruboss_config/USAGE +5 -0
  29. data/generators/ruboss_config/ruboss_config_generator.rb +24 -0
  30. data/generators/ruboss_controller/USAGE +10 -0
  31. data/generators/ruboss_controller/ruboss_controller_generator.rb +34 -0
  32. data/{merb_generators/templates/ruboss_controller → generators/ruboss_controller/templates}/controller.as.erb +0 -4
  33. data/generators/ruboss_main_app/USAGE +8 -0
  34. data/generators/ruboss_main_app/ruboss_main_app_generator.rb +46 -0
  35. data/generators/ruboss_main_app/templates/mainapp.mxml +31 -0
  36. data/generators/ruboss_scaffold/USAGE +29 -0
  37. data/generators/ruboss_scaffold/ruboss_scaffold_generator.rb +117 -0
  38. data/generators/ruboss_scaffold/templates/component.mxml.erb +149 -0
  39. data/generators/ruboss_scaffold/templates/model.as.erb +42 -0
  40. data/generators/ruboss_yaml_scaffold/USAGE +7 -0
  41. data/generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +43 -0
  42. data/lib/ruboss4ruby/active_foo.rb +0 -64
  43. data/lib/ruboss4ruby/active_record_default_methods.rb +54 -0
  44. data/lib/ruboss4ruby/configuration.rb +13 -28
  45. data/lib/ruboss4ruby/datamapper_foo.rb +1 -1
  46. data/lib/ruboss4ruby/rails/recipes.rb +58 -0
  47. data/lib/ruboss4ruby/rails/swf_helper.rb +59 -0
  48. data/lib/ruboss4ruby/tasks.rb +1 -1
  49. data/lib/ruboss4ruby.rb +35 -15
  50. data/rails_generators/ruboss_config/ruboss_config_generator.rb +2 -2
  51. data/rails_generators/ruboss_config/templates/mainair-app.xml +2 -2
  52. data/rails_generators/ruboss_controller/USAGE +1 -2
  53. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +1 -1
  54. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +1 -1
  55. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +69 -69
  56. data/rails_generators/ruboss_scaffold/templates/model.as.erb +1 -1
  57. data/ruboss4ruby.gemspec +43 -0
  58. data/spec/ruboss4ruby_spec.rb +7 -0
  59. data/spec/spec_helper.rb +16 -0
  60. data/test/rails/controllers/application.rb +15 -0
  61. data/test/rails/controllers/locations_controller.rb +93 -0
  62. data/test/rails/controllers/notes_controller.rb +96 -0
  63. data/test/rails/controllers/projects_controller.rb +93 -0
  64. data/test/rails/controllers/tasks_controller.rb +93 -0
  65. data/test/rails/controllers/users_controller.rb +93 -0
  66. data/test/rails/database.yml +4 -0
  67. data/test/rails/fixtures/locations.yml +8 -0
  68. data/test/rails/fixtures/notes.yml +17 -0
  69. data/test/rails/fixtures/projects.yml +25 -0
  70. data/test/rails/fixtures/simple_properties.yml +19 -0
  71. data/test/rails/fixtures/tasks.yml +46 -0
  72. data/test/rails/fixtures/users.yml +13 -0
  73. data/test/rails/helpers/functional_test_helper.rb +21 -0
  74. data/test/rails/helpers/test_helper.rb +61 -0
  75. data/test/rails/helpers/unit_test_helper.rb +30 -0
  76. data/test/rails/model.yml +35 -0
  77. data/test/rails/models/location.rb +4 -0
  78. data/test/rails/models/note.rb +3 -0
  79. data/test/rails/models/project.rb +4 -0
  80. data/test/rails/models/simple_property.rb +2 -0
  81. data/test/rails/models/task.rb +20 -0
  82. data/test/rails/models/user.rb +22 -0
  83. data/test/rails/playing_around_in_a_console.txt +71 -0
  84. data/test/rails/schema.rb +77 -0
  85. data/test/rails/test.swf +1 -0
  86. data/test/rails/test_active_foo.rb +81 -0
  87. data/test/rails/test_ruboss_rails_integration_functional.rb +22 -0
  88. data/test/rails/test_to_fxml.rb +77 -0
  89. data/test/rails/test_to_json.rb +23 -0
  90. data/test/rails/views/notes/empty_params_action.html.erb +1 -0
  91. data/test/rails/views/notes/index.html.erb +1 -0
  92. metadata +121 -92
  93. data/Generators +0 -7
  94. data/lib/ruboss4ruby/generated_attribute.rb +0 -61
  95. data/merb_generators/ruboss_config.rb +0 -103
  96. data/merb_generators/ruboss_controller.rb +0 -59
  97. data/merb_generators/ruboss_flex_app.rb +0 -67
  98. data/merb_generators/ruboss_resource.rb +0 -37
  99. data/merb_generators/ruboss_resource_controller.rb +0 -80
  100. data/merb_generators/ruboss_scaffold.rb +0 -157
  101. data/merb_generators/templates/ruboss_config/ruboss.yml +0 -16
  102. data/merb_generators/templates/ruboss_resource_controller/controller_ar.rb.erb +0 -49
  103. data/merb_generators/templates/ruboss_resource_controller/controller_dm.rb.erb +0 -46
  104. data/merb_generators/templates/ruboss_resource_controller/spec/controllers/%file_name%_spec.rb +0 -7
  105. data/merb_generators/templates/ruboss_resource_controller/spec/requests/%file_name%_spec.rb +0 -1
  106. data/merb_generators/templates/ruboss_resource_controller/test/controllers/%file_name%_test.rb +0 -17
@@ -1,80 +0,0 @@
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
@@ -1,157 +0,0 @@
1
- require Ruboss::LIB_DIR + 'generated_attribute'
2
-
3
- #NOTE: this is currently (merb 0.9.9 broken and needs to be rethought anyway. This line of thinking was based
4
- # on the kind of code generation you could do with rails, it's a different code generation paradigm with Merb anyway)
5
- module Merb::Generators
6
- class RubossScaffoldGenerator < NamespacedGenerator
7
- include Ruboss::Configuration
8
-
9
- option :flex_only, :as => :boolean, :default => false, :desc => 'Scaffold Flex code only.'
10
- option :skip_migration, :as => :boolean, :default => false, :desc => 'Skip migration for this model.'
11
-
12
- first_argument :name, :required => true, :desc => "model name"
13
- second_argument :properties, :as => :hash, :required => true, :default => {}, :desc => "space separated model properties in form of name:type. Example: state:string"
14
-
15
- def initialize(*args)
16
- @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
17
- super
18
- end
19
-
20
- def table_name
21
- file_name.pluralize
22
- end
23
-
24
- alias_method :resource_controller_name, :table_name
25
-
26
- def model_name
27
- name
28
- end
29
-
30
- def controller_name
31
- name.pluralize
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 base_package
47
- @base_package
48
- end
49
-
50
- def command_controller_name
51
- @command_controller_name
52
- end
53
-
54
- def belongs_tos
55
- @belongs_tos
56
- end
57
-
58
- def has_manies
59
- @has_manies
60
- end
61
-
62
- def has_ones
63
- @has_ones
64
- end
65
-
66
- def attributes
67
- @belongs_tos = []
68
- @has_ones = []
69
- @has_manies = []
70
- # Figure out has_one, has_many and belongs_to based on args
71
- self.properties.each do |key,value|
72
- puts key + value
73
- key = key.to_sym
74
- if key == :has_one
75
- # arg = "has_one:arg1,arg2", so all the has_one are together
76
- @has_ones = value.split(',')
77
- elsif key == :has_many
78
- # arg = "has_many:arg1,arg2", so all the has_many are together
79
- @has_manies = value.split(",")
80
- elsif key == :belongs_to # belongs_to:arg1,arg2
81
- @belongs_tos = value.split(',')
82
- end
83
- end
84
-
85
- puts "does this even run?"
86
-
87
- puts belongs_tos
88
- puts has_manies
89
-
90
- # Remove the has_one and has_many arguments since they are
91
- # not for consumption by the scaffold generator, and since
92
- # we have already used them to set the @belongs_tos, @has_ones and
93
- # @has_manies.
94
- self.properties.delete_if { |key, value| key =~ /^(has_one|has_many|belongs_to)/ }
95
-
96
- @attributes ||= self.properties.collect do |key, value|
97
- Ruboss::Generator::GeneratedAttribute.new(key, value)
98
- end
99
- end
100
-
101
- def self.source_root
102
- File.join(File.dirname(__FILE__), 'templates', 'ruboss_scaffold')
103
- end
104
-
105
- invoke :ruboss_resource_controller do |generator|
106
- generator.new(destination_root, options, controller_name)
107
- end
108
-
109
- template :ar_model, :flex_only => false do |t|
110
- t.source = 'model.rb.erb'
111
- t.destination = File.join('app', 'models', "#{file_name}.rb")
112
- end
113
-
114
- empty_directory :fixtures, File.join('spec', 'fixtures')
115
-
116
- template :fixture, :flex_only => false do |t|
117
- t.source = 'fixtures.yml.erb'
118
- t.destination = File.join('spec', 'fixtures', "#{table_name}.yml")
119
- end
120
-
121
- empty_directory :migrations, File.join('schema', 'migrations')
122
-
123
- template :migration, :flex_only => false, :skip_migration => false do |t|
124
- t.source = 'migration.rb.erb'
125
- t.destination = File.join('schema', 'migrations', "#{migration_file_name}.rb")
126
- end
127
-
128
- template :as_model do |t|
129
- t.source = 'model.as.erb'
130
- t.destination = File.join('app', 'flex', base_folder, 'models', "#{class_name}.as")
131
- end
132
-
133
- template :flex_component do |t|
134
- t.source = 'component.mxml.erb'
135
- t.destination = File.join('app', 'flex', base_folder, 'components', 'generated', "#{class_name}Box.mxml")
136
- end
137
-
138
- invoke :ruboss_controller do |generator|
139
- generator.new(destination_root, options)
140
- end
141
-
142
- def migration_file_name
143
- current_migration_number = Dir[Dir.pwd+'/schema/migrations/*'].map{|f| File.basename(f) =~ /^(\d+)/; $1}.max
144
- migration_file_name = format("%03d_%s", (current_migration_number.to_i+1), file_name) + "_migration"
145
- end
146
-
147
- def migration_name
148
- "#{class_name}Migration"
149
- end
150
-
151
- desc <<-DESC
152
- Foobar.
153
- DESC
154
- end
155
-
156
- add :ruboss_scaffold, RubossScaffoldGenerator
157
- end
@@ -1,16 +0,0 @@
1
- # Ruboss code generation configuration options
2
-
3
- # By default flex models, commands, controllers and components are genearated into
4
- # app/flex/<your rails project name> folder. If you'd like to customize the target folder
5
- # (to say append a "com" package before your rails project name) uncomment the line below
6
- # base-package must follow the usual flex package notation (a string separated by ".")
7
-
8
- #base-package: com.pomodo
9
-
10
- # Main ruboss controller is typically named after your rails project name (camel-cased with a word
11
- # Controller appended at the end, e.g. if your application is called "pomodo" the flex application
12
- # controller will be called "PomodoController"). This controller is created in
13
- # <base-package>.controllers folder. You can customize the name by uncommenting the following line
14
- # and changing the controller name.
15
-
16
- #controller-name: PomodoController
@@ -1,49 +0,0 @@
1
- class <%= class_name %> < Application
2
- provides :xml, :fxml
3
-
4
- # GET /<%= resource_path %>
5
- def index
6
- @<%= plural_model %> = <%= model_class_name %>.find(:all)
7
- display @<%= plural_model %>
8
- end
9
-
10
- # GET /<%= resource_path %>/:id
11
- def show
12
- @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
13
- raise NotFound unless @<%= singular_model %>
14
- display @<%= singular_model %>
15
- end
16
-
17
- # POST /<%= resource_path %>
18
- def create
19
- @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
20
- if @<%= singular_model %>.save
21
- display @<%= singular_model %>
22
- else
23
- display @<%= singular_model %>.errors
24
- end
25
- end
26
-
27
- # PUT /<%= resource_path %>/:id
28
- def update
29
- @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
30
- raise NotFound unless @<%= singular_model %>
31
- if @<%= singular_model %>.update_attributes(params[:<%= singular_model %>])
32
- display @<%= singular_model %>
33
- else
34
- display @<%= singular_model %>.errors
35
- end
36
- end
37
-
38
- # DELETE /<%= resource_path %>/:id
39
- def destroy
40
- @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
41
- raise NotFound unless @<%= singular_model %>
42
- if @<%= singular_model %>.destroy
43
- display @<%= singular_model %>
44
- else
45
- display @<%= singular_model %>.errors
46
- end
47
- end
48
-
49
- end
@@ -1,46 +0,0 @@
1
- <% with_modules(modules) do -%>
2
- class <%= class_name %> < Application
3
- provides :xml, :fxml
4
-
5
- def index
6
- @<%= plural_model %> = <%= model_class_name %>.all
7
- display @<%= plural_model %>
8
- end
9
-
10
- def show
11
- @<%= singular_model %> = <%= model_class_name %>.get(<%= params_for_get %>)
12
- raise NotFound unless @<%= singular_model %>
13
- display @<%= singular_model %>
14
- end
15
-
16
- def create
17
- @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
18
- if @<%= singular_model %>.save
19
- display @<%= singular_model %>
20
- else
21
- display @<%= singular_model %>.errors
22
- end
23
- end
24
-
25
- def update
26
- @<%= singular_model %> = <%= model_class_name %>.get(<%= params_for_get %>)
27
- raise NotFound unless @<%= singular_model %>
28
- if @<%= singular_model %>.update_attributes(params[:<%= singular_model %>]) || !@<%= singular_model %>.dirty?
29
- display @<%= singular_model %>
30
- else
31
- display @<%= singular_model %>.errors
32
- end
33
- end
34
-
35
- def destroy
36
- @<%= singular_model %> = <%= model_class_name %>.get(<%= params_for_get %>)
37
- raise NotFound unless @<%= singular_model %>
38
- if @<%= singular_model %>.destroy
39
- display @<%= singular_model %>
40
- else
41
- display @<%= singular_model %>.errors
42
- end
43
- end
44
-
45
- end # <%= class_name %>
46
- <% end -%>
@@ -1,7 +0,0 @@
1
- require File.join(File.dirname(__FILE__), <%= go_up(modules.size + 1) %>, 'spec_helper.rb')
2
-
3
- describe <%= full_class_name %>, "index action" do
4
- before(:each) do
5
- dispatch_to(<%= full_class_name %>, :index)
6
- end
7
- end
@@ -1 +0,0 @@
1
- require File.join(File.dirname(__FILE__), <%= go_up(modules.size + 1) %>, 'spec_helper.rb')
@@ -1,17 +0,0 @@
1
- require File.join(File.dirname(__FILE__), <%= go_up(modules.size + 1) %>, "test_helper")
2
-
3
- # Re-raise errors caught by the controller.
4
- class <%= full_class_name %>; def rescue_action(e) raise e end; end
5
-
6
- class <%= full_class_name %>Test < Test::Unit::TestCase
7
-
8
- def setup
9
- @controller = <%= full_class_name %>.build(fake_request)
10
- @controller.dispatch('index')
11
- end
12
-
13
- # Replace this with your real tests.
14
- def test_should_be_setup
15
- assert false
16
- end
17
- end