keen 0.3.0 → 0.4.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.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +17 -0
- data/Gemfile +29 -11
- data/Guardfile +16 -0
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +104 -32
- data/Rakefile +9 -42
- data/{conf → config}/cacert.pem +0 -0
- data/keen.gemspec +16 -71
- data/lib/keen.rb +46 -4
- data/lib/keen/client.rb +95 -71
- data/lib/keen/http.rb +40 -0
- data/lib/keen/version.rb +2 -18
- data/spec/integration/api_spec.rb +63 -0
- data/spec/integration/spec_helper.rb +8 -0
- data/spec/keen/client_spec.rb +191 -0
- data/spec/keen/keen_spec.rb +61 -0
- data/spec/keen/spec_helper.rb +10 -0
- data/spec/spec_helper.rb +16 -0
- metadata +58 -124
- data/.rvmrc +0 -2
- data/VERSION.yml +0 -5
- data/examples.rb +0 -40
- data/features/add_event.feature +0 -15
- data/features/step_definitions/keen_steps.rb +0 -28
- data/features/support/before_and_after.rb +0 -4
- data/features/support/env.rb +0 -15
- data/keen.gemspec.old +0 -30
- data/lib/keen/event.rb +0 -13
- data/lib/keen/keys.rb +0 -6
- data/lib/keen/utils.rb +0 -12
data/.rvmrc
DELETED
data/VERSION.yml
DELETED
data/examples.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'keen'
|
3
|
-
|
4
|
-
# Get these from the keen.io website:
|
5
|
-
project_id = 'asdfasldkfjalsdkfalskdfj'
|
6
|
-
api_key = 'asldfjklj325tkl32jaskdlfjaf'
|
7
|
-
|
8
|
-
# First you must setup the client:
|
9
|
-
keen = Keen::Client.new(project_id, api_key, :storage_mode => :redis)
|
10
|
-
|
11
|
-
# Then, you can use that client to send events.
|
12
|
-
|
13
|
-
keen.add_event("purchases", {
|
14
|
-
:quantity => @quantity,
|
15
|
-
:user => @user.hashify,
|
16
|
-
:item => @item.hashify,
|
17
|
-
:session => @session.hashify,
|
18
|
-
})
|
19
|
-
|
20
|
-
keen.add_event("pageviews", {
|
21
|
-
:user => @user.hashify,
|
22
|
-
:route => @current_route,
|
23
|
-
:session => @session.hashify,
|
24
|
-
})
|
25
|
-
|
26
|
-
keen.add_event("purchases", [{
|
27
|
-
:quantity => @quantity1,
|
28
|
-
:user => @user1.hashify,
|
29
|
-
:item => @item1.hashify,
|
30
|
-
:session => @session1.hashify,
|
31
|
-
},{
|
32
|
-
:quantity => @quantity2,
|
33
|
-
:user => @user2.hashify,
|
34
|
-
:item => @item2.hashify,
|
35
|
-
:session => @session2.hashify,
|
36
|
-
}])
|
37
|
-
|
38
|
-
|
39
|
-
# (These examples pretend your important objects all have a method called
|
40
|
-
# "hashify", and that method serializes state information you wish to track.)
|
data/features/add_event.feature
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Language: en
|
2
|
-
Feature: AddEvent
|
3
|
-
In order to send an event to Keen's servers
|
4
|
-
As a developer
|
5
|
-
I want to be able to post an event to the Keen Client as a Hash/Dictionary
|
6
|
-
|
7
|
-
Scenario: Send Event directly to Keen
|
8
|
-
Given a Keen Client in Direct Send mode
|
9
|
-
When I post an event
|
10
|
-
Then the response from the server should be good.
|
11
|
-
|
12
|
-
Scenario: Send Multiple Event directly to Keen
|
13
|
-
Given a Keen Client in Direct Send mode
|
14
|
-
When I post mulitple events
|
15
|
-
Then the response from the server should be good for each event
|
@@ -1,28 +0,0 @@
|
|
1
|
-
begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end
|
2
|
-
require 'cucumber/formatter/unicode'
|
3
|
-
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
4
|
-
require 'keen'
|
5
|
-
|
6
|
-
Given /^a Keen Client in Direct Send mode$/ do
|
7
|
-
@client = Keen::Client.new(@project_id,
|
8
|
-
@api_key,
|
9
|
-
:logging => false )
|
10
|
-
end
|
11
|
-
|
12
|
-
When /^I post an event$/ do
|
13
|
-
@result = @client.add_event("cucumber_events", {:hi_from => "cucumber!", :keen_version => Keen::VERSION})
|
14
|
-
end
|
15
|
-
|
16
|
-
Then /^the response from the server should be good\.$/ do
|
17
|
-
response = @result
|
18
|
-
response.should == {"created" => true}
|
19
|
-
end
|
20
|
-
|
21
|
-
When /^I post mulitple events$/ do
|
22
|
-
@result = @client.add_event("cucumber_events", [{:hi_from => "cucumber 1!", :keen_version => Keen::VERSION},{:hi_from => "cucumber 2!", :keen_version => Keen::VERSION}])
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^the response from the server should be good for each event$/ do
|
26
|
-
response = @result
|
27
|
-
response.should == {"cucumber_events" => [{"success" => true},{"success" => true}]}
|
28
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#require 'bundler'
|
2
|
-
#begin
|
3
|
-
#Bundler.setup(:default, :development)
|
4
|
-
#rescue Bundler::BundlerError => e
|
5
|
-
#$stderr.puts e.message
|
6
|
-
#$stderr.puts "Run `bundle install` to install missing gems"
|
7
|
-
#exit e.status_code
|
8
|
-
#end
|
9
|
-
|
10
|
-
#$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
-
#require 'keen'
|
12
|
-
|
13
|
-
#require 'test/unit/assertions'
|
14
|
-
|
15
|
-
#World(Test::Unit::Assertions)
|
data/keen.gemspec.old
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "keen/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "keen"
|
7
|
-
s.version = Keen::VERSION
|
8
|
-
s.authors = ["Kyle Wild"]
|
9
|
-
s.email = ["kyle@keen.io"]
|
10
|
-
s.homepage = "https://github.com/keenlabs/KeenClient-Ruby"
|
11
|
-
s.summary = "A library for batching and sending arbitrary events to the Keen API at http://keen.io"
|
12
|
-
s.description = "See the github repo or examples.rb for usage information."
|
13
|
-
|
14
|
-
s.rubyforge_project = "keen"
|
15
|
-
|
16
|
-
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.extensions = ["ext/mkrf_conf.rb"]
|
20
|
-
s.require_paths = ["lib"]
|
21
|
-
|
22
|
-
# specify any dependencies here; for example:
|
23
|
-
# s.add_development_dependency "rspec"
|
24
|
-
# s.add_runtime_dependency "rest-client"
|
25
|
-
|
26
|
-
|
27
|
-
# This is no longer necessary, since we support several storage modes now:
|
28
|
-
# s.add_dependency("redis", ">= 2.2.2")
|
29
|
-
|
30
|
-
end
|
data/lib/keen/event.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module Keen
|
2
|
-
class Event
|
3
|
-
|
4
|
-
attr_accessor :event_collection, :properties, :timestamp
|
5
|
-
|
6
|
-
def initialize(event_collection, properties, timestamp=nil)
|
7
|
-
@event_collection = event_collection
|
8
|
-
@properties = properties
|
9
|
-
@timestamp = timestamp
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
data/lib/keen/keys.rb
DELETED