dfeojm 0.0.1 → 0.0.2
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/.gitignore +6 -0
- data/.rspec +1 -0
- data/.rvmrc +32 -0
- data/.travis.yml +8 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +31 -0
- data/README.md +3 -0
- data/Rakefile +47 -0
- data/dfeojm.gemspec +29 -0
- data/lib/dfeojm.rb +22 -10
- data/lib/dfeojm/util/command_line.rb +12 -17
- data/lib/dfeojm/version.rb +1 -1
- data/spec/dfeojm_spec.rb +39 -0
- metadata +42 -11
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.rvmrc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
ruby_string="ruby-1.9.2-p290"
|
4
|
+
gemset_name="dfeojm"
|
5
|
+
|
6
|
+
if rvm list strings | grep -q "${ruby_string}" ; then
|
7
|
+
|
8
|
+
# Load or create the specified environment
|
9
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
10
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
|
11
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}"
|
12
|
+
else
|
13
|
+
rvm --create "${ruby_string}@${gemset_name}"
|
14
|
+
fi
|
15
|
+
|
16
|
+
(
|
17
|
+
# Ensure that Bundler is installed, install it if it is not.
|
18
|
+
if ! command -v bundle ; then
|
19
|
+
gem install bundler
|
20
|
+
fi
|
21
|
+
|
22
|
+
# Bundle while redcing excess noise.
|
23
|
+
echo "Bundling in the background, may take time."
|
24
|
+
bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d' || echo "May require platform-specific packages."
|
25
|
+
)&
|
26
|
+
|
27
|
+
else
|
28
|
+
|
29
|
+
# Notify the user to install the desired interpreter before proceeding.
|
30
|
+
echo "${ruby_string} was not found, please run 'rvm install ${ruby_string}' and then cd back into the project directory."
|
31
|
+
|
32
|
+
fi
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dfeojm (0.0.1)
|
5
|
+
nokogiri
|
6
|
+
trollop
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.1.3)
|
12
|
+
nokogiri (1.5.0)
|
13
|
+
rake (0.9.2.2)
|
14
|
+
rspec (2.7.0)
|
15
|
+
rspec-core (~> 2.7.0)
|
16
|
+
rspec-expectations (~> 2.7.0)
|
17
|
+
rspec-mocks (~> 2.7.0)
|
18
|
+
rspec-core (2.7.1)
|
19
|
+
rspec-expectations (2.7.0)
|
20
|
+
diff-lcs (~> 1.1.2)
|
21
|
+
rspec-mocks (2.7.0)
|
22
|
+
trollop (1.16.2)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bundler (>= 1.0.0)
|
29
|
+
dfeojm!
|
30
|
+
rake (>= 0.8.3)
|
31
|
+
rspec (>= 2.7.0)
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
[](http://travis-ci.org/steakknife/dfeojm)
|
2
|
+
|
1
3
|
DownForEveryoneOrJustMe.com CLI and Ruby API
|
2
4
|
=============================
|
3
5
|
|
6
|
+
|
4
7
|
This is an unofficial gem and in no way connected with DownForEveryoneOrJustMe.com.
|
5
8
|
|
6
9
|
Setup
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require 'rubygems'
|
3
|
+
require 'dfeojm/version'
|
4
|
+
|
5
|
+
PROJECT = 'dfeojm'
|
6
|
+
VERSION = DFEOJM::VERSION
|
7
|
+
FULL_PROJECT = "#{PROJECT}-#{VERSION}"
|
8
|
+
|
9
|
+
desc 'Default: run specs.'
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
desc "build gem"
|
13
|
+
task :build do
|
14
|
+
system "gem build #{PROJECT}.gemspec"
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "push gem to ruby gems"
|
18
|
+
task :release => :build do
|
19
|
+
system "gem push #{FULL_PROJECT}.gem"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "install the gem locally"
|
23
|
+
task :local_install => :build do
|
24
|
+
system "gem install #{FULL_PROJECT}"
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "uninstall all of this gem locally"
|
28
|
+
task :local_uninstall do
|
29
|
+
system "gem uninstall -ax #{PROJECT}"
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "cleanup"
|
33
|
+
task :clean => :local_uninstall do
|
34
|
+
system "rm *.gem"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Rspec
|
38
|
+
#
|
39
|
+
require 'rspec/core/rake_task'
|
40
|
+
|
41
|
+
desc "Run specs"
|
42
|
+
task :spec => :local_install do
|
43
|
+
RSpec::Core::RakeTask.new do |t|
|
44
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
45
|
+
# Put spec opts in a file named .rspec in root
|
46
|
+
end
|
47
|
+
end
|
data/dfeojm.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dfeojm/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'dfeojm'
|
6
|
+
s.version = DFEOJM::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = 'Barry Allard (steakknife)'
|
9
|
+
s.email = 'barry@barryallard.name'
|
10
|
+
s.homepage = 'https://github.com/steakknife/dfeojm'
|
11
|
+
s.summary = 'Unofficial Ruby interface and command-line to DownForEveryoneOrJustMe.com'
|
12
|
+
s.description = 'See http://downforeveryoneorjustme.com'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.required_rubygems_version = '>= 1.3.6'
|
16
|
+
s.rubyforge_project = 'dfeojm'
|
17
|
+
|
18
|
+
s.add_dependency 'nokogiri'
|
19
|
+
s.add_dependency 'trollop'
|
20
|
+
s.add_development_dependency 'bundler', '>= 1.0.0'
|
21
|
+
s.add_development_dependency 'rspec', '>= 2.7.0'
|
22
|
+
s.add_development_dependency 'rake', '>= 0.8.3'
|
23
|
+
|
24
|
+
# Man files are required because they are ignored by git
|
25
|
+
s.files = `git ls-files`.split("\n")
|
26
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
27
|
+
s.require_paths = ['lib']
|
28
|
+
|
29
|
+
end
|
data/lib/dfeojm.rb
CHANGED
@@ -14,22 +14,34 @@ module DFEOJM
|
|
14
14
|
def initialize(site)
|
15
15
|
# Remove the protocol part
|
16
16
|
@site = site.gsub(/.*:\/\//, '')
|
17
|
-
check
|
18
17
|
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
result
|
19
|
+
def down?
|
20
|
+
! up?
|
21
|
+
end
|
22
|
+
|
23
|
+
def up?
|
24
|
+
_check
|
28
25
|
end
|
29
26
|
|
30
27
|
# Return a human-friendly representation.
|
31
28
|
def to_s()
|
32
|
-
"#{site} #{
|
29
|
+
"#{site} #{up? ? 'is up' : 'looks down'}"
|
30
|
+
end
|
31
|
+
private
|
32
|
+
|
33
|
+
def _check
|
34
|
+
if @result.nil?
|
35
|
+
_actual_check
|
36
|
+
end
|
37
|
+
@result
|
38
|
+
end
|
39
|
+
|
40
|
+
def _actual_check
|
41
|
+
@doc = Nokogiri::HTML(open('http://www.downforeveryoneorjustme.com/'+site))
|
42
|
+
@doc.css('div#container').each do |dom|
|
43
|
+
@result = ! dom.content.index('is up').nil?
|
44
|
+
end
|
33
45
|
end
|
34
46
|
end # class DFEOJM
|
35
47
|
end # module DFEOJM
|
@@ -6,28 +6,23 @@ module DFEOJM
|
|
6
6
|
module Util
|
7
7
|
class CommandLine
|
8
8
|
def exec
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
DownForEveryoneOrJustMe (tm) unofficial ruby utility #{::DFEOJM::VERSION} (c) 2011 Barry Allard
|
9
|
+
opts = Trollop::options do
|
10
|
+
version "DownForEveryoneOrJustMe (tm) unofficial ruby utility #{::DFEOJM::VERSION} (c) 2011 Barry Allard"
|
11
|
+
banner <<-EOS
|
12
|
+
DownForEveryoneOrJustMe (tm) unofficial ruby utility #{::DFEOJM::VERSION} (c) 2011 Barry Allard
|
14
13
|
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
Usage:
|
16
|
+
dfeojm hostname.com
|
18
17
|
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
EOS
|
20
|
+
end
|
21
|
+
Trollop::die "hostname must be present" if ARGV.empty? # show help screen
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
# puts e
|
28
|
-
# exit 1
|
29
|
-
raise e
|
30
|
-
end
|
23
|
+
app = DFEOJM.new ARGV[0]
|
24
|
+
puts app.to_s
|
25
|
+
exit 1 if app.down?
|
31
26
|
end # def exec
|
32
27
|
end # class CommandLine
|
33
28
|
end # module Util
|
data/lib/dfeojm/version.rb
CHANGED
data/spec/dfeojm_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'dfeojm'
|
2
|
+
|
3
|
+
describe DFEOJM do
|
4
|
+
it "provides usage information by default" do
|
5
|
+
output = `dfeojm 2>&1`
|
6
|
+
result = $?.exitstatus
|
7
|
+
|
8
|
+
output.should match /Error: hostname must be present/
|
9
|
+
output.should_not match /is up/
|
10
|
+
output.should_not match /looks down/
|
11
|
+
result.should_not be 0
|
12
|
+
end
|
13
|
+
|
14
|
+
it "provides version information" do
|
15
|
+
output = `dfeojm -v 2>/dev/null`
|
16
|
+
result = $?.exitstatus
|
17
|
+
|
18
|
+
output.should match /[0-9]+\.[0-9]+/
|
19
|
+
result.should be 0
|
20
|
+
end
|
21
|
+
|
22
|
+
it "shows that www.google.com should usually be up" do
|
23
|
+
output = `dfeojm www.google.com 2>/dev/null`
|
24
|
+
result = $?.exitstatus
|
25
|
+
|
26
|
+
output.should match /is up/
|
27
|
+
output.should_not match /looks down/
|
28
|
+
result.should be 0
|
29
|
+
end
|
30
|
+
|
31
|
+
it "shows that www.thiswillneverexist.com should usually be down" do
|
32
|
+
output = `dfeojm www.thiswillneverexist.com 2>/dev/null`
|
33
|
+
result = $?.exitstatus
|
34
|
+
|
35
|
+
output.should match /looks down/
|
36
|
+
output.should_not match /is up/
|
37
|
+
result.should_not be 0
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dfeojm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-19 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70133008588020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70133008588020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: trollop
|
27
|
-
requirement: &
|
27
|
+
requirement: &70133008587560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70133008587560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70133008587060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,29 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70133008587060
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &70133008586560 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.7.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70133008586560
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: &70133008586100 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.8.3
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70133008586100
|
47
69
|
description: See http://downforeveryoneorjustme.com
|
48
70
|
email: barry@barryallard.name
|
49
71
|
executables:
|
@@ -51,12 +73,21 @@ executables:
|
|
51
73
|
extensions: []
|
52
74
|
extra_rdoc_files: []
|
53
75
|
files:
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .rvmrc
|
79
|
+
- .travis.yml
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
58
82
|
- LICENSE
|
59
83
|
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/dfeojm
|
86
|
+
- dfeojm.gemspec
|
87
|
+
- lib/dfeojm.rb
|
88
|
+
- lib/dfeojm/util/command_line.rb
|
89
|
+
- lib/dfeojm/version.rb
|
90
|
+
- spec/dfeojm_spec.rb
|
60
91
|
homepage: https://github.com/steakknife/dfeojm
|
61
92
|
licenses:
|
62
93
|
- MIT
|