delayed_kiss 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -2,5 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in delayed_kiss.gemspec
4
4
  gemspec
5
+ gem 'rake', '~> 0.9.2.2'
5
6
  gem 'rspec', '2.7.0'
6
- gem 'mocha', '0.10.0'
7
+ gem 'mocha', '0.10.0'
@@ -1,3 +1,5 @@
1
+ !https://secure.travis-ci.org/ddeyoung/delayed_kiss.png?branch=master(Build Status)!:http://travis-ci.org/ddeyoung/delayed_kiss
2
+
1
3
  h1. Delayed Kiss
2
4
 
3
5
  A simple interface for the KISSmetrics API that plays nicely with Delayed Job and Heroku.
@@ -45,6 +47,8 @@ h3. In Version 0.0.1
45
47
  end
46
48
  end</pre>
47
49
 
50
+ Follow the instructions for setting up Delayed Job: https://github.com/collectiveidea/delayed_job
51
+
48
52
  h2. Usage
49
53
 
50
54
  Start recording events anywhere in your application: <pre> DelayedKiss.alias(anonymous_user, user.km_id)
@@ -4,15 +4,17 @@ require 'delayed_kiss/railtie' if defined?(Rails)
4
4
  require 'httparty'
5
5
 
6
6
  module DelayedKiss
7
+ include HTTParty
8
+
7
9
  mattr_accessor :key
8
10
  @@key = nil
9
-
11
+
10
12
  mattr_accessor :whiny_config
11
13
  @@whiny_config = false
12
-
14
+
13
15
  mattr_accessor :config_file
14
16
  @@config_file = "config/delayed_kiss.yml"
15
-
17
+
16
18
  def self.configure
17
19
  yield self
18
20
  end
@@ -21,45 +23,45 @@ module DelayedKiss
21
23
  self.verify_configuration
22
24
  raise ArgumentError.new("id can't be blank") if id.blank?
23
25
  raise ArgumentError.new("event can't be blank") if event.blank?
24
-
26
+
25
27
  query_params.merge!({
26
28
  '_n' => event,
27
29
  '_p' => id,
28
30
  '_t' => Time.now.to_i.to_s,
29
31
  '_k' => @@key
30
32
  })
31
- HTTParty.delay.get('https://trk.kissmetrics.com/e?' + query_params.to_param) unless @@key.blank?
33
+ self.delay.get('https://trk.kissmetrics.com/e?' + query_params.to_param) unless @@key.blank?
32
34
  end
33
35
 
34
36
  def self.alias(alias_from, alias_to)
35
37
  self.verify_configuration
36
38
  raise ArgumentError.new("you must specify both a from a to value") if alias_from.blank? || alias_to.blank?
37
-
39
+
38
40
  query_params = {
39
41
  '_n' => alias_to,
40
42
  '_p' => alias_from,
41
43
  '_t' => Time.now.to_i.to_s,
42
44
  '_k' => @@key
43
45
  }
44
- HTTParty.delay.get('https://trk.kissmetrics.com/a?' + query_params.to_param) unless @@key.blank?
46
+ self.delay.get('https://trk.kissmetrics.com/a?' + query_params.to_param) unless @@key.blank?
45
47
  end
46
48
 
47
49
  def self.set(id, query_params)
48
50
  self.verify_configuration
49
51
  raise ArgumentError.new("id can't be blank") if !id || id.blank?
50
52
  return if query_params.blank? # don't do anything if we're not setting any values on the identity
51
-
53
+
52
54
  query_params.merge!({
53
55
  '_p' => id,
54
56
  '_t' => Time.now.to_i.to_s,
55
57
  '_k' => @@key
56
58
  })
57
- HTTParty.delay.get('https://trk.kissmetrics.com/s?' + query_params.to_param) unless @@key.blank?
59
+ self.delay.get('https://trk.kissmetrics.com/s?' + query_params.to_param) unless @@key.blank?
58
60
  end
59
-
61
+
60
62
  def self.verify_configuration
61
63
  raise DelayedKiss::ConfigurationError if @@whiny_config && @@key.blank?
62
64
  end
63
-
65
+
64
66
  class ConfigurationError < StandardError; end
65
67
  end
@@ -1,3 +1,3 @@
1
1
  module DelayedKiss
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -4,143 +4,143 @@ describe DelayedKiss do
4
4
  before(:each) do
5
5
  DelayedKiss.cache_config
6
6
  end
7
-
7
+
8
8
  after(:each) do
9
9
  DelayedKiss.reset_config
10
10
  end
11
-
11
+
12
12
  describe :configure do
13
13
  it "should configure the key" do
14
14
  test_key = "youraikeyvalue"
15
15
  DelayedKiss.configure do |config|
16
16
  config.key = test_key
17
17
  end
18
-
18
+
19
19
  DelayedKiss.key.should == test_key
20
20
  end
21
21
  end
22
-
22
+
23
23
  describe :record do
24
24
  it "should send a request to the KISSmetrics API when valid parameters are supplied" do
25
- HTTParty.expects(:get).once.returns(true)
25
+ DelayedKiss.expects(:get).once.returns(true)
26
26
  DelayedKiss.record("identity", "event")
27
27
  end
28
-
28
+
29
29
  it "should raise an error without an identity" do
30
- HTTParty.expects(:get).never
30
+ DelayedKiss.expects(:get).never
31
31
  expect { DelayedKiss.record(nil, "event") }.to raise_error(ArgumentError)
32
32
  end
33
-
33
+
34
34
  it "should raise an error without an event" do
35
35
  expect { DelayedKiss.record("identity", nil) }.to raise_error(ArgumentError)
36
36
  end
37
-
37
+
38
38
  it "should send a request to the KISSmetrics API with custom properties in the URL's query string" do
39
- HTTParty.expects(:get).with(regexp_matches(/type=crazy/)).returns(true)
39
+ DelayedKiss.expects(:get).with(regexp_matches(/type=crazy/)).returns(true)
40
40
  DelayedKiss.record("identity", "event", {:type => "crazy"})
41
41
  end
42
-
42
+
43
43
  it "should raise an error if the key is not configured and the whiny config is turned on" do
44
44
  DelayedKiss.key = nil
45
45
  DelayedKiss.whiny_config = true
46
46
  expect { DelayedKiss.record("identity", "event") }.to raise_error(DelayedKiss::ConfigurationError)
47
47
  end
48
-
48
+
49
49
  it "should not raise an error if the key is not configured and the whiny config is turned off" do
50
50
  DelayedKiss.whiny_config = false
51
51
  expect { DelayedKiss.record("identity", "event") }.to_not raise_error(DelayedKiss::ConfigurationError)
52
52
  end
53
-
53
+
54
54
  it "should not send a request to the KISSmetrics API if the API key is blank and the whiny config is turned off" do
55
- HTTParty.expects(:get).never
56
-
55
+ DelayedKiss.expects(:get).never
56
+
57
57
  DelayedKiss.key = nil
58
58
  DelayedKiss.whiny_config = false
59
59
  DelayedKiss.record("identity", "event")
60
60
  end
61
61
  end
62
-
62
+
63
63
  describe :alias do
64
64
  it "should send a request to the KISSmetrics API when valid parameters are supplied" do
65
- HTTParty.expects(:get).once.returns(true)
65
+ DelayedKiss.expects(:get).once.returns(true)
66
66
  DelayedKiss.alias("oldname", "newname")
67
67
  end
68
-
68
+
69
69
  it "should include the from alias in the query string" do
70
- HTTParty.expects(:get).with(regexp_matches(/_p=oldname/)).returns(true)
70
+ DelayedKiss.expects(:get).with(regexp_matches(/_p=oldname/)).returns(true)
71
71
  DelayedKiss.alias("oldname", "newname")
72
72
  end
73
-
73
+
74
74
  it "should include the to alias in the query string" do
75
- HTTParty.expects(:get).with(regexp_matches(/_n=newname/)).returns(true)
75
+ DelayedKiss.expects(:get).with(regexp_matches(/_n=newname/)).returns(true)
76
76
  DelayedKiss.alias("oldname", "newname")
77
77
  end
78
-
78
+
79
79
  it "should raise an error without a from alias" do
80
80
  expect { DelayedKiss.alias(nil, "newname") }.to raise_error(ArgumentError)
81
81
  end
82
-
82
+
83
83
  it "should raise an error without a to alias" do
84
84
  expect { DelayedKiss.alias("oldname", nil) }.to raise_error(ArgumentError)
85
85
  end
86
-
86
+
87
87
  it "should raise an error if the key is not configured and the whiny config is turned on" do
88
88
  DelayedKiss.key = nil
89
89
  DelayedKiss.whiny_config = true
90
90
  expect { DelayedKiss.alias("oldname", "newname") }.to raise_error(DelayedKiss::ConfigurationError)
91
91
  end
92
-
92
+
93
93
  it "should not raise an error if the key is not configured and the whiny config is turned off" do
94
94
  DelayedKiss.whiny_config = false
95
95
  expect { DelayedKiss.alias("oldname", "newname") }.to_not raise_error(DelayedKiss::ConfigurationError)
96
96
  end
97
-
97
+
98
98
  it "should not send a request to the KISSmetrics API if the API key is blank and the whiny config is turned off" do
99
- HTTParty.expects(:get).never
100
-
99
+ DelayedKiss.expects(:get).never
100
+
101
101
  DelayedKiss.key = nil
102
102
  DelayedKiss.whiny_config = false
103
103
  DelayedKiss.alias("oldname", "newname")
104
104
  end
105
105
  end
106
-
106
+
107
107
  describe :set do
108
108
  it "should send a request to the KISSmetrics API when valid parameters are supplied" do
109
- HTTParty.expects(:get).once.returns(true)
109
+ DelayedKiss.expects(:get).once.returns(true)
110
110
  DelayedKiss.set("identity", {:gender => :male})
111
111
  end
112
-
112
+
113
113
  it "should include the set properties in the query string" do
114
- HTTParty.expects(:get).with(regexp_matches(/age=27/)).returns(true)
114
+ DelayedKiss.expects(:get).with(regexp_matches(/age=27/)).returns(true)
115
115
  DelayedKiss.set("identity", {:age => 27})
116
116
  end
117
-
117
+
118
118
  it "should not send a reuqest to the KISSmetrics API when the set paramters are blank" do
119
- HTTParty.expects(:get).never
119
+ DelayedKiss.expects(:get).never
120
120
  DelayedKiss.set("identity", {})
121
121
  end
122
-
122
+
123
123
  it "raises an error without an identity" do
124
124
  expect { DelayedKiss.set(nil, {:gener => :female}) }.to raise_error(ArgumentError)
125
125
  end
126
-
126
+
127
127
  it "should raise an error if the key is not configured and the whiny config is turned on" do
128
128
  DelayedKiss.key = nil
129
129
  DelayedKiss.whiny_config = true
130
130
  expect { DelayedKiss.set("identity", {:occupation => "Lab Rat"}) }.to raise_error(DelayedKiss::ConfigurationError)
131
131
  end
132
-
132
+
133
133
  it "should not raise an error if the key is not configured and the whiny config is turned off" do
134
134
  DelayedKiss.whiny_config = false
135
135
  expect { DelayedKiss.set("identity", {:age => "old"}) }.to_not raise_error(DelayedKiss::ConfigurationError)
136
136
  end
137
-
137
+
138
138
  it "should not send a request to the KISSmetrics API if the API key is blank and the whiny config is turned off" do
139
- HTTParty.expects(:get).never
140
-
139
+ DelayedKiss.expects(:get).never
140
+
141
141
  DelayedKiss.key = nil
142
142
  DelayedKiss.whiny_config = false
143
143
  DelayedKiss.set("identity", {:education => "college"})
144
144
  end
145
145
  end
146
- end
146
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_kiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-10 00:00:00.000000000 Z
12
+ date: 2012-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -85,6 +85,7 @@ files:
85
85
  - .gitignore
86
86
  - .rspec
87
87
  - .rvmrc
88
+ - .travis.yml
88
89
  - Gemfile
89
90
  - README.textile
90
91
  - Rakefile
@@ -110,12 +111,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
111
  - - ! '>='
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
114
+ segments:
115
+ - 0
116
+ hash: -3435836212551605131
113
117
  required_rubygems_version: !ruby/object:Gem::Requirement
114
118
  none: false
115
119
  requirements:
116
120
  - - ! '>='
117
121
  - !ruby/object:Gem::Version
118
122
  version: '0'
123
+ segments:
124
+ - 0
125
+ hash: -3435836212551605131
119
126
  requirements: []
120
127
  rubyforge_project: delayed_kiss
121
128
  rubygems_version: 1.8.24