ixtlan 0.4.0.pre2 → 0.4.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/gwt_ixtlan_datamapper_rspec_scaffold_generator.rb +1 -1
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Fields.java +13 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Model.java +11 -14
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/ModelFactory.java +2 -7
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Screen.java +14 -7
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/TestGwt.java +12 -10
- data/generators/ixtlan_datamapper_model/templates/migration.rb +22 -0
- data/generators/ixtlan_datamapper_model/templates/model.rb +2 -2
- data/generators/ixtlan_datamapper_rspec_model/ixtlan_datamapper_rspec_model_generator.rb +2 -0
- data/generators/ixtlan_datamapper_rspec_model/templates/model_spec.rb +8 -5
- data/generators/ixtlan_datamapper_rspec_scaffold/ixtlan_datamapper_rspec_scaffold_generator.rb +2 -0
- data/generators/ixtlan_datamapper_rspec_scaffold/templates/controller_spec.rb +13 -7
- data/lib/dm-serializer/to_xml.rb +2 -2
- data/lib/ixtlan/controllers/authentications_controller.rb +1 -1
- data/lib/ixtlan/controllers/locales_controller.rb +1 -0
- data/lib/ixtlan/controllers/users_controller.rb +5 -3
- data/lib/ixtlan/models/authentication.rb +1 -3
- data/lib/ixtlan/models/i18n_text.rb +4 -4
- data/lib/ixtlan/models/user.rb +2 -0
- data/lib/ixtlan/models/word.rb +3 -1
- data/lib/ixtlan/modified_by.rb +1 -1
- data/lib/ixtlan/optimistic_persistence.rb +2 -5
- data/lib/ixtlan/rails/migrations.rb +30 -25
- data/lib/ixtlan/rails/unrestful_authentication.rb +1 -1
- data/lib/ixtlan/session.rb +2 -2
- data/lib/ixtlan/simple_client.rb +126 -0
- data/lib/ixtlan/user_logger.rb +0 -1
- data/lib/ixtlan/version.rb +1 -1
- data/lib/models.rb +1 -0
- metadata +267 -219
- data/History.txt +0 -49
- data/MIT-LICENSE +0 -20
- data/Manifest.txt +0 -103
- data/README.txt +0 -86
- data/Rakefile +0 -55
- data/ixtlan_rails_templates.rb +0 -537
- data/whitespace.rb +0 -31
data/ixtlan_rails_templates.rb
DELETED
@@ -1,537 +0,0 @@
|
|
1
|
-
# inspired by http://www.rowtheboat.com/archives/32
|
2
|
-
###################################################
|
3
|
-
|
4
|
-
# --------------
|
5
|
-
# HELPER METHODS
|
6
|
-
# --------------
|
7
|
-
|
8
|
-
def middleware(name)
|
9
|
-
log 'middleware', name
|
10
|
-
environment "config.middleware.use '#{name}'"
|
11
|
-
end
|
12
|
-
def ixtlan_model(name)
|
13
|
-
file "app/models/#{name}.rb", <<-CODE
|
14
|
-
class #{name.camelcase} < Ixtlan::Models::#{name.camelcase}; end
|
15
|
-
CODE
|
16
|
-
end
|
17
|
-
def ixtlan_controller(name, guards = {:actions => [:index,:show,:new,:create,:edit,:update,:destroy], :default => nil}, singleton = nil)
|
18
|
-
if guards
|
19
|
-
file "app/guards/#{name}_guard.rb", <<-CODE
|
20
|
-
Ixtlan::Guard.initialize(:#{name}, {
|
21
|
-
#{guards[:actions].collect {|g| ":#{g} => [#{guards[:default]}]" }.join(",\n") }
|
22
|
-
})
|
23
|
-
CODE
|
24
|
-
end
|
25
|
-
file "app/controllers/#{name}_controller.rb", <<-CODE
|
26
|
-
class #{name.camelize}Controller < ApplicationController
|
27
|
-
include Ixtlan::Controllers::#{name.camelize}Controller
|
28
|
-
end
|
29
|
-
CODE
|
30
|
-
if singleton
|
31
|
-
route "map.resource :#{singleton}"
|
32
|
-
else
|
33
|
-
route "map.resources :#{name}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def add_gem(name, version, options = {})
|
38
|
-
gem name, options
|
39
|
-
java = name =~ /^do_/ ? "<classifier>java</classifier>\n" : ""
|
40
|
-
gsub_file 'pom.xml', /<\/dependencies>/, "<dependency>\n<groupId>rubygems</groupId>\n<artifactId>#{name}</artifactId>\n<version>#{version}</version>\n<type>gem</type>\n#{java}</dependency>\n</dependencies>"
|
41
|
-
end
|
42
|
-
|
43
|
-
def migration(model)
|
44
|
-
@__index ||= 0
|
45
|
-
@__index = @__index + 1
|
46
|
-
file "db/migrate/#{@__index}_create_#{model}.rb", <<-CODE
|
47
|
-
require 'config/initializers/00_models.rb'
|
48
|
-
require 'ixtlan/rails/migrations'
|
49
|
-
migration #{@__index}, :create_#{model} do
|
50
|
-
up do
|
51
|
-
Ixtlan::Rails::Migrations.create_#{model}
|
52
|
-
end
|
53
|
-
|
54
|
-
down do
|
55
|
-
end
|
56
|
-
end
|
57
|
-
CODE
|
58
|
-
end
|
59
|
-
|
60
|
-
# --------
|
61
|
-
# VERSIONS
|
62
|
-
# --------
|
63
|
-
|
64
|
-
JRUBY_PLUGINS_VERSION='0.12.0'
|
65
|
-
DM_VERSION='0.10.2'
|
66
|
-
|
67
|
-
# -----------
|
68
|
-
# MAVEN SETUP
|
69
|
-
# -----------
|
70
|
-
|
71
|
-
# setup a pom.xml
|
72
|
-
inside("..") do
|
73
|
-
run("mvn archetype:generate -DarchetypeArtifactId=rails-maven-archetype -DarchetypeGroupId=de.saumya.mojo -DarchetypeVersion=#{JRUBY_PLUGINS_VERSION} -DartifactId=#{File.basename(root)} -DgroupId=com.example -Dversion=0.1.0-SNAPSHOT -B")
|
74
|
-
end
|
75
|
-
File.delete('lib/tasks/jdbc.rake')
|
76
|
-
File.delete('config/initializers/jdbc.rb')
|
77
|
-
gsub_file 'pom.xml', /<version>1.5.0<\/version>/, "<version>1.4.1<\/version>"
|
78
|
-
|
79
|
-
# ---------------------
|
80
|
-
# GWT AND ECLIPSE SETUP
|
81
|
-
# ---------------------
|
82
|
-
|
83
|
-
#if ENV['GWT'] == 'true' || (!ENV['GWT'] && yes?("install GWT interface ?"))
|
84
|
-
gwt_prefix = "gwt_"
|
85
|
-
File.rename("src/main/webapp/WEB-INF/web.xml",
|
86
|
-
"src/main/webapp/WEB-INF/web.xml.rails")
|
87
|
-
inside("..") do
|
88
|
-
run("mvn archetype:generate -DarchetypeArtifactId=gui -DarchetypeGroupId=de.saumya.gwt.translation -DarchetypeVersion=0.3.1 -DartifactId=#{File.basename(root)} -DgroupId=com.example -Dversion=0.1.0-SNAPSHOT -B")
|
89
|
-
end
|
90
|
-
File.rename("src/main/webapp/WEB-INF/web.xml.rails",
|
91
|
-
"src/main/webapp/WEB-INF/web.xml")
|
92
|
-
|
93
|
-
file '.classpath', <<-CODE
|
94
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
95
|
-
<classpath>
|
96
|
-
<classpathentry kind="src" output="war/WEB-INF/classes" path="src/main/java"/>
|
97
|
-
<classpathentry excluding="**" kind="src" output="war/WEB-INF/classes" path="src/main/resources"/>
|
98
|
-
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
99
|
-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
100
|
-
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
101
|
-
<classpathentry kind="output" path="war/WEB-INF/classes"/>
|
102
|
-
</classpath>
|
103
|
-
CODE
|
104
|
-
file '.project', <<-CODE
|
105
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
106
|
-
<projectDescription>
|
107
|
-
<name>ixtlan-test</name>
|
108
|
-
<comment></comment>
|
109
|
-
<projects>
|
110
|
-
</projects>
|
111
|
-
<buildSpec>
|
112
|
-
<buildCommand>
|
113
|
-
<name>org.eclipse.jdt.core.javabuilder</name>
|
114
|
-
<arguments>
|
115
|
-
</arguments>
|
116
|
-
</buildCommand>
|
117
|
-
<buildCommand>
|
118
|
-
<name>org.maven.ide.eclipse.maven2Builder</name>
|
119
|
-
<arguments>
|
120
|
-
</arguments>
|
121
|
-
</buildCommand>
|
122
|
-
</buildSpec>
|
123
|
-
<natures>
|
124
|
-
<nature>org.maven.ide.eclipse.maven2Nature</nature>
|
125
|
-
<nature>org.eclipse.jdt.core.javanature</nature>
|
126
|
-
</natures>
|
127
|
-
</projectDescription>
|
128
|
-
CODE
|
129
|
-
file '.settings/org.maven.ide.eclipse.prefs', <<-CODE
|
130
|
-
activeProfiles=
|
131
|
-
eclipse.preferences.version=1
|
132
|
-
fullBuildGoals=process-test-resources
|
133
|
-
includeModules=false
|
134
|
-
resolveWorkspaceProjects=true
|
135
|
-
resourceFilterGoals=process-resources resources\:testResources
|
136
|
-
skipCompilerPlugin=true
|
137
|
-
version=1
|
138
|
-
CODE
|
139
|
-
file '.settings/org.eclipse.jdt.core.prefs', <<-CODE
|
140
|
-
eclipse.preferences.version=1
|
141
|
-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
142
|
-
org.eclipse.jdt.core.compiler.compliance=1.6
|
143
|
-
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
144
|
-
org.eclipse.jdt.core.compiler.source=1.6
|
145
|
-
CODE
|
146
|
-
#else
|
147
|
-
# gwt_prefix = nil
|
148
|
-
#end
|
149
|
-
|
150
|
-
# --------------------
|
151
|
-
# ADD GEM DEPENDENCIES
|
152
|
-
# --------------------
|
153
|
-
|
154
|
-
# ixtlan gems
|
155
|
-
add_gem 'rack', '1.0.1'
|
156
|
-
add_gem 'rack-datamapper', '0.2.5'
|
157
|
-
add_gem 'ixtlan', '0.2.5'
|
158
|
-
|
159
|
-
# assume sqlite3 to be database
|
160
|
-
add_gem 'do_sqlite3', '0.10.1.1'
|
161
|
-
|
162
|
-
# serialization, validations and timestamps in your models
|
163
|
-
add_gem 'dm-validations', DM_VERSION
|
164
|
-
add_gem 'dm-timestamps', DM_VERSION
|
165
|
-
add_gem 'dm-migrations', DM_VERSION
|
166
|
-
add_gem 'dm-aggregates', DM_VERSION
|
167
|
-
add_gem 'dm-core', DM_VERSION
|
168
|
-
|
169
|
-
# get all datamapper related gems
|
170
|
-
# gem 'addressable', :lib => 'addressable/uri'
|
171
|
-
|
172
|
-
# assume you prefer rspec over unit tests
|
173
|
-
add_gem 'rspec', '[1.3.0,1.4.0]', :lib => false
|
174
|
-
add_gem 'rspec-rails', '1.3.0', :lib => false
|
175
|
-
|
176
|
-
# install all gems
|
177
|
-
rake 'gems:install'
|
178
|
-
|
179
|
-
# install specs rake tasks
|
180
|
-
generate('rspec', '-f')
|
181
|
-
|
182
|
-
# install datamapper rake tasks
|
183
|
-
generate('datamapper_install')
|
184
|
-
|
185
|
-
# fix config files to work with datamapper instead of active_record
|
186
|
-
environment ''
|
187
|
-
environment 'config.frameworks -= [ :active_record ]'
|
188
|
-
environment '# deactive active_record'
|
189
|
-
gsub_file 'spec/spec_helper.rb', /^\s*config[.]/, ' #\0'
|
190
|
-
gsub_file 'test/test_helper.rb', /^[^#]*fixtures/, ' #\0'
|
191
|
-
|
192
|
-
file 'spec/support/datamapper.rb', <<-CODE
|
193
|
-
require 'datamapper4rails/rspec'
|
194
|
-
CODE
|
195
|
-
|
196
|
-
# ----------
|
197
|
-
# MIDDLEWARE
|
198
|
-
# ----------
|
199
|
-
|
200
|
-
environment ''
|
201
|
-
middleware 'DataMapper::RestfulTransactions'
|
202
|
-
middleware 'DataMapper::IdentityMaps'
|
203
|
-
middleware 'Rack::Deflater'
|
204
|
-
environment "#config.middleware.use 'Ixtlan::CmsScript'"
|
205
|
-
environment '# add middleware'
|
206
|
-
|
207
|
-
# ------------
|
208
|
-
# INITIALIZERS
|
209
|
-
# ------------
|
210
|
-
|
211
|
-
# define locale model names
|
212
|
-
initializer '00_models.rb', <<-CODE
|
213
|
-
module Ixtlan
|
214
|
-
module Models
|
215
|
-
AUTHENTICATION = "Authentication"
|
216
|
-
USER = "User"
|
217
|
-
GROUP = "Group"
|
218
|
-
LOCALE = "Locale"
|
219
|
-
DOMAIN = "Domain"
|
220
|
-
TEXT = "I18nText"
|
221
|
-
CONFIGURATION = "Configuration"
|
222
|
-
end
|
223
|
-
end
|
224
|
-
CODE
|
225
|
-
|
226
|
-
# load ixtlan classes
|
227
|
-
initializer '01_ixtlan.rb', <<-CODE
|
228
|
-
require 'ixtlan/modified_by'
|
229
|
-
if ENV['RAILS_ENV']
|
230
|
-
require 'models'
|
231
|
-
require 'ixtlan/rails/error_handling'
|
232
|
-
require 'ixtlan/rails/audit'
|
233
|
-
require 'ixtlan/rails/session_timeout'
|
234
|
-
require 'ixtlan/rails/unrestful_authentication'
|
235
|
-
require 'ixtlan/rails/guard'
|
236
|
-
require 'ixtlan/rails/timestamps_modified_by_filter'
|
237
|
-
require 'ixtlan/optimistic_persistence'
|
238
|
-
end
|
239
|
-
require 'ixtlan/monkey_patches'
|
240
|
-
# auto require to load needed libraries . . .
|
241
|
-
require 'datamapper4rails'
|
242
|
-
require 'slf4r'
|
243
|
-
CODE
|
244
|
-
|
245
|
-
# logger config
|
246
|
-
initializer '02_loggers.rb', <<-CODE
|
247
|
-
require 'ixtlan/logger_config' if ENV['RAILS_ENV']
|
248
|
-
CODE
|
249
|
-
|
250
|
-
# load the guard config
|
251
|
-
initializer '03_guard.rb', <<-CODE
|
252
|
-
# load the guard config files from RAILS_ROOT/app/guards
|
253
|
-
Ixtlan::Guard.load(Slf4r::LoggerFacade.new(Ixtlan::Guard))
|
254
|
-
CODE
|
255
|
-
|
256
|
-
# init a session store
|
257
|
-
initializer '04_datamapper_store.rb', <<-CODE
|
258
|
-
# init a session store which uses a memory cache and drops the user object
|
259
|
-
# and the flash which results into a very thin session and hardly any
|
260
|
-
# database updates !
|
261
|
-
# cleanup can be a problem. jruby uses soft-references for the cache so
|
262
|
-
# memory cleanup with jruby is no problem.
|
263
|
-
require 'ixtlan/session'
|
264
|
-
ActionController::Base.session_store = :datamapper_store
|
265
|
-
ActionController::Base.session = {
|
266
|
-
:cache => true,
|
267
|
-
:session_class => Ixtlan::Session
|
268
|
-
}
|
269
|
-
CODE
|
270
|
-
|
271
|
-
# define the date/time pattern for the xml
|
272
|
-
initializer '05_time_formats.rb', <<-CODE
|
273
|
-
Time::DATE_FORMATS[:xml] = lambda { |time| time.utc.strftime("%Y-%m-%d %H:%M:%S") }
|
274
|
-
CODE
|
275
|
-
|
276
|
-
# ----------
|
277
|
-
# MIGRATIONS
|
278
|
-
# ----------
|
279
|
-
|
280
|
-
migration("user")
|
281
|
-
migration("configuration")
|
282
|
-
migration("locale")
|
283
|
-
migration("domain")
|
284
|
-
migration("text")
|
285
|
-
|
286
|
-
# -----
|
287
|
-
# VIEWS
|
288
|
-
# -----
|
289
|
-
|
290
|
-
#some small html pages
|
291
|
-
file "app/views/sessions/login.html.erb", <<-CODE
|
292
|
-
<p style="color: darkgreen"><%= @notice %></p>
|
293
|
-
<form method="post">
|
294
|
-
<p>
|
295
|
-
<label for="login">login</label><br />
|
296
|
-
<input type="text" name="login" />
|
297
|
-
</p>
|
298
|
-
<p>
|
299
|
-
<label for="password">password</label><br />
|
300
|
-
<input type="password" name="password" />
|
301
|
-
</p>
|
302
|
-
<p>
|
303
|
-
<input type="submit" value="login" />
|
304
|
-
</p>
|
305
|
-
</form>
|
306
|
-
CODE
|
307
|
-
|
308
|
-
file 'app/views/errors/error.html.erb', <<-CODE
|
309
|
-
<h1><%= @notice %></h1>
|
310
|
-
CODE
|
311
|
-
|
312
|
-
file 'app/views/errors/stale.html.erb', <<-CODE
|
313
|
-
<h1>stale resource</h1>
|
314
|
-
<p>please reload resource and change it again</p>
|
315
|
-
CODE
|
316
|
-
|
317
|
-
|
318
|
-
# ----------------------
|
319
|
-
# MODELS AND CONTROLLERs
|
320
|
-
# ----------------------
|
321
|
-
|
322
|
-
# setup permissions controller
|
323
|
-
ixtlan_controller("permissions", {:actions => [:index]})
|
324
|
-
|
325
|
-
# user model/controller
|
326
|
-
generate "ixtlan_datamapper_rspec_scaffold", '--skip-migration', 'User', 'login:string', 'name:string', 'email:string', 'language:string'
|
327
|
-
gsub_file 'spec/models/user_spec.rb', /.*:name => "sc'?r&?ipt".*/, ''
|
328
|
-
gsub_file 'spec/models/user_spec.rb', /value for login/, 'valueForLogin'
|
329
|
-
gsub_file 'spec/models/user_spec.rb', /value for email/, 'value@for.email'
|
330
|
-
gsub_file 'spec/models/user_spec.rb', /value for language/, 'vl'
|
331
|
-
ixtlan_model 'user'
|
332
|
-
ixtlan_controller 'users'
|
333
|
-
|
334
|
-
# group model/controller
|
335
|
-
generate "ixtlan_datamapper_rspec_scaffold", '--skip-migration', 'Group', 'name:string'
|
336
|
-
ixtlan_model 'group'
|
337
|
-
ixtlan_controller 'groups'
|
338
|
-
|
339
|
-
# domain model/controller
|
340
|
-
generate "ixtlan_datamapper_rspec_scaffold", '--skip-migration', 'Domain', 'name:string'
|
341
|
-
ixtlan_model 'domain'
|
342
|
-
ixtlan_controller 'domains'
|
343
|
-
|
344
|
-
# i18n stuff: i18n model, phrases, word_bundles controller
|
345
|
-
ixtlan_model 'i18n_text'
|
346
|
-
ixtlan_controller "phrases"
|
347
|
-
ixtlan_controller "word_bundles"
|
348
|
-
|
349
|
-
# locale model/controller
|
350
|
-
generate "ixtlan_datamapper_rspec_scaffold", '--skip-migration', '--skip-modified-by', 'Locale', 'code:string'
|
351
|
-
gsub_file 'spec/models/locale_spec.rb', /value for code/, 'vc'
|
352
|
-
ixtlan_model "locale"
|
353
|
-
ixtlan_controller "locales"
|
354
|
-
|
355
|
-
# configuration guard/model/controller
|
356
|
-
file 'app/models/configuration.rb', <<-CODE
|
357
|
-
class Configuration < Ixtlan::Models::Configuration
|
358
|
-
def self.instance
|
359
|
-
get!(1)
|
360
|
-
end
|
361
|
-
end
|
362
|
-
CODE
|
363
|
-
ixtlan_controller 'configurations', {:actions => [:show, :edit, :update]}, 'configuration'
|
364
|
-
|
365
|
-
# authentication model/controller
|
366
|
-
ixtlan_model "authentication"
|
367
|
-
ixtlan_controller "authentications", {:actions => [:create]}, 'authentication'
|
368
|
-
|
369
|
-
# modify application controller as needed
|
370
|
-
gsub_file 'app/controllers/application_controller.rb', /^\s*helper.*/, <<-CODE
|
371
|
-
filter_parameter_logging :password, :login
|
372
|
-
before_filter :check_session_expiry
|
373
|
-
|
374
|
-
# override default to use nice User (without namespace)
|
375
|
-
#def login_from_params
|
376
|
-
# User.authenticate(params[:login], params[:password])
|
377
|
-
#end
|
378
|
-
|
379
|
-
#def login_from_session
|
380
|
-
# User.get(session[:user_id])
|
381
|
-
#end
|
382
|
-
|
383
|
-
# override default to use value from configuration
|
384
|
-
#def session_timeout
|
385
|
-
# Configuration.instance.session_idle_timeout
|
386
|
-
#end
|
387
|
-
|
388
|
-
def render_error_page_with_session(status)
|
389
|
-
render :template => "errors/error_with_session", :status => status
|
390
|
-
end
|
391
|
-
|
392
|
-
def render_error_page(status)
|
393
|
-
render :template => "errors/error", :status => status
|
394
|
-
end
|
395
|
-
|
396
|
-
# needs 'optimistic_persistence'
|
397
|
-
rescue_from DataMapper::StaleResourceError, :with => :stale_resource
|
398
|
-
|
399
|
-
# needs 'guard'
|
400
|
-
rescue_from Ixtlan::GuardException, :with => :page_not_found
|
401
|
-
rescue_from Ixtlan::PermissionDenied, :with => :page_not_found
|
402
|
-
|
403
|
-
#standard rails or datamapper/dataobjects
|
404
|
-
rescue_from DataObjects::SQLError, :with => :internal_server_error
|
405
|
-
rescue_from DataMapper::ObjectNotFoundError, :with => :page_not_found
|
406
|
-
rescue_from ActionController::RoutingError, :with => :page_not_found
|
407
|
-
rescue_from ActionController::UnknownAction, :with => :page_not_found
|
408
|
-
rescue_from ActionController::MethodNotAllowed, :with => :page_not_found
|
409
|
-
rescue_from ActionController::NotImplemented, :with => :page_not_found
|
410
|
-
rescue_from ActionController::InvalidAuthenticityToken, :with => :stale_resource
|
411
|
-
|
412
|
-
# have nice stacktraces in development mode
|
413
|
-
unless consider_all_requests_local
|
414
|
-
rescue_from ActionView::MissingTemplate, :with => :internal_server_error
|
415
|
-
rescue_from ActionView::TemplateError, :with => :internal_server_error
|
416
|
-
end
|
417
|
-
|
418
|
-
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
419
|
-
CODE
|
420
|
-
|
421
|
-
# --------------------------------
|
422
|
-
# GLOBAL CONFIG VIA PREINITIALIZER
|
423
|
-
# --------------------------------
|
424
|
-
|
425
|
-
# configuration before starting rails
|
426
|
-
file 'config/preinitializer.rb', <<-CODE
|
427
|
-
require 'yaml'
|
428
|
-
require 'erb'
|
429
|
-
module Ixtlan
|
430
|
-
class Configurator
|
431
|
-
|
432
|
-
def self.symbolize_keys(h, compact)
|
433
|
-
result = {}
|
434
|
-
|
435
|
-
h.each do |k, v|
|
436
|
-
v = ' ' if v.nil?
|
437
|
-
if v.is_a?(Hash)
|
438
|
-
result[k.to_sym] = symbolize_keys(v, compact) unless compact and v.size == 0
|
439
|
-
else
|
440
|
-
result[k.to_sym] = v unless compact and k.to_sym == v.to_sym
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
|
-
result
|
445
|
-
end
|
446
|
-
|
447
|
-
def self.load(dir, file, compact = true)
|
448
|
-
symbolize_keys(YAML::load(ERB.new(IO.read(File.join(dir, file))).result), compact)
|
449
|
-
end
|
450
|
-
end
|
451
|
-
end
|
452
|
-
|
453
|
-
CONFIG = Ixtlan::Configurator.load(File.dirname(__FILE__), 'global.yml')
|
454
|
-
CODE
|
455
|
-
|
456
|
-
file 'config/global.yml', <<-CODE
|
457
|
-
# possible example to have a file with all the (production) passwords
|
458
|
-
# outside GIT/SUBVERSION/CVS/etc !!!
|
459
|
-
mysql:
|
460
|
-
database: example
|
461
|
-
host: mysql.example.com
|
462
|
-
username: rails
|
463
|
-
password: run_it
|
464
|
-
|
465
|
-
smtp:
|
466
|
-
address: smtp.gmail.com
|
467
|
-
port: 587
|
468
|
-
domain: example.com
|
469
|
-
authentication: plain
|
470
|
-
user_name: mail@example.com
|
471
|
-
password: mail_it
|
472
|
-
CODE
|
473
|
-
|
474
|
-
append_file 'config/environments/production.rb', <<-CODE
|
475
|
-
|
476
|
-
config.action_mailer.delivery_method = :smtp
|
477
|
-
|
478
|
-
require "smtp_tls"
|
479
|
-
|
480
|
-
ActionMailer::Base.smtp_settings = {
|
481
|
-
:address => CONFIG[:smtp][:address],
|
482
|
-
:port => CONFIG[:smtp][:port],
|
483
|
-
:domain => CONFIG[:smtp][:domain],
|
484
|
-
:authentication => CONFIG[:smtp][:authentication],
|
485
|
-
:user_name => CONFIG[:smtp][:user_name],
|
486
|
-
:password => CONFIG[:smtp][:password]
|
487
|
-
}
|
488
|
-
CODE
|
489
|
-
|
490
|
-
# ------
|
491
|
-
# EPILOG
|
492
|
-
# ------
|
493
|
-
|
494
|
-
logger.info
|
495
|
-
logger.info
|
496
|
-
logger.info "info mavenized rails application"
|
497
|
-
logger.info "\thttp://github.org/mkristian/rails-maven-plugin"
|
498
|
-
logger.info
|
499
|
-
logger.info "if you want to run jruby please first uninstall"
|
500
|
-
logger.info "the native extension of do_sqlite3"
|
501
|
-
logger.info "\truby -S gem uninstall do_sqlite3"
|
502
|
-
logger.info "and the install it with java extension"
|
503
|
-
logger.info "\tjruby -S rake gems:install"
|
504
|
-
logger.info "rake gems:unpack does NOT work with jruby due to a bug in rail <=2.3.5"
|
505
|
-
logger.info "you can try"
|
506
|
-
logger.info "\tmvn rails:rails-freeze-gems"
|
507
|
-
logger.info "which patches rails after freezing it"
|
508
|
-
logger.info
|
509
|
-
logger.info
|
510
|
-
|
511
|
-
# -----------------------
|
512
|
-
# SETUP AND SEED DATABASE
|
513
|
-
# -----------------------
|
514
|
-
|
515
|
-
rake 'db:migrate:down VERSION=0'
|
516
|
-
rake 'db:sessions:create'
|
517
|
-
run('rake db:migrate --trace')
|
518
|
-
rake 'db:autoupgrade RAILS_ENV=development'
|
519
|
-
logger.info
|
520
|
-
logger.info "you find the root password in the file 'root'"
|
521
|
-
logger.info
|
522
|
-
|
523
|
-
# GWT GUI installation
|
524
|
-
if gwt_prefix
|
525
|
-
logger.info
|
526
|
-
logger.info "first start rails in one console"
|
527
|
-
logger.info "\tscript/server"
|
528
|
-
logger.info
|
529
|
-
logger.info "and then start the GWT gui in another console"
|
530
|
-
logger.info "\tmvn gwt:run"
|
531
|
-
end
|
532
|
-
|
533
|
-
logger.info
|
534
|
-
logger.info
|
535
|
-
logger.info "for dm-core version 0.10.2 there are a lot of deprecated warnings but everything works as expected"
|
536
|
-
logger.info
|
537
|
-
logger.info
|
data/whitespace.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
require 'zlib'
|
5
|
-
|
6
|
-
# files and extensions to process
|
7
|
-
FILES = %w[ capfile CHANGELOG LICENSE Manifest MIT-LICENSE README QUICKLINKS README_FOR_APP RUNNING_UNIT_TESTS Rakefile SPECS TODO USAGE .autotest .gitignore .htaccess ].freeze
|
8
|
-
EXTENSIONS = %w[ builder cgi conf css deploy erb example fcgi feature gemspec haml htc htm html java js key markdown opts php rake ratom rb rcsv rdf rhtml rjs rpdf ru rxml sake sass sh sql thor txt vcf xml yml ].freeze
|
9
|
-
|
10
|
-
Pathname.glob(ARGV).each do |path_in|
|
11
|
-
start_path = path_in.directory? ? path_in + '**/*' : path_in
|
12
|
-
|
13
|
-
Pathname.glob((start_path).to_s).each do |path|
|
14
|
-
unless path.file? && path.size? && path.readable? && path.writable? && (FILES.include?(path.basename.to_s) || EXTENSIONS.include?(path.extname[1..-1]))
|
15
|
-
# puts "Skipping #{path}" if path.file?
|
16
|
-
next
|
17
|
-
end
|
18
|
-
|
19
|
-
# replace leading whitespace (including tabs) with spaces
|
20
|
-
# replace trailing whitespace with a newline
|
21
|
-
document = path.open('r') do |f|
|
22
|
-
f.collect { |line| line.gsub(/\G\s/, ' ').rstrip + "\n" }.join.rstrip
|
23
|
-
end + "\n"
|
24
|
-
|
25
|
-
# skip it if the file was not modified
|
26
|
-
next if Zlib.crc32(document) == Zlib.crc32(path.read)
|
27
|
-
|
28
|
-
puts "Modifying #{path}"
|
29
|
-
path.open('w') { |f| f.write document }
|
30
|
-
end
|
31
|
-
end
|