resty-generators 0.1.0 → 0.2.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.
- data/lib/generators/resty/setup/setup_generator.rb +7 -1
- data/lib/generators/resty/setup/templates/Mavenfile +20 -6
- data/lib/generators/resty/setup/templates/empty.css +0 -0
- data/lib/generators/resty/setup/templates/initializer.rb +25 -0
- data/lib/generators/resty/setup/templates/module.gwt.xml +1 -1
- data/lib/generators/resty/setup/templates/monkey_patch.rb +47 -0
- data/lib/generators/resty/setup/templates/page.html +29 -0
- data/lib/generators/resty/templates/Controller.java +7 -7
- metadata +64 -17
|
@@ -25,8 +25,14 @@ module Resty
|
|
|
25
25
|
template 'EntryPoint.java', File.join(java_root, base_package.gsub(/\./, "/"), "#{application_name}.java")
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def
|
|
28
|
+
def create_initializers
|
|
29
29
|
template 'initializer.rb', File.join('config', 'initializers', 'resty.rb')
|
|
30
|
+
template 'monkey_patch.rb', File.join('config', 'initializers', 'resty_monkey_patch.rb')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def create_html
|
|
34
|
+
template 'page.html', File.join('public', "#{application_name.underscore}.html")
|
|
35
|
+
template 'empty.css', File.join('public', 'stylesheets', "#{application_name.underscore}.css")
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
def base_package
|
|
@@ -1,16 +1,30 @@
|
|
|
1
|
+
#-*- mode: ruby -*-
|
|
1
2
|
jar('org.fusesource.restygwt:restygwt', '1.1').scope = :provided
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
jar('javax.ws.rs:jsr311-api', '1.1').scope :provided
|
|
4
|
+
jar('com.google.gwt:gwt-user', '2.2.0').scope :provided
|
|
5
|
+
|
|
6
|
+
plugin('org.codehaus.mojo:gwt-maven-plugin', '2.2.0') do |gwt|
|
|
7
|
+
gwt.with({ :warSourceDirectory => "${basedir}/public",
|
|
8
|
+
:webXml => "${basedir}/public/WEB-INF/web.xml",
|
|
9
|
+
:webappDirectory => "${basedir}/public",
|
|
10
|
+
:hostedWebapp => "${basedir}/public",
|
|
11
|
+
:inplace => true,
|
|
12
|
+
:logLevel => "INFO",
|
|
4
13
|
:style => "DETAILED",
|
|
5
14
|
:treeLogger => true,
|
|
6
15
|
:extraJvmArgs => "-Xmx512m",
|
|
7
|
-
:runTarget => "<%= application_name.underscore
|
|
16
|
+
:runTarget => "<%= application_name.underscore %>.html",
|
|
8
17
|
:includes => "**/<%= application_name %>GWTTestSuite.java"
|
|
9
18
|
})
|
|
10
|
-
gwt.
|
|
19
|
+
gwt.executions.goals << ["clean", "compile", "test"]
|
|
11
20
|
end
|
|
21
|
+
plugin(:bundler, "${jruby.plugins.version}").execution.goals << :install
|
|
22
|
+
plugin(:rails3).in_phase("initialize").execute_goal(:pom).with :force => true
|
|
23
|
+
|
|
12
24
|
#-- Macs need the -d32 -XstartOnFirstThread jvm options -->
|
|
13
25
|
profile("mac") do |mac|
|
|
14
|
-
mac.activation
|
|
15
|
-
plugin('org.codehaus.mojo
|
|
26
|
+
mac.activation.os.family "mac"
|
|
27
|
+
mac.plugin('org.codehaus.mojo:gwt-maven-plugin').with(:extraJvmArgs => "-d32 -XstartOnFirstThread -Xmx512m")
|
|
16
28
|
end
|
|
29
|
+
|
|
30
|
+
# vim: syntax=Ruby
|
|
File without changes
|
|
@@ -1,3 +1,28 @@
|
|
|
1
1
|
require 'resty/child_path'
|
|
2
2
|
|
|
3
3
|
Rails.application.config.middleware.use Resty::ChildPath, '<%= application_name.underscore %>'
|
|
4
|
+
|
|
5
|
+
ActiveRecord::Base.include_root_in_json = false
|
|
6
|
+
|
|
7
|
+
# get the time/date format right ;-)
|
|
8
|
+
class DateTime
|
|
9
|
+
def as_json(options = nil)
|
|
10
|
+
strftime('%Y-%m-%dT%H:%M:%S.%s%z')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
class ActiveSupport::TimeWithZone
|
|
14
|
+
def as_json(options = nil)
|
|
15
|
+
strftime('%Y-%m-%dT%H:%M:%S.%s%z')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
class Date
|
|
19
|
+
def as_json(options = nil)
|
|
20
|
+
strftime('%Y-%m-%dT%H:%M:%S.%s%z')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Time
|
|
25
|
+
def as_json(options = nil)
|
|
26
|
+
strftime('%Y-%m-%dT%H:%M:%S.%s%z')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'action_dispatch/http/request'
|
|
2
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
|
3
|
+
|
|
4
|
+
module ActionDispatch
|
|
5
|
+
class ParamsParser
|
|
6
|
+
|
|
7
|
+
alias :call_old :call
|
|
8
|
+
def call(env)
|
|
9
|
+
request = Request.new(env)
|
|
10
|
+
mime_type = content_type_from_legacy_post_data_format_header(env) ||
|
|
11
|
+
request.content_mime_type
|
|
12
|
+
|
|
13
|
+
case mime_type
|
|
14
|
+
when Mime::JSON
|
|
15
|
+
data = ActiveSupport::JSON.decode(request.body)
|
|
16
|
+
request.body.rewind if request.body.respond_to?(:rewind)
|
|
17
|
+
data = {:_json => data} unless data.is_a?(Hash)
|
|
18
|
+
env["action_dispatch.request.request_parameters"] = {:json => data}.with_indifferent_access
|
|
19
|
+
|
|
20
|
+
@app.call(env)
|
|
21
|
+
else
|
|
22
|
+
call_old(env)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
module ActionController
|
|
29
|
+
class Base
|
|
30
|
+
def from_java(map)
|
|
31
|
+
result = map.dup
|
|
32
|
+
map.each do |k,v|
|
|
33
|
+
result.delete(k)
|
|
34
|
+
result[k.underscore] = v.is_a?(Hash) ? from_java(v) : v
|
|
35
|
+
end
|
|
36
|
+
result
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
::ActionController::Base.send(:before_filter) do
|
|
42
|
+
json = params.delete(:json)
|
|
43
|
+
if json
|
|
44
|
+
params[params[:controller].singularize] = from_java(json)
|
|
45
|
+
end
|
|
46
|
+
true
|
|
47
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
5
|
+
<!-- -->
|
|
6
|
+
<!-- Any title is fine -->
|
|
7
|
+
<!-- -->
|
|
8
|
+
<title><%= application_name %></title>
|
|
9
|
+
|
|
10
|
+
<!-- -->
|
|
11
|
+
<!-- This script loads your compiled module. -->
|
|
12
|
+
<!-- If you add any GWT meta tags, they must -->
|
|
13
|
+
<!-- be added before this line. -->
|
|
14
|
+
<!-- -->
|
|
15
|
+
<script type="text/javascript" language="javascript" src="<%= application_name.underscore %>/<%= application_name.underscore %>.nocache.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<!-- -->
|
|
19
|
+
<!-- The body can have arbitrary html, or -->
|
|
20
|
+
<!-- you can leave the body empty if you want -->
|
|
21
|
+
<!-- to create a completely dynamic UI. -->
|
|
22
|
+
<!-- -->
|
|
23
|
+
<body>
|
|
24
|
+
|
|
25
|
+
<!-- OPTIONAL: include this if you want history support -->
|
|
26
|
+
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
|
|
27
|
+
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
|
@@ -18,30 +18,30 @@ public interface <%= controller_class_name %>Controller extends RestService {
|
|
|
18
18
|
<% actions.each do |action|
|
|
19
19
|
case action_map[action]
|
|
20
20
|
when :get_all -%>
|
|
21
|
-
@GET @Path(
|
|
21
|
+
@GET @Path("/<%= table_name %>.json")
|
|
22
22
|
void <%= action %>(MethodCallback<List<<%= class_name %>>> callback);
|
|
23
23
|
|
|
24
|
-
// @GET @Path(
|
|
24
|
+
// @GET @Path("/<%= table_name %>.json")
|
|
25
25
|
// void <%= action %>(MethodCallback<List<<%= class_name %>>> callback, @QueryParam("limit") int limit, @QueryParam("offset") int offset);
|
|
26
26
|
//
|
|
27
27
|
<% when :get_single -%>
|
|
28
|
-
@GET<% unless options[:singleton] -%> @Path("
|
|
28
|
+
@GET<% unless options[:singleton] -%> @Path("/<%= table_name %>/{id}.json")<% end %>
|
|
29
29
|
void <%= action %>(<% unless options[:singleton] -%>@PathParam("id") int id, <% end -%>MethodCallback<<%= class_name %>> callback);
|
|
30
30
|
|
|
31
31
|
<% when :post -%>
|
|
32
|
-
@POST @Path(
|
|
32
|
+
@POST @Path("/<%= table_name %>.json")
|
|
33
33
|
void <%= action %>(<%= class_name %> value, MethodCallback<<%= class_name %>> callback);
|
|
34
34
|
|
|
35
35
|
<% when :put -%>
|
|
36
|
-
@PUT<% unless options[:singleton] -%> @Path("
|
|
36
|
+
@PUT<% unless options[:singleton] -%> @Path("/<%= table_name %>/{id}.json")<% end %>
|
|
37
37
|
void <%= action %>(<% unless options[:singleton] -%>@PathParam("id") @Attribute("id") <% end -%><%= class_name %> value, MethodCallback<<%= class_name %>> callback);
|
|
38
38
|
|
|
39
39
|
<% when :delete -%>
|
|
40
|
-
@DELETE @Path("
|
|
40
|
+
@DELETE @Path("/<%= table_name %>/{id}.json")
|
|
41
41
|
void <%= action %>(@PathParam("id") @Attribute("id") <%= class_name %> value, MethodCallback<Void> callback);
|
|
42
42
|
|
|
43
43
|
<% else -%>
|
|
44
|
-
@GET @Path("/<%= action %>.json")
|
|
44
|
+
@GET @Path("/<%= table_name %>/<%= action %>.json")
|
|
45
45
|
void <%= action %>(MethodCallback<Void> callback);
|
|
46
46
|
|
|
47
47
|
<% end
|
metadata
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: resty-generators
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
prerelease:
|
|
5
|
-
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 2
|
|
8
|
+
- 0
|
|
9
|
+
version: 0.2.0
|
|
6
10
|
platform: ruby
|
|
7
11
|
authors:
|
|
8
12
|
- mkristian
|
|
@@ -10,53 +14,91 @@ autorequire:
|
|
|
10
14
|
bindir: bin
|
|
11
15
|
cert_chain: []
|
|
12
16
|
|
|
13
|
-
date: 2011-
|
|
17
|
+
date: 2011-04-05 00:00:00 +05:30
|
|
14
18
|
default_executable:
|
|
15
19
|
dependencies:
|
|
16
20
|
- !ruby/object:Gem::Dependency
|
|
17
|
-
name:
|
|
21
|
+
name: ixtlan-core
|
|
18
22
|
prerelease: false
|
|
19
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
20
|
-
none: false
|
|
21
24
|
requirements:
|
|
22
|
-
- - "
|
|
25
|
+
- - ">="
|
|
23
26
|
- !ruby/object:Gem::Version
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
segments:
|
|
28
|
+
- 0
|
|
29
|
+
- 2
|
|
30
|
+
- 0
|
|
31
|
+
version: 0.2.0
|
|
32
|
+
- - <
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
segments:
|
|
35
|
+
- 0
|
|
36
|
+
- 2
|
|
37
|
+
- 99999
|
|
38
|
+
version: 0.2.99999
|
|
39
|
+
type: :runtime
|
|
26
40
|
version_requirements: *id001
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
42
|
+
name: rails
|
|
29
43
|
prerelease: false
|
|
30
44
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
31
|
-
none: false
|
|
32
45
|
requirements:
|
|
33
46
|
- - "="
|
|
34
47
|
- !ruby/object:Gem::Version
|
|
35
|
-
|
|
48
|
+
segments:
|
|
49
|
+
- 3
|
|
50
|
+
- 0
|
|
51
|
+
- 5
|
|
52
|
+
version: 3.0.5
|
|
36
53
|
type: :development
|
|
37
54
|
version_requirements: *id002
|
|
38
55
|
- !ruby/object:Gem::Dependency
|
|
39
56
|
name: cucumber
|
|
40
57
|
prerelease: false
|
|
41
58
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
42
|
-
none: false
|
|
43
59
|
requirements:
|
|
44
60
|
- - "="
|
|
45
61
|
- !ruby/object:Gem::Version
|
|
46
|
-
|
|
62
|
+
segments:
|
|
63
|
+
- 0
|
|
64
|
+
- 10
|
|
65
|
+
- 2
|
|
66
|
+
version: 0.10.2
|
|
47
67
|
type: :development
|
|
48
68
|
version_requirements: *id003
|
|
49
69
|
- !ruby/object:Gem::Dependency
|
|
50
70
|
name: rake
|
|
51
71
|
prerelease: false
|
|
52
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
|
53
|
-
none: false
|
|
54
73
|
requirements:
|
|
55
74
|
- - "="
|
|
56
75
|
- !ruby/object:Gem::Version
|
|
76
|
+
segments:
|
|
77
|
+
- 0
|
|
78
|
+
- 8
|
|
79
|
+
- 7
|
|
57
80
|
version: 0.8.7
|
|
58
81
|
type: :development
|
|
59
82
|
version_requirements: *id004
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: ruby-maven
|
|
85
|
+
prerelease: false
|
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - "="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
segments:
|
|
91
|
+
- 0
|
|
92
|
+
- 8
|
|
93
|
+
- 3
|
|
94
|
+
- 0
|
|
95
|
+
- 2
|
|
96
|
+
- 0
|
|
97
|
+
- 26
|
|
98
|
+
- 0
|
|
99
|
+
version: 0.8.3.0.2.0.26.0
|
|
100
|
+
type: :development
|
|
101
|
+
version_requirements: *id005
|
|
60
102
|
description: simple authorization framework for rails controllers
|
|
61
103
|
email:
|
|
62
104
|
- m.kristian@web.de
|
|
@@ -77,6 +119,9 @@ files:
|
|
|
77
119
|
- lib/generators/resty/templates/Model.java
|
|
78
120
|
- lib/generators/resty/setup/setup_generator.rb
|
|
79
121
|
- lib/generators/resty/setup/templates/Mavenfile
|
|
122
|
+
- lib/generators/resty/setup/templates/page.html
|
|
123
|
+
- lib/generators/resty/setup/templates/monkey_patch.rb
|
|
124
|
+
- lib/generators/resty/setup/templates/empty.css
|
|
80
125
|
- lib/generators/resty/setup/templates/module.gwt.xml
|
|
81
126
|
- lib/generators/resty/setup/templates/EntryPoint.java
|
|
82
127
|
- lib/generators/resty/setup/templates/initializer.rb
|
|
@@ -93,21 +138,23 @@ rdoc_options:
|
|
|
93
138
|
require_paths:
|
|
94
139
|
- lib
|
|
95
140
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
|
-
none: false
|
|
97
141
|
requirements:
|
|
98
142
|
- - ">="
|
|
99
143
|
- !ruby/object:Gem::Version
|
|
144
|
+
segments:
|
|
145
|
+
- 0
|
|
100
146
|
version: "0"
|
|
101
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
|
-
none: false
|
|
103
148
|
requirements:
|
|
104
149
|
- - ">="
|
|
105
150
|
- !ruby/object:Gem::Version
|
|
151
|
+
segments:
|
|
152
|
+
- 0
|
|
106
153
|
version: "0"
|
|
107
154
|
requirements: []
|
|
108
155
|
|
|
109
156
|
rubyforge_project:
|
|
110
|
-
rubygems_version: 1.
|
|
157
|
+
rubygems_version: 1.3.6
|
|
111
158
|
signing_key:
|
|
112
159
|
specification_version: 3
|
|
113
160
|
summary: guard your controller actions
|