captproton-restfulx 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +50 -0
- data/Rakefile +79 -0
- data/VERSION.yml +4 -0
- data/app_generators/rx_app/USAGE +22 -0
- data/app_generators/rx_app/rx_app_generator.rb +110 -0
- data/app_generators/rx_app/templates/actionscript.properties +16 -0
- data/app_generators/rx_app/templates/actionscriptair.properties +16 -0
- data/app_generators/rx_app/templates/app.yaml.erb +12 -0
- data/app_generators/rx_app/templates/default_tasks.rake +38 -0
- data/app_generators/rx_app/templates/empty.txt +0 -0
- data/app_generators/rx_app/templates/expressInstall.swf +0 -0
- data/app_generators/rx_app/templates/flex.properties +2 -0
- data/app_generators/rx_app/templates/generate.rb +17 -0
- data/app_generators/rx_app/templates/html-template/AC_OETags.js +276 -0
- data/app_generators/rx_app/templates/html-template/history/history.css +6 -0
- data/app_generators/rx_app/templates/html-template/history/history.js +645 -0
- data/app_generators/rx_app/templates/html-template/history/historyFrame.html +29 -0
- data/app_generators/rx_app/templates/html-template/index.template.html +121 -0
- data/app_generators/rx_app/templates/html-template/playerProductInstall.swf +0 -0
- data/app_generators/rx_app/templates/index.html.erb +18 -0
- data/app_generators/rx_app/templates/index.yaml +11 -0
- data/app_generators/rx_app/templates/mainair-app.xml +134 -0
- data/app_generators/rx_app/templates/mainapp-config.xml +22 -0
- data/app_generators/rx_app/templates/mainapp.mxml +152 -0
- data/app_generators/rx_app/templates/project-textmate.erb +72 -0
- data/app_generators/rx_app/templates/project.properties +18 -0
- data/app_generators/rx_app/templates/projectair.properties +24 -0
- data/app_generators/rx_app/templates/restfulx.yml +46 -0
- data/app_generators/rx_app/templates/swfobject.js +5 -0
- data/bin/rx-gen +31 -0
- data/lib/restfulx.rb +90 -0
- data/lib/restfulx/active_foo.rb +181 -0
- data/lib/restfulx/active_record_tasks.rb +90 -0
- data/lib/restfulx/active_record_uuid_helper.rb +17 -0
- data/lib/restfulx/configuration.rb +75 -0
- data/lib/restfulx/datamapper_foo.rb +81 -0
- data/lib/restfulx/rails/recipes.rb +60 -0
- data/lib/restfulx/rails/schema_to_yaml.rb +112 -0
- data/lib/restfulx/rails/schema_to_yaml/extensions/enumerable.rb +8 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/config.rb +17 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/core.rb +73 -0
- data/lib/restfulx/rails/swf_helper.rb +59 -0
- data/lib/restfulx/tasks.rb +110 -0
- data/rails_generators/rx_config/USAGE +19 -0
- data/rails_generators/rx_config/rx_config_generator.rb +151 -0
- data/rails_generators/rx_config/templates/actionscript.properties +16 -0
- data/rails_generators/rx_config/templates/actionscriptair.properties +16 -0
- data/rails_generators/rx_config/templates/expressInstall.swf +0 -0
- data/rails_generators/rx_config/templates/flex.properties +2 -0
- data/rails_generators/rx_config/templates/flex_controller.erb +4 -0
- data/rails_generators/rx_config/templates/html-template/AC_OETags.js +276 -0
- data/rails_generators/rx_config/templates/html-template/history/history.css +6 -0
- data/rails_generators/rx_config/templates/html-template/history/history.js +645 -0
- data/rails_generators/rx_config/templates/html-template/history/historyFrame.html +29 -0
- data/rails_generators/rx_config/templates/html-template/index.template.html +121 -0
- data/rails_generators/rx_config/templates/html-template/playerProductInstall.swf +0 -0
- data/rails_generators/rx_config/templates/index.erb +16 -0
- data/rails_generators/rx_config/templates/mainair-app.xml +134 -0
- data/rails_generators/rx_config/templates/mainapp-config.xml +22 -0
- data/rails_generators/rx_config/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_config/templates/project-textmate.erb +72 -0
- data/rails_generators/rx_config/templates/project.properties +18 -0
- data/rails_generators/rx_config/templates/projectair.properties +24 -0
- data/rails_generators/rx_config/templates/restfulx.erb +75 -0
- data/rails_generators/rx_config/templates/restfulx.yml +65 -0
- data/rails_generators/rx_config/templates/restfulx_tasks.rake +9 -0
- data/rails_generators/rx_config/templates/routes.erb +47 -0
- data/rails_generators/rx_config/templates/session_store_flash.erb +1 -0
- data/rails_generators/rx_config/templates/swfobject.js +5 -0
- data/rails_generators/rx_controller/USAGE +10 -0
- data/rails_generators/rx_controller/rx_controller_generator.rb +31 -0
- data/rails_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rails_generators/rx_main_app/USAGE +8 -0
- data/rails_generators/rx_main_app/rx_main_app_generator.rb +60 -0
- data/rails_generators/rx_main_app/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_scaffold/USAGE +35 -0
- data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +242 -0
- data/rails_generators/rx_scaffold/templates/controllers/default.rb.erb +125 -0
- data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +23 -0
- data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +39 -0
- data/rails_generators/rx_scaffold/templates/functional_test.rb +45 -0
- data/rails_generators/rx_scaffold/templates/helper_test.rb +4 -0
- data/rails_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rails_generators/rx_scaffold/templates/migration.rb.erb +46 -0
- data/rails_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rails_generators/rx_scaffold/templates/model.rb.erb +46 -0
- data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +68 -0
- data/rxgen_generators/rx_config/USAGE +5 -0
- data/rxgen_generators/rx_config/rx_config_generator.rb +21 -0
- data/rxgen_generators/rx_controller/USAGE +10 -0
- data/rxgen_generators/rx_controller/rx_controller_generator.rb +41 -0
- data/rxgen_generators/rx_controller/templates/assist.py +65 -0
- data/rxgen_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rxgen_generators/rx_controller/templates/iso8601.py +92 -0
- data/rxgen_generators/rx_controller/templates/restful.py +136 -0
- data/rxgen_generators/rx_main_app/USAGE +8 -0
- data/rxgen_generators/rx_main_app/rx_main_app_generator.rb +65 -0
- data/rxgen_generators/rx_main_app/templates/main.py.erb +29 -0
- data/rxgen_generators/rx_main_app/templates/mainapp.mxml +152 -0
- data/rxgen_generators/rx_scaffold/USAGE +29 -0
- data/rxgen_generators/rx_scaffold/rx_scaffold_generator.rb +194 -0
- data/rxgen_generators/rx_scaffold/templates/controller.py.erb +27 -0
- data/rxgen_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rxgen_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rxgen_generators/rx_scaffold/templates/model.py.erb +14 -0
- data/rxgen_generators/rx_yaml_scaffold/USAGE +45 -0
- data/rxgen_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +47 -0
- data/spec/restfulx_spec.rb +4 -0
- data/spec/spec_helper.rb +13 -0
- data/tasks/restfulx.rake +2 -0
- data/test/rails/controllers/application_controller.rb +15 -0
- data/test/rails/controllers/locations_controller.rb +93 -0
- data/test/rails/controllers/notes_controller.rb +96 -0
- data/test/rails/controllers/projects_controller.rb +93 -0
- data/test/rails/controllers/tasks_controller.rb +93 -0
- data/test/rails/controllers/users_controller.rb +93 -0
- data/test/rails/database.yml +4 -0
- data/test/rails/fixtures/locations.yml +8 -0
- data/test/rails/fixtures/notes.yml +17 -0
- data/test/rails/fixtures/projects.yml +25 -0
- data/test/rails/fixtures/simple_properties.yml +19 -0
- data/test/rails/fixtures/tasks.yml +46 -0
- data/test/rails/fixtures/users.yml +13 -0
- data/test/rails/helpers/functional_test_helper.rb +21 -0
- data/test/rails/helpers/test_helper.rb +54 -0
- data/test/rails/helpers/unit_test_helper.rb +29 -0
- data/test/rails/model.yml +35 -0
- data/test/rails/models/location.rb +4 -0
- data/test/rails/models/note.rb +3 -0
- data/test/rails/models/project.rb +4 -0
- data/test/rails/models/simple_property.rb +2 -0
- data/test/rails/models/task.rb +18 -0
- data/test/rails/models/user.rb +20 -0
- data/test/rails/schema.rb +77 -0
- data/test/rails/test.swf +1 -0
- data/test/rails/test_active_foo.rb +36 -0
- data/test/rails/test_rails_integration_functional.rb +22 -0
- data/test/rails/test_to_fxml.rb +35 -0
- data/test/rails/test_to_json.rb +23 -0
- data/test/rails/views/notes/empty_params_action.html.erb +1 -0
- data/test/rails/views/notes/index.html.erb +1 -0
- metadata +234 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
import restful
|
2
|
+
import logging
|
3
|
+
|
4
|
+
from google.appengine.ext import webapp
|
5
|
+
from google.appengine.api import users
|
6
|
+
from google.appengine.ext import db
|
7
|
+
from app.models import assist, <%= file_name %>
|
8
|
+
|
9
|
+
class Controller(restful.Controller):
|
10
|
+
def get(self):
|
11
|
+
restful.send_successful_response(self, assist.all(<%= file_name %>.<%= class_name %>))
|
12
|
+
|
13
|
+
@restful.methods_via_query_allowed
|
14
|
+
def post(self):
|
15
|
+
model = <%= file_name %>.<%= class_name %>()
|
16
|
+
assist.update_model_from_params(model, self.request.params)
|
17
|
+
restful.send_successful_response(self, model.to_xml())
|
18
|
+
|
19
|
+
def put(self):
|
20
|
+
model = <%= file_name %>.<%= class_name %>.get(db.Key(restful.get_model_key(self)))
|
21
|
+
assist.update_model_from_params(model, self.request.params)
|
22
|
+
restful.send_successful_response(self, model.to_xml())
|
23
|
+
|
24
|
+
def delete(self):
|
25
|
+
model = <%= file_name %>.<%= class_name %>.get(db.Key(restful.get_model_key(self)))
|
26
|
+
db.delete(model)
|
27
|
+
restful.send_successful_response(self, model.to_xml())
|
@@ -0,0 +1,167 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" label="<%= class_name %>"
|
3
|
+
xmlns:rx="org.restfulx.components.rx.*">
|
4
|
+
<mx:Script><![CDATA[
|
5
|
+
import org.restfulx.Rx;
|
6
|
+
import org.restfulx.utils.RxUtils;
|
7
|
+
import <%= base_package %>.models.<%= class_name %>;
|
8
|
+
<% for model in belongs_tos -%>
|
9
|
+
import <%= base_package %>.models.<%= model.camelcase %>;
|
10
|
+
<% end -%>
|
11
|
+
<% if attachment_field.size > 0 -%>
|
12
|
+
import flash.net.FileReference;
|
13
|
+
import org.restfulx.utils.RxFileReference;
|
14
|
+
<% end -%>
|
15
|
+
|
16
|
+
[Bindable]
|
17
|
+
private var <%= class_name.dcfirst %>:<%= class_name %> = new <%= class_name %>();
|
18
|
+
<% if attachment_field.size > 0 -%>
|
19
|
+
|
20
|
+
[Bindable]
|
21
|
+
private var fileName:String = "None selected";
|
22
|
+
|
23
|
+
private var file:RxFileReference;
|
24
|
+
<% end -%>
|
25
|
+
|
26
|
+
private function new<%= class_name %>():void {
|
27
|
+
<%= class_name.dcfirst %> = new <%= class_name %>();
|
28
|
+
<%= class_name.dcfirst.pluralize %>List.selectedIndex = -1;
|
29
|
+
}
|
30
|
+
|
31
|
+
private function save<%= class_name %>():void {
|
32
|
+
updateModelProperties();
|
33
|
+
if (<%= class_name.dcfirst %>.id) {
|
34
|
+
<%= class_name.dcfirst %>.update({onSuccess: on<%= class_name %>Update});
|
35
|
+
} else {
|
36
|
+
<%= class_name.dcfirst %>.create({onSuccess: on<%= class_name %>Create});
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
private function updateModelProperties():void {
|
41
|
+
<% for attribute in attributes -%>
|
42
|
+
<% if attribute.type == :boolean -%>
|
43
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
|
44
|
+
<% elsif attribute.type == :string -%>
|
45
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
|
46
|
+
<% elsif attribute.type == :text -%>
|
47
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
|
48
|
+
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
49
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
|
50
|
+
<% elsif attribute.type == :date -%>
|
51
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
|
52
|
+
<% else -%>
|
53
|
+
<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_type %>(<%= attribute.flex_name %>TextInput.text);
|
54
|
+
<% end -%>
|
55
|
+
<% end -%>
|
56
|
+
<% for model in belongs_tos -%>
|
57
|
+
<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
|
58
|
+
<% end -%>
|
59
|
+
<% if attachment_field.size > 0 -%>
|
60
|
+
<%= class_name.dcfirst %>.attachment = file;
|
61
|
+
<% end -%>
|
62
|
+
}
|
63
|
+
|
64
|
+
private function destroy<%= class_name %>():void {
|
65
|
+
<%= class_name.dcfirst %>.destroy({onSuccess: on<%= class_name %>Destroy});
|
66
|
+
}
|
67
|
+
|
68
|
+
private function on<%= class_name %>Select():void {
|
69
|
+
<%= class_name.dcfirst %> = RxUtils.clone(<%= class_name.dcfirst.pluralize %>List.selectedItem) as <%= class_name %>;
|
70
|
+
}
|
71
|
+
|
72
|
+
private function on<%= class_name %>Create(result:<%= class_name %>):void {
|
73
|
+
<%= class_name.dcfirst %> = new <%= class_name %>;
|
74
|
+
}
|
75
|
+
|
76
|
+
private function on<%= class_name %>Update(result:<%= class_name %>):void {
|
77
|
+
<%= class_name.dcfirst.pluralize %>List.selectedItem = result;
|
78
|
+
on<%= class_name %>Select();
|
79
|
+
}
|
80
|
+
|
81
|
+
private function on<%= class_name %>Destroy(result:<%= class_name %>):void {
|
82
|
+
on<%= class_name %>Create(result);
|
83
|
+
}
|
84
|
+
<% if attachment_field.size > 0 -%>
|
85
|
+
|
86
|
+
private function chooseFile():void {
|
87
|
+
file = new RxFileReference("<%= attachment_field[0].camelcase(:lower) %>");
|
88
|
+
file.reference.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
|
89
|
+
file.reference.addEventListener(Event.SELECT, selectFile, false, 0, true);
|
90
|
+
file.reference.addEventListener(Event.CANCEL, cancelBrowse, false, 0, true);
|
91
|
+
file.reference.browse();
|
92
|
+
}
|
93
|
+
|
94
|
+
private function selectFile(event:Event):void {
|
95
|
+
fileSelected(event)
|
96
|
+
}
|
97
|
+
|
98
|
+
private function cancelBrowse(event:Event):void {
|
99
|
+
file = null;
|
100
|
+
}
|
101
|
+
|
102
|
+
private function fileSelected(event:Event):void {
|
103
|
+
fileName = FileReference(event.target).name;
|
104
|
+
}
|
105
|
+
|
106
|
+
private function ioErrorHandler(event:Event):void {
|
107
|
+
fileChooser.errorString = "Failed to selected a file. Please try again.";
|
108
|
+
}
|
109
|
+
<% end -%>
|
110
|
+
]]></mx:Script>
|
111
|
+
<mx:Panel id="<%= class_name.dcfirst.pluralize %>Panel"
|
112
|
+
title="<%= class_name.pluralize %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
|
113
|
+
borderThickness="1" backgroundColor="#EEEEEE" width="25%" height="100%">
|
114
|
+
<mx:List id="<%= class_name.dcfirst.pluralize %>List"
|
115
|
+
width="100%" height="100%"
|
116
|
+
dataProvider="{Rx.models.index(<%= class_name %>)}"
|
117
|
+
change="on<%= class_name %>Select()"/>
|
118
|
+
<mx:ControlBar width="100%">
|
119
|
+
<mx:Button label="New <%= class_name %>" width="100%" height="30"
|
120
|
+
click="new<%= class_name %>()"/>
|
121
|
+
</mx:ControlBar>
|
122
|
+
</mx:Panel>
|
123
|
+
<mx:Panel title="Edit <%= class_name %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
|
124
|
+
borderThickness="1" backgroundColor="#EEEEEE" width="75%" height="100%">
|
125
|
+
<mx:Form width="100%" height="100%">
|
126
|
+
<% for attribute in attributes -%>
|
127
|
+
<mx:FormItem label="<%= attribute.flex_name.ucfirst %>" width="100%">
|
128
|
+
<% if attribute.type == :boolean -%>
|
129
|
+
<mx:CheckBox id="<%= attribute.flex_name %>CheckBox" selected="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
130
|
+
<% elsif attribute.type == :string -%>
|
131
|
+
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
132
|
+
<% elsif attribute.type == :text -%>
|
133
|
+
<mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
134
|
+
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
135
|
+
<rx:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
136
|
+
<% elsif attribute.type == :date -%>
|
137
|
+
<mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
138
|
+
<% else -%>
|
139
|
+
<mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
140
|
+
<% end -%>
|
141
|
+
</mx:FormItem>
|
142
|
+
<% end -%>
|
143
|
+
<% if attachment_field.size > 0 -%>
|
144
|
+
<mx:FormItem label="<%= attachment_field[0].camelcase %>:" width="100%" id="fileChooser">
|
145
|
+
<mx:Button label="Browse…" id="fileBrowseButton" click="chooseFile()"/>
|
146
|
+
<mx:Label text="{fileName}" maxWidth="190"/>
|
147
|
+
<mx:Image source="{<%= class_name.dcfirst %>.attachmentUrl}"/>
|
148
|
+
</mx:FormItem>
|
149
|
+
<% end -%>
|
150
|
+
<% for model in belongs_tos -%>
|
151
|
+
<mx:FormItem label="<%= model.camelcase %>" width="100%">
|
152
|
+
<mx:ComboBox id="<%= model.camelcase(:lower) %>ComboBox" width="200"
|
153
|
+
labelField="{<%= model.camelcase %>.LABEL}"
|
154
|
+
dataProvider="{Rx.models.index(<%= model.camelcase %>)}" prompt="<%= model.camelcase %> ..."
|
155
|
+
selectedItem="{<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %>}"/>
|
156
|
+
</mx:FormItem>
|
157
|
+
<% end -%>
|
158
|
+
</mx:Form>
|
159
|
+
<mx:ControlBar width="100%">
|
160
|
+
<mx:Button label="Save <%= class_name %>" width="50%" height="30"
|
161
|
+
click="save<%= class_name %>()"/>
|
162
|
+
<mx:Button label="Delete <%= class_name %>" width="50%" height="30"
|
163
|
+
enabled="{RxUtils.canDeleteModel(<%= class_name.dcfirst %>)}"
|
164
|
+
click="destroy<%= class_name %>()"/>
|
165
|
+
</mx:ControlBar>
|
166
|
+
</mx:Panel>
|
167
|
+
</mx:HBox>
|
@@ -0,0 +1,73 @@
|
|
1
|
+
package <%= base_package %>.models {
|
2
|
+
<% if has_manies.length > 0 || has_many_through.length > 0 -%>
|
3
|
+
import org.restfulx.collections.ModelsCollection;
|
4
|
+
<% end -%>
|
5
|
+
<% if tree_model.size > 0 -%>
|
6
|
+
<% @tree_or_no_tree = 'RxTreeModel' %>
|
7
|
+
import org.restfulx.models.RxTreeModel
|
8
|
+
<% end -%>
|
9
|
+
<% unless tree_model.size > 0 -%>
|
10
|
+
<% @tree_or_no_tree = 'RxModel' %>
|
11
|
+
import org.restfulx.models.RxModel;
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
[Resource(name="<%= resource_controller_name %>")]
|
15
|
+
[Bindable]
|
16
|
+
public class <%= class_name %> extends <%= @tree_or_no_tree %> {
|
17
|
+
<% if attributes && !attributes.empty? && attributes[0].flex_type != "Boolean" -%>
|
18
|
+
public static const LABEL:String = "<%= attributes[0].flex_name %>";
|
19
|
+
<% else -%>
|
20
|
+
public static const LABEL:String = "id";
|
21
|
+
<% end -%>
|
22
|
+
|
23
|
+
<% for attribute in attributes -%>
|
24
|
+
<% if attribute.type == :datetime || attribute.type == :time -%>
|
25
|
+
[DateTime]
|
26
|
+
<% end -%>
|
27
|
+
public var <%= attribute.flex_name %>:<%= attribute.flex_type %> = <%= attribute.flex_default %>;
|
28
|
+
|
29
|
+
<% end -%>
|
30
|
+
<% for model in belongs_tos -%>
|
31
|
+
[BelongsTo]
|
32
|
+
public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>;
|
33
|
+
|
34
|
+
<% end -%>
|
35
|
+
<% if tree_model.size > 0 -%>
|
36
|
+
[BelongsTo]
|
37
|
+
public var <%= tree_model[0].camelcase(:lower) %>:<%= class_name %>;
|
38
|
+
|
39
|
+
<% end -%>
|
40
|
+
<% for model in polymorphic -%>
|
41
|
+
[BelongsTo(polymorphic="true", dependsOn="Model1, Model2")]
|
42
|
+
public var <%= model.camelcase(:lower) %>:Object;
|
43
|
+
|
44
|
+
<% end -%>
|
45
|
+
<% if has_many_through.size > 0 -%>
|
46
|
+
<% has_many_through.each do |k,v| %>
|
47
|
+
[HasMany]
|
48
|
+
public var <%= k.camelcase(:lower) %>:ModelsCollection;
|
49
|
+
|
50
|
+
[HasMany(through="<%= k.camelcase %>")]
|
51
|
+
public var <%= v.camelcase(:lower) %>:ModelsCollection;
|
52
|
+
<% end -%>
|
53
|
+
<% end -%>
|
54
|
+
<% for model in has_ones -%>
|
55
|
+
[HasOne]
|
56
|
+
public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>;
|
57
|
+
|
58
|
+
<% end -%>
|
59
|
+
<% for model in has_manies -%>
|
60
|
+
[HasMany]
|
61
|
+
public var <%= model.camelcase(:lower) %>:ModelsCollection;
|
62
|
+
|
63
|
+
<% end -%>
|
64
|
+
<% if attachment_field.size > 0 -%>
|
65
|
+
[Ignored]
|
66
|
+
public var attachmentUrl:String;
|
67
|
+
|
68
|
+
<% end -%>
|
69
|
+
public function <%= class_name %>() {
|
70
|
+
super(LABEL);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from google.appengine.ext import db
|
2
|
+
<% if belongs_tos.length > 0 -%>
|
3
|
+
import <%= belongs_tos.join(", ") %>
|
4
|
+
<% end -%>
|
5
|
+
|
6
|
+
class <%= class_name %>(db.Model):
|
7
|
+
<% for attribute in attributes -%>
|
8
|
+
<%= attribute.name %> = db.<%= attribute.gae_type %>(<%= attribute.gae_default %>)
|
9
|
+
<% end -%>
|
10
|
+
<% for model in belongs_tos -%>
|
11
|
+
<%= model %> = db.ReferenceProperty(<%= model %>.<%= model.camelcase %>)
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire application based on db/model.yml file.
|
3
|
+
|
4
|
+
This generator transforms entries in db/model.yml into
|
5
|
+
command line calls to "rx_scaffold".
|
6
|
+
|
7
|
+
Examples:
|
8
|
+
`./script/generate rx_yaml_scaffold`
|
9
|
+
|
10
|
+
Sample Model File:
|
11
|
+
project:
|
12
|
+
- name: string
|
13
|
+
- notes: text
|
14
|
+
- start_date: date
|
15
|
+
- end_date: date
|
16
|
+
- completed: boolean
|
17
|
+
- belongs_to: [user]
|
18
|
+
- has_many: [tasks]
|
19
|
+
|
20
|
+
location:
|
21
|
+
- name: string
|
22
|
+
- notes: text
|
23
|
+
- belongs_to: [user]
|
24
|
+
- has_many: [tasks]
|
25
|
+
|
26
|
+
task:
|
27
|
+
- name: string
|
28
|
+
- notes: text
|
29
|
+
- start_time: datetime
|
30
|
+
- end_time: datetime
|
31
|
+
- completed: boolean
|
32
|
+
- next_action: boolean
|
33
|
+
- belongs_to: [project, location, user]
|
34
|
+
|
35
|
+
note:
|
36
|
+
- content: text
|
37
|
+
- belongs_to: [user]
|
38
|
+
|
39
|
+
user:
|
40
|
+
- login: string
|
41
|
+
- first_name: string
|
42
|
+
- last_name: string
|
43
|
+
- email: string
|
44
|
+
- has_many: [tasks, projects, locations]
|
45
|
+
- has_one: [note]
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class RxYamlScaffoldGenerator < RubiGen::Base
|
4
|
+
include RestfulX::Configuration
|
5
|
+
|
6
|
+
def extract_attrs(line, attrs)
|
7
|
+
attrs.each do |key,value|
|
8
|
+
if value.class == Array
|
9
|
+
line << " #{key}:#{value.join(',')}"
|
10
|
+
else
|
11
|
+
line << " #{key}:#{value}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
line
|
15
|
+
end
|
16
|
+
|
17
|
+
def manifest
|
18
|
+
record do |m|
|
19
|
+
models = YAML.load(File.open(File.join(APP_ROOT, 'db/model.yml'), 'r'))
|
20
|
+
models.each do |model|
|
21
|
+
line = ""
|
22
|
+
attrs = model[1]
|
23
|
+
if attrs.class == Array
|
24
|
+
attrs.each do |elm|
|
25
|
+
line = extract_attrs(line, elm)
|
26
|
+
end
|
27
|
+
else
|
28
|
+
line = extract_attrs(line, attrs)
|
29
|
+
end
|
30
|
+
line = model[0].camelcase + " " + line
|
31
|
+
puts 'running: rx_scaffold ' + line
|
32
|
+
RubiGen::Scripts::Generate.new.run(line.split, :generator => 'rx_scaffold',
|
33
|
+
:gae => options[:gae])
|
34
|
+
puts 'done ...'
|
35
|
+
end
|
36
|
+
RubiGen::Scripts::Generate.new.run([], :generator => 'rx_main_app', :gae => options[:gae])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def add_options!(opt)
|
42
|
+
opt.separator ''
|
43
|
+
opt.separator 'Options:'
|
44
|
+
opt.on("--gae", "Generate Google App Engine Python classes in addition to RestfulX Flex resources.",
|
45
|
+
"Default: false") { |v| options[:gae] = v }
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(
|
2
|
+
File.join(File.dirname(__FILE__), %w[.. lib restfulx]))
|
3
|
+
|
4
|
+
Spec::Runner.configure do |config|
|
5
|
+
# == Mock Framework
|
6
|
+
#
|
7
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
8
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
9
|
+
#
|
10
|
+
# config.mock_with :mocha
|
11
|
+
# config.mock_with :flexmock
|
12
|
+
# config.mock_with :rr
|
13
|
+
end
|
data/tasks/restfulx.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
|
7
|
+
# See ActionController::RequestForgeryProtection for details
|
8
|
+
# Uncomment the :secret if you're not using the cookie session store
|
9
|
+
protect_from_forgery # :secret => 'c83e3ff98f15718c4544ca8821f2b6d4'
|
10
|
+
|
11
|
+
# See ActionController::Base for details
|
12
|
+
# Uncomment this to filter the contents of submitted sensitive data parameters
|
13
|
+
# from your application log (in this case, all fields with names like "password").
|
14
|
+
# filter_parameter_logging :password
|
15
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
class LocationsController < ApplicationController
|
2
|
+
# GET /locations
|
3
|
+
# GET /locations.xml
|
4
|
+
def index
|
5
|
+
@locations = Location.find(:all)
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.xml { render :xml => @locations }
|
10
|
+
format.fxml { render :fxml => @locations }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /locations/1
|
15
|
+
# GET /locations/1.xml
|
16
|
+
def show
|
17
|
+
@location = Location.find(params[:id])
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
format.xml { render :xml => @location }
|
22
|
+
format.fxml { render :fxml => @location }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /locations/new
|
27
|
+
# GET /locations/new.xml
|
28
|
+
def new
|
29
|
+
@location = Location.new
|
30
|
+
|
31
|
+
respond_to do |format|
|
32
|
+
format.html # new.html.erb
|
33
|
+
format.xml { render :xml => @location }
|
34
|
+
format.fxml { render :fxml => @location }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# GET /locations/1/edit
|
39
|
+
def edit
|
40
|
+
@location = Location.find(params[:id])
|
41
|
+
end
|
42
|
+
|
43
|
+
# POST /locations
|
44
|
+
# POST /locations.xml
|
45
|
+
def create
|
46
|
+
@location = Location.new(params[:location])
|
47
|
+
|
48
|
+
respond_to do |format|
|
49
|
+
if @location.save
|
50
|
+
flash[:notice] = 'Location was successfully created.'
|
51
|
+
format.html { redirect_to(@location) }
|
52
|
+
format.xml { render :xml => @location, :status => :created, :location => @location }
|
53
|
+
format.fxml { render :fxml => @location }
|
54
|
+
else
|
55
|
+
format.html { render :action => "new" }
|
56
|
+
format.xml { render :xml => @location.errors, :status => :unprocessable_entity }
|
57
|
+
format.fxml { render :fxml => @location.errors }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# PUT /locations/1
|
63
|
+
# PUT /locations/1.xml
|
64
|
+
def update
|
65
|
+
@location = Location.find(params[:id])
|
66
|
+
|
67
|
+
respond_to do |format|
|
68
|
+
if @location.update_attributes(params[:location])
|
69
|
+
flash[:notice] = 'Location was successfully updated.'
|
70
|
+
format.html { redirect_to(@location) }
|
71
|
+
format.xml { head :ok }
|
72
|
+
format.fxml { render :fxml => @location }
|
73
|
+
else
|
74
|
+
format.html { render :action => "edit" }
|
75
|
+
format.xml { render :xml => @location.errors, :status => :unprocessable_entity }
|
76
|
+
format.fxml { render :fxml => @location.errors }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# DELETE /locations/1
|
82
|
+
# DELETE /locations/1.xml
|
83
|
+
def destroy
|
84
|
+
@location = Location.find(params[:id])
|
85
|
+
@location.destroy
|
86
|
+
|
87
|
+
respond_to do |format|
|
88
|
+
format.html { redirect_to(locations_url) }
|
89
|
+
format.xml { head :ok }
|
90
|
+
format.fxml { render :fxml => @location }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|