statsmix 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/README.md +75 -0
  2. data/VERSION +1 -1
  3. data/lib/statsmix.rb +11 -1
  4. data/statsmix.gemspec +4 -4
  5. metadata +27 -27
  6. data/README.txt +0 -59
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ A Ruby gem for the StatsMix API - http://www.statsmix.com/developers
2
+
3
+ ## What is StatsMix?
4
+
5
+ StatsMix makes it easy to track, chart, and share application and business metrics. Use StatsMix to:
6
+
7
+ * Log every time a particular event happens (such as a user creating a new blog post)
8
+ * View a real-time chart of these application events in StatsMix's web UI
9
+ * Share the charts with users inside and outside your organization
10
+ * Create and share custom dashboards that aggregate multiple metrics together
11
+ * Example dashboard: http://www.statsmix.com/d/0e788d59208900e7e3bc
12
+ * Example embedded dashboard: http://www.statsmix.com/example-embedded
13
+
14
+ To get started, you'll need an API key for StatsMix. You can get a free developer account here: http://www.statsmix.com/try?plan=developer
15
+
16
+ Full gem documentation is at http://www.statsmix.com/developers/ruby_gem
17
+
18
+ ## Quick Start
19
+
20
+ Install the gem from the command line.
21
+
22
+ gem install statsmix
23
+
24
+ The basic pattern in your code:
25
+
26
+ require "statsmix"
27
+ StatsMix.api_key = "YOUR API KEY"
28
+ StatsMix.track(name_of_metric, value = 1, options = {})
29
+
30
+ Push a stat with the value 1 (default) to a metric called "My First Metric":
31
+
32
+ StatsMix.track("My First Metric")
33
+
34
+ Push the value 20:
35
+
36
+ StatsMix.track("My First Metric",20)
37
+
38
+ Add metadata via the `:meta` option in the options hash. Metadata is useful for adding granularity to your stats. This example tracks file uploads by file type:
39
+
40
+ StatsMix.track("File Uploads", 1, {:meta => {"file type" => "PDF"}})
41
+
42
+ If you need the ability to update a stat after the fact, you can pass in a unique identifier `ref_id` (scoped to that metric, so you can use the same `ref_id` across metrics). This example use's today's date, which is useful if you want to do intraday updates to a stat:
43
+
44
+ StatsMix.track("File Uploads", 1, {:ref_id => Time.now.strftime('%Y-%m-%d'), :meta => {"file type" => "PDF"}})
45
+
46
+ If you need to timestamp the stat for something other than now, pass in a UTC datetime called `:generated_at`:
47
+
48
+ StatsMix.track("File Uploads", 1, {:generated_at => 1.days.ago})
49
+
50
+ To turn off tracking in your development environment:
51
+
52
+ StatsMix.ignore = true
53
+
54
+ To redirect all stats in dev environment to a test metric:
55
+
56
+ StatsMix.test_metric_name = "My Test Metric"
57
+
58
+ ## More Documentation
59
+
60
+ The StatsMix gem supports all the methods documented at http://www.statsmix.com/developers/documentation
61
+
62
+ ## Contributing to statsmix
63
+
64
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
65
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
66
+ * Fork the project
67
+ * Start a feature/bugfix branch
68
+ * Commit and push until you are happy with your contribution
69
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
70
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
71
+
72
+
73
+ ### Copyright
74
+
75
+ Copyright (c) 2011 StatsMix, Inc. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
data/lib/statsmix.rb CHANGED
@@ -5,7 +5,7 @@ require 'json'
5
5
  class StatsMix
6
6
 
7
7
  BASE_URI = 'https://statsmix.com/api/v2/'
8
-
8
+ RootCA = '/etc/ssl/certs'
9
9
  GEM_VERSION = File.exist?('../VERSION') ? File.read('../VERSION') : ""
10
10
 
11
11
  # Track an event
@@ -263,10 +263,20 @@ class StatsMix
263
263
  if @api_key.nil?
264
264
  raise "API key not set. You must set it first with StatsMix.api_key = [your api key]"
265
265
  end
266
+
266
267
  # Resources available: stats, metrics, TODO: profiles
267
268
  @url = URI.parse(BASE_URI + resource)
268
269
  @connection = Net::HTTP.new(@url.host, @url.port)
269
270
  @connection.use_ssl = (@url.scheme == 'https')
271
+
272
+ if File.directory? RootCA
273
+ @connection.ca_path = RootCA
274
+ @connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
275
+ @connection.verify_depth = 5
276
+ else
277
+ @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
278
+ end
279
+
270
280
  @request = Hash.new
271
281
  @request["User-Agent"] = @user_agent
272
282
  @params = Hash.new
data/statsmix.gemspec CHANGED
@@ -5,23 +5,23 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{statsmix}
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tom Markiewicz", "Derek Scruggs"]
12
- s.date = %q{2011-07-06}
12
+ s.date = %q{2011-08-09}
13
13
  s.description = %q{A Ruby gem for the StatsMix API - http://www.statsmix.com/developers}
14
14
  s.email = ["tmarkiewicz@gmail.com", "me@derekscruggs.com"]
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.txt"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  "Gemfile",
22
22
  "Gemfile.lock",
23
23
  "LICENSE.txt",
24
- "README.txt",
24
+ "README.md",
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "lib/statsmix.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsmix
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Markiewicz
@@ -16,11 +16,14 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-06 00:00:00 -06:00
19
+ date: 2011-08-09 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ type: :development
24
+ prerelease: false
25
+ name: shoulda
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
27
  none: false
25
28
  requirements:
26
29
  - - ">="
@@ -29,12 +32,12 @@ dependencies:
29
32
  segments:
30
33
  - 0
31
34
  version: "0"
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
32
37
  type: :development
33
- name: shoulda
34
38
  prerelease: false
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ name: bundler
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
41
  none: false
39
42
  requirements:
40
43
  - - ~>
@@ -45,12 +48,12 @@ dependencies:
45
48
  - 0
46
49
  - 0
47
50
  version: 1.0.0
51
+ requirement: *id002
52
+ - !ruby/object:Gem::Dependency
48
53
  type: :development
49
- name: bundler
50
54
  prerelease: false
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- requirement: &id003 !ruby/object:Gem::Requirement
55
+ name: jeweler
56
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
57
  none: false
55
58
  requirements:
56
59
  - - ~>
@@ -61,12 +64,12 @@ dependencies:
61
64
  - 5
62
65
  - 1
63
66
  version: 1.5.1
67
+ requirement: *id003
68
+ - !ruby/object:Gem::Dependency
64
69
  type: :development
65
- name: jeweler
66
70
  prerelease: false
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- requirement: &id004 !ruby/object:Gem::Requirement
71
+ name: rcov
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
70
73
  none: false
71
74
  requirements:
72
75
  - - ">="
@@ -75,12 +78,12 @@ dependencies:
75
78
  segments:
76
79
  - 0
77
80
  version: "0"
81
+ requirement: *id004
82
+ - !ruby/object:Gem::Dependency
78
83
  type: :development
79
- name: rcov
80
84
  prerelease: false
81
- version_requirements: *id004
82
- - !ruby/object:Gem::Dependency
83
- requirement: &id005 !ruby/object:Gem::Requirement
85
+ name: json
86
+ version_requirements: &id005 !ruby/object:Gem::Requirement
84
87
  none: false
85
88
  requirements:
86
89
  - - ~>
@@ -91,10 +94,7 @@ dependencies:
91
94
  - 5
92
95
  - 1
93
96
  version: 1.5.1
94
- type: :development
95
- name: json
96
- prerelease: false
97
- version_requirements: *id005
97
+ requirement: *id005
98
98
  description: A Ruby gem for the StatsMix API - http://www.statsmix.com/developers
99
99
  email:
100
100
  - tmarkiewicz@gmail.com
@@ -105,13 +105,13 @@ extensions: []
105
105
 
106
106
  extra_rdoc_files:
107
107
  - LICENSE.txt
108
- - README.txt
108
+ - README.md
109
109
  files:
110
110
  - .document
111
111
  - Gemfile
112
112
  - Gemfile.lock
113
113
  - LICENSE.txt
114
- - README.txt
114
+ - README.md
115
115
  - Rakefile
116
116
  - VERSION
117
117
  - lib/statsmix.rb
data/README.txt DELETED
@@ -1,59 +0,0 @@
1
- A Ruby gem for the StatsMix API - http://www.statsmix.com/developers
2
-
3
- WARNING: This gem is undergoing rapid improvements. Please use caution and check for updates accordingly.
4
-
5
- StatsMix makes it easy to track, chart, and share application and business metrics.
6
-
7
- To get started, you'll need a API key for StatsMix. You can get a free developer account here: http://www.statsmix.com/try?plan=developer
8
-
9
- Full gem documentation is at http://www.statsmix.com/developers/ruby_gem
10
-
11
- == Quick Start ==
12
-
13
- #install the gem from the command line
14
- gem install statsmix
15
-
16
- #in your code
17
- require "statsmix"
18
- StatsMix.api_key = "YOUR API KEY"
19
-
20
- #push a stat with the value 1 (default) to a metric called "My First Metric"
21
- StatsMix.track("My First Metric")
22
-
23
- #push the value 20
24
- StatsMix.track("My First Metric",20)
25
-
26
- #add metadata - you can use this to add granularity to your chart via Chart Settings in StatsMix
27
- #this example tracks file uploads by file type
28
- StatsMix.track("File Uploads", 1, {:meta => {"file type" => "PDF"}})
29
-
30
- #if you need the ability to update a stat after the fact, you can pass in a unique identifier ref_id (scoped to that metric)
31
- StatsMix.track("File Uploads", 1, {:ref_id => "abc123", :meta => {"file type" => "PDF"}})
32
-
33
- #if you need to timestamp the stat for something other than now, pass in a UTC datetime called generated_at
34
- StatsMix.track("File Uploads", 1, {:generated_at => 1.days.ago })
35
-
36
- #to turn off tracking in your development environment
37
- StatsMix.ignore = true
38
-
39
- #to redirect all stats in dev environment to a test metric
40
- StatsMix.test_metric_name = "My Test Metric"
41
-
42
- == More Documentation ==
43
-
44
- The StatsMix gem supports all the methods documented at http://www.statsmix.com/developers/documentation
45
-
46
- == Contributing to statsmix
47
-
48
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
49
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
50
- * Fork the project
51
- * Start a feature/bugfix branch
52
- * Commit and push until you are happy with your contribution
53
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
54
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
55
-
56
-
57
- == Copyright
58
-
59
- Copyright (c) 2011 StatsMix, Inc. See LICENSE.txt for further details.