bernard 0.2.1 → 0.3.0

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: 5ee07b4eefaa3f54912b6b07688953013a6dba1e
4
- data.tar.gz: a49617d264746d926f6e04ccd10dcca88628413b
3
+ metadata.gz: ddba97c1717f871b71e0d8b206fa8a85e90896b2
4
+ data.tar.gz: ff3ed7b6f55f910966ed98348192031591382239
5
5
  SHA512:
6
- metadata.gz: 890cfcc5f68c802c1f6d5136ebe670465bd31bbda6c1572ecba3934d28c460bde8c6eece1fb99aeb9d8e6397152aaf3bbde728e7c4b09ae45ed5d962628fd329
7
- data.tar.gz: 379fc9fe38e16b142ecc6176d697141ce572bf632adf1eb1bfbd54c8ef06b9c001413d72ad585ab6527e6b1306b7dc9a54a07404a918b51339a7340731c59adb
6
+ metadata.gz: 69dca033e296b405b6cd3ce4c80fcc43bd04d7e4aabf3bd5f2e3fb90dc9c1c1bb6ade7138bba859dd5b93b8c648ae2fe981f974e55f4b72033da7a28efbd82a5
7
+ data.tar.gz: a10ef9b2bf6074a2428b2172fe5690b214212312e3a1ca5b8b882d46497a4aae8f09c51dc93190b8b23168b1c5f9eab11107dea6fab95ea1ac35358f030487c2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bernard (0.2.0)
4
+ bernard (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -43,10 +43,10 @@ PLATFORMS
43
43
 
44
44
  DEPENDENCIES
45
45
  bernard!
46
- pry (= 0.10.3)
47
- rake (= 11.1.2)
48
- rspec (= 3.4.0)
49
- webmock (= 1.24.2)
46
+ pry (~> 0.10)
47
+ rake (~> 11.1)
48
+ rspec (~> 3.4)
49
+ webmock (~> 1.24)
50
50
 
51
51
  BUNDLED WITH
52
52
  1.12.3
data/README.md CHANGED
@@ -53,6 +53,13 @@ Increment an event that has occurred by 1.
53
53
  client.tick('foo')
54
54
  ```
55
55
 
56
+ ### Count
57
+
58
+ Increment an event that has occurred by 1.
59
+ ```ruby
60
+ client.count('visitors', '10')
61
+ ```
62
+
56
63
  ### Gauge
57
64
 
58
65
  Update an event to a new value.
data/bernard.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'bernard/version'
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'bernard'
7
7
  gem.version = Bernard::VERSION
8
- gem.date = '2016-05-17'
8
+ gem.date = '2016-05-18'
9
9
  gem.summary = 'Sends event data to visualisation services'
10
10
  gem.description = 'Sends event data to visualisation services.'
11
11
  gem.authors = ['Tom Hipkin', 'Robert Lee-Cann']
@@ -1,9 +1,9 @@
1
1
  require 'bernard/connection'
2
+ require 'bernard/keen/methods'
2
3
 
3
4
  module Bernard
4
5
  module Keen
5
6
  class Client
6
-
7
7
  class << self
8
8
  attr_reader :config
9
9
 
@@ -21,6 +21,8 @@ module Bernard
21
21
  end
22
22
  end
23
23
 
24
+ include Bernard::Keen::Methods
25
+
24
26
  attr_reader :uri, :project_id, :write_key, :read_key
25
27
 
26
28
  def initialize(args = {})
@@ -61,33 +63,6 @@ module Bernard
61
63
  def read_key=(value)
62
64
  @read_key = value
63
65
  end
64
-
65
- def tick(event)
66
- write(:tick, type: event, count: 1)
67
- end
68
-
69
- def gauge(event, value)
70
- write(:gauge, type: event, value: Float(value))
71
- end
72
-
73
- def write(event, metadata)
74
-
75
- event = String(event).strip.downcase
76
- uri.path = "/3.0/projects/#{project_id}/events/#{event}"
77
-
78
- request = Net::HTTP::Post.new(uri.path)
79
- request['Authorization'] = write_key
80
- request['Content-Type'] = 'application/json'
81
- request.body = metadata.to_json
82
-
83
- begin
84
- connection = Bernard::Connection.new(uri).call
85
- response = connection.request(request)
86
- # puts "Bernards #{event} response was #{response.code}"
87
- rescue Timeout::Error
88
- return false
89
- end
90
- end
91
66
  end
92
67
  end
93
68
  end
@@ -0,0 +1,35 @@
1
+ module Bernard
2
+ module Keen
3
+ module Methods
4
+ def tick(event)
5
+ write(:tick, type: event, count: 1)
6
+ end
7
+
8
+ def count(event, value)
9
+ write(:count, type: event, count: Integer(value))
10
+ end
11
+
12
+ def gauge(event, value)
13
+ write(:gauge, type: event, value: Float(value))
14
+ end
15
+
16
+ def write(event, metadata)
17
+
18
+ event = String(event).strip.downcase
19
+ uri.path = "/3.0/projects/#{project_id}/events/#{event}"
20
+
21
+ request = Net::HTTP::Post.new(uri.path)
22
+ request['Authorization'] = write_key
23
+ request['Content-Type'] = 'application/json'
24
+ request.body = metadata.to_json
25
+
26
+ begin
27
+ connection = Bernard::Connection.new(uri).call
28
+ connection.request(request)
29
+ rescue Timeout::Error
30
+ return false
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Bernard
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bernard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Hipkin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-17 00:00:00.000000000 Z
12
+ date: 2016-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -91,6 +91,7 @@ files:
91
91
  - lib/bernard/exception.rb
92
92
  - lib/bernard/keen/.keep
93
93
  - lib/bernard/keen/client.rb
94
+ - lib/bernard/keen/methods.rb
94
95
  - lib/bernard/schema.rb
95
96
  - lib/bernard/version.rb
96
97
  homepage: https://github.com/dxw/bernard