fuey_client 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33f9b817ea660d01a4c8c659a187296deb9360ab
4
+ data.tar.gz: af9e710efc90e273351c63b2ef4c624677d3e77d
5
+ SHA512:
6
+ metadata.gz: 33c7bba5d06092ef1fa9327d14f0b8fcaab2221d0a9218c01e77378acef87ac3f4bc3811a8d6ddc54363d391173cfd03068810d105e5709375056cdedbfbf319
7
+ data.tar.gz: ed572129688e23cb0def1f6c930992085eb720d1776dc2c3aa2076d79bc25bd2318cb9ddcc68fb1723b78b16ddcae0523cc0d2670e2fd3c694517db61694f766
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ log
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.rvmrc ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bash
2
+
3
+ #
4
+ # Based on the example from: http://rvm.beginrescueend.com/workflow/rvmrc/
5
+ #
6
+
7
+ ruby_string="ruby-2.0.0-p247"
8
+ gemset_name="fuey_client"
9
+
10
+ if rvm list strings | grep -q "${ruby_string}" ; then
11
+
12
+ # Load or create the specified environment
13
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
14
+ && -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
15
+ \. "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}"
16
+ else
17
+ rvm --create "${ruby_string}@${gemset_name}"
18
+ fi
19
+
20
+ # Ensure that Bundler is installed, install it if it is not.
21
+ if ! command -v bundle ; then
22
+ echo "Installing bundler"
23
+ gem install bundler
24
+ fi
25
+
26
+ # Bundle while reducing excess noise.
27
+ echo "Making sure bundle is up-to-date..."
28
+ bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
29
+
30
+ else
31
+
32
+ # Notify the user to install the desired interpreter before proceeding.
33
+ echo "${ruby_string} was not found, please run 'rvm install ${ruby_string}' and then cd back into the project directory."
34
+
35
+ fi
data/.travis-ci.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0.0"
4
+ - "1.9.3"
5
+ script:
6
+ - rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fuey_client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Matt Snyder
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # FueyClient
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fuey_client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fuey_client
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :spec
4
+
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new
data/bin/fuey ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fuey_client'
3
+
4
+ Fuey::Client.new(ARGV[0]).run
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: "My app server"
3
+ logfile: /var/log/fuey.log
4
+ inspections:
5
+ pings:
6
+ - ['Google DNS', '8.8.8.8']
7
+ - ['Localhost', '0.0.0.0']
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fuey_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fuey_client"
8
+ spec.version = FueyClient::VERSION
9
+ spec.authors = ["Matt Snyder"]
10
+ spec.email = ["snyder2112@me.com"]
11
+ spec.description = %q{Client for inspecting server state and reports it back to Fuey}
12
+ spec.summary = %q{Client for inspecting server state and reports it back to Fuey. Requires the Fuey web app to have any value.}
13
+ spec.homepage = "http://github.com/b2b2dot0/fuey_client"
14
+ spec.licenses = ["MIT", "GPL-2"]
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.default_executable = "fuey"
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "configurethis", ">= 1.0.4"
23
+ spec.add_dependency "net-ping", "~> 1.6"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec-given", ">= 3.0.0"
28
+ end
@@ -0,0 +1,6 @@
1
+ require "fuey_client/version"
2
+ require "fuey_client/fuey/client"
3
+
4
+ module FueyClient
5
+
6
+ end
@@ -0,0 +1,28 @@
1
+ require "fuey_client/fuey/log"
2
+ require "fuey_client/fuey/config"
3
+ require "fuey_client/fuey/inspections"
4
+ require "net/ping"
5
+
6
+ module Fuey
7
+ class Client
8
+ def initialize(path_to_config_dir="")
9
+ Configurethis.root_path = path_to_config_dir
10
+ end
11
+
12
+ def run
13
+ Config.inspections.pings.map{|name, host| Inspections::Ping.new(name, host) }.each do |ping|
14
+ ping.execute
15
+ end
16
+
17
+ 0
18
+ rescue => caught
19
+ if (caught.message =~ /is not configured/)
20
+ Log.write "Nothing configured."
21
+ return 0
22
+ else
23
+ Log.write caught.message
24
+ return 1
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ require 'configurethis'
2
+
3
+ module Fuey
4
+ class Config
5
+ extend Configurethis
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require "fuey_client/fuey/inspections/ping"
@@ -0,0 +1,18 @@
1
+ require 'net/ping'
2
+
3
+ module Fuey
4
+ module Inspections
5
+ class Ping
6
+ def initialize(name, host)
7
+ @host = host
8
+ @name = name
9
+ end
10
+
11
+ def execute
12
+ result = Net::Ping::External.new(@host).ping
13
+ Log.write "[#{@name}] Pinging #{@host} #{result ? 'failed' : 'succeeded'}."
14
+ result
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ require "fuey_client/fuey/config"
2
+ require 'logger'
3
+
4
+ module Fuey
5
+ class Log
6
+ def self.write(message)
7
+ logger.info "[#{Config.title}] #{message}"
8
+ end
9
+
10
+ def self.logger
11
+ @@logger ||= Logger.new Config.logfile, 'daily'
12
+ end
13
+ private_class_method :logger
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module FueyClient
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ describe Fuey::Client do
4
+
5
+ describe "#initialize" do
6
+ context "passing a configuration path" do
7
+ Given { Configurethis.should_receive(:root_path=).with('path/to/dir') }
8
+ When (:result) { Fuey::Client.new 'path/to/dir' }
9
+ Then { expect( result ).to be_a(Fuey::Client) }
10
+ end
11
+ end
12
+
13
+ describe "#run" do
14
+ after(:each) { Fuey::Config.reload_configuration }
15
+
16
+ context "when nothing is configured" do
17
+ Given { Fuey::Log.should_receive(:write).with("Nothing configured.") }
18
+ Given { Fuey::Config.test_with(no_inspections) }
19
+ When (:result) { Fuey::Client.new.run }
20
+ Then { expect( result ).to eql(0) }
21
+ end
22
+
23
+ context "when one ping is configured" do
24
+ Given { Fuey::Config.test_with(one_ping) }
25
+ Given (:mock_ping) { double Fuey::Inspections::Ping }
26
+ Given { mock_ping.should_receive(:execute).and_return true }
27
+ Given { Fuey::Inspections::Ping.stub(:new).with("test-server", "0.0.0.1").and_return mock_ping }
28
+ When (:result) { Fuey::Client.new.run }
29
+ Then { expect( result ).to eql(0) }
30
+ end
31
+
32
+ context "when two pings are configured" do
33
+ Given { Fuey::Config.test_with(two_pings) }
34
+ Given (:mock_ping) { double Fuey::Inspections::Ping }
35
+ Given { mock_ping.should_receive(:execute).twice.and_return true }
36
+ Given { Fuey::Inspections::Ping.stub(:new).twice.and_return mock_ping }
37
+ When (:result) { Fuey::Client.new.run }
38
+ Then { expect( result ).to eql(0) }
39
+ end
40
+
41
+ context "and there is a configuration error" do
42
+ Given { Fuey::Log.should_receive(:write).with("crap") }
43
+ Given { Fuey::Config.stub(:inspections).and_raise(RuntimeError, "crap") }
44
+ When (:result) { Fuey::Client.new.run }
45
+ Then { expect( result ).to eql(1) }
46
+ end
47
+ end
48
+
49
+ def no_inspections
50
+ {
51
+ "inspections" => {}
52
+ }
53
+ end
54
+
55
+ def one_ping
56
+ {
57
+ "inspections" => {
58
+ "pings" => [
59
+ ['test-server', '0.0.0.1']
60
+ ]
61
+ }
62
+ }
63
+ end
64
+
65
+ def two_pings
66
+ {
67
+ "inspections" => {
68
+ "pings" => [
69
+ ['test-server', '0.0.0.1'],
70
+ ['vpn-tunnel', '5.5.5.5']
71
+ ]
72
+ }
73
+ }
74
+ end
75
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fuey::Inspections::Ping do
4
+
5
+ describe "#execute" do
6
+ context "when the ping succeeds" do
7
+ Given { Fuey::Log.should_receive(:write).with("[some-server] Pinging 172.0.0.1 failed.") }
8
+ Given { Net::Ping::External.stub(:new).with("172.0.0.1").and_return double("ping", :ping => true) }
9
+ When (:result){ Fuey::Inspections::Ping.new('some-server', '172.0.0.1').execute }
10
+ Then { expect( result ).to eql(true) }
11
+ end
12
+
13
+ context "when the ping fails" do
14
+ Given { Fuey::Log.should_receive(:write).with("[some-server] Pinging 172.0.0.1 succeeded.") }
15
+ Given { Net::Ping::External.stub(:new).with("172.0.0.1").and_return double("ping", :ping => false) }
16
+ When (:result){ Fuey::Inspections::Ping.new('some-server', '172.0.0.1').execute }
17
+ Then { expect( result ).to eql(false) }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require "fuey_client"
9
+ require "rspec/given"
10
+
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuey_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Snyder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: configurethis
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: net-ping
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-given
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ description: Client for inspecting server state and reports it back to Fuey
84
+ email:
85
+ - snyder2112@me.com
86
+ executables:
87
+ - fuey
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - .rvmrc
94
+ - .travis-ci.yml
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/fuey
100
+ - config_example/fuey/config.yml
101
+ - fuey_client.gemspec
102
+ - lib/fuey_client.rb
103
+ - lib/fuey_client/fuey/client.rb
104
+ - lib/fuey_client/fuey/config.rb
105
+ - lib/fuey_client/fuey/inspections.rb
106
+ - lib/fuey_client/fuey/inspections/ping.rb
107
+ - lib/fuey_client/fuey/log.rb
108
+ - lib/fuey_client/version.rb
109
+ - spec/fuey_client/fuey/client_spec.rb
110
+ - spec/fuey_client/fuey/inspections/ping_spec.rb
111
+ - spec/spec_helper.rb
112
+ homepage: http://github.com/b2b2dot0/fuey_client
113
+ licenses:
114
+ - MIT
115
+ - GPL-2
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.0.6
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Client for inspecting server state and reports it back to Fuey. Requires
137
+ the Fuey web app to have any value.
138
+ test_files:
139
+ - spec/fuey_client/fuey/client_spec.rb
140
+ - spec/fuey_client/fuey/inspections/ping_spec.rb
141
+ - spec/spec_helper.rb