ruboss4ruby 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -2
- data/Manifest.txt +86 -79
- data/README.rdoc +53 -0
- data/Rakefile +42 -5
- data/app_generators/ruboss_app/USAGE +22 -0
- data/app_generators/ruboss_app/ruboss_app_generator.rb +94 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/actionscript.properties +1 -1
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/actionscriptair.properties +0 -0
- data/app_generators/ruboss_app/templates/app.yaml.erb +12 -0
- data/app_generators/ruboss_app/templates/default_tasks.rake +51 -0
- data/app_generators/ruboss_app/templates/empty.txt +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/expressInstall.swf +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/flex.properties +0 -0
- data/app_generators/ruboss_app/templates/generate.rb +17 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/AC_OETags.js +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/history.css +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/history.js +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/historyFrame.html +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/index.template.html +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/playerProductInstall.swf +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/index.html.erb +2 -2
- data/app_generators/ruboss_app/templates/index.yaml +11 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/mainair-app.xml +3 -3
- data/app_generators/ruboss_app/templates/mainapp-config.xml +21 -0
- data/{merb_generators/templates/ruboss_flex_app → app_generators/ruboss_app/templates}/mainapp.mxml +6 -9
- data/app_generators/ruboss_app/templates/project-textmate.erb +52 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/project.properties +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/projectair.properties +0 -0
- data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/swfobject.js +0 -0
- data/bin/ruboss-gen +31 -0
- data/generators/ruboss_config/USAGE +5 -0
- data/generators/ruboss_config/ruboss_config_generator.rb +19 -0
- data/generators/ruboss_controller/USAGE +10 -0
- data/generators/ruboss_controller/ruboss_controller_generator.rb +38 -0
- data/generators/ruboss_controller/templates/assist.py +65 -0
- data/{merb_generators/templates/ruboss_controller → generators/ruboss_controller/templates}/controller.as.erb +7 -6
- data/generators/ruboss_controller/templates/restful.py +136 -0
- data/generators/ruboss_main_app/USAGE +8 -0
- data/generators/ruboss_main_app/ruboss_main_app_generator.rb +60 -0
- data/generators/ruboss_main_app/templates/main.py.erb +29 -0
- data/generators/ruboss_main_app/templates/mainapp.mxml +35 -0
- data/generators/ruboss_scaffold/USAGE +29 -0
- data/generators/ruboss_scaffold/ruboss_scaffold_generator.rb +148 -0
- data/generators/ruboss_scaffold/templates/component.mxml.erb +149 -0
- data/generators/ruboss_scaffold/templates/controller.py.erb +27 -0
- data/generators/ruboss_scaffold/templates/model.as.erb +42 -0
- data/generators/ruboss_scaffold/templates/model.py.erb +14 -0
- data/generators/ruboss_yaml_scaffold/USAGE +45 -0
- data/generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +47 -0
- data/lib/ruboss4ruby/active_foo.rb +109 -86
- data/lib/ruboss4ruby/active_record_default_methods.rb +66 -0
- data/lib/ruboss4ruby/active_record_tasks.rb +10 -4
- data/lib/ruboss4ruby/configuration.rb +48 -34
- data/lib/ruboss4ruby/datamapper_foo.rb +31 -0
- data/lib/ruboss4ruby/{recipes.rb → rails/recipes.rb} +7 -9
- data/lib/ruboss4ruby/{ruboss_helper.rb → rails/swf_helper.rb} +14 -8
- data/lib/ruboss4ruby/tasks.rb +9 -4
- data/lib/ruboss4ruby.rb +72 -27
- data/rails_generators/ruboss_config/ruboss_config_generator.rb +3 -15
- data/rails_generators/ruboss_config/templates/mainair-app.xml +2 -2
- data/rails_generators/ruboss_config/templates/mainapp-config.xml +1 -1
- data/rails_generators/ruboss_config/templates/ruboss.yml +2 -4
- data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +5 -15
- data/rails_generators/ruboss_controller/USAGE +1 -2
- data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +3 -14
- data/rails_generators/ruboss_controller/templates/controller.as.erb +11 -6
- data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +67 -76
- data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +69 -69
- data/rails_generators/ruboss_scaffold/templates/model.as.erb +2 -2
- data/rails_generators/ruboss_yaml_scaffold/USAGE +38 -1
- data/rcl-1.0.txt +0 -0
- data/rdoc/generators/template/html/jamis.rb +588 -0
- data/ruboss4ruby.gemspec +43 -0
- data/spec/ruboss4ruby_spec.rb +7 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/manifest.rake +48 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +279 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/test/{controllers → rails/controllers}/application.rb +0 -0
- data/test/{controllers → rails/controllers}/locations_controller.rb +0 -0
- data/test/{controllers → rails/controllers}/notes_controller.rb +0 -0
- data/test/{controllers → rails/controllers}/projects_controller.rb +0 -0
- data/test/{controllers → rails/controllers}/tasks_controller.rb +0 -0
- data/test/{controllers → rails/controllers}/users_controller.rb +0 -0
- data/test/{database.yml → rails/database.yml} +0 -0
- data/test/{fixtures → rails/fixtures}/locations.yml +0 -0
- data/test/{fixtures → rails/fixtures}/notes.yml +0 -0
- data/test/{fixtures → rails/fixtures}/projects.yml +0 -0
- data/test/rails/fixtures/simple_properties.yml +19 -0
- data/test/{fixtures → rails/fixtures}/tasks.yml +0 -0
- data/test/{fixtures → rails/fixtures}/users.yml +0 -0
- data/test/{helpers → rails/helpers}/functional_test_helper.rb +0 -11
- data/test/rails/helpers/test_helper.rb +61 -0
- data/test/rails/helpers/unit_test_helper.rb +30 -0
- data/test/{model.yml → rails/model.yml} +0 -0
- data/test/{models → rails/models}/location.rb +0 -0
- data/test/{models → rails/models}/note.rb +0 -0
- data/test/{models → rails/models}/project.rb +1 -3
- data/test/rails/models/simple_property.rb +2 -0
- data/test/{models → rails/models}/task.rb +1 -1
- data/test/{models → rails/models}/user.rb +1 -2
- data/test/{playing_around_in_a_console.txt → rails/playing_around_in_a_console.txt} +0 -0
- data/test/{schema.rb → rails/schema.rb} +14 -0
- data/test/{test.swf → rails/test.swf} +0 -0
- data/test/rails/test_active_foo.rb +81 -0
- data/test/{test_ruboss_rails_integration_functional.rb → rails/test_ruboss_rails_integration_functional.rb} +4 -9
- data/test/{to_fxml_test.rb → rails/test_to_fxml.rb} +35 -37
- data/test/rails/test_to_json.rb +23 -0
- data/test/{views → rails/views}/notes/empty_params_action.html.erb +0 -0
- data/test/{views → rails/views}/notes/index.html.erb +0 -0
- metadata +138 -103
- data/Generators +0 -5
- data/README.txt +0 -37
- data/config/hoe.rb +0 -72
- data/config/requirements.rb +0 -15
- data/lib/ruboss4ruby/generated_attribute.rb +0 -61
- data/lib/ruboss4ruby/ruboss_test_helpers.rb +0 -31
- data/lib/ruboss4ruby/version.rb +0 -11
- data/merb_generators/ruboss_config.rb +0 -105
- data/merb_generators/ruboss_controller.rb +0 -61
- data/merb_generators/ruboss_flex_app.rb +0 -69
- data/merb_generators/ruboss_resource_controller.rb +0 -4
- data/merb_generators/ruboss_scaffold.rb +0 -158
- data/merb_generators/templates/ruboss_config/ruboss.yml +0 -16
- data/merb_generators/templates/ruboss_resource_controller/controller.rb.erb +0 -49
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/helpers/controllers.log +0 -8
- data/test/helpers/models.log +0 -170
- data/test/helpers/test_helper.rb +0 -25
- data/test/helpers/unit_test_helper.rb +0 -23
- data/test/test.sqlite3 +0 -0
- data/test/test_active_foo.rb +0 -79
- data/test/test_swfobject_helper.rb +0 -63
- data/website/index.html +0 -63
- data/website/index.txt +0 -34
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -47
@@ -0,0 +1,52 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>currentDocument</key>
|
6
|
+
<string>app/flex/<%= project_name %>.mxml</string>
|
7
|
+
<key>documents</key>
|
8
|
+
<array>
|
9
|
+
<dict>
|
10
|
+
<key>expanded</key>
|
11
|
+
<true/>
|
12
|
+
<key>name</key>
|
13
|
+
<string><%= project_name.underscore %></string>
|
14
|
+
<key>regexFolderFilter</key>
|
15
|
+
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
16
|
+
<key>sourceDirectory</key>
|
17
|
+
<string></string>
|
18
|
+
</dict>
|
19
|
+
</array>
|
20
|
+
<key>fileHierarchyDrawerWidth</key>
|
21
|
+
<integer>299</integer>
|
22
|
+
<key>metaData</key>
|
23
|
+
<dict/>
|
24
|
+
<key>openDocuments</key>
|
25
|
+
<array>
|
26
|
+
<string>app/flex/<%= project_name %>.mxml</string>
|
27
|
+
</array>
|
28
|
+
<key>shellVariables</key>
|
29
|
+
<array>
|
30
|
+
<dict>
|
31
|
+
<key>enabled</key>
|
32
|
+
<true/>
|
33
|
+
<key>value</key>
|
34
|
+
<string>app/flex/<%= project_name %>.mxml</string>
|
35
|
+
<key>variable</key>
|
36
|
+
<string>TM_FLEX_FILE_SPECS</string>
|
37
|
+
</dict>
|
38
|
+
<dict>
|
39
|
+
<key>enabled</key>
|
40
|
+
<true/>
|
41
|
+
<key>value</key>
|
42
|
+
<string>public/bin/<%= project_name %>.swf</string>
|
43
|
+
<key>variable</key>
|
44
|
+
<string>TM_FLEX_OUTPUT</string>
|
45
|
+
</dict>
|
46
|
+
</array>
|
47
|
+
<key>showFileHierarchyDrawer</key>
|
48
|
+
<false/>
|
49
|
+
<key>windowFrame</key>
|
50
|
+
<string>{{5, 15}, {1073, 860}}</string>
|
51
|
+
</dict>
|
52
|
+
</plist>
|
File without changes
|
File without changes
|
data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/swfobject.js
RENAMED
File without changes
|
data/bin/ruboss-gen
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Generates the primary Ruboss project directory structure and
|
4
|
+
# sets up Flex Builder and TextMate specific descriptor files
|
5
|
+
#
|
6
|
+
# You can generate Flex Builder configuration for either *pure* Flex
|
7
|
+
# project or an AIR project. To generate AIR configuration pass the -a
|
8
|
+
# (--air) option to the generator.
|
9
|
+
#
|
10
|
+
# Examples:
|
11
|
+
# `ruboss-gen pomodo` # generates project structure and a
|
12
|
+
# # default Flex app configuration.
|
13
|
+
# `ruboss-gen -a pomodo` # as above but generates an AIR app
|
14
|
+
# # and configuration
|
15
|
+
#
|
16
|
+
# Next Steps:
|
17
|
+
# In your new Ruboss project folder run `ruby script/generate` for
|
18
|
+
# a list of available generators.
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require 'rubigen'
|
22
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'ruboss4ruby')
|
23
|
+
|
24
|
+
if %w(-v --version).include? ARGV.first
|
25
|
+
puts "#{File.basename($0)} #{Ruboss4Ruby::VERSION}"
|
26
|
+
exit(0)
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'rubigen/scripts/generate'
|
30
|
+
RubiGen::Base.use_application_sources!
|
31
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'ruboss_app')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
class RubossConfigGenerator < RubiGen::Base
|
4
|
+
include Ruboss4Ruby::Configuration
|
5
|
+
|
6
|
+
def manifest
|
7
|
+
record do |m|
|
8
|
+
framework_release = Ruboss4Ruby::RUBOSS_FRAMEWORK_VERSION
|
9
|
+
framework_distribution_url = "http://ruboss.com/releases/ruboss-#{framework_release}.swc"
|
10
|
+
framework_destination_file = "lib/ruboss-#{framework_release}.swc"
|
11
|
+
|
12
|
+
if !options[:skip_framework] && !File.exist?(framework_destination_file)
|
13
|
+
puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
|
14
|
+
open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
|
15
|
+
puts "done. saved to #{framework_destination_file}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Description:
|
2
|
+
Generates/updates the main Flex application controller, typically
|
3
|
+
app/flex/<yourappname>/controllers/ApplicationController.as
|
4
|
+
|
5
|
+
It pulls out all available models and commands from respective
|
6
|
+
folders and makes sure they'll be pulled into the Flex application
|
7
|
+
at runtime. Doesn't require any arguments or options.
|
8
|
+
|
9
|
+
Examples:
|
10
|
+
`./script/generate ruboss_controller`
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class RubossControllerGenerator < RubiGen::Base
|
2
|
+
include Ruboss4Ruby::Configuration
|
3
|
+
|
4
|
+
attr_reader :project_name,
|
5
|
+
:flex_project_name,
|
6
|
+
:base_package,
|
7
|
+
:base_folder,
|
8
|
+
:command_controller_name,
|
9
|
+
:model_names,
|
10
|
+
:command_names
|
11
|
+
|
12
|
+
def initialize(runtime_args, runtime_options = {})
|
13
|
+
super
|
14
|
+
@project_name, @flex_project_name, @command_controller_name,
|
15
|
+
@base_package, @base_folder = extract_names
|
16
|
+
|
17
|
+
@model_names = list_as_files("app/flex/#{base_folder}/models")
|
18
|
+
@command_names = list_as_files("app/flex/#{base_folder}/commands")
|
19
|
+
end
|
20
|
+
|
21
|
+
def manifest
|
22
|
+
record do |m|
|
23
|
+
m.template 'controller.as.erb', File.join("app/flex/#{base_folder}/controllers",
|
24
|
+
"#{command_controller_name}.as")
|
25
|
+
if options[:gae]
|
26
|
+
m.file 'restful.py', 'app/controllers/restful.py' if !File.exist?('app/controllers/restful.py')
|
27
|
+
m.file 'assist.py', 'app/models/assist.py' if !File.exist?('app/models/assist.py')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_options!(opt)
|
33
|
+
opt.separator ''
|
34
|
+
opt.separator 'Options:'
|
35
|
+
opt.on("--gae", "Generate Google App Engine Python classes in addition to Ruboss Flex resources.",
|
36
|
+
"Default: false") { |v| options[:gae] = v }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2008 Dima Berastau
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to
|
7
|
+
# deal in the Software without restriction, including without limitation
|
8
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9
|
+
# and/or sell copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
21
|
+
# DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
__author__ = 'Dima Berastau'
|
24
|
+
|
25
|
+
from google.appengine.ext import db
|
26
|
+
import datetime
|
27
|
+
|
28
|
+
# Some useful module methods
|
29
|
+
def all(model):
|
30
|
+
items = "".join(str(item.to_xml()) for item in model.all())
|
31
|
+
if items == "":
|
32
|
+
return '<entities type="array"/>'
|
33
|
+
else:
|
34
|
+
return '<entities kind="%s" type="array">%s</entities>' % (model.kind(), items)
|
35
|
+
|
36
|
+
def update_model_from_params(model, params):
|
37
|
+
for k, v in params.items():
|
38
|
+
if k.endswith("_id"):
|
39
|
+
if v == "":
|
40
|
+
setattr(model, k.replace("_id", ""), None)
|
41
|
+
else:
|
42
|
+
setattr(model, k.replace("_id", ""), db.Key(v))
|
43
|
+
elif hasattr(model, k):
|
44
|
+
if isinstance(getattr(model, k), bool):
|
45
|
+
if v == "false" or v == "":
|
46
|
+
setattr(model, k, False)
|
47
|
+
else:
|
48
|
+
setattr(model, k, True)
|
49
|
+
elif isinstance(getattr(model, k), float) and v != "":
|
50
|
+
setattr(model, k, float(v))
|
51
|
+
elif isinstance(getattr(model, k), int) and v != "":
|
52
|
+
setattr(model, k, int(v))
|
53
|
+
elif isinstance(getattr(model, k), datetime.datetime) and v != "":
|
54
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S")
|
55
|
+
setattr(model, k, value)
|
56
|
+
elif isinstance(getattr(model, k), datetime.date) and v != "":
|
57
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%d")
|
58
|
+
setattr(model, k, datetime.date(value.year, value.month, value.day))
|
59
|
+
elif isinstance(getattr(model, k), datetime.time) and v != "":
|
60
|
+
value = datetime.datetime.strptime(v, "%Y-%m-%dT%H:%M:%S")
|
61
|
+
setattr(model, k, datetime.time(value.hour, value.minute, value.second))
|
62
|
+
else:
|
63
|
+
setattr(model, k, v)
|
64
|
+
|
65
|
+
model.put()
|
@@ -1,20 +1,22 @@
|
|
1
1
|
package <%= base_package %>.controllers {
|
2
2
|
import <%= base_package %>.models.*;
|
3
3
|
import <%= base_package %>.commands.*;
|
4
|
-
|
4
|
+
|
5
|
+
import mx.core.Application;
|
5
6
|
import org.ruboss.Ruboss;
|
6
|
-
import org.ruboss.controllers.
|
7
|
+
import org.ruboss.controllers.RubossApplicationController;
|
7
8
|
import org.ruboss.utils.RubossUtils;
|
8
9
|
|
9
|
-
public class <%= command_controller_name %> extends
|
10
|
+
public class <%= command_controller_name %> extends RubossApplicationController {
|
10
11
|
private static var controller:<%= command_controller_name %>;
|
11
12
|
|
12
13
|
public static var models:Array = [<%= model_names %>]; /* Models */
|
13
14
|
|
15
|
+
public static var commands:Array = [<%= command_names %>]; /* Commands */
|
16
|
+
|
14
17
|
public function <%= command_controller_name %>(enforcer:SingletonEnforcer, extraServices:Array,
|
15
18
|
defaultServiceId:int = -1) {
|
16
|
-
super(
|
17
|
-
models, extraServices, defaultServiceId);
|
19
|
+
super(commands, models, extraServices, defaultServiceId);
|
18
20
|
}
|
19
21
|
|
20
22
|
public static function get instance():<%= command_controller_name %> {
|
@@ -27,7 +29,6 @@ package <%= base_package %>.controllers {
|
|
27
29
|
if (!RubossUtils.isEmpty(airDatabaseName)) Ruboss.airDatabaseName = airDatabaseName;
|
28
30
|
controller = new <%= command_controller_name %>(new SingletonEnforcer, extraServices,
|
29
31
|
defaultServiceId);
|
30
|
-
Ruboss.commands = controller;
|
31
32
|
}
|
32
33
|
}
|
33
34
|
}
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2008 William T. Katz
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to
|
7
|
+
# deal in the Software without restriction, including without limitation
|
8
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9
|
+
# and/or sell copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
21
|
+
# DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
"""
|
24
|
+
RESTful Controller
|
25
|
+
|
26
|
+
We want our RESTful controllers to simply throw up their hands if they get
|
27
|
+
an unhandled HTTP verb. This is better for rich clients and server load
|
28
|
+
than throwing back lots of useless HTML.
|
29
|
+
|
30
|
+
These inherited methods should be overridden if there's a chance a human
|
31
|
+
browser is involved.
|
32
|
+
|
33
|
+
TODO: Return more information HTTP status codes that won't autotrip
|
34
|
+
browser login forms. For example, return status 405 (Method not allowed)
|
35
|
+
with an Allow header containing the list of valid methods.
|
36
|
+
"""
|
37
|
+
__author__ = 'William T. Katz'
|
38
|
+
|
39
|
+
from google.appengine.ext import webapp
|
40
|
+
|
41
|
+
import logging
|
42
|
+
|
43
|
+
# Some useful module methods
|
44
|
+
def send_successful_response(handler, response):
|
45
|
+
logging.debug("Sending successful response: %s", response)
|
46
|
+
handler.response.headers["Content-Type"] = "application/xml"
|
47
|
+
handler.response.out.write('<?xml version="1.0" encoding="UTF-8"?>')
|
48
|
+
handler.response.out.write(response)
|
49
|
+
|
50
|
+
def get_model_key(handler):
|
51
|
+
return handler.request.path_info.split("/").pop().replace(".xml", "")
|
52
|
+
|
53
|
+
def get_sent_properties(request_func, propname_list):
|
54
|
+
"""
|
55
|
+
This maps request strings to values in a hash, optionally run through
|
56
|
+
a function with previous request values as parameters to the func.
|
57
|
+
1) key -> just read in the corresponding request value
|
58
|
+
2) tuple (key, func) -> Read the request value for the string key
|
59
|
+
and pass it through func
|
60
|
+
3) tuple (key, func, additional keys...) -> Get the request
|
61
|
+
values for the additional keys and pass them through func
|
62
|
+
before setting the key's value with the output.
|
63
|
+
If a key is not present in the request, then we do not insert a key
|
64
|
+
with None or empty string. The key is simply absent, therefore allowing
|
65
|
+
you to use the returned hash to initial a Model instance.
|
66
|
+
"""
|
67
|
+
prop_hash = {}
|
68
|
+
for item in propname_list:
|
69
|
+
if isinstance(item, basestring):
|
70
|
+
key = item
|
71
|
+
value = request_func(item)
|
72
|
+
elif isinstance(item, tuple):
|
73
|
+
key = item[0]
|
74
|
+
prop_func = item[1]
|
75
|
+
if len(item) <= 2:
|
76
|
+
value = prop_func(request_func(key))
|
77
|
+
else:
|
78
|
+
try:
|
79
|
+
addl_keys = map(prop_hash.get, item[2:])
|
80
|
+
value = prop_func(*addl_keys)
|
81
|
+
except:
|
82
|
+
return None
|
83
|
+
if value:
|
84
|
+
prop_hash[key] = value
|
85
|
+
return prop_hash
|
86
|
+
|
87
|
+
def methods_via_query_allowed(handler_method):
|
88
|
+
"""
|
89
|
+
A decorator to automatically re-route overloaded POSTs
|
90
|
+
that specify the real HTTP method in a _method query string.
|
91
|
+
|
92
|
+
To use it, decorate your post method like this:
|
93
|
+
|
94
|
+
import restful
|
95
|
+
...
|
96
|
+
@restful.methods_via_query_allowed
|
97
|
+
def post(self):
|
98
|
+
pass
|
99
|
+
|
100
|
+
The decorator will check for a _method query string or POST argument,
|
101
|
+
and if present, will redirect to delete(), put(), etc.
|
102
|
+
"""
|
103
|
+
def redirect_if_needed(self, *args, **kwargs):
|
104
|
+
real_verb = self.request.get('_method', None)
|
105
|
+
if not real_verb and 'X-HTTP-Method-Override' in self.request.environ:
|
106
|
+
real_verb = self.request.environ['X-HTTP-Method-Override']
|
107
|
+
if real_verb:
|
108
|
+
logging.debug("Redirected from POST. Detected method override = %s", real_verb)
|
109
|
+
method = real_verb.upper()
|
110
|
+
if method == 'HEAD':
|
111
|
+
self.head(*args, **kwargs)
|
112
|
+
elif method == 'PUT':
|
113
|
+
self.put(*args, **kwargs)
|
114
|
+
elif method == 'DELETE':
|
115
|
+
self.delete(*args, **kwargs)
|
116
|
+
elif method == 'TRACE':
|
117
|
+
self.trace(*args, **kwargs)
|
118
|
+
elif method == 'OPTIONS':
|
119
|
+
self.head(*args, **kwargs)
|
120
|
+
# POST and GET included for completeness
|
121
|
+
elif method == 'POST':
|
122
|
+
self.post(*args, **kwargs)
|
123
|
+
elif method == 'GET':
|
124
|
+
self.get(*args, **kwargs)
|
125
|
+
else:
|
126
|
+
self.error(405)
|
127
|
+
else:
|
128
|
+
handler_method(self, *args, **kwargs)
|
129
|
+
return redirect_if_needed
|
130
|
+
|
131
|
+
class Controller(webapp.RequestHandler):
|
132
|
+
def get(self, *params):
|
133
|
+
self.redirect("/403.html")
|
134
|
+
|
135
|
+
def head(self, *params):
|
136
|
+
pass
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Description:
|
2
|
+
Refreshes main Flex/AIR application file to make sure that
|
3
|
+
any of the generated components are included. Warning,
|
4
|
+
this will wipe your main application file. Used mostly
|
5
|
+
during code generation phase.
|
6
|
+
|
7
|
+
Examples:
|
8
|
+
`./script/generate ruboss_main_app`
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class RubossMainAppGenerator < RubiGen::Base
|
2
|
+
include Ruboss4Ruby::Configuration
|
3
|
+
|
4
|
+
attr_reader :project_name,
|
5
|
+
:flex_project_name,
|
6
|
+
:base_package,
|
7
|
+
:base_folder,
|
8
|
+
:command_controller_name,
|
9
|
+
:model_names,
|
10
|
+
:component_names,
|
11
|
+
:controller_names,
|
12
|
+
:use_air,
|
13
|
+
:use_gae,
|
14
|
+
:application_tag
|
15
|
+
|
16
|
+
def initialize(runtime_args, runtime_options = {})
|
17
|
+
super
|
18
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
|
19
|
+
|
20
|
+
project_file_name = APP_ROOT + '/.project'
|
21
|
+
if File.exist?(project_file_name)
|
22
|
+
@use_air = true if File.read(project_file_name) =~/com.adobe.flexbuilder.apollo.apollobuilder/m
|
23
|
+
end
|
24
|
+
|
25
|
+
if @use_air
|
26
|
+
@application_tag = 'WindowedApplication'
|
27
|
+
else
|
28
|
+
@application_tag = 'Application'
|
29
|
+
end
|
30
|
+
|
31
|
+
@component_names = []
|
32
|
+
if File.exists?("app/flex/#{base_folder}/components/generated")
|
33
|
+
@component_names = list_mxml_files("app/flex/#{base_folder}/components/generated")
|
34
|
+
end
|
35
|
+
|
36
|
+
@controller_names = []
|
37
|
+
if options[:gae] && File.exists?("app/controllers")
|
38
|
+
@use_gae = true
|
39
|
+
@controller_names =
|
40
|
+
Dir.entries("app/controllers").grep(/\.py$/).delete_if { |name| name == "__init__.py" || name == "restful.py" }.map { |name| name.sub(/\.py$/, "") }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def manifest
|
45
|
+
record do |m|
|
46
|
+
m.template 'mainapp.mxml', File.join('app', 'flex', "#{project_name}.mxml")
|
47
|
+
if options[:gae]
|
48
|
+
m.template 'main.py.erb', 'main.py'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
def add_options!(opt)
|
55
|
+
opt.separator ''
|
56
|
+
opt.separator 'Options:'
|
57
|
+
opt.on("--gae", "Generate Google App Engine Python classes in addition to Ruboss Flex resources.",
|
58
|
+
"Default: false") { |v| options[:gae] = v }
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
|
3
|
+
import logging
|
4
|
+
import wsgiref.handlers
|
5
|
+
|
6
|
+
from google.appengine.api import users
|
7
|
+
from google.appengine.ext import webapp
|
8
|
+
from google.appengine.ext.webapp.util import run_wsgi_app
|
9
|
+
from app.controllers import <%= controller_names.join(", ") %>
|
10
|
+
|
11
|
+
class AppController(webapp.RequestHandler):
|
12
|
+
def get(self):
|
13
|
+
self.redirect("/public/index.html")
|
14
|
+
|
15
|
+
def main():
|
16
|
+
application = webapp.WSGIApplication(
|
17
|
+
[('/*$', AppController),
|
18
|
+
<% for component in controller_names -%>
|
19
|
+
<% if component == controller_names.last -%>
|
20
|
+
('/<%= component %>.*', <%= component %>.Controller)
|
21
|
+
<% else -%>
|
22
|
+
('/<%= component %>.*', <%= component %>.Controller),
|
23
|
+
<% end -%>
|
24
|
+
<% end -%>
|
25
|
+
], debug=True)
|
26
|
+
wsgiref.handlers.CGIHandler().run(application)
|
27
|
+
|
28
|
+
if __name__ == '__main__':
|
29
|
+
main()
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<mx:<%= application_tag %> xmlns:mx="http://www.adobe.com/2006/mxml"
|
3
|
+
xmlns:generated="<%= base_package %>.components.generated.*"
|
4
|
+
paddingBottom="8" paddingLeft="8" paddingRight="8" paddingTop="8"
|
5
|
+
layout="horizontal" styleName="plain" initialize="init()">
|
6
|
+
<mx:Script>
|
7
|
+
<![CDATA[
|
8
|
+
<% if use_air -%>
|
9
|
+
import org.ruboss.services.air.AIRServiceProvider;
|
10
|
+
<% end -%>
|
11
|
+
<% if use_gae -%>
|
12
|
+
import org.ruboss.services.http.GAEHTTPServiceProvider;
|
13
|
+
<% end -%>
|
14
|
+
import <%= base_package %>.controllers.<%= command_controller_name %>;
|
15
|
+
|
16
|
+
private function init():void {
|
17
|
+
<% if use_air -%>
|
18
|
+
<%= command_controller_name %>.initialize([AIRServiceProvider], AIRServiceProvider.ID, "<%= base_package %>");
|
19
|
+
<% elsif use_gae -%>
|
20
|
+
<%= command_controller_name %>.initialize([GAEHTTPServiceProvider], GAEHTTPServiceProvider.ID);
|
21
|
+
<% else -%>
|
22
|
+
<%= command_controller_name %>.initialize();
|
23
|
+
<% end -%>
|
24
|
+
}
|
25
|
+
]]>
|
26
|
+
</mx:Script>
|
27
|
+
<mx:LinkBar dataProvider="{mainViewStack}" direction="vertical" borderStyle="solid" backgroundColor="#EEEEEE"/>
|
28
|
+
<mx:ViewStack id="mainViewStack" width="100%" height="100%">
|
29
|
+
<!-- For a simple demo, put all the components here. -->
|
30
|
+
<% for component in component_names -%>
|
31
|
+
<generated:<%= component %>/>
|
32
|
+
<% end -%>
|
33
|
+
</mx:ViewStack>
|
34
|
+
</mx:<%= application_tag %>>
|
35
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire Ruboss resources. The resource is ready to use as a
|
3
|
+
starting point for your restful, resource-oriented application.
|
4
|
+
|
5
|
+
ruboss_scaffold :
|
6
|
+
1. Generates all required Flex code.
|
7
|
+
2. You can pass special belongs_to, has_one and has_many attributes
|
8
|
+
to generate appropriate relationships.
|
9
|
+
|
10
|
+
Pass the name of the model, either CamelCased or under_scored, as the first
|
11
|
+
argument, and an optional list of attribute pairs.
|
12
|
+
|
13
|
+
Attribute pairs are column_name:sql_type arguments specifying the
|
14
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
15
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
16
|
+
|
17
|
+
The syntax for belongs_to, has_one and has_many attributes is as follows:
|
18
|
+
belongs_to:<relationship_name> or
|
19
|
+
belongs_to:<relationship_name>,<another_relationship>,<and_another>
|
20
|
+
|
21
|
+
You don't have to think up every attribute up front, but it helps to
|
22
|
+
sketch out a few so you can start working with the resource immediately.
|
23
|
+
|
24
|
+
For example, `ruboss_scaffold post title:string body:text published:boolean`
|
25
|
+
gives you a model with those three attributes.
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
`./script/generate ruboss_scaffold project name:string has_many:tasks`
|
29
|
+
`./script/generate ruboss_scaffold task name:string belongs_to:project`
|