rubicante 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.
- data/History.txt +7 -0
- data/Manifest.txt +26 -0
- data/README.rdoc +118 -0
- data/README.txt +118 -0
- data/Rakefile +14 -0
- data/bin/rubicante +34 -0
- data/lib/rubicante.rb +6 -0
- data/lib/rubicante/cli.rb +89 -0
- data/lib/rubicante/environment.rb +78 -0
- data/lib/rubicante/host.rb +140 -0
- data/lib/rubicante/host_error.rb +21 -0
- data/lib/rubicante/host_group.rb +18 -0
- data/lib/rubicante/type.rb +20 -0
- data/lib/rubicante/type_group.rb +18 -0
- data/lib/rubicante/website.rb +54 -0
- data/lib/rubicante/website_error.rb +10 -0
- data/spec/environment_spec.rb +84 -0
- data/spec/helper.rb +3 -0
- data/spec/host_error_spec.rb +61 -0
- data/spec/host_group_spec.rb +33 -0
- data/spec/host_spec.rb +159 -0
- data/spec/type_group_spec.rb +35 -0
- data/spec/type_spec.rb +42 -0
- data/spec/website_error_spec.rb +35 -0
- data/spec/website_spec.rb +53 -0
- data/test/test_rubicante.rb +9 -0
- metadata +111 -0
data/spec/host_spec.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)),"helper")
|
2
|
+
require "#{LIB_DIR}/host"
|
3
|
+
|
4
|
+
describe "A newtork host" do
|
5
|
+
before :each do
|
6
|
+
@host_name = "spec-host"
|
7
|
+
@host = Rubicante::Host.new(@host_name)
|
8
|
+
|
9
|
+
@host_with_sites = Rubicante::Host.new(@host_name)
|
10
|
+
@sites = [
|
11
|
+
'www.rubicante-good-site.com',
|
12
|
+
'www.rubicante-bad-site.com',
|
13
|
+
'www.rubicante-worse-site.com',
|
14
|
+
'www.rubicante-redirect.com'
|
15
|
+
]
|
16
|
+
@sites.each do |site|
|
17
|
+
@host_with_sites.website(site)
|
18
|
+
end
|
19
|
+
|
20
|
+
@host_with_ports = Rubicante::Host.new(@host_name)
|
21
|
+
@ports = [80, 22, 443]
|
22
|
+
@ports.each do |port|
|
23
|
+
@host_with_ports.port(port)
|
24
|
+
end
|
25
|
+
|
26
|
+
Net::HTTP.stub!(:get_response).and_return(Net::HTTPServerError.new('1', '500', 'Internal Server Error'))
|
27
|
+
Ping.stub!(:pingecho).and_return(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should exist" do
|
31
|
+
@host.should_not be_nil
|
32
|
+
@host.should be_an_instance_of(Rubicante::Host)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should require a name parameter for initialization" do
|
36
|
+
lambda { Host.new.should raise_error(ArgumentError) }
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have an empty array of ports by default" do
|
40
|
+
@host.ports.should == []
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should allow adding more ports with port()" do
|
44
|
+
port = 12345
|
45
|
+
@host.port(port)
|
46
|
+
@host.ports.include?(port).should == true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return self for port()" do
|
50
|
+
@host.port(12345).should be_an_instance_of(Rubicante::Host)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have an empty array of services by default" do
|
54
|
+
@host.services.should == []
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should allow adding more services with service()" do
|
58
|
+
service = "W32Time"
|
59
|
+
@host.service(service)
|
60
|
+
@host.services.include?(service).should == true
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should return self for service()" do
|
64
|
+
@host.service("test").should be_an_instance_of(Rubicante::Host)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have an empty array of types" do
|
68
|
+
@host.types.should == []
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should allow adding more types with type()" do
|
72
|
+
type = "SQL Server"
|
73
|
+
@host.type(type)
|
74
|
+
@host.types.include?(type).should == true
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should return self for type()" do
|
78
|
+
@host.type("testing").should be_an_instance_of(Rubicante::Host)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should have an empty array of websites by default" do
|
82
|
+
@host.websites.should == []
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should allow adding more webistes with site()" do
|
86
|
+
url = "http://www.example.com/"
|
87
|
+
@host.website(url)
|
88
|
+
@host.websites.size.should == 1
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should return self for site()" do
|
92
|
+
@host.website("http://www.example.com/").should be_an_instance_of(Rubicante::Host)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should check all websites" do
|
96
|
+
@host_with_sites.check_websites do |result|
|
97
|
+
@sites.include?(result.url).should == true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should return a HostError for wrong?" do
|
102
|
+
@host.wrong?.should be_an_instance_of(Rubicante::HostError)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should return website errors with the HostError" do
|
106
|
+
host_error = @host.wrong?
|
107
|
+
|
108
|
+
host_error.website_errors.should_not be_nil
|
109
|
+
host_error.website_errors.each do |website_error|
|
110
|
+
website_error.should be_an_instance_of(Rubicante::WebsiteError)
|
111
|
+
@sites.include?(website_error.url).should == true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should support pinging" do
|
116
|
+
@host.respond_to?('ping').should == true
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should update HostError.ping to true for alive hosts" do
|
120
|
+
host_error = @host.wrong?
|
121
|
+
host_error.ping.should == true
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should update HostError.ping to false for down hosts" do
|
125
|
+
Ping.stub!(:pingecho).and_return(false)
|
126
|
+
host_error = @host.wrong?
|
127
|
+
host_error.ping.should == false
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should skip website processing for downed hosts" do
|
131
|
+
Ping.stub!(:pingecho).and_return(false)
|
132
|
+
host_error = @host_with_sites.wrong?
|
133
|
+
host_error.ping.should == false
|
134
|
+
host_error.website_errors.should == []
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should check a specified port" do
|
138
|
+
@host.respond_to?('check_port').should == true
|
139
|
+
TCPSocket.stub!(:open).and_return(true)
|
140
|
+
@host.check_port(80).should == true
|
141
|
+
TCPSocket.stub!(:open).and_raise(ArgumentError)
|
142
|
+
@host.check_port(443).should == false
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should check all registered ports" do
|
146
|
+
TCPSocket.stub!(:open).and_raise(ArgumentError)
|
147
|
+
@host_with_ports.check_ports do |port, is_alive|
|
148
|
+
@ports.include?(port).should == true
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should update HostError.bad_ports for all down ports" do
|
153
|
+
TCPSocket.stub!(:open).and_raise(ArgumentError)
|
154
|
+
host_error = @host_with_ports.wrong?
|
155
|
+
host_error.bad_ports.each do |bad_port|
|
156
|
+
@ports.include?(bad_port).should == true
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)),"helper")
|
2
|
+
require "#{LIB_DIR}/type_group"
|
3
|
+
|
4
|
+
describe "A group of server types" do
|
5
|
+
before :each do
|
6
|
+
@type_group = Rubicante::TypeGroup.instance
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should exist" do
|
10
|
+
@type_group.should_not be_nil
|
11
|
+
@type_group.should be_an_instance_of(Rubicante::TypeGroup)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have an empty hash of types by default" do
|
15
|
+
@type_group.types.should == {}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should create a new type in types if it doesn't exist" do
|
19
|
+
type_name = "new-type"
|
20
|
+
@type_group[type_name].name.should == type_name
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should allow for modifying previously defined types" do
|
24
|
+
type_name = "new-type"
|
25
|
+
new_port = 80
|
26
|
+
new_service = "new-service"
|
27
|
+
@type_group[type_name]
|
28
|
+
|
29
|
+
@type_group[type_name].port(new_port)
|
30
|
+
@type_group[type_name].ports.include?(new_port).should == true
|
31
|
+
|
32
|
+
@type_group[type_name].service(new_service)
|
33
|
+
@type_group[type_name].services.include?(new_service).should == true
|
34
|
+
end
|
35
|
+
end
|
data/spec/type_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)),"helper")
|
2
|
+
require "#{LIB_DIR}/type"
|
3
|
+
|
4
|
+
describe "A server type" do
|
5
|
+
before :each do
|
6
|
+
@type_name = "spec-type"
|
7
|
+
@type = Rubicante::Type.new(@type_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should exist" do
|
11
|
+
@type.should_not be_nil
|
12
|
+
@type.should be_an_instance_of(Rubicante::Type)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should require a name when initializing" do
|
16
|
+
lambda { @new_type = Rubicante::Type.new }.should raise_error(ArgumentError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have a name" do
|
20
|
+
@type.name.should == @type_name
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have an empty array of ports by default" do
|
24
|
+
@type.ports.should == []
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have an empty array of services by default" do
|
28
|
+
@type.services.should == []
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should allow appending of ports" do
|
32
|
+
new_port = 80
|
33
|
+
@type.port(new_port)
|
34
|
+
@type.ports.include?(new_port).should == true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should allow appending of services" do
|
38
|
+
new_service = "W32Time"
|
39
|
+
@type.service(new_service)
|
40
|
+
@type.services.include?(new_service).should == true
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)),"helper")
|
2
|
+
require "#{LIB_DIR}/website_error"
|
3
|
+
|
4
|
+
describe "An error with a website" do
|
5
|
+
before :each do
|
6
|
+
@url = "http://www.rubicante-example.com/"
|
7
|
+
@code = "500"
|
8
|
+
@website_error = Rubicante::WebsiteError.new(@url, @code)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should exist" do
|
12
|
+
@website_error.should_not be_nil
|
13
|
+
@website_error.should be_an_instance_of(Rubicante::WebsiteError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should require parameters to be created" do
|
17
|
+
lambda { Rubicante::WebsiteError.new }.should raise_error(ArgumentError)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have a URL" do
|
21
|
+
@website_error.url.should == @url
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have an HTTP code" do
|
25
|
+
@website_error.code.should == @code
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not allow modification to the URL" do
|
29
|
+
lambda { @website_error.url = "http://www.rubyforge-example.org/" }.should raise_error(NoMethodError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not allow modification to the HTTP code" do
|
33
|
+
lambda { @website_error.code = "301" }.should raise_error(NoMethodError)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)),"helper")
|
2
|
+
require "#{LIB_DIR}/website"
|
3
|
+
|
4
|
+
describe "A website" do
|
5
|
+
before :each do
|
6
|
+
@url = 'http://www.rubicante-test.com/'
|
7
|
+
@website = Rubicante::Website.new(@url)
|
8
|
+
|
9
|
+
@http_ok = Net::HTTPOK.new('1', '200', 'OK')
|
10
|
+
@http_redirect = Net::HTTPMovedPermanently.new('1', '301', 'Moved Permanently')
|
11
|
+
@http_client_error = Net::HTTPNotFound.new('1', '404', 'File Not Found')
|
12
|
+
@http_server_error = Net::HTTPInternalServerError.new('1', '500', 'Internal Server Error')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should exist" do
|
16
|
+
@website.should_not be_nil
|
17
|
+
@website.should be_an_instance_of(Rubicante::Website)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should require a name parameter for initialization" do
|
21
|
+
lambda { Website.new.should raise_error(ArgumentError) }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the HTTP code number for a site" do
|
25
|
+
Net::HTTP.stub!(:get_response).and_return(@http_redirect)
|
26
|
+
@website.response_code.should == "301"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return true for good websites" do
|
30
|
+
Net::HTTP.stub!(:get_response).and_return(@http_ok)
|
31
|
+
@website.is_ok?.should == true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return true for redirected websites" do
|
35
|
+
Net::HTTP.stub!(:get_response).and_return(@http_redirect)
|
36
|
+
@website.is_ok?.should == true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return false for websites having problems" do
|
40
|
+
Net::HTTP.stub!(:get_response).and_return(@http_server_error)
|
41
|
+
@website.is_ok?.should == false
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return false for missing files" do
|
45
|
+
Net::HTTP.stub!(:get_response).and_return(@http_client_error)
|
46
|
+
@website.is_ok?.should == false
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return a WebsiteError for bad sites" do
|
50
|
+
Net::HTTP.stub!(:get_response).and_return(@http_server_error)
|
51
|
+
@website.wrong?.should be_an_instance_of(Rubicante::WebsiteError)
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubicante
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam VanderHook
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-08 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: logging
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.7
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: trollop
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "1.13"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.11.0
|
44
|
+
version:
|
45
|
+
description: Rubicante is a business natural language (BNL) for System Administrators (SAs). It allows SAs to define their networks in terms of servers, what those servers provide (websites, Win32 services), and what ports they listen on. Once the network is defined, SAs can type in natural language questions about the network and receive answers.
|
46
|
+
email:
|
47
|
+
- avanderhook@gmail.com
|
48
|
+
executables:
|
49
|
+
- rubicante
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- README.txt
|
56
|
+
files:
|
57
|
+
- History.txt
|
58
|
+
- Manifest.txt
|
59
|
+
- README.rdoc
|
60
|
+
- README.txt
|
61
|
+
- Rakefile
|
62
|
+
- bin/rubicante
|
63
|
+
- lib/rubicante.rb
|
64
|
+
- lib/rubicante/cli.rb
|
65
|
+
- lib/rubicante/environment.rb
|
66
|
+
- lib/rubicante/host.rb
|
67
|
+
- lib/rubicante/host_error.rb
|
68
|
+
- lib/rubicante/host_group.rb
|
69
|
+
- lib/rubicante/type.rb
|
70
|
+
- lib/rubicante/type_group.rb
|
71
|
+
- lib/rubicante/website.rb
|
72
|
+
- lib/rubicante/website_error.rb
|
73
|
+
- spec/environment_spec.rb
|
74
|
+
- spec/helper.rb
|
75
|
+
- spec/host_error_spec.rb
|
76
|
+
- spec/host_group_spec.rb
|
77
|
+
- spec/host_spec.rb
|
78
|
+
- spec/type_group_spec.rb
|
79
|
+
- spec/type_spec.rb
|
80
|
+
- spec/website_error_spec.rb
|
81
|
+
- spec/website_spec.rb
|
82
|
+
- test/test_rubicante.rb
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: RubyForge http://rubicante.rubyforge.org
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options:
|
87
|
+
- --main
|
88
|
+
- README.txt
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project: rubicante
|
106
|
+
rubygems_version: 1.3.1
|
107
|
+
signing_key:
|
108
|
+
specification_version: 2
|
109
|
+
summary: Rubicante is a business natural language (BNL) for System Administrators (SAs)
|
110
|
+
test_files:
|
111
|
+
- test/test_rubicante.rb
|