godot 0.1.0
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/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +80 -0
- data/Guardfile +10 -0
- data/LICENSE +21 -0
- data/README.md +22 -0
- data/godot.gemspec +25 -0
- data/lib/godot.rb +70 -0
- data/lib/godot/version.rb +3 -0
- data/script/ci.sh +1 -0
- data/spec/contexts/with_server_context.rb +7 -0
- data/spec/contexts/without_server_context.rb +8 -0
- data/spec/lib/godot_spec.rb +59 -0
- data/spec/spec_helper.rb +6 -0
- metadata +177 -0
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use ruby-1.9.3-p286@godot
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
godot (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.3.2)
|
10
|
+
capybara (1.1.2)
|
11
|
+
mime-types (>= 1.16)
|
12
|
+
nokogiri (>= 1.3.3)
|
13
|
+
rack (>= 1.0.0)
|
14
|
+
rack-test (>= 0.5.4)
|
15
|
+
selenium-webdriver (~> 2.0)
|
16
|
+
xpath (~> 0.1.4)
|
17
|
+
childprocess (0.3.6)
|
18
|
+
ffi (~> 1.0, >= 1.0.6)
|
19
|
+
coderay (1.0.8)
|
20
|
+
diff-lcs (1.1.3)
|
21
|
+
ffi (1.1.5)
|
22
|
+
guard (1.5.0)
|
23
|
+
listen (>= 0.4.2)
|
24
|
+
lumberjack (>= 1.0.2)
|
25
|
+
pry (>= 0.9.10)
|
26
|
+
thor (>= 0.14.6)
|
27
|
+
guard-bundler (1.0.0)
|
28
|
+
bundler (~> 1.0)
|
29
|
+
guard (~> 1.1)
|
30
|
+
guard-rspec (2.1.0)
|
31
|
+
guard (>= 1.1)
|
32
|
+
rspec (~> 2.11)
|
33
|
+
libwebsocket (0.1.5)
|
34
|
+
addressable
|
35
|
+
listen (0.5.3)
|
36
|
+
lumberjack (1.0.2)
|
37
|
+
method_source (0.8.1)
|
38
|
+
mime-types (1.19)
|
39
|
+
multi_json (1.3.6)
|
40
|
+
nokogiri (1.5.5)
|
41
|
+
pry (0.9.10)
|
42
|
+
coderay (~> 1.0.5)
|
43
|
+
method_source (~> 0.8)
|
44
|
+
slop (~> 3.3.1)
|
45
|
+
rack (1.4.1)
|
46
|
+
rack-test (0.6.2)
|
47
|
+
rack (>= 1.0)
|
48
|
+
rb-fsevent (0.9.2)
|
49
|
+
rspec (2.11.0)
|
50
|
+
rspec-core (~> 2.11.0)
|
51
|
+
rspec-expectations (~> 2.11.0)
|
52
|
+
rspec-mocks (~> 2.11.0)
|
53
|
+
rspec-core (2.11.1)
|
54
|
+
rspec-expectations (2.11.3)
|
55
|
+
diff-lcs (~> 1.1.3)
|
56
|
+
rspec-mocks (2.11.3)
|
57
|
+
rubyzip (0.9.9)
|
58
|
+
selenium-webdriver (2.25.0)
|
59
|
+
childprocess (>= 0.2.5)
|
60
|
+
libwebsocket (~> 0.1.3)
|
61
|
+
multi_json (~> 1.0)
|
62
|
+
rubyzip
|
63
|
+
slop (3.3.3)
|
64
|
+
terminal-notifier (1.4.2)
|
65
|
+
thor (0.16.0)
|
66
|
+
xpath (0.1.4)
|
67
|
+
nokogiri (~> 1.3)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
capybara
|
74
|
+
godot!
|
75
|
+
guard
|
76
|
+
guard-bundler
|
77
|
+
guard-rspec
|
78
|
+
rb-fsevent
|
79
|
+
rspec
|
80
|
+
terminal-notifier
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Doc Ritezel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Godot
|
2
|
+
|
3
|
+
[](http://travis-ci.org/ohrite/godot)
|
4
|
+
[](https://gemnasium.com/ohrite/godot)
|
5
|
+
|
6
|
+
Introducing Godot, the gem what makes waiting for stuff all easy-like.
|
7
|
+
|
8
|
+
|
9
|
+
## What?
|
10
|
+
|
11
|
+
Ever need to wait for a server to come up on a given port?
|
12
|
+
|
13
|
+
puts "My life is so much better now!" if Godot.wait("pivotallabs.com", 80)
|
14
|
+
|
15
|
+
How about that same few lines of timeout-wrapped curl matching output?
|
16
|
+
|
17
|
+
puts "So that's doc!" if Godot.match("pivotallabs.com", 80, /doc/, "/who")
|
18
|
+
|
19
|
+
|
20
|
+
## License
|
21
|
+
|
22
|
+
See LICENSE for more information.
|
data/godot.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path("../lib/godot/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "godot"
|
5
|
+
s.version = Godot::VERSION
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.homepage = "https://github.com/ohrite/godot"
|
8
|
+
s.authors = ["Doc Ritezel", "Matthew Kocher"]
|
9
|
+
s.email = "ritezel+godot@pivotallabs.com"
|
10
|
+
s.summary = "The gem what makes waiting for stuff all easy-like."
|
11
|
+
s.description = "If you're going to be bored waiting for something, why not our good friend?"
|
12
|
+
|
13
|
+
s.add_development_dependency "rspec"
|
14
|
+
s.add_development_dependency "guard"
|
15
|
+
s.add_development_dependency "guard-rspec"
|
16
|
+
s.add_development_dependency "guard-bundler"
|
17
|
+
s.add_development_dependency "rb-fsevent"
|
18
|
+
s.add_development_dependency "terminal-notifier"
|
19
|
+
s.add_development_dependency "capybara"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split( "\n" )
|
22
|
+
s.test_files = `git ls-files -- spec/*`.split( "\n" )
|
23
|
+
s.executables = `git ls-files -- bin/*`.split( "\n" ).map{ |f| File.basename( f ) }
|
24
|
+
s.require_path = "lib"
|
25
|
+
end
|
data/lib/godot.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require "timeout"
|
2
|
+
require "socket"
|
3
|
+
|
4
|
+
class Godot
|
5
|
+
attr_reader :host, :port
|
6
|
+
attr_writer :interval, :timeout
|
7
|
+
|
8
|
+
def self.wait!(host, port)
|
9
|
+
new(host, port).wait!
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.wait(host, port)
|
13
|
+
new(host, port).wait
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.match!(host, port, pattern, path = "", options = "-ks")
|
17
|
+
new(host, port).match!(pattern, path, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.match(host, port, pattern, path = "", options = "-ks")
|
21
|
+
new(host, port).match(pattern, path, options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(host, port)
|
25
|
+
@host = host
|
26
|
+
@port = port
|
27
|
+
end
|
28
|
+
|
29
|
+
def interval
|
30
|
+
@interval || 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def timeout
|
34
|
+
@timeout || 10
|
35
|
+
end
|
36
|
+
|
37
|
+
def wait!
|
38
|
+
Timeout.timeout(timeout) do
|
39
|
+
socket = nil
|
40
|
+
until socket
|
41
|
+
begin
|
42
|
+
Timeout.timeout(interval) do
|
43
|
+
socket = TCPSocket.open(host, port)
|
44
|
+
end
|
45
|
+
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error, Errno::EHOSTUNREACH
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def wait
|
52
|
+
wait!
|
53
|
+
true
|
54
|
+
rescue Timeout::Error
|
55
|
+
false
|
56
|
+
end
|
57
|
+
|
58
|
+
def match!(pattern, path = "", options = "-ks")
|
59
|
+
Timeout.timeout(timeout) do
|
60
|
+
sleep interval until `curl #{options} http://#{host}:#{port}/#{path}` =~ pattern
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def match(pattern, path = "", options = "-ks")
|
65
|
+
match!(pattern, options)
|
66
|
+
true
|
67
|
+
rescue Timeout::Error
|
68
|
+
false
|
69
|
+
end
|
70
|
+
end
|
data/script/ci.sh
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bundle exec rspec
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Godot do
|
4
|
+
describe "#wait!" do
|
5
|
+
context "with a target", :target => true do
|
6
|
+
it "is silent after successfully waiting" do
|
7
|
+
expect { godot.wait! }.not_to raise_error
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "without a target", :target => false do
|
12
|
+
it "raises an exception when waiting goes awry" do
|
13
|
+
expect { godot.wait! }.to raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#wait" do
|
19
|
+
context "with a target", :target => true do
|
20
|
+
it "returns true" do
|
21
|
+
godot.wait.should be_true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "without a target", :target => false do
|
26
|
+
it "returns false" do
|
27
|
+
godot.wait.should be_false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#match!" do
|
33
|
+
context "with a target", :target => true do
|
34
|
+
it "is silent" do
|
35
|
+
expect { godot.match!(/This will match/) }.not_to raise_error
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "without a target", :target => false do
|
40
|
+
it "raises an exception" do
|
41
|
+
expect { godot.match!(/Nope/) }.to raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#match" do
|
47
|
+
context "without a target", :target => false do
|
48
|
+
it "returns false" do
|
49
|
+
godot.match(/Not in the least/).should be_false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with a target", :target => true do
|
54
|
+
it "returns true" do
|
55
|
+
godot.match(/This will match/).should be_true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: godot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Doc Ritezel
|
9
|
+
- Matthew Kocher
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-10-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: guard
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: guard-rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: guard-bundler
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: rb-fsevent
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :development
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: terminal-notifier
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: capybara
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
description: If you're going to be bored waiting for something, why not our good friend?
|
128
|
+
email: ritezel+godot@pivotallabs.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .rspec
|
134
|
+
- .rvmrc
|
135
|
+
- .travis.yml
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- Guardfile
|
139
|
+
- LICENSE
|
140
|
+
- README.md
|
141
|
+
- godot.gemspec
|
142
|
+
- lib/godot.rb
|
143
|
+
- lib/godot/version.rb
|
144
|
+
- script/ci.sh
|
145
|
+
- spec/contexts/with_server_context.rb
|
146
|
+
- spec/contexts/without_server_context.rb
|
147
|
+
- spec/lib/godot_spec.rb
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
homepage: https://github.com/ohrite/godot
|
150
|
+
licenses: []
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 1.8.24
|
170
|
+
signing_key:
|
171
|
+
specification_version: 3
|
172
|
+
summary: The gem what makes waiting for stuff all easy-like.
|
173
|
+
test_files:
|
174
|
+
- spec/contexts/with_server_context.rb
|
175
|
+
- spec/contexts/without_server_context.rb
|
176
|
+
- spec/lib/godot_spec.rb
|
177
|
+
- spec/spec_helper.rb
|