gesund 0.0.3 → 0.0.4

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: 6c31ddd62325ecea471dc6327c57dc78511045fe
4
+ data.tar.gz: 804cce6293fdac061676f97404d60c6e500c14a0
5
+ SHA512:
6
+ metadata.gz: 3889e58bb2ccf066b00b01edb88e2eba233a55359ae161e85004c58ccd94ecfca0192fad68d35fd970a3f4b4a44340e17bc0cbd24de96799efe10976b7a2cc27
7
+ data.tar.gz: 4a22688827c4a36b0e326d39a5b477f73c5928f6c0f79baa90f9951c05c27d19a3ffcd1af42c855d52bf01a6651601c93bc8ec4bb49bd8b1cbf95fbd97c72403
@@ -0,0 +1,3 @@
1
+ ruby/
2
+ bundler/
3
+ bin/
data/.bundle/config CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- BUNDLE_PATH: bundle
3
- BUNDLE_BIN: bundle/bin
2
+ BUNDLE_PATH: .bundle
3
+ BUNDLE_BIN: .bundle/bin
4
4
  BUNDLE_DISABLE_SHARED_GEMS: '1'
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  *.gem
2
2
  *.rbc
3
- /bundle
4
3
  .config
5
4
  .yardoc
6
5
  InstalledFiles
data/Gemfile.lock CHANGED
@@ -1,30 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gesund (0.0.3)
4
+ gesund (0.0.4)
5
5
  rack
6
6
  thor
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- diff-lcs (1.2.4)
12
- multi_json (1.7.2)
11
+ diff-lcs (1.2.5)
12
+ docile (1.1.5)
13
+ multi_json (1.10.1)
13
14
  rack (1.5.2)
14
- rake (10.0.4)
15
- rspec (2.13.0)
16
- rspec-core (~> 2.13.0)
17
- rspec-expectations (~> 2.13.0)
18
- rspec-mocks (~> 2.13.0)
19
- rspec-core (2.13.1)
20
- rspec-expectations (2.13.0)
21
- diff-lcs (>= 1.1.3, < 2.0)
22
- rspec-mocks (2.13.1)
23
- simplecov (0.7.1)
24
- multi_json (~> 1.0)
25
- simplecov-html (~> 0.7.1)
26
- simplecov-html (0.7.1)
27
- thor (0.18.1)
15
+ rake (10.3.2)
16
+ rspec (3.1.0)
17
+ rspec-core (~> 3.1.0)
18
+ rspec-expectations (~> 3.1.0)
19
+ rspec-mocks (~> 3.1.0)
20
+ rspec-core (3.1.2)
21
+ rspec-support (~> 3.1.0)
22
+ rspec-expectations (3.1.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.1.0)
25
+ rspec-mocks (3.1.0)
26
+ rspec-support (~> 3.1.0)
27
+ rspec-support (3.1.0)
28
+ simplecov (0.9.0)
29
+ docile (~> 1.1.0)
30
+ multi_json
31
+ simplecov-html (~> 0.8.0)
32
+ simplecov-html (0.8.0)
33
+ thor (0.19.1)
28
34
 
29
35
  PLATFORMS
30
36
  ruby
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/devops-israel/gesund.png)](https://travis-ci.org/devops-israel/gesund)
2
+
1
3
  # Gesund
2
4
 
3
5
  To have healthy servers, it is important to have an automated check that can tell you if something is wrong. Gesund for the rescue!
data/lib/gesund/cli.rb CHANGED
@@ -13,11 +13,21 @@ module Gesund
13
13
  Gesund::Output::Text.new(checks)
14
14
  end
15
15
 
16
+ # http://rubydoc.info/github/rack/rack/master/Rack/Server#initialize-instance_method
17
+ option :port, :type => :numeric, :aliases => [:'-p'], :default => 9998, :desc => 'the port to bind to'
18
+ option :host, :type => :string, :aliases => [:'-h'], :default => '0.0.0.0', :desc => 'the host address to bind to'
19
+ option :daemonize, :type => :boolean, :aliases => [:'-d'], :default => false, :desc => 'if true, the server will daemonize itself (fork, detach, etc)'
20
+ option :pid, :type => :string, :default => nil, :desc => 'path to write a pid file after daemonize'
21
+ option :accesslog, :type => :string, :default => nil, :desc => 'webrick acess log options'
22
+ option :debug, :type => :boolean, :default => false, :desc => 'turn on debug output'
23
+ option :warn, :type => :boolean, :default => true, :desc => 'turn on warnings'
16
24
  desc "http", "Starts a web server that answers to requests with results of checks from Gesundfile"
17
25
  def http
18
- gesundfile = File.expand_path(options[:gesundfile]) if options[:gesundfile]
19
- checks = Gesund::Dsl.evaluate(gesundfile)
20
- Gesund::Output::Rack.start(checks)
26
+ opts = {}.merge(options)
27
+ if gesundfile = opts.delete(:gesundfile)
28
+ checks = Gesund::Dsl.evaluate(File.expand_path(gesundfile))
29
+ end
30
+ Gesund::Output::Rack.start(checks, opts)
21
31
  end
22
32
 
23
33
  end
@@ -2,10 +2,13 @@ require "rack"
2
2
 
3
3
  module Gesund::Output
4
4
  class Rack
5
- def self.start(checks)
5
+ def self.start(checks, options={})
6
6
  app = self.new
7
7
  app.checks = checks
8
- ::Rack::Server.start app: app
8
+ # http://rubydoc.info/github/rack/rack/master/Rack/Server#initialize-instance_method
9
+ options[:Port] = options.delete 'port'
10
+ options[:Host] = options.delete 'host'
11
+ ::Rack::Server.start({ :app => app }.merge(options))
9
12
  end
10
13
 
11
14
  attr_accessor :checks
@@ -1,3 +1,3 @@
1
1
  module Gesund
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -4,31 +4,31 @@ describe "Gesund::Check module" do
4
4
  let(:dummy_check) { Class.new.extend Gesund::Check }
5
5
  let(:headers) { {"Content-Type" => "text/plain"} }
6
6
  it "has an accessor named success" do
7
- dummy_check.should respond_to :call
7
+ expect(dummy_check).to respond_to :call
8
8
  end
9
9
  it "has an accessor named message" do
10
- dummy_check.should respond_to :message
10
+ expect(dummy_check).to respond_to :message
11
11
  end
12
12
  it "returns status 200 on healthy checks" do
13
13
  dummy_check.success = true
14
14
  dummy_check.message = "something is healthy"
15
- dummy_check.call.should == [200, headers, ["something is healthy"]]
15
+ expect(dummy_check.call).to be == [200, headers, ["something is healthy"]]
16
16
  end
17
17
  it "returns status 500 on sick checks" do
18
18
  dummy_check.success = false
19
19
  dummy_check.message = "something is sick"
20
- dummy_check.call.should == [500, headers, ["something is sick"]]
20
+ expect(dummy_check.call).to be == [500, headers, ["something is sick"]]
21
21
  end
22
22
  it "returns status 500 on empty messages" do
23
23
  dummy_check.success = true
24
- dummy_check.call.should == [500, headers, ["Class is broken!"]]
24
+ expect(dummy_check.call).to be == [500, headers, ["Class is broken!"]]
25
25
  end
26
26
  it "fails when fail is called" do
27
27
  dummy_check.fail("booo!")
28
- dummy_check.call.should == [500, headers, ["booo!"]]
28
+ expect(dummy_check.call).to be == [500, headers, ["booo!"]]
29
29
  end
30
30
  it "passes when pass is called" do
31
31
  dummy_check.pass("yey!")
32
- dummy_check.call.should == [200, headers, ["yey!"]]
32
+ expect(dummy_check.call).to be == [200, headers, ["yey!"]]
33
33
  end
34
34
  end
@@ -2,15 +2,15 @@ require "spec_helper"
2
2
 
3
3
  describe Gesund::Checks::Directory do
4
4
  it "sets success to false when arg is not a directory" do
5
- File.stub(:directory?).and_return false
5
+ expect(File).to receive(:directory?) { false }
6
6
  chk = described_class.new("somedir")
7
- chk.success.should be_false
8
- chk.message.should match "Directory somedir is not a directory"
7
+ expect(chk.success).to equal(false)
8
+ expect(chk.message).to match "Directory somedir is not a directory"
9
9
  end
10
10
  it "sets success to true when arg is a directory" do
11
- File.stub(:directory?).and_return true
11
+ expect(File).to receive(:directory?) { true }
12
12
  chk = described_class.new("somedir")
13
- chk.success.should be_true
14
- chk.message.should match "Directory somedir is a directory"
13
+ expect(chk.success).to equal(true)
14
+ expect(chk.message).to match "Directory somedir is a directory"
15
15
  end
16
16
  end
@@ -3,13 +3,13 @@ require "spec_helper"
3
3
  describe Gesund::Checks::File do
4
4
  subject { Gesund::Checks::File.new('somefile') }
5
5
  it "sets success as true when file is a file" do
6
- File.stub(:file?).and_return true
7
- subject.success.should be_true
8
- subject.message.should match "File somefile is a file"
6
+ expect(File).to receive(:file?) { true }
7
+ expect(subject.success).to equal(true)
8
+ expect(subject.message).to match "File somefile is a file"
9
9
  end
10
10
  it "sets success to false when file is not a file" do
11
- File.stub(:file?).and_return false
12
- subject.success.should be_false
13
- subject.message.should match "File somefile is not a file"
11
+ expect(File).to receive(:file?) { false }
12
+ expect(subject.success).to equal(false)
13
+ expect(subject.message).to match "File somefile is not a file"
14
14
  end
15
15
  end
@@ -2,29 +2,29 @@ require "spec_helper"
2
2
 
3
3
  describe Gesund::Checks::Link do
4
4
  it "sets success to false when arg is not a symlink" do
5
- File.stub(:symlink?).and_return false
5
+ expect(File).to receive(:symlink?) { false }
6
6
  chk = described_class.new("somelink-xxx")
7
- chk.success.should be_false
8
- chk.message.should match "Symbolic link somelink-xxx is not a symlink"
7
+ expect(chk.success).to equal(false)
8
+ expect(chk.message).to match "Symbolic link somelink-xxx is not a symlink"
9
9
  end
10
10
  it "sets success to true when arg is a symlink" do
11
- File.stub(:symlink?).and_return true
11
+ expect(File).to receive(:symlink?) { true }
12
12
  chk = described_class.new("somelink-xxx")
13
- chk.success.should be_true
14
- chk.message.should match "Symbolic link somelink-xxx is a symlink"
13
+ expect(chk.success).to equal(true)
14
+ expect(chk.message).to match "Symbolic link somelink-xxx is a symlink"
15
15
  end
16
16
  it "sets success to false when arg does not target target" do
17
- File.stub(:symlink?).and_return true
18
- File.stub(:readlink).and_return "wrongtarget"
17
+ expect(File).to receive(:symlink?) { true }
18
+ expect(File).to receive(:readlink) { "wrongtarget" }
19
19
  chk = described_class.new("somelink-xxx", "xxx")
20
- chk.success.should be_false
21
- chk.message.should match "Symbolic link somelink-xxx is not targetting xxx"
20
+ expect(chk.success).to equal(false)
21
+ expect(chk.message).to match "Symbolic link somelink-xxx is not targetting xxx"
22
22
  end
23
23
  it "sets success to true when arg targets target" do
24
- File.stub(:symlink?).and_return true
25
- File.stub(:readlink).and_return "xxx"
24
+ expect(File).to receive(:symlink?) { true }
25
+ expect(File).to receive(:readlink) { "xxx" }
26
26
  chk = described_class.new("somelink-xxx", "xxx")
27
- chk.success.should be_true
28
- chk.message.should match "Symbolic link somelink-xxx is targetting xxx"
27
+ expect(chk.success).to equal(true)
28
+ expect(chk.message).to match "Symbolic link somelink-xxx is targetting xxx"
29
29
  end
30
30
  end
@@ -1,3 +1,3 @@
1
1
  describe Gesund::VERSION do
2
- it { should == "0.0.3" }
2
+ it { should == "0.0.4" }
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -11,10 +11,11 @@ SimpleCov.start do
11
11
  add_filter 'bundle'
12
12
  end
13
13
  RSpec.configure do |config|
14
- config.treat_symbols_as_metadata_keys_with_true_values = true
15
14
  config.run_all_when_everything_filtered = true
16
15
  config.filter_run :focus
17
16
 
17
+ config.raise_errors_for_deprecations!
18
+
18
19
  # Run specs in random order to surface order dependencies. If you find an
19
20
  # order dependency and want to debug it, you can fix the order by providing
20
21
  # the seed, which is printed after each run.
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gesund
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Evgeny Zislis
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-05 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,49 +27,43 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rack
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: thor
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Gesund is a simple health checker.
@@ -83,6 +74,7 @@ executables:
83
74
  extensions: []
84
75
  extra_rdoc_files: []
85
76
  files:
77
+ - .bundle/.gitignore
86
78
  - .bundle/config
87
79
  - .gitignore
88
80
  - .rspec
@@ -125,33 +117,26 @@ files:
125
117
  homepage: ''
126
118
  licenses:
127
119
  - MIT
120
+ metadata: {}
128
121
  post_install_message:
129
122
  rdoc_options: []
130
123
  require_paths:
131
124
  - lib
132
125
  required_ruby_version: !ruby/object:Gem::Requirement
133
- none: false
134
126
  requirements:
135
- - - ! '>='
127
+ - - '>='
136
128
  - !ruby/object:Gem::Version
137
129
  version: '0'
138
- segments:
139
- - 0
140
- hash: -987443717623063982
141
130
  required_rubygems_version: !ruby/object:Gem::Requirement
142
- none: false
143
131
  requirements:
144
- - - ! '>='
132
+ - - '>='
145
133
  - !ruby/object:Gem::Version
146
134
  version: '0'
147
- segments:
148
- - 0
149
- hash: -987443717623063982
150
135
  requirements: []
151
136
  rubyforge_project:
152
- rubygems_version: 1.8.25
137
+ rubygems_version: 2.0.14
153
138
  signing_key:
154
- specification_version: 3
139
+ specification_version: 4
155
140
  summary: Health checker for services and state.
156
141
  test_files:
157
142
  - spec/lib/gesund/check_runner_spec.rb