app_monit 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dc9e44529d531ea68014aa8ae4a9e3db8b58606
4
- data.tar.gz: 604fec1a5f824061397732fdde64f78b6e699eed
3
+ metadata.gz: 82f03f0553ce25ef5c665b11b1f088cfee89031a
4
+ data.tar.gz: 091ef855fe35d74590549e46af2a7077e2ab6519
5
5
  SHA512:
6
- metadata.gz: 9171a668759d6fb693299ab8cc6c04f415e7ce8934bd0b35b36665005dd8e198a21f8790fa976fa6cd7f060a895f4b3bbf322089b4d2d2535943863ad24edf3e
7
- data.tar.gz: f8eb9f13c51202064f09b0166fde7da9c97c6c107ed581b4a77b903f16d15d9db56e90660ea023d9aef6a90a9b2f291e00cbaf7a4e98f59a6c68018fb667ab96
6
+ metadata.gz: 2fa67ecdc1fad1fa70b8c9f095978400535bf05fba7aa01c71d6ea8068bea02a8784783bcf5e2cae3a4e2f7cc2fdbadfa49bc8564c2ac4f3355ac951554999a6
7
+ data.tar.gz: 81305c18b8418db8df128784bb48ecb63eb32ff0144a6e32d03a9800f006c12e0360f2a6c6096bb467e7ce3f9848c7cdb624c8aa5b1f256ed78c7b3df3f7510f
@@ -1,7 +1,7 @@
1
1
  module AppMonit
2
2
  class Config
3
3
  class << self
4
- attr_writer :api_key, :env, :end_point, :fail_silent
4
+ attr_writer :api_key, :env, :end_point, :fail_silent, :enabled
5
5
 
6
6
  def api_key
7
7
  @api_key || raise(ApiKeyNotSetError.new("Please set your API key"))
@@ -18,6 +18,10 @@ module AppMonit
18
18
  def fail_silent
19
19
  @fail_silent || false
20
20
  end
21
+
22
+ def enabled?
23
+ @enabled.nil? ? env != "test" : @enabled
24
+ end
21
25
  end
22
26
  end
23
27
  end
@@ -13,6 +13,7 @@ module AppMonit
13
13
  end
14
14
 
15
15
  def self.create!(name, data_hash = {})
16
+ return false unless AppMonit::Config.enabled?
16
17
  created_at = data_hash.delete(:created_at) || Time.now.utc
17
18
 
18
19
  message = { created_at: created_at, name: name, payload: data_hash }
@@ -1,3 +1,3 @@
1
1
  module AppMonit
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -8,6 +8,7 @@ describe AppMonit::Event do
8
8
  AppMonit::Config.api_key = 'MYAPIKEY'
9
9
  AppMonit::Config.end_point = 'http://api.appmon.it'
10
10
  AppMonit::Config.env = nil
11
+ AppMonit::Config.enabled = true
11
12
 
12
13
  stub_request(:post, /.*/)
13
14
  end
@@ -54,6 +55,20 @@ describe AppMonit::Event do
54
55
  end
55
56
 
56
57
  describe '#create!' do
58
+ it 'only makes request if enabled' do
59
+ AppMonit::Config.enabled = false
60
+
61
+ @mock = MiniTest::Mock.new
62
+ @mock.expect(:post, true, ['', {}])
63
+
64
+ subject.stub(:client, @mock) do
65
+ subject.create!('test', {})
66
+ assert_raises(MockExpectationError, "post should not be called") do
67
+ @mock.verify
68
+ end
69
+ end
70
+ end
71
+
57
72
  it 'sets a created at if not given' do
58
73
  @mock = MiniTest::Mock.new
59
74
  @mock.expect(:post, true, ['/v1/events', { created_at: Time.at(0).utc, name: 'test', payload: {} }])
@@ -67,12 +82,12 @@ describe AppMonit::Event do
67
82
  end
68
83
 
69
84
  it 'sets calls post on http with the correct params' do
70
- time = Time.now
85
+ time = Time.now
71
86
  @mock = MiniTest::Mock.new
72
- @mock.expect(:post, true, ['/v1/events', { created_at: time.utc, name: 'test', payload: {test: 'test'} }])
87
+ @mock.expect(:post, true, ['/v1/events', { created_at: time.utc, name: 'test', payload: { test: 'test' } }])
73
88
 
74
89
  subject.stub(:client, @mock) do
75
- subject.create!('test', {created_at: time, test: 'test'})
90
+ subject.create!('test', { created_at: time, test: 'test' })
76
91
  @mock.verify
77
92
  end
78
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_monit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Redmar Kerkhoff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-18 00:00:00.000000000 Z
12
+ date: 2014-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler