rtomcat 0.0.1

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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Darrin Holst
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ = rtomcat
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 Darrin Holst. See LICENSE for details.
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rtomcat"
8
+ gem.summary = %Q{ruby wrapper around the tomcat manager}
9
+ gem.email = "darrinholst@gmail.com"
10
+ gem.homepage = "http://github.com/darrinholst/rtomcat"
11
+ gem.authors = ["Darrin Holst"]
12
+ gem.rubyforge_project = "rtomcat"
13
+ gem.add_dependency("rest-client", ">= 1.0.3")
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+
17
+ Jeweler::RubyforgeTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/*_test.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/*_test.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION.yml')
48
+ config = YAML.load(File.read('VERSION.yml'))
49
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
50
+ else
51
+ version = ""
52
+ end
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "rtomcat #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
59
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,29 @@
1
+ require 'rest_client'
2
+
3
+ class Tomcat::Manager
4
+ def initialize(url, username, password)
5
+ @url = url
6
+ @username = username
7
+ @password = password
8
+ end
9
+
10
+ def undeploy(appname)
11
+ check_response(resource('undeploy', appname).get)
12
+ end
13
+
14
+ def deploy(appname, file)
15
+ check_response(resource('deploy', appname).put file)
16
+ end
17
+
18
+ private
19
+
20
+ def check_response(response)
21
+ match = response.match(/(.*) - .*/)
22
+ raise("http status code: #{response.code}, message: #{response}") unless match && match[1].eql?("OK")
23
+ response
24
+ end
25
+
26
+ def resource(function, appname)
27
+ RestClient::Resource.new("#{@url}/#{function}?path=/#{appname}", :user => @username, :password => @password)
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ module Tomcat
2
+ end
3
+
4
+ require 'manager'
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{rtomcat}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Darrin Holst"]
9
+ s.date = %q{2009-07-15}
10
+ s.email = %q{darrinholst@gmail.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "lib/manager.rb",
23
+ "lib/rtomcat.rb",
24
+ "rtomcat.gemspec",
25
+ "test/manager_test.rb",
26
+ "test/test_helper.rb"
27
+ ]
28
+ s.homepage = %q{http://github.com/darrinholst/rtomcat}
29
+ s.rdoc_options = ["--charset=UTF-8"]
30
+ s.require_paths = ["lib"]
31
+ s.rubyforge_project = %q{rtomcat}
32
+ s.rubygems_version = %q{1.3.4}
33
+ s.summary = %q{ruby wrapper around the tomcat manager}
34
+ s.test_files = [
35
+ "test/manager_test.rb",
36
+ "test/test_helper.rb"
37
+ ]
38
+
39
+ if s.respond_to? :specification_version then
40
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<rest-client>, [">= 1.0.3"])
45
+ else
46
+ s.add_dependency(%q<rest-client>, [">= 1.0.3"])
47
+ end
48
+ else
49
+ s.add_dependency(%q<rest-client>, [">= 1.0.3"])
50
+ end
51
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ class ManagerTest < Test::Unit::TestCase
4
+ def setup
5
+ @manager = Tomcat::Manager.new("http://localhost:8080", "user", "password")
6
+ end
7
+
8
+ def test_undeploy
9
+ FakeWeb.register_uri(:get, undeploy_url, :body => "OK - Undeployed application at context path /appname")
10
+ assert_nothing_raised { undeploy }
11
+ end
12
+
13
+ def test_undeploy_when_not_a_200_status
14
+ FakeWeb.register_uri(:get, undeploy_url, :status => ["401", "Unauthorized"])
15
+ assert_raises_with("Unauthorized") { undeploy }
16
+ end
17
+
18
+ def test_undeploy_when_non_ok_response
19
+ FakeWeb.register_uri(:get, undeploy_url, :body => "FAIL - some error")
20
+ assert_raises_with("http status code: 200, message: FAIL - some error") { undeploy }
21
+ end
22
+
23
+ def test_deploy
24
+ FakeWeb.register_uri(:put, deploy_url, :body => "OK - Undeployed application at context path /appname")
25
+ assert_nothing_raised { deploy }
26
+ end
27
+
28
+ def test_deploy_when_not_a_200_status
29
+ FakeWeb.register_uri(:put, deploy_url, :status => ["401", "Unauthorized"])
30
+ assert_raises_with("Unauthorized") { deploy }
31
+ end
32
+
33
+ def test_deploy_when_non_ok_response
34
+ FakeWeb.register_uri(:put, deploy_url, :body => "FAIL - some error")
35
+ assert_raises_with("http status code: 200, message: FAIL - some error") { deploy }
36
+ end
37
+
38
+ private
39
+
40
+ def undeploy_url
41
+ "http://user:password@localhost:8080/undeploy?path=/appname"
42
+ end
43
+
44
+ def undeploy
45
+ @manager.undeploy('appname')
46
+ end
47
+
48
+ def deploy_url
49
+ "http://user:password@localhost:8080/deploy?path=/appname"
50
+ end
51
+
52
+ def deploy
53
+ @manager.deploy('appname', "FakeWeb doesn't allow for put body interrogation right now, so this parameter doesn't matter")
54
+ end
55
+
56
+ def assert_raises_with(message)
57
+ begin
58
+ yield
59
+ fail("should have raised")
60
+ rescue Exception => e
61
+ assert_equal(message, e.message)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'fakeweb'
4
+
5
+ FakeWeb.allow_net_connect = false
6
+
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
+ require 'rtomcat'
10
+
11
+ class Test::Unit::TestCase
12
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtomcat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Darrin Holst
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-15 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rest-client
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.3
24
+ version:
25
+ description:
26
+ email: darrinholst@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - VERSION
41
+ - lib/manager.rb
42
+ - lib/rtomcat.rb
43
+ - rtomcat.gemspec
44
+ - test/manager_test.rb
45
+ - test/test_helper.rb
46
+ has_rdoc: true
47
+ homepage: http://github.com/darrinholst/rtomcat
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --charset=UTF-8
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ requirements: []
68
+
69
+ rubyforge_project: rtomcat
70
+ rubygems_version: 1.3.4
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: ruby wrapper around the tomcat manager
74
+ test_files:
75
+ - test/manager_test.rb
76
+ - test/test_helper.rb