hudson-war 0.0 → 1.386

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/bin/hudson.war CHANGED
@@ -1,2 +1,111 @@
1
1
  #!/usr/bin/env ruby
2
- require 'hudson/war/0.0'
2
+
3
+ require 'optparse'
4
+ require 'ostruct'
5
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/hudson/war')
6
+
7
+
8
+
9
+
10
+ options = OpenStruct.new({
11
+ :home => File.join(ENV['HOME'], ".hudson", "server"),
12
+ :port => 3001,
13
+ :control => 3002,
14
+ :daemon => false,
15
+ :kill => false
16
+ })
17
+ parser = OptionParser.new
18
+ parser.banner = "Usage: hudson.war server [options]"
19
+ parser.on("--home DIR", String, "use this directory to store server data") {|dir| options.home = dir}
20
+ parser.on("-p", "--port PORT", Integer, "run hudson server on this port") {|port| options.port = port}
21
+ parser.on("-c", "--control PORT", Integer, "set the shutdown/control port") {|control| options.control = control}
22
+ parser.on("--daemon") {options.daemon = true}
23
+ parser.on("-k", "--kill") {options.kill = true}
24
+ parser.on("--logfile PATH", String, "redirect log messages to this file") {|path| options.logfile = path}
25
+
26
+ help = proc do |cmd|
27
+ help = Help.new(parser)
28
+ if cmd && help.respond_to?(cmd)
29
+ puts help.send(cmd)
30
+ else
31
+ puts "usage: hudson.war COMMAND [OPTIONS]"
32
+ puts " hudson.war help command"
33
+ puts " hudson.war version"
34
+ puts " hudson.war unpack DESTINATION"
35
+ puts " hudson.war classpath"
36
+ puts " hudson.war cp DESTINATION"
37
+ puts " hudson.war server [OPTIONS]"
38
+ puts ""
39
+ end
40
+ end
41
+
42
+ class Help
43
+ def initialize(server_options)
44
+ @server_options = server_options
45
+ end
46
+ def help
47
+ <<-HERE
48
+ Usage: hudson.war help COMMAND
49
+ shows help for the specified command
50
+ HERE
51
+ end
52
+ def version
53
+ <<-HERE
54
+ Usage: hudson.war version
55
+ displays the version of hudson represented by this war
56
+ HERE
57
+ end
58
+ def unpack
59
+ <<-HERE
60
+ Usage: hudson.war unpack DESTINATION
61
+ unpack the hudson war to directory at DESTINATION
62
+ HERE
63
+ end
64
+ def classpath
65
+ <<-HERE
66
+ Usage: hudson.war classpath
67
+ return a classpath for hudson core which can be used for a javac invocation
68
+ HERE
69
+ end
70
+ def cp
71
+ <<-HERE
72
+ Usage: hudson.war cp PATH
73
+ copy the hudson.war file to PATH
74
+ HERE
75
+ end
76
+ def location
77
+ <<-HERE
78
+ Usage: hudson.war location
79
+ prints the actual location on the file system of the hudson.war
80
+ HERE
81
+ end
82
+ def server
83
+ @server_options.to_s
84
+ end
85
+ end
86
+
87
+
88
+ war = Hudson::War
89
+ case cmd = ARGV.shift
90
+ when "version", "-v", "--version"
91
+ puts war::VERSION
92
+ exit
93
+ when 'unpack'
94
+ dest = ARGV.first
95
+ war.unpack(dest)
96
+ when 'classpath'
97
+ puts war.classpath
98
+ when 'cp'
99
+ dest = ARGV.first
100
+ war.cp dest
101
+ when 'server'
102
+ parser.parse(ARGV)
103
+ war.server(options)
104
+ when "help", "-h", "--help"
105
+ help[ARGV.first]
106
+ when "location"
107
+ puts war::LOCATION
108
+ else
109
+ help[nil]
110
+ end
111
+
data/hudson-war.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hudson-war}
5
- s.version = "0.0"
5
+ s.version = "1.386"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Charles Lowell"]
9
- s.date = %q{2010-12-28}
9
+ s.date = %q{2011-01-06}
10
10
  s.default_executable = %q{hudson.war}
11
11
  s.description = %q{download and install a specific version of the hudson war file which can be used for either running a server, or for plugin development}
12
12
  s.email = ["cowboyd@thefrontside.net"]
13
13
  s.executables = ["hudson.war"]
14
- s.files = ["bin", "bin/hudson.war", "hudson-war.gemspec", "lib", "lib/hudson", "lib/hudson/war", "lib/hudson/war/0.0.rb", "lib/hudson/war.rb"]
14
+ s.files = ["bin", "bin/hudson.war", "hudson-war.gemspec", "lib", "lib/hudson", "lib/hudson/hudson.war", "lib/hudson/war.rb"]
15
15
  s.homepage = %q{http://rubygems.org/gems/hudson-war}
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{hudson-war}
Binary file
data/lib/hudson/war.rb CHANGED
@@ -1,5 +1,68 @@
1
+ require 'fileutils'
1
2
  module Hudson
2
3
  module War
3
- require 'hudson/war/0.0'
4
+ VERSION = '1.386'
5
+ LOCATION = File.expand_path(File.join(File.dirname(__FILE__), "hudson.war"))
6
+
7
+ module_function
8
+
9
+ def unpack(dest_dir, output = $stdout)
10
+ target = File.dirname(dest_dir).tap do |dir_of_dest_dir|
11
+ raise "'#{dir_of_dest_dir}' is not a directory" unless File.directory?(dir_of_dest_dir)
12
+ end
13
+ FileUtils.mkdir_p dest_dir
14
+ Dir.chdir(dest_dir) do
15
+ sh "jar xvf #{LOCATION}", output
16
+ end
17
+ end
18
+
19
+ def cp(dest, output = $stdout)
20
+ FileUtils.cp(LOCATION, dest)
21
+ output << "copied #{LOCATION} -> #{dest}\n"
22
+ end
23
+
24
+ def server(options, output = $stdout)
25
+ home = options.home || File.join(ENV['HOME'], ".hudson", "server")
26
+ port = options.port.to_i || 3001
27
+ control = options.control.to_i || 3002
28
+ daemon = options.daemon
29
+ kill = options.kill
30
+ logfile = options.logfile
31
+
32
+ if kill
33
+ require 'socket'
34
+ TCPSocket.open("localhost", control) do |sock|
35
+ sock.write("0")
36
+ end
37
+ else
38
+ javatmp = File.join(home, "javatmp")
39
+ FileUtils.mkdir_p javatmp
40
+ ENV['HUDSON_HOME'] = home
41
+ cmd = ["java", "-Djava.io.tmpdir=#{javatmp}", "-jar", LOCATION]
42
+ cmd << "--daemon" if daemon
43
+ cmd << "--logfile=#{File.expand_path(logfile)}" if logfile
44
+ cmd << "--httpPort=#{port}"
45
+ cmd << "--controlPort=#{control}"
46
+ output << cmd.join(" ")
47
+ exec(*cmd)
48
+ end
49
+ end
50
+
51
+ def classpath
52
+ dest_dir = File.join(ENV['HOME'], '.hudson', 'wars', VERSION)
53
+ if File.directory?(dest_dir)
54
+ "#{dest_dir}/WEB-INF/lib/hudson-core-#{VERSION}.jar"
55
+ else
56
+ FileUtils.mkdir_p(dest_dir)
57
+ unpack(dest_dir, [])
58
+ classpath
59
+ end
60
+ end
61
+
62
+ def sh(command, output = $stdout)
63
+ output << command + "\n"
64
+ output << result = `#{command}`
65
+ raise result unless $?.success?
66
+ end
4
67
  end
5
68
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hudson-war
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 779
5
5
  prerelease: false
6
6
  segments:
7
- - 0
8
- - 0
9
- version: "0.0"
7
+ - 1
8
+ - 386
9
+ version: "1.386"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Charles Lowell
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-28 00:00:00 -06:00
17
+ date: 2011-01-06 00:00:00 -06:00
18
18
  default_executable: hudson.war
19
19
  dependencies: []
20
20
 
@@ -30,7 +30,7 @@ extra_rdoc_files: []
30
30
  files:
31
31
  - bin/hudson.war
32
32
  - hudson-war.gemspec
33
- - lib/hudson/war/0.0.rb
33
+ - lib/hudson/hudson.war
34
34
  - lib/hudson/war.rb
35
35
  has_rdoc: true
36
36
  homepage: http://rubygems.org/gems/hudson-war
@@ -1,6 +0,0 @@
1
- module Hudson
2
- module War
3
- module V0_0
4
- end
5
- end
6
- end