org.torquebox.rake-support 1.0.0.Beta22 → 1.0.0.Beta23

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +1,44 @@
1
- if ( rails?( Dir.pwd ) )
2
- namespace :torquebox do
3
-
4
- desc "Create a self-contained application archive"
5
- task :archive do
6
- puts "Creating archive of #{RAILS_ROOT}"
7
- bundle_name = File.basename( RAILS_ROOT ) + '.rails'
8
- FileUtils.rm_rf( bundle_name )
9
-
10
- skip_files = [
11
- 'log',
12
- 'tmp',
13
- ]
14
- include_files = []
15
- Dir[ "#{RAILS_ROOT}/*" ].each do |entry|
16
- entry = File.basename( entry )
17
- unless ( skip_files.include?( entry ) )
18
- include_files << entry
19
- end
1
+
2
+ def get_archive_name root=Dir.pwd
3
+ File.basename(root) + (rails?(root) ? '.rails' : '.rack')
4
+ end
5
+
6
+ namespace :torquebox do
7
+
8
+ desc "Create a self-contained application archive"
9
+ task :archive do
10
+ skip_files = %w{ ^log$ ^tmp$ \.rails$ \.rack$ }
11
+
12
+ include_files = []
13
+ Dir[ "*", ".bundle" ].each do |entry|
14
+ entry = File.basename( entry )
15
+ unless ( skip_files.any?{ |regex| entry.match(regex)} )
16
+ include_files << entry
20
17
  end
21
-
22
- puts "Creating archive: #{bundle_name}"
23
-
24
- Dir.chdir( RAILS_ROOT ) do
25
- cmd = "jar cf #{bundle_name} #{include_files.join(' ')}"
26
- Open3.popen3( cmd ) do |stdin, stdout, stderr|
27
- stdin.close
28
- stdout_thr = Thread.new(stdout) {|stdout_io|
29
- stdout_io.readlines.each do |l|
30
- puts l
31
- end
32
- stdout_io.close
33
- }
34
- stderr_thr = Thread.new(stderr) {|stderr_io|
35
- stderr_io.readlines.each do |l|
36
- puts l
37
- end
38
- }
39
- stdout_thr.join
40
- stderr_thr.join
18
+ end
19
+
20
+ archive_name = get_archive_name
21
+ puts "Creating archive: #{archive_name}"
22
+ cmd = "jar cvf #{archive_name} #{include_files.join(' ')}"
23
+ Open3.popen3( cmd ) do |stdin, stdout, stderr|
24
+ stdin.close
25
+ stdout_thr = Thread.new(stdout) {|stdout_io|
26
+ stdout_io.readlines.each do |l|
27
+ puts l
41
28
  end
42
- end
43
- puts "Created archive: #{bundle_name}"
29
+ stdout_io.close
30
+ }
31
+ stderr_thr = Thread.new(stderr) {|stderr_io|
32
+ stderr_io.readlines.each do |l|
33
+ puts l
34
+ end
35
+ }
36
+ stdout_thr.join
37
+ stderr_thr.join
44
38
  end
39
+ puts "Created archive: #{Dir.pwd}/#{archive_name}"
45
40
  end
46
41
 
47
42
  end
48
43
 
44
+
@@ -11,7 +11,7 @@ def rails_deployment(app_name, root, context_path)
11
11
  deployment_descriptor = {
12
12
  'application' => {
13
13
  'RAILS_ROOT'=>root,
14
- 'RAILS_ENV'=>( defined?( RAILS_ENV ) ? RAILS_ENV : 'development' ),
14
+ 'RAILS_ENV'=>( defined?( RAILS_ENV ) ? RAILS_ENV : 'development' ).to_s,
15
15
  },
16
16
  'web' => {
17
17
  'context'=> context_path[0,1] != '/'? %Q(/#{context_path}) : context_path
@@ -22,10 +22,11 @@ def rails_deployment(app_name, root, context_path)
22
22
  end
23
23
 
24
24
  def rack_deployment(app_name, root, context_path)
25
+ env = defined?(RACK_ENV) ? RACK_ENV : ENV['RACK_ENV']
25
26
  deployment_descriptor = {
26
27
  'application' => {
27
28
  'RACK_ROOT'=>root,
28
- 'RACK_ENV'=>( defined?( RACK_ENV ) ? RACK_ENV : 'development' ),
29
+ 'RACK_ENV'=>( env || 'development' ).to_s,
29
30
  },
30
31
  'web' => {
31
32
  'context'=> context_path[0,1] != '/'? %Q(/#{context_path}) : context_path
@@ -35,12 +36,12 @@ def rack_deployment(app_name, root, context_path)
35
36
  [ rack_deployment_name( app_name ), deployment_descriptor ]
36
37
  end
37
38
 
38
- def rails?(root)
39
+ def rails?(root = Dir.pwd)
39
40
  File.exist?( File.join( root, 'config', 'environment.rb' ) )
40
41
  end
41
42
 
42
- def rack?(root)
43
- File.exist?( File.join( root, 'config.ru' ) )
43
+ def rack?(root = Dir.pwd)
44
+ not rails?(root)
44
45
  end
45
46
 
46
47
  def deployment(app_name, root, context_path)
@@ -78,22 +79,20 @@ namespace :torquebox do
78
79
  puts "Undeployed #{deployment_name}"
79
80
  end
80
81
 
81
- if ( rails?( Dir.pwd ) )
82
- desc "Create (if needed) and deploy as application archive"
83
- namespace :deploy do
84
- task :archive=>[ 'torquebox:archive' ] do
85
- archive_name = File.basename( Dir.pwd ) + '.rails'
86
- src = "#{Dir.pwd}/#{archive_name}"
87
- FileUtils.cp( src, TorqueBox::RakeUtils.deploy_dir )
88
- puts "Deployed #{archive_name}"
89
- end
82
+ desc "Create (if needed) and deploy as application archive"
83
+ namespace :deploy do
84
+ task :archive=>[ 'torquebox:archive' ] do
85
+ archive_name = get_archive_name
86
+ src = "#{Dir.pwd}/#{archive_name}"
87
+ FileUtils.cp( src, TorqueBox::RakeUtils.deploy_dir )
88
+ puts "Deployed #{archive_name}"
90
89
  end
91
- namespace :undeploy do
92
- task :archive do
93
- archive_name = File.basename( Dir.pwd ) + '.rails'
94
- FileUtils.rm_f( File.join( TorqueBox::RakeUtils.deploy_dir, archive_name ) )
95
- puts "Undeployed #{archive_name}"
96
- end
90
+ end
91
+ namespace :undeploy do
92
+ task :archive do
93
+ archive_name = get_archive_name
94
+ FileUtils.rm_f( File.join( TorqueBox::RakeUtils.deploy_dir, archive_name ) )
95
+ puts "Undeployed #{archive_name}"
97
96
  end
98
97
  end
99
98
 
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 0
8
8
  - 0
9
- - Beta22
10
- version: 1.0.0.Beta22
9
+ - Beta23
10
+ version: 1.0.0.Beta23
11
11
  platform: ruby
12
12
  authors: []
13
13
 
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-30 00:00:00 -05:00
18
+ date: 2010-12-06 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21