metric 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,10 @@ bundler_args: --binstubs
3
3
  rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
6
+ - 1.9.3
6
7
  - ree
7
8
 
8
- script: "bundle exec rspec spec"
9
+ script: "bundle exec rspec spec"
9
10
 
10
11
  notifications:
11
12
  recipients:
data/Gemfile CHANGED
@@ -1,9 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'ruby-debug', :platform => :ruby_18
4
- gem 'linecache19', :platform => :ruby_19
5
- gem 'ruby-debug19', :platform => :ruby_19
6
-
7
3
  group :test do
8
4
  gem 'webmock'
9
5
  end
@@ -1,4 +1,4 @@
1
- # Metric [![Build Status](http://travis-ci.org/bittersweet/metric.png)](http://travis-ci.org/bittersweet/metric)
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
 
@@ -23,21 +23,27 @@ module Metric
23
23
  url
24
24
  end
25
25
 
26
- # Uses a thread to perform the request
27
- # @note If this gem is used with Rails it will only track data in the production environment
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 defined?(Rails) && !Rails.env.production?
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]
@@ -1,3 +1,3 @@
1
1
  module Metric
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -1,6 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Metric::Configuration do
4
+ after do
5
+ reset_config
6
+ end
7
+
4
8
  it "uses configuration defaults" do
5
9
  Metric.configure do |config|
6
10
  config.api_key = "test"
@@ -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
@@ -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
@@ -1,10 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Metric do
4
- before do
5
- reset_config
6
- end
7
-
8
4
  it "passes through options to track" do
9
5
  Metric::Track.should_receive(:track).with("hits", {})
10
6
  Metric.track("hits")
@@ -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
- hash: 19
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
- date: 2011-09-08 00:00:00 +02:00
19
- default_executable:
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
- prerelease: false
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
- hash: 3
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
- requirement: &id002 !ruby/object:Gem::Requirement
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
- hash: 3
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
- requirement: &id003 !ruby/object:Gem::Requirement
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
- hash: 3
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
- requirement: &id004 !ruby/object:Gem::Requirement
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
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
75
55
  type: :development
76
- version_requirements: *id004
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
- hash: 3
120
- segments:
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
- hash: 3
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.6.2
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