metric 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -1
- data/Gemfile +0 -4
- data/README.markdown +1 -1
- data/lib/metric/track.rb +11 -5
- data/lib/metric/version.rb +1 -1
- data/spec/metric/configuration_spec.rb +4 -0
- data/spec/metric/receive_spec.rb +0 -7
- data/spec/metric/track_spec.rb +1 -4
- data/spec/metric_spec.rb +0 -4
- data/spec/spec_helper.rb +4 -1
- metadata +53 -85
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Metric [![Build Status](
|
1
|
+
# Metric [![Build Status](https://secure.travis-ci.org/bittersweet/metric.png)](http://travis-ci.org/bittersweet/metric)
|
2
2
|
|
3
3
|
Track simple metrics via [metric.io](metric.io).
|
4
4
|
|
data/lib/metric/track.rb
CHANGED
@@ -23,21 +23,27 @@ module Metric
|
|
23
23
|
url
|
24
24
|
end
|
25
25
|
|
26
|
-
#
|
27
|
-
# @note
|
26
|
+
# Track the metric
|
27
|
+
# @note curl is called in a seperate thread so this won't block execution
|
28
28
|
#
|
29
29
|
# @param [String, Hash]
|
30
30
|
# @return [nil]
|
31
31
|
def self.track(metric, options = {})
|
32
|
-
return if
|
33
|
-
return if options[:amount] && options[:amount] == 0
|
34
|
-
|
32
|
+
return if quit_early?(options)
|
35
33
|
url = compose(metric, options)
|
36
34
|
Thread.new do
|
37
35
|
`curl "#{url}" 2>&1 ; `
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
39
|
+
# Check if Rails or Rack env is production, or amount is 0
|
40
|
+
def self.quit_early?(options)
|
41
|
+
return true if defined?(Rails) && !Rails.env.production?
|
42
|
+
return true if ENV['RACK_ENV'] && ENV['RACK_ENV'] != "production"
|
43
|
+
return true if options[:amount] && options[:amount] == 0
|
44
|
+
false
|
45
|
+
end
|
46
|
+
|
41
47
|
# CGI escape the metric name so spaces and characters are allowed
|
42
48
|
#
|
43
49
|
# @param [String]
|
data/lib/metric/version.rb
CHANGED
data/spec/metric/receive_spec.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Metric::Receive do
|
4
|
-
before do
|
5
|
-
reset_config
|
6
|
-
Metric.configure do |config|
|
7
|
-
config.secret_key = "1234"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
4
|
it "generates correct hash via secret_token" do
|
12
5
|
Metric::Receive.generate_token("hits").should == "c6daa87bcf8bf7cb4d1c74d872793e5e"
|
13
6
|
end
|
data/spec/metric/track_spec.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Metric::Track do
|
4
|
-
before do
|
5
|
-
reset_config
|
6
|
-
end
|
7
|
-
|
8
4
|
it "composes the request url" do
|
9
5
|
Metric::Track.compose("hits").should == "http://api.metric.io/track?api_key=spec&metric=hits"
|
10
6
|
end
|
11
7
|
|
12
8
|
it "gets correct url when tracking" do
|
9
|
+
Metric::Track.should_receive(:quit_early?).and_return(false)
|
13
10
|
Metric::Track.should_receive(:compose).with("hits", {})
|
14
11
|
Metric::Track.track("hits")
|
15
12
|
end
|
data/spec/metric_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
require File.expand_path('../../lib/metric', __FILE__)
|
2
|
-
require 'ruby-debug'
|
3
2
|
require 'webmock/rspec'
|
4
3
|
|
5
4
|
def reset_config
|
6
5
|
Metric.configuration = nil
|
7
6
|
Metric.configure do |config|
|
8
7
|
config.api_key = "spec"
|
8
|
+
config.secret_key = "1234"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.before(:all) { reset_config }
|
14
|
+
end
|
metadata
CHANGED
@@ -1,89 +1,67 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: metric
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 6
|
10
|
-
version: 0.0.6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Mark Mulder
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: faraday
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2152308620 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: multi_json
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *2152308620
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: multi_json
|
27
|
+
requirement: &2161467860 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
47
33
|
type: :runtime
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rspec
|
51
34
|
prerelease: false
|
52
|
-
|
35
|
+
version_requirements: *2161467860
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &2161467000 !ruby/object:Gem::Requirement
|
53
39
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
61
44
|
type: :development
|
62
|
-
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: webmock
|
65
45
|
prerelease: false
|
66
|
-
|
46
|
+
version_requirements: *2161467000
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: webmock
|
49
|
+
requirement: &2161465040 !ruby/object:Gem::Requirement
|
67
50
|
none: false
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
75
55
|
type: :development
|
76
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2161465040
|
77
58
|
description: Track metrics via metric.io
|
78
|
-
email:
|
59
|
+
email:
|
79
60
|
- markmulder@gmail.com
|
80
61
|
executables: []
|
81
|
-
|
82
62
|
extensions: []
|
83
|
-
|
84
63
|
extra_rdoc_files: []
|
85
|
-
|
86
|
-
files:
|
64
|
+
files:
|
87
65
|
- .gitignore
|
88
66
|
- .rspec
|
89
67
|
- .travis.yml
|
@@ -102,41 +80,31 @@ files:
|
|
102
80
|
- spec/metric/track_spec.rb
|
103
81
|
- spec/metric_spec.rb
|
104
82
|
- spec/spec_helper.rb
|
105
|
-
has_rdoc: true
|
106
83
|
homepage: http://github.com/bittersweet/metric
|
107
84
|
licenses: []
|
108
|
-
|
109
85
|
post_install_message:
|
110
86
|
rdoc_options: []
|
111
|
-
|
112
|
-
require_paths:
|
87
|
+
require_paths:
|
113
88
|
- lib
|
114
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
90
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
|
120
|
-
|
121
|
-
- 0
|
122
|
-
version: "0"
|
123
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
96
|
none: false
|
125
|
-
requirements:
|
126
|
-
- -
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
version: "0"
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
132
101
|
requirements: []
|
133
|
-
|
134
102
|
rubyforge_project:
|
135
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.8.10
|
136
104
|
signing_key:
|
137
105
|
specification_version: 3
|
138
106
|
summary: Companion gem to the metric.io site to track metrics
|
139
|
-
test_files:
|
107
|
+
test_files:
|
140
108
|
- spec/metric/configuration_spec.rb
|
141
109
|
- spec/metric/receive_spec.rb
|
142
110
|
- spec/metric/track_spec.rb
|