torquebox-rake-support 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/adjust-rails-template.rb +63 -0
- data/lib/torquebox/deploy_utils.rb +1 -1
- data/lib/torquebox/rails.rb +2 -1
- data/share/rails/template.rb +123 -0
- metadata +19 -16
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class RailsTemplateAdjuster
|
7
|
+
|
8
|
+
attr_accessor :build_number
|
9
|
+
|
10
|
+
def initialize( version, build_number )
|
11
|
+
@version = version
|
12
|
+
@build_number = build_number
|
13
|
+
@incremental = @version =~ /\-SNAPSHOT$/
|
14
|
+
@version.gsub!(/\-SNAPSHOT$/, '')
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def adjust
|
19
|
+
original = template_path
|
20
|
+
modified = original + '.modified'
|
21
|
+
FileUtils.rm( modified, :force => true )
|
22
|
+
FileUtils.cp( original, modified )
|
23
|
+
File.open( original, 'r' ) do |input|
|
24
|
+
File.open( modified, 'w' ) do |output|
|
25
|
+
output.puts generate_source
|
26
|
+
input.each_line { |line| write_line( output, line ) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
FileUtils.rm original
|
30
|
+
FileUtils.mv( modified, original )
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def local_build?
|
36
|
+
@build_number.nil? || @build_number == '' || @build_number == "${env.BUILD_NUMBER}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def write_line( output, line )
|
40
|
+
if line =~ /gem [\'\"](torquebox.*?)[\'\"]/
|
41
|
+
output.puts line.sub( @build_number, @version ).sub( "${env.BUILD_NUMBER}", @version )
|
42
|
+
else
|
43
|
+
output.puts line unless line =~ /^add_source \"http\:\/\/torquebox.org\/.+?\/builds\/[0-9]+\/gem-repo\"$/
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_source
|
48
|
+
if local_build?
|
49
|
+
"# Local build - no source needed"
|
50
|
+
elsif @incremental
|
51
|
+
"add_source \"http://torquebox.org/2x/builds/#{@build_number}/gem-repo\""
|
52
|
+
else
|
53
|
+
""
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def template_path
|
58
|
+
File.dirname( __FILE__ ) + '/../target/torquebox-rake-support/share/rails/template.rb'
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
RailsTemplateAdjuster.new( ARGV[0], ARGV[1] ).adjust
|
@@ -271,7 +271,7 @@ module TorqueBox
|
|
271
271
|
includes.write( include_files.join( "\n" ) )
|
272
272
|
includes.flush
|
273
273
|
|
274
|
-
cmd = "jar cvf
|
274
|
+
cmd = "jar cvf \"#{archive_path}\" @#{includes.path}"
|
275
275
|
|
276
276
|
run_command( cmd )
|
277
277
|
includes.close( true )
|
data/lib/torquebox/rails.rb
CHANGED
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
RAILS_2 = Rails::VERSION::MAJOR == 2
|
3
|
+
RAILS_3_0 = Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 0
|
4
|
+
RAILS_3_1 = Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 1
|
5
|
+
|
6
|
+
if RAILS_2
|
7
|
+
gem "activerecord-jdbc-adapter", :lib => "arjdbc"
|
8
|
+
elsif RAILS_3_0
|
9
|
+
text = File.read 'Gemfile'
|
10
|
+
File.open('Gemfile', 'w') {|f| f << text.gsub(/^(gem 'sqlite3)/, '# \1') }
|
11
|
+
gem "activerecord-jdbc-adapter", :require => "arjdbc"
|
12
|
+
gem "jdbc-sqlite3"
|
13
|
+
gem "jruby-openssl"
|
14
|
+
else
|
15
|
+
# rails 3.1+ properly detects jruby and does the right thing
|
16
|
+
end
|
17
|
+
|
18
|
+
if RAILS_2
|
19
|
+
gem 'torquebox', :version => "2.3.1"
|
20
|
+
else
|
21
|
+
gem 'torquebox', "2.3.1"
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# Write a dummy torquebox.yml file
|
26
|
+
if File.exists? 'config/torquebox.yml'
|
27
|
+
puts "TorqueBox configuration file already exists."
|
28
|
+
else
|
29
|
+
File.open('config/torquebox.yml', 'w') do |f|
|
30
|
+
f << <<-TORQUEBOX_CONFIG
|
31
|
+
---
|
32
|
+
# This is the TorqueBox configuration file. Refer to the TorqueBox
|
33
|
+
# documentation at http://torquebox.org/documentation/current/
|
34
|
+
# for all configuration options.
|
35
|
+
web:
|
36
|
+
context: "/"
|
37
|
+
TORQUEBOX_CONFIG
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if RAILS_2
|
42
|
+
initializer("session_store.rb") do
|
43
|
+
<<-INIT
|
44
|
+
# Configure the TorqueBox Servlet-based session store.
|
45
|
+
# Provides for server-based, in-memory, cluster-compatible sessions.
|
46
|
+
if ENV['TORQUEBOX_APP_NAME']
|
47
|
+
ActionController::Base.session_store = :torquebox_store
|
48
|
+
else
|
49
|
+
ActionController::Base.session = { :session_key => '_CHANGEME_session', :secret => 'CHANGEME_107f23805ff8eed10736e03d1d8ab229706afedfa8d7918be604dc291d6772c56cdf94d2b7a3d656d1ebc8ed83d91c2042445670208f07df38acb4ebe93bbef7' }
|
50
|
+
ActionController::Base.session_store = :cookie_store
|
51
|
+
end
|
52
|
+
INIT
|
53
|
+
end
|
54
|
+
else
|
55
|
+
remove_file( 'config/initializers/session_store.rb' )
|
56
|
+
initializer("session_store.rb") do
|
57
|
+
<<-INIT
|
58
|
+
# Configure the TorqueBox Servlet-based session store.
|
59
|
+
# Provides for server-based, in-memory, cluster-compatible sessions
|
60
|
+
if ENV['TORQUEBOX_APP_NAME']
|
61
|
+
#{app_const}.config.session_store :torquebox_store
|
62
|
+
else
|
63
|
+
#{app_const}.config.session_store :cookie_store, :key => '_CHANGEME_session'
|
64
|
+
end
|
65
|
+
INIT
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
environment do
|
70
|
+
<<-ENVIRONMENT
|
71
|
+
# Use TorqueBox::Infinispan::Cache for the Rails cache store
|
72
|
+
if defined? TorqueBox::Infinispan::Cache
|
73
|
+
config.cache_store = :torque_box_store
|
74
|
+
end
|
75
|
+
ENVIRONMENT
|
76
|
+
end
|
77
|
+
|
78
|
+
initializer("active_record_backgroundable.rb") do
|
79
|
+
<<-INIT
|
80
|
+
# Enable backgroundable methods for ActiveRecord classes. Provides:
|
81
|
+
# class AModel < ActiveRecord::Base
|
82
|
+
# always_background :a_method
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# a_model_instance.background.another_method
|
86
|
+
if defined?(TorqueBox::Messaging::Backgroundable) && defined?(ActiveRecord::Base)
|
87
|
+
ActiveRecord::Base.send(:include, TorqueBox::Messaging::Backgroundable)
|
88
|
+
end
|
89
|
+
INIT
|
90
|
+
end
|
91
|
+
|
92
|
+
# Create directories for jobs, services, and processors just for fun
|
93
|
+
inside('app') {
|
94
|
+
%w(jobs services processors).each { |dir| FileUtils.mkdir(dir) unless File.exists?(dir) }
|
95
|
+
}
|
96
|
+
|
97
|
+
app_constant = RAILS_2 ? 'Rails::Application' : app_const
|
98
|
+
|
99
|
+
rake_task = <<TASK
|
100
|
+
begin
|
101
|
+
require 'torquebox-rake-support'
|
102
|
+
rescue LoadError => ex
|
103
|
+
puts "Failed to load the TorqueBox rake gem (torquebox-rake-support). Make sure it is available in your environment."
|
104
|
+
end
|
105
|
+
TASK
|
106
|
+
|
107
|
+
if RAILS_2 || RAILS_3_0
|
108
|
+
rake_task << <<TASK
|
109
|
+
|
110
|
+
# Patch db:load_config to make sure activerecord-jdbc-adapter gets loaded
|
111
|
+
namespace :db do
|
112
|
+
task :load_config => :rails_env do
|
113
|
+
require 'active_record'
|
114
|
+
require 'activerecord-jdbc-adapter'
|
115
|
+
ActiveRecord::Base.configurations = #{app_constant}.config.database_configuration
|
116
|
+
end
|
117
|
+
end
|
118
|
+
TASK
|
119
|
+
end
|
120
|
+
|
121
|
+
# We need the app to find the rake tasks
|
122
|
+
rakefile( 'torquebox.rake', rake_task )
|
123
|
+
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: torquebox-rake-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.3.
|
5
|
+
version: 2.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- The TorqueBox Team
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -46,38 +46,41 @@ dependencies:
|
|
46
46
|
description: ''
|
47
47
|
email:
|
48
48
|
- torquebox-dev@torquebox.org
|
49
|
-
executables:
|
49
|
+
executables:
|
50
|
+
- adjust-rails-template.rb
|
50
51
|
extensions: []
|
51
52
|
extra_rdoc_files: []
|
52
53
|
files:
|
53
54
|
- licenses/lgpl-2.1.txt
|
54
|
-
-
|
55
|
+
- share/rails/template.rb
|
56
|
+
- bin/adjust-rails-template.rb
|
55
57
|
- lib/torquebox-rake-support.rb
|
58
|
+
- lib/org.torquebox.rake-support.rb
|
59
|
+
- lib/torquebox/upstart.rb
|
60
|
+
- lib/torquebox/rails.rb
|
56
61
|
- lib/torquebox/deploy_utils.rb
|
57
62
|
- lib/torquebox/launchd.rb
|
58
63
|
- lib/torquebox/server.rb
|
59
|
-
- lib/torquebox/rails.rb
|
60
|
-
- lib/torquebox/upstart.rb
|
61
64
|
- lib/torquebox/rake/tasks.rb
|
62
|
-
- lib/torquebox/rake/tasks/archive.rb
|
63
65
|
- lib/torquebox/rake/tasks/deployment.rb
|
66
|
+
- lib/torquebox/rake/tasks/archive.rb
|
64
67
|
- lib/torquebox/rake/tasks/server.rb
|
65
|
-
- generators/torquebox_queue_generator.rb
|
66
68
|
- generators/USAGE
|
69
|
+
- generators/torquebox_queue_generator.rb
|
67
70
|
- generators/templates/queue.rb
|
68
|
-
- spec/server_spec.rb
|
69
|
-
- spec/deploy_utils_spec.rb
|
70
71
|
- spec/upstart_spec.rb
|
71
72
|
- spec/rails_spec.rb
|
73
|
+
- spec/deploy_utils_spec.rb
|
72
74
|
- spec/spec_helper.rb
|
73
|
-
- spec/
|
75
|
+
- spec/server_spec.rb
|
74
76
|
- spec/fixtures/simpleapp/simpleapp.box
|
77
|
+
- spec/fixtures/simpleapp/config.ru
|
78
|
+
- spec/fixtures/simpleapp/vendor/vendor.rb
|
79
|
+
- spec/fixtures/simpleapp/puppet/puppet.rb
|
75
80
|
- spec/fixtures/simpleapp/app/app.rb
|
76
|
-
- spec/fixtures/simpleapp/app/app.box
|
77
81
|
- spec/fixtures/simpleapp/app/puppet-master.rb
|
82
|
+
- spec/fixtures/simpleapp/app/app.box
|
78
83
|
- spec/fixtures/simpleapp/app/a-non-cached.gem
|
79
|
-
- spec/fixtures/simpleapp/vendor/vendor.rb
|
80
|
-
- spec/fixtures/simpleapp/puppet/puppet.rb
|
81
84
|
homepage: http://torquebox.org/
|
82
85
|
licenses:
|
83
86
|
- lgpl
|
@@ -106,7 +109,7 @@ signing_key:
|
|
106
109
|
specification_version: 3
|
107
110
|
summary: TorqueBox Rake Support
|
108
111
|
test_files:
|
109
|
-
- spec/server_spec.rb
|
110
|
-
- spec/deploy_utils_spec.rb
|
111
112
|
- spec/upstart_spec.rb
|
112
113
|
- spec/rails_spec.rb
|
114
|
+
- spec/deploy_utils_spec.rb
|
115
|
+
- spec/server_spec.rb
|