resty-generators 0.7.2 → 0.7.3

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 (34) hide show
  1. data/features/generators.feature +10 -10
  2. data/lib/generators/resty/model/model_generator.rb +7 -1
  3. data/lib/generators/resty/scaffold/scaffold_generator.rb +1 -1
  4. data/lib/generators/resty/setup/setup_generator.rb +61 -46
  5. data/lib/generators/resty/setup/templates/ActivityPlaceActivityMapper.java +1 -1
  6. data/lib/generators/resty/setup/templates/Application.java +31 -0
  7. data/lib/generators/resty/setup/templates/Application.java~ +95 -0
  8. data/lib/generators/resty/setup/templates/ApplicationLinksPanel.java +29 -0
  9. data/lib/generators/resty/setup/templates/ApplicationLinksPanel.java~ +29 -0
  10. data/lib/generators/resty/setup/templates/BreadCrumbsPanel.java +2 -2
  11. data/lib/generators/resty/setup/templates/EntryPoint.java +14 -4
  12. data/lib/generators/resty/setup/templates/LoginActivity.java +2 -2
  13. data/lib/generators/resty/setup/templates/Mavenfile +10 -2
  14. data/lib/generators/resty/setup/templates/SessionActivityPlaceActivityMapper.java +3 -3
  15. data/lib/generators/resty/setup/templates/User.java +14 -1
  16. data/lib/generators/resty/setup/templates/application.rb +15 -0
  17. data/lib/generators/resty/setup/templates/authentication.rb +2 -2
  18. data/lib/generators/resty/setup/templates/gwt.css +13 -1
  19. data/lib/generators/resty/setup/templates/remote_user.rb +1 -1
  20. data/lib/generators/resty/setup/templates/remote_user.rb~ +1 -1
  21. data/lib/generators/resty/setup/templates/session.rb +7 -0
  22. data/lib/generators/resty/setup/templates/sessions_controller.rb +2 -2
  23. data/lib/generators/resty/setup/templates/user.rb +23 -5
  24. data/lib/generators/resty/templates/Activity.java +22 -5
  25. data/lib/generators/resty/templates/Editor.java +1 -0
  26. data/lib/generators/resty/templates/Model.java +8 -2
  27. data/lib/generators/resty/templates/RestService.java +0 -1
  28. data/lib/ixtlan/core/heartbeat.rb~ +8 -2
  29. data/lib/rails_gwt/dsl.rb +210 -0
  30. data/lib/rails_gwt/dsl.rb~ +210 -0
  31. data/lib/rails_gwt/user_config.rb +80 -0
  32. data/lib/rails_gwt/user_config.rb~ +76 -0
  33. metadata +11 -3
  34. data/lib/ixtlan/core/heartbeat.rb +0 -59
@@ -14,16 +14,16 @@ Feature: Generators for Resty
14
14
  Then the output should contain "src/main/java/com/example/Simple.gwt.xml" and "Mavenfile" and "src/main/java/com/example/client/SimpleEntryPoint.java" and "public/Simple.html" and "public/stylesheets/simple.css"
15
15
 
16
16
  Given me an existing rails application "simple"
17
- And I execute "compile gwt:compile"
18
- Then the output should contain "Compilation succeeded"
17
+ And I execute "compile"
18
+ Then the output should contain "BUILD SUCCESS"
19
19
 
20
20
  Given me an existing rails application "simple"
21
21
  And I execute "rails generate scaffold user name:string"
22
22
  Then the output should contain "src/main/java/com/example/client/models/User.java" and "src/main/java/com/example/client/restservices/UsersRestService.java"
23
23
 
24
24
  Given me an existing rails application "simple"
25
- And I execute "compile gwt:compile"
26
- Then the output should contain "Compilation succeeded"
25
+ And I execute "compile"
26
+ Then the output should contain "BUILD SUCCESS"
27
27
 
28
28
  Given me an existing rails application "simple"
29
29
  And I execute "rake db:migrate test"
@@ -31,13 +31,13 @@ Feature: Generators for Resty
31
31
 
32
32
  Given me an existing rails application "simple"
33
33
  And I execute "rails generate scaffold project name:string children:number cars:fixnum age:integer weight:float activated:boolean expires_at:date fire_up_at:datetime --skip-timestamps"
34
- And I execute "compile gwt:compile"
35
- Then the output should contain "Compilation succeeded"
34
+ And I execute "compile"
35
+ Then the output should contain "BUILD SUCCESS"
36
36
 
37
37
  Given me an existing rails application "simple"
38
38
  And I execute "rails generate scaffold accounts name:string --timestamps --optimistic"
39
- And I execute "compile gwt:compile"
40
- Then the output should contain "Compilation succeeded"
39
+ And I execute "compile"
40
+ Then the output should contain "BUILD SUCCESS"
41
41
 
42
42
  Given me an existing rails application "simple"
43
43
  And I execute "rails generate model cars name:string"
@@ -52,8 +52,8 @@ Feature: Generators for Resty
52
52
  Then the output should contain "src/main/java/com/example/client/SessionActivityPlaceActivityMapper.java" and "src/main/java/com/example/client/managed/CompleteMenuPanel.java" and "src/main/java/com/example/client/activities/LoginActivity.java"
53
53
 
54
54
  Given me an existing rails application "complete"
55
- And I execute "compile gwt:compile"
56
- Then the output should contain "Compilation succeeded"
55
+ And I execute "compile"
56
+ Then the output should contain "BUILD SUCCESS"
57
57
 
58
58
  Given me an existing rails application "complete"
59
59
  And I execute "rails generate scaffold accounts name:string"
@@ -18,6 +18,12 @@ module Resty
18
18
  template 'Model.java', File.join(java_root, models_package.gsub(/\./, "/"), class_path, "#{class_name}.java")
19
19
  end
20
20
 
21
+ def create_cache_file
22
+ if !options[:singleton] && !options[:read_only]
23
+ template 'Cache.java', File.join(java_root, caches_package.gsub(/\./, "/"), class_path, "#{class_name.pluralize}Cache.java")
24
+ end
25
+ end
26
+
21
27
  def create_event_files
22
28
  template 'Event.java', File.join(java_root, events_package.gsub(/\./, "/"), class_path, "#{class_name}Event.java")
23
29
  template 'EventHandler.java', File.join(java_root, events_package.gsub(/\./, "/"), class_path, "#{class_name}EventHandler.java")
@@ -28,7 +34,7 @@ module Resty
28
34
  end
29
35
 
30
36
  def controller_class_name
31
- @controller_class_name ||= class_name
37
+ @controller_class_name ||= class_name.pluralize
32
38
  end
33
39
 
34
40
  def actions
@@ -61,7 +61,7 @@ module Resty
61
61
  if factory =~ /@Named\(.#{table_name}.\)/
62
62
  log 'keep', factory_file
63
63
  else
64
- factory.sub! /interface\s+ActivityFactory\s+\{/, "interface ActivityFactory {\n @Named(\"#{table_name}\") Activity create(#{places_package}.#{class_name}Place place);"
64
+ factory.sub! /interface\s+ActivityFactory\s+\{/, "interface ActivityFactory {\n @Named(\"#{table_name}\") Activity create(#{places_package}.#{class_name}Place place);"
65
65
  File.open(factory_file, 'w') { |f| f.print factory }
66
66
  log "added to", factory_file
67
67
  end
@@ -20,25 +20,25 @@ module Resty
20
20
  end
21
21
 
22
22
  def create_module_file
23
- template 'module.gwt.xml', File.join(java_root, name.gsub(/\./, "/"), "#{application_name}.gwt.xml")
23
+ template 'module.gwt.xml', File.join(java_root, name.gsub(/\./, '/'), "#{application_name}.gwt.xml")
24
24
  end
25
25
 
26
26
  def create_maven_file
27
- template 'Mavenfile', "Mavenfile"
28
- unless File.read(".gitignore") =~ /^target/
29
- File.open(".gitignore", "a") { |f| f.puts "target/" }
27
+ template 'Mavenfile', 'Mavenfile'
28
+ unless File.read('.gitignore') =~ /^target/
29
+ File.open('.gitignore', 'a') { |f| f.puts 'target/' }
30
30
  end
31
- unless File.read(".gitignore") =~ /^\*pom/
32
- File.open(".gitignore", "a") { |f| f.puts "*pom" }
31
+ unless File.read('.gitignore') =~ /^\*pom/
32
+ File.open('.gitignore', 'a') { |f| f.puts '*pom' }
33
33
  end
34
34
  end
35
35
 
36
36
  def create_entry_point_file
37
- template 'EntryPoint.java', File.join(java_root, base_package.gsub(/\./, "/"), "#{application_name}EntryPoint.java")
37
+ template 'EntryPoint.java', File.join(java_root, base_package.gsub(/\./, '/'), "#{application_name}EntryPoint.java")
38
38
  end
39
39
 
40
40
  def create_managed_files
41
- path = managed_package.gsub(/\./, "/")
41
+ path = managed_package.gsub(/\./, '/')
42
42
  template 'PlaceHistoryMapper.java',
43
43
  File.join(java_root, path,
44
44
  "#{application_name}PlaceHistoryMapper.java")
@@ -47,7 +47,7 @@ module Resty
47
47
  "#{application_name}Module.java")
48
48
  template 'ActivityFactory.java',
49
49
  File.join(java_root, path,
50
- "ActivityFactory.java")
50
+ 'ActivityFactory.java')
51
51
  if options[:menu]
52
52
  template 'MenuPanel.java',
53
53
  File.join(java_root, path,
@@ -56,43 +56,40 @@ module Resty
56
56
  end
57
57
 
58
58
  def create_scaffolded_files
59
- path = base_package.gsub(/\./, "/")
60
- #template 'ActivityPlace.java',
61
- # File.join(java_root, path,
62
- # "ActivityPlace.java")
59
+ path = base_package.gsub(/\./, '/')
63
60
  template 'ActivityPlaceActivityMapper.java',
64
61
  File.join(java_root, path,
65
- "ActivityPlaceActivityMapper.java")
62
+ 'ActivityPlaceActivityMapper.java')
66
63
  if options[:session]
67
64
  template 'SessionActivityPlaceActivityMapper.java',
68
65
  File.join(java_root, path,
69
- "SessionActivityPlaceActivityMapper.java")
66
+ 'SessionActivityPlaceActivityMapper.java')
70
67
  template 'BreadCrumbsPanel.java',
71
68
  File.join(java_root, path,
72
- "BreadCrumbsPanel.java")
69
+ 'BreadCrumbsPanel.java')
73
70
  end
74
71
  end
75
72
 
76
73
  def create_session_files
77
74
  if options[:session]
78
75
  template 'LoginActivity.java',
79
- File.join(java_root, activities_package.gsub(/\./, "/"),
80
- "LoginActivity.java")
76
+ File.join(java_root, activities_package.gsub(/\./, '/'),
77
+ 'LoginActivity.java')
81
78
  template 'User.java',
82
- File.join(java_root, models_package.gsub(/\./, "/"),
83
- "User.java")
79
+ File.join(java_root, models_package.gsub(/\./, '/'),
80
+ 'User.java')
84
81
  template 'LoginPlace.java',
85
- File.join(java_root, places_package.gsub(/\./, "/"),
86
- "LoginPlace.java")
82
+ File.join(java_root, places_package.gsub(/\./, '/'),
83
+ 'LoginPlace.java')
87
84
  template 'SessionRestService.java',
88
- File.join(java_root, restservices_package.gsub(/\./, "/"),
89
- "SessionRestService.java")
85
+ File.join(java_root, restservices_package.gsub(/\./, '/'),
86
+ 'SessionRestService.java')
90
87
  template 'LoginViewImpl.java',
91
- File.join(java_root, views_package.gsub(/\./, "/"),
92
- "LoginViewImpl.java")
88
+ File.join(java_root, views_package.gsub(/\./, '/'),
89
+ 'LoginViewImpl.java')
93
90
  template 'LoginView.ui.xml',
94
- File.join(java_root, views_package.gsub(/\./, "/"),
95
- "LoginView.ui.xml")
91
+ File.join(java_root, views_package.gsub(/\./, '/'),
92
+ 'LoginView.ui.xml')
96
93
  end
97
94
  end
98
95
 
@@ -110,30 +107,45 @@ module Resty
110
107
  gem 'ixtlan-core'
111
108
  end
112
109
 
110
+ def add_raketask
111
+ prepend_file 'Rakefile', '#-*- mode: ruby -*-\n'
112
+ append_file 'Rakefile', <<-EOF
113
+
114
+ desc 'triggers the heartbeat request (user updates)'
115
+ task :heartbeat => [:environment] do
116
+ heartbeat = Heartbeat.new
117
+ heartbeat.beat
118
+
119
+ puts "\#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')} - \#{heartbeat}"
120
+ end
121
+ # vim: syntax=Ruby
122
+ EOF
123
+ end
124
+
113
125
  def create_rails_session_files
114
126
  if options[:session]
115
- template 'sessions_controller.rb', File.join('app', 'controllers', "sessions_controller.rb")
116
- file = File.join('config', 'environments', "development.rb")
127
+ template 'sessions_controller.rb', File.join('app', 'controllers', 'sessions_controller.rb')
128
+ file = File.join('config', 'environments', 'development.rb')
117
129
  development = File.read(file)
118
130
  changed = false
119
- unless development =~ /config.remote_sso_url/
131
+ unless development =~ /config.remote_service_url/
120
132
  changed = true
121
133
  development.sub! /^end\s*$/, <<ENV
122
134
 
123
135
  if ENV['SSO'] == 'true' || ENV['SSO'] == ''
124
- config.remote_sso_url = "http://localhost:3000"
125
- config.remote_token = "be happy"
136
+ config.remote_service_url = 'http://localhost:3000'
137
+ config.remote_token = 'be happy'
126
138
  end
127
139
  end
128
140
  ENV
129
141
  end
130
142
  if changed
131
143
  File.open(file, 'w') { |f| f.print development }
132
- log "changed", file
144
+ log 'changed', file
133
145
  else
134
- log "unchanged", file
146
+ log 'unchanged', file
135
147
  end
136
- file = File.join('app', 'controllers', "application_controller.rb")
148
+ file = File.join('app', 'controllers', 'application_controller.rb')
137
149
  app_controller = File.read(file)
138
150
  changed = false
139
151
  unless app_controller =~ /def\s+current_user/
@@ -165,17 +177,20 @@ SESSION
165
177
  end
166
178
  if changed
167
179
  File.open(file, 'w') { |f| f.print app_controller }
168
- log "changed", file
180
+ log 'changed', file
169
181
  else
170
- log "unchanged", file
182
+ log 'unchanged', file
171
183
  end
172
- template 'authentication.rb', File.join('app', 'models', "authentication.rb")
173
- template 'group.rb', File.join('app', 'models', "group.rb")
174
- template 'session.rb', File.join('app', 'models', "session.rb")
175
- template 'user.rb', File.join('app', 'models', "user.rb")
184
+ template 'authentication.rb', File.join('app', 'models', 'authentication.rb')
185
+ template 'group.rb', File.join('app', 'models', 'group.rb')
186
+ template 'session.rb', File.join('app', 'models', 'session.rb')
187
+ template 'user.rb', File.join('app', 'models', 'user.rb')
176
188
  if options[:remote_users]
177
- template 'remote_user.rb', File.join('app', 'models', "remote_user.rb")
178
- template 'create_users.rb', File.join('db', 'migrate', "0_create_users.rb")
189
+ template 'remote_user.rb', File.join('app', 'models', 'remote_user.rb')
190
+ template 'application.rb', File.join('app', 'models', 'application.rb')
191
+ template 'ApplicationLinksPanel.java', File.join(java_root, base_package.gsub(/\./, '/'), 'ApplicationLinksPanel.java')
192
+ template 'Application.java', File.join(java_root, models_package.gsub(/\./, '/'), 'Application.java')
193
+ template 'create_users.rb', File.join('db', 'migrate', '0_create_users.rb')
179
194
  template 'heartbeat.rb', File.join('lib', 'heartbeat.rb')
180
195
  end
181
196
  FileUtils.mv(File.join('db', 'seeds.rb'), File.join('db', 'seeds-old.rb'))
@@ -190,12 +205,12 @@ ROUTE
190
205
  gem 'ixtlan-session-timeout'
191
206
  gem 'ixtlan-guard'
192
207
  # needs to be in Gemfile to have jruby find the gem
193
- gem "jruby-openssl", "~> 0.7.4", :platforms => :jruby
208
+ gem 'jruby-openssl', '~> 0.7.4', :platforms => :jruby
194
209
  end
195
210
  end
196
211
 
197
212
  def base_package
198
- name + ".client"
213
+ name + '.client'
199
214
  end
200
215
 
201
216
  end
@@ -27,7 +27,7 @@ public class ActivityPlaceActivityMapper implements ActivityMapper {
27
27
  GWT.log(place.toString());
28
28
  return ((RestfulPlace<?, ActivityFactory>) place).create(factory);
29
29
  }
30
- notice.setText("nothing to see");
30
+ notice.warn("nothing to see");
31
31
  return null;
32
32
  }
33
33
  }
@@ -0,0 +1,31 @@
1
+ package <%= models_package %>;
2
+
3
+ import org.codehaus.jackson.annotate.JsonCreator;
4
+ import org.codehaus.jackson.annotate.JsonProperty;
5
+
6
+ import org.fusesource.restygwt.client.Json;
7
+ import org.fusesource.restygwt.client.Json.Style;
8
+
9
+ @Json(style = Style.RAILS)
10
+ public class Application {
11
+
12
+ private final String name;
13
+
14
+ private final String url;
15
+
16
+ @JsonCreator
17
+ public Application(@JsonProperty("name") String name,
18
+ @JsonProperty("url") String url){
19
+ this.url = url;
20
+ this.name = name;
21
+ }
22
+
23
+ public String getName(){
24
+ return name;
25
+ }
26
+
27
+ public String getUrl(){
28
+ return url;
29
+ }
30
+
31
+ }
@@ -0,0 +1,95 @@
1
+ package org.dhamma.users.client.models;
2
+
3
+
4
+ import java.util.Date;
5
+
6
+ import org.codehaus.jackson.annotate.JsonCreator;
7
+ import org.codehaus.jackson.annotate.JsonProperty;
8
+ import org.fusesource.restygwt.client.Json;
9
+ import org.fusesource.restygwt.client.Json.Style;
10
+
11
+ import de.mkristian.gwt.rails.models.HasToDisplay;
12
+ import de.mkristian.gwt.rails.models.Identifyable;
13
+
14
+ @Json(style = Style.RAILS)
15
+ public class Application implements HasToDisplay, Identifyable {
16
+
17
+ public final int id;
18
+
19
+ @Json(name = "created_at")
20
+ private final Date createdAt;
21
+
22
+ @Json(name = "updated_at")
23
+ private final Date updatedAt;
24
+
25
+ @Json(name = "modified_by")
26
+ private final User modifiedBy;
27
+
28
+ private String name;
29
+
30
+ private String url;
31
+
32
+ public Application(){
33
+ this(0, null, null, null);
34
+ }
35
+
36
+ public Application(int id) {
37
+ this(id, null, null, null);
38
+ }
39
+
40
+ @JsonCreator
41
+ public Application(@JsonProperty("id") int id,
42
+ @JsonProperty("createdAt") Date createdAt,
43
+ @JsonProperty("updatedAt") Date updatedAt,
44
+ @JsonProperty("modifiedBy") User modifiedBy){
45
+ this.id = id;
46
+ this.createdAt = createdAt;
47
+ this.updatedAt = updatedAt;
48
+ this.modifiedBy = modifiedBy;
49
+ }
50
+
51
+ public int getId(){
52
+ return id;
53
+ }
54
+
55
+ public Date getCreatedAt(){
56
+ return createdAt;
57
+ }
58
+
59
+ public Date getUpdatedAt(){
60
+ return updatedAt;
61
+ }
62
+
63
+ public User getModifiedBy(){
64
+ return modifiedBy;
65
+ }
66
+
67
+ public String getName(){
68
+ return name;
69
+ }
70
+
71
+ public void setName(String value){
72
+ name = value;
73
+ }
74
+
75
+ public String getUrl(){
76
+ return url;
77
+ }
78
+
79
+ public void setUrl(String value){
80
+ url = value;
81
+ }
82
+
83
+ public int hashCode(){
84
+ return id;
85
+ }
86
+
87
+ public boolean equals(Object other){
88
+ return (other instanceof Application) &&
89
+ ((Application)other).id == id;
90
+ }
91
+
92
+ public String toDisplay() {
93
+ return name;
94
+ }
95
+ }
@@ -0,0 +1,29 @@
1
+ package <%= base_package %>;
2
+
3
+ import javax.inject.Singleton;
4
+
5
+ import <%= models_package %>.Application;
6
+ import <%= models_package %>.User;
7
+ import com.google.inject.Inject;
8
+
9
+ import de.mkristian.gwt.rails.session.SessionManager;
10
+ import de.mkristian.gwt.rails.views.LinksPanel;
11
+
12
+ @Singleton
13
+ public class ApplicationLinksPanel extends LinksPanel<User> {
14
+
15
+ @Inject
16
+ ApplicationLinksPanel(SessionManager<User> sessionManager) {
17
+ super(sessionManager);
18
+ }
19
+
20
+ @Override
21
+ protected void initUser(User user) {
22
+ for(Application app: user.applications){
23
+ addLink(app.getName().equals("THIS") ?
24
+ "users" :
25
+ app.getName(), app.getUrl());
26
+ }
27
+ }
28
+
29
+ }
@@ -0,0 +1,29 @@
1
+ package com.example.client;
2
+
3
+ import javax.inject.Singleton;
4
+
5
+ import com.example.client.models.Application;
6
+ import com.example.client.models.User;
7
+ import com.google.inject.Inject;
8
+
9
+ import de.mkristian.gwt.rails.session.SessionManager;
10
+ import de.mkristian.gwt.rails.views.LinksPanel;
11
+
12
+ @Singleton
13
+ public class ApplicationLinksPanel extends LinksPanel<User> {
14
+
15
+ @Inject
16
+ ApplicationLinksPanel(SessionManager<User> sessionManager) {
17
+ super(sessionManager);
18
+ }
19
+
20
+ @Override
21
+ protected void initUser(User user) {
22
+ for(Application app: user.applications){
23
+ addLink(app.getName().equals("THIS") ?
24
+ "users" :
25
+ app.getName(), app.getUrl());
26
+ }
27
+ }
28
+
29
+ }