dima-restfulx 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/app_generators/rx_app/templates/project-textmate.erb +29 -9
- data/generators/rx_scaffold/templates/component.mxml.erb +2 -2
- data/lib/restfulx.rb +6 -2
- data/lib/restfulx/datamapper_foo.rb +64 -14
- data/rails_generators/rx_config/templates/project-textmate.erb +29 -9
- data/rails_generators/rx_scaffold/templates/component.mxml.erb +2 -2
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -21,10 +21,6 @@
|
|
21
21
|
<integer>299</integer>
|
22
22
|
<key>metaData</key>
|
23
23
|
<dict/>
|
24
|
-
<key>openDocuments</key>
|
25
|
-
<array>
|
26
|
-
<string>app/flex/<%= project_name %>.mxml</string>
|
27
|
-
</array>
|
28
24
|
<key>shellVariables</key>
|
29
25
|
<array>
|
30
26
|
<dict>
|
@@ -43,10 +39,34 @@
|
|
43
39
|
<key>variable</key>
|
44
40
|
<string>TM_FLEX_OUTPUT</string>
|
45
41
|
</dict>
|
42
|
+
<dict>
|
43
|
+
<key>enabled</key>
|
44
|
+
<true/>
|
45
|
+
<key>value</key>
|
46
|
+
<string>app/flex</string>
|
47
|
+
<key>variable</key>
|
48
|
+
<string>TM_AS3_USUAL_SRC_DIRS</string>
|
49
|
+
</dict>
|
50
|
+
<dict>
|
51
|
+
<key>enabled</key>
|
52
|
+
<true/>
|
53
|
+
<key>value</key>
|
54
|
+
<string>/Users/Dima/Projects/dev/restfulx_framework/framework/src</string>
|
55
|
+
<key>variable</key>
|
56
|
+
<string>TM_AS3_LIB_SRC_DIRS</string>
|
57
|
+
</dict>
|
58
|
+
<dict>
|
59
|
+
<key>enabled</key>
|
60
|
+
<true/>
|
61
|
+
<key>value</key>
|
62
|
+
<string><%= use_air ? 'air' : 'flex' %></string>
|
63
|
+
<key>variable</key>
|
64
|
+
<string>TM_FLEX_RUNTIME</string>
|
65
|
+
</dict>
|
46
66
|
</array>
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
67
|
+
<key>showFileHierarchyDrawer</key>
|
68
|
+
<false/>
|
69
|
+
<key>windowFrame</key>
|
70
|
+
<string>{{53, 14}, {1221, 864}}</string>
|
51
71
|
</dict>
|
52
|
-
</plist>
|
72
|
+
</plist>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
2
|
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" label="<%= class_name %>"
|
3
|
-
xmlns:
|
3
|
+
xmlns:rx="org.restfulx.components.rx.*">
|
4
4
|
<mx:Script><![CDATA[
|
5
5
|
import org.restfulx.Rx;
|
6
6
|
import org.restfulx.utils.RxUtils;
|
@@ -121,7 +121,7 @@
|
|
121
121
|
<% elsif attribute.type == :text -%>
|
122
122
|
<mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
123
123
|
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
124
|
-
<
|
124
|
+
<rx:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
125
125
|
<% elsif attribute.type == :date -%>
|
126
126
|
<mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
127
127
|
<% else -%>
|
data/lib/restfulx.rb
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
module RestfulX
|
6
6
|
|
7
7
|
# :stopdoc:
|
8
|
-
VERSION = '1.2.
|
9
|
-
FRAMEWORK_VERSION = '1.2.
|
8
|
+
VERSION = '1.2.1'
|
9
|
+
FRAMEWORK_VERSION = '1.2.1'
|
10
10
|
LIB_DIR = File.join(File.dirname(__FILE__), 'restfulx/')
|
11
11
|
# :startdoc:
|
12
12
|
|
@@ -114,4 +114,8 @@ elsif defined?(ActionController::Base)
|
|
114
114
|
|
115
115
|
# temporarily disable forgery protection site-wise
|
116
116
|
ActionController::Base.allow_forgery_protection = false
|
117
|
+
elsif defined?(DataMapper)
|
118
|
+
require RestfulX::LIB_DIR + 'datamapper_foo'
|
119
|
+
elsif defined?(ActiveRecord::Base)
|
120
|
+
require RestfulX::LIB_DIR + 'active_foo'
|
117
121
|
end
|
@@ -1,9 +1,54 @@
|
|
1
|
-
require 'builder'
|
2
|
-
require RestfulX::LIB_DIR + 'configuration'
|
3
|
-
|
4
1
|
# Flex friendly DataMapper patches, more specifically we just add +to_xml+ on
|
5
2
|
# ValidationErrors class
|
3
|
+
require 'dm-serializer/common'
|
4
|
+
require 'dm-serializer/xml_serializers'
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'restfulx') if !defined?(RestfulX)
|
6
|
+
|
7
|
+
# RestfulX datamapper patches
|
6
8
|
module DataMapper
|
9
|
+
|
10
|
+
# Monkey patches dm-serialization to_json method to add ruby_class: YourClass
|
11
|
+
# to all serialized objects
|
12
|
+
module Serialize
|
13
|
+
# Serialize a Resource to JavaScript Object Notation (JSON; RFC 4627)
|
14
|
+
#
|
15
|
+
# @return <String> a JSON representation of the Resource
|
16
|
+
def to_json(*args)
|
17
|
+
options = args.first || {}
|
18
|
+
result = '{ '
|
19
|
+
fields = []
|
20
|
+
|
21
|
+
propset = properties_to_serialize(options)
|
22
|
+
|
23
|
+
fields += propset.map do |property|
|
24
|
+
"#{property.name.to_json}: #{send(property.getter).to_json}"
|
25
|
+
end
|
26
|
+
|
27
|
+
fields << "\"ruby_class\": #{self.class.to_json}"
|
28
|
+
|
29
|
+
# add methods
|
30
|
+
(options[:methods] || []).each do |meth|
|
31
|
+
if self.respond_to?(meth)
|
32
|
+
fields << "#{meth.to_json}: #{send(meth).to_json}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Note: if you want to include a whole other model via relation, use :methods
|
37
|
+
# comments.to_json(:relationships=>{:user=>{:include=>[:first_name],:methods=>[:age]}})
|
38
|
+
# add relationships
|
39
|
+
# TODO: This needs tests and also needs to be ported to #to_xml and #to_yaml
|
40
|
+
(options[:relationships] || {}).each do |rel,opts|
|
41
|
+
if self.respond_to?(rel)
|
42
|
+
fields << "#{rel.to_json}: #{send(rel).to_json(opts)}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
result << fields.join(', ')
|
47
|
+
result << ' }'
|
48
|
+
result
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
7
52
|
# see DataMapper docs for more details
|
8
53
|
module Validate
|
9
54
|
# By default DataMapper validation errors doesn't have +to_xml+ method. This is
|
@@ -11,20 +56,25 @@ module DataMapper
|
|
11
56
|
class ValidationErrors
|
12
57
|
# Add Flex-friendly +to_xml+ implementation
|
13
58
|
def to_xml
|
14
|
-
xml =
|
15
|
-
|
16
|
-
xml.errors
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
59
|
+
xml = DataMapper::Serialize::XMLSerializers::SERIALIZER
|
60
|
+
doc ||= xml.new_document
|
61
|
+
root = xml.root_node(doc, "errors")
|
62
|
+
@errors.each_key do |attribute|
|
63
|
+
@errors[attribute].each do |msg|
|
64
|
+
next if msg.nil?
|
65
|
+
if attribute == "base"
|
66
|
+
xml.add_node(root, "error", nil, {"message" => msg})
|
67
|
+
else
|
68
|
+
xml.add_node(root, "error", nil, {"field" => attribute.to_s.camel_case.dcfirst, "message" => msg})
|
25
69
|
end
|
26
70
|
end
|
27
71
|
end
|
72
|
+
xml.output(doc)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Add to_json support for datamapper errors too
|
76
|
+
def to_json
|
77
|
+
@errors.to_json
|
28
78
|
end
|
29
79
|
end
|
30
80
|
end
|
@@ -21,10 +21,6 @@
|
|
21
21
|
<integer>299</integer>
|
22
22
|
<key>metaData</key>
|
23
23
|
<dict/>
|
24
|
-
<key>openDocuments</key>
|
25
|
-
<array>
|
26
|
-
<string>app/flex/<%= project_name %>.mxml</string>
|
27
|
-
</array>
|
28
24
|
<key>shellVariables</key>
|
29
25
|
<array>
|
30
26
|
<dict>
|
@@ -43,10 +39,34 @@
|
|
43
39
|
<key>variable</key>
|
44
40
|
<string>TM_FLEX_OUTPUT</string>
|
45
41
|
</dict>
|
42
|
+
<dict>
|
43
|
+
<key>enabled</key>
|
44
|
+
<true/>
|
45
|
+
<key>value</key>
|
46
|
+
<string>app/flex</string>
|
47
|
+
<key>variable</key>
|
48
|
+
<string>TM_AS3_USUAL_SRC_DIRS</string>
|
49
|
+
</dict>
|
50
|
+
<dict>
|
51
|
+
<key>enabled</key>
|
52
|
+
<true/>
|
53
|
+
<key>value</key>
|
54
|
+
<string>/Users/Dima/Projects/dev/restfulx_framework/framework/src</string>
|
55
|
+
<key>variable</key>
|
56
|
+
<string>TM_AS3_LIB_SRC_DIRS</string>
|
57
|
+
</dict>
|
58
|
+
<dict>
|
59
|
+
<key>enabled</key>
|
60
|
+
<true/>
|
61
|
+
<key>value</key>
|
62
|
+
<string><%= use_air ? 'air' : 'flex' %></string>
|
63
|
+
<key>variable</key>
|
64
|
+
<string>TM_FLEX_RUNTIME</string>
|
65
|
+
</dict>
|
46
66
|
</array>
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
67
|
+
<key>showFileHierarchyDrawer</key>
|
68
|
+
<false/>
|
69
|
+
<key>windowFrame</key>
|
70
|
+
<string>{{53, 14}, {1221, 864}}</string>
|
51
71
|
</dict>
|
52
|
-
</plist>
|
72
|
+
</plist>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
2
|
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" label="<%= class_name %>"
|
3
|
-
xmlns:
|
3
|
+
xmlns:rx="org.restfulx.components.rx.*">
|
4
4
|
<mx:Script><![CDATA[
|
5
5
|
import org.restfulx.Rx;
|
6
6
|
import org.restfulx.utils.RxUtils;
|
@@ -121,7 +121,7 @@
|
|
121
121
|
<% elsif attribute.type == :text -%>
|
122
122
|
<mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
123
123
|
<% elsif attribute.type == :datetime || attribute.type == :time -%>
|
124
|
-
<
|
124
|
+
<rx:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
125
125
|
<% elsif attribute.type == :date -%>
|
126
126
|
<mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
|
127
127
|
<% else -%>
|
@@ -42,8 +42,8 @@ class RxYamlScaffoldGenerator < Rails::Generator::Base
|
|
42
42
|
opt.separator ''
|
43
43
|
opt.separator 'Options:'
|
44
44
|
opt.on("--flex-only", "Only generate the Flex/AIR files.",
|
45
|
-
"Default: false") { |v| options[:
|
45
|
+
"Default: false") { |v| options[:flex_only] = v }
|
46
46
|
opt.on("--skip-framework", "Don't fetch the latest framework binary. You'll have to link/build the framework yourself.",
|
47
47
|
"Default: false") { |v| options[:skip_framework] = v }
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dima-restfulx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dima Berastau
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-02 00:00:00 -08:00
|
13
13
|
default_executable: rx-gen
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|