replay_api 0.0.3
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +112 -0
- data/Rakefile +14 -0
- data/lib/replay_api/address.rb +11 -0
- data/lib/replay_api/client.rb +44 -0
- data/lib/replay_api/compact_attributes.rb +26 -0
- data/lib/replay_api/configuration.rb +33 -0
- data/lib/replay_api/event.rb +11 -0
- data/lib/replay_api/event_properties.rb +33 -0
- data/lib/replay_api/event_properties_extensions.rb +5 -0
- data/lib/replay_api/model.rb +6 -0
- data/lib/replay_api/trait.rb +10 -0
- data/lib/replay_api/trait_properties.rb +36 -0
- data/lib/replay_api/trait_properties_extensions.rb +5 -0
- data/lib/replay_api/version.rb +3 -0
- data/lib/replay_api.rb +13 -0
- data/replay_api.gemspec +29 -0
- data/spec/feature/client_spec.rb +16 -0
- data/spec/replay_api/client_spec.rb +40 -0
- data/spec/replay_api/compact_attributes_spec.rb +34 -0
- data/spec/replay_api/configuration_spec.rb +44 -0
- data/spec/replay_api/event_properties_spec.rb +22 -0
- data/spec/replay_api/event_spec.rb +11 -0
- data/spec/replay_api/trait_properties_spec.rb +22 -0
- data/spec/replay_api/trait_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dabf42fd3f06393835e7a03d3b9be1b762e802c7
|
4
|
+
data.tar.gz: 21184818aca27ea627132bcc761b92ee5dc161d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4d2a0096dbf2ab8507019b66d9cceed9189b823f0a3cbd0ec4cc66ae358083a9887b70ea94a75be3ff2669f02795cfb01a21f56bee342cb3214343c8e43423b9
|
7
|
+
data.tar.gz: 2744e9eb161280b6aa859a8cd20e07593a83d7f4e8c4dd7ba14378b7cd3e986737686f767abb2ddb23246b68a255d646cab935fd6023aeab38366a2c08cc1718
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 alexpeachey
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
# ReplayApi
|
2
|
+
|
3
|
+
Send your events and traits to Replay.io from the server using Ruby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'replay_api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install replay_api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
First, configure the library with your `replay_key`. In Rails
|
22
|
+
this is best done in an initializer. Outside of Rails, it just
|
23
|
+
needs to happen before you start sending events and traits.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ReplayApi.configure do |config|
|
27
|
+
config.replay_key = 'xxx-xxx-xxx-xxx'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
You may opt to create a globally accessible instance of the client
|
32
|
+
or you can create a new one for each event. In either case, the
|
33
|
+
mechanism for sending events and traits is the same.
|
34
|
+
|
35
|
+
### Send an Event
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
client = ReplayApi::Client.new
|
39
|
+
client.event do |event|
|
40
|
+
event.event_name = 'Purchase'
|
41
|
+
event.distinct_id = user.id
|
42
|
+
event.properties.amount = 100
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
### Send a Trait
|
47
|
+
```ruby
|
48
|
+
client = ReplayApi::Client.new
|
49
|
+
client.trait do |trait|
|
50
|
+
trait.distinct_id = user.id
|
51
|
+
trait.properties.email = user.email
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
### Alternative Usages
|
56
|
+
|
57
|
+
You can alternatively create a `ReplayApi::Event` or `ReplayApi::Trait`
|
58
|
+
and pass it to the `event` or `trait` method with or without a block.
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
event = ReplayApi::Event.new(event_name: 'Purchase', distinct_id: user.id, properties: { amount: 100 })
|
62
|
+
client = ReplayApi::Client.new
|
63
|
+
client.event(event)
|
64
|
+
```
|
65
|
+
|
66
|
+
The `ReplayApi::Event` object has three fields, `event_name`, `distinct_id`, and `properties`.
|
67
|
+
The `ReplayApi::Trait` object has two fields, `distinct_id` and `properties`.
|
68
|
+
The `properties` by default know about all of the API Special Properties for the event or trait.
|
69
|
+
|
70
|
+
You can choose to add your own custom properties by create the definitions in the configuration block.
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
ReplayApi.configure do |config|
|
74
|
+
config.replay_key = 'xxx-xxx-xxx-xxx'
|
75
|
+
config.extend_event_properties do |ext|
|
76
|
+
ext.attribute :source, String
|
77
|
+
end
|
78
|
+
config.extend_trait_properties do |ext|
|
79
|
+
ext.attribute :favorite_color, String
|
80
|
+
ext.attribute :favorite_number, Integer
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
The models use [Virtus][1] for the attributes. Any valid type supported by Virtus is available.
|
86
|
+
You can also make your own custom types for embeded objects of information.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
class SubscriptionPlan < ReplayApi::Model
|
90
|
+
attribute :name, String
|
91
|
+
attribute :price, 25
|
92
|
+
end
|
93
|
+
|
94
|
+
ReplayApi.configure do |config|
|
95
|
+
config.replay_key = 'xxx-xxx-xxx-xxx'
|
96
|
+
config.extend_trait_properties do |ext|
|
97
|
+
ext.attribute :subscription_plan, SubscriptionPlan
|
98
|
+
end
|
99
|
+
end
|
100
|
+
```
|
101
|
+
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
1. Fork it ( https://github.com/Originate/replay_api/fork )
|
106
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
107
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
108
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
109
|
+
5. Create a new Pull Request
|
110
|
+
|
111
|
+
|
112
|
+
[1]: https://github.com/solnic/virtus
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'typhoeus'
|
4
|
+
require 'typhoeus/adapters/faraday'
|
5
|
+
|
6
|
+
module ReplayApi
|
7
|
+
class Client
|
8
|
+
attr_reader :configuration
|
9
|
+
attr_writer :connection
|
10
|
+
|
11
|
+
def initialize(configuration=ReplayApi.configuration)
|
12
|
+
@configuration ||= configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
def event(event=Event.new)
|
16
|
+
yield event if block_given?
|
17
|
+
connection.post '/events', payload(event.compact_attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def trait(trait=Trait.new)
|
21
|
+
yield trait if block_given?
|
22
|
+
connection.post '/traits', payload(trait.compact_attributes)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def connection
|
28
|
+
@connection ||= Faraday.new(url: "#{protocol}://#{configuration.replay_server}") do |conn|
|
29
|
+
conn.request :json
|
30
|
+
conn.response :json
|
31
|
+
conn.adapter :typhoeus
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def protocol
|
36
|
+
return 'http' unless configuration.ssl?
|
37
|
+
'https'
|
38
|
+
end
|
39
|
+
|
40
|
+
def payload(data)
|
41
|
+
{ replay_key: configuration.replay_key }.merge data
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ReplayApi
|
2
|
+
module CompactAttributes
|
3
|
+
def compact_attributes
|
4
|
+
compact(attributes)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def compact(input)
|
10
|
+
input.each_with_object({}) do |(key, value), hash|
|
11
|
+
next if value.nil?
|
12
|
+
if value.is_a? Hash
|
13
|
+
new_value = compact(value)
|
14
|
+
next if new_value.empty?
|
15
|
+
hash[key] = new_value
|
16
|
+
elsif value.is_a? Model
|
17
|
+
new_value = value.compact_attributes
|
18
|
+
next if new_value.empty?
|
19
|
+
hash[key] = new_value
|
20
|
+
else
|
21
|
+
hash[key] = value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ReplayApi
|
2
|
+
class << self
|
3
|
+
attr_accessor :configuration
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
self.configuration ||= Configuration.new
|
8
|
+
yield configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
class Configuration
|
12
|
+
attr_accessor :replay_key
|
13
|
+
attr_accessor :replay_server
|
14
|
+
attr_accessor :ssl
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@replay_server = 'api.replay.io'
|
18
|
+
@ssl = true
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :ssl?, :ssl
|
22
|
+
|
23
|
+
def extend_event_properties(&block)
|
24
|
+
yield EventPropertiesExtensions
|
25
|
+
ReplayApi::EventProperties.include EventPropertiesExtensions
|
26
|
+
end
|
27
|
+
|
28
|
+
def extend_trait_properties(&block)
|
29
|
+
yield TraitPropertiesExtensions
|
30
|
+
ReplayApi::TraitProperties.include TraitPropertiesExtensions
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ReplayApi
|
2
|
+
class EventProperties < Model
|
3
|
+
|
4
|
+
attribute :amount, Float
|
5
|
+
attribute :app_version, String
|
6
|
+
attribute :client_os, String
|
7
|
+
attribute :client_sdk, String
|
8
|
+
attribute :device_brand, String
|
9
|
+
attribute :device_carrier, String
|
10
|
+
attribute :device_id, String
|
11
|
+
attribute :device_manufacturer, String
|
12
|
+
attribute :device_model, String
|
13
|
+
attribute :device_type, String
|
14
|
+
attribute :country, String
|
15
|
+
attribute :event_category, String, default: 'general'
|
16
|
+
attribute :ip, String
|
17
|
+
attribute :language, String
|
18
|
+
attribute :latitude, String
|
19
|
+
attribute :longitude, String
|
20
|
+
attribute :page_name, String
|
21
|
+
attribute :page_url, String
|
22
|
+
attribute :past_event, Integer, default: 0
|
23
|
+
attribute :timestamp, Integer, default: -> (_, _) { clock.now.to_i }
|
24
|
+
|
25
|
+
def self.clock=(val)
|
26
|
+
@clock = val
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.clock
|
30
|
+
@clock ||= Time
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'replay_api/address'
|
2
|
+
|
3
|
+
module ReplayApi
|
4
|
+
class TraitProperties < Model
|
5
|
+
|
6
|
+
attribute :address, Address, default: -> (_, _) { Address.new }
|
7
|
+
attribute :age, Integer
|
8
|
+
attribute :birthday, String
|
9
|
+
attribute :avatar, String
|
10
|
+
attribute :created_at, Integer
|
11
|
+
attribute :description, String
|
12
|
+
attribute :email, String
|
13
|
+
attribute :employees, Integer
|
14
|
+
attribute :first_name, String
|
15
|
+
attribute :gender, String
|
16
|
+
attribute :industry, String
|
17
|
+
attribute :ip, String
|
18
|
+
attribute :last_name, String
|
19
|
+
attribute :name, String
|
20
|
+
attribute :page_name, String
|
21
|
+
attribute :page_url, String
|
22
|
+
attribute :past_event, Integer, default: 0
|
23
|
+
attribute :phone, String
|
24
|
+
attribute :timestamp, Integer, default: -> (_, _) { clock.now }
|
25
|
+
attribute :title, String
|
26
|
+
attribute :username, String
|
27
|
+
|
28
|
+
def self.clock=(val)
|
29
|
+
@clock = val
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.clock
|
33
|
+
@clock ||= Time
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/replay_api.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
require 'replay_api/version'
|
3
|
+
require 'replay_api/compact_attributes'
|
4
|
+
require 'replay_api/model'
|
5
|
+
require 'replay_api/event_properties_extensions'
|
6
|
+
require 'replay_api/trait_properties_extensions'
|
7
|
+
require 'replay_api/configuration'
|
8
|
+
require 'replay_api/event'
|
9
|
+
require 'replay_api/trait'
|
10
|
+
require 'replay_api/client'
|
11
|
+
|
12
|
+
module ReplayApi
|
13
|
+
end
|
data/replay_api.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'replay_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'replay_api'
|
8
|
+
spec.version = ReplayApi::VERSION
|
9
|
+
spec.authors = ['Originate']
|
10
|
+
spec.email = ['support@replay.io']
|
11
|
+
spec.summary = %q{Ruby SDK for Replay.io API}
|
12
|
+
spec.description = %q{Ruby SDK for Replay.io API}
|
13
|
+
spec.homepage = 'https://github.com/Originate/replay-gem'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'faraday', '~> 0.9'
|
22
|
+
spec.add_dependency 'typhoeus', '~> 0.6'
|
23
|
+
spec.add_dependency 'faraday_middleware', '~> 0.9'
|
24
|
+
spec.add_dependency 'virtus', '~> 1.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.3'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
ReplayApi.configure do |config|
|
4
|
+
config.replay_key = 'bogus-key'
|
5
|
+
config.ssl = false
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'Posting Events' do
|
9
|
+
let(:client) { ReplayApi::Client.new }
|
10
|
+
|
11
|
+
it 'can post an event' do
|
12
|
+
client.event do |event|
|
13
|
+
event.event_name = 'Test Event'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ReplayApi
|
4
|
+
describe Client do
|
5
|
+
subject(:client) { Client.new(configuration) }
|
6
|
+
let(:connection) { double :connection, post: nil }
|
7
|
+
let(:configuration) { Configuration.new.tap { |c| c.replay_key = 'my_key' } }
|
8
|
+
before do
|
9
|
+
client.connection = connection
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#event' do
|
13
|
+
let(:event) { Event.new }
|
14
|
+
let(:payload) { { replay_key: 'my_key' }.merge event.compact_attributes }
|
15
|
+
|
16
|
+
it 'yields the provided event' do
|
17
|
+
expect { |b| client.event(event, &b) }.to yield_with_args(event)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'posts the event' do
|
21
|
+
client.event(event)
|
22
|
+
expect(connection).to have_received(:post).with('/events', payload)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#trait' do
|
27
|
+
let(:trait) { Trait.new }
|
28
|
+
let(:payload) { { replay_key: 'my_key' }.merge trait.compact_attributes }
|
29
|
+
|
30
|
+
it 'yields the provided trait' do
|
31
|
+
expect { |b| client.trait(trait, &b) }.to yield_with_args(trait)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'posts the trait' do
|
35
|
+
client.trait(trait)
|
36
|
+
expect(connection).to have_received(:post).with('/traits', payload)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ReplayApi
|
4
|
+
describe CompactAttributes do
|
5
|
+
subject(:container_class) { Struct.new(:attributes) }
|
6
|
+
let(:container) { container_class.new(attributes) }
|
7
|
+
let(:attributes) { {} }
|
8
|
+
before do
|
9
|
+
container_class.include CompactAttributes
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#compact_attributes' do
|
13
|
+
test_cases = {
|
14
|
+
{} => {},
|
15
|
+
{ attribute1: nil } => {},
|
16
|
+
{ attribute1: :value1 } => { attribute1: :value1 },
|
17
|
+
{ attribute1: :value1, attribute2: nil } => { attribute1: :value1 },
|
18
|
+
{ attribute1: :value1, attribute2: {} } => { attribute1: :value1 },
|
19
|
+
{ attribute1: :value1, attribute2: { attribute3: :value3 } } => { attribute1: :value1, attribute2: { attribute3: :value3 } },
|
20
|
+
{ attribute1: :value1, attribute2: { attribute3: nil } } => { attribute1: :value1 },
|
21
|
+
{ attribute1: :value1, attribute2: { attribute3: :value3, attribute4: nil } } => { attribute1: :value1, attribute2: { attribute3: :value3 } },
|
22
|
+
{ attribute1: :value1, attribute2: Event.new(event_name: 'Test Event', properties: { timestamp: 12345 }) } => { attribute1: :value1, attribute2: { event_name: 'Test Event', properties: { event_category: 'general', past_event: 0, timestamp: 12345 } } },
|
23
|
+
}
|
24
|
+
|
25
|
+
test_cases.each do |input, output|
|
26
|
+
context "when attributes is #{input.inspect}" do
|
27
|
+
let(:attributes) { input }
|
28
|
+
|
29
|
+
specify { expect(container.compact_attributes).to eq output }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ReplayApi
|
4
|
+
describe Configuration do
|
5
|
+
subject(:configuration) { Configuration.new }
|
6
|
+
|
7
|
+
describe '#replay_server' do
|
8
|
+
specify { expect(configuration.replay_server).to eq 'api.replay.io' }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#ssl' do
|
12
|
+
specify { expect(configuration.ssl).to eq true }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#extend_event_properties' do
|
16
|
+
it 'yields the extensions module' do
|
17
|
+
expect { |b| configuration.extend_event_properties(&b) }.to yield_with_args(ReplayApi::EventPropertiesExtensions)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'includes the extensions in the properties' do
|
21
|
+
configuration.extend_event_properties {}
|
22
|
+
expect(ReplayApi::EventProperties.ancestors).to include(ReplayApi::EventPropertiesExtensions)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#extend_trait_properties' do
|
27
|
+
it 'yields the extensions module' do
|
28
|
+
expect { |b| configuration.extend_trait_properties(&b) }.to yield_with_args(ReplayApi::TraitPropertiesExtensions)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'includes the extensions in the properties' do
|
32
|
+
configuration.extend_trait_properties {}
|
33
|
+
expect(ReplayApi::TraitProperties.ancestors).to include(ReplayApi::TraitPropertiesExtensions)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'ReplayApi#configure' do
|
38
|
+
it 'should yield a configuration object' do
|
39
|
+
ReplayApi.configuration = Configuration.new
|
40
|
+
expect { |b| ReplayApi.configure(&b) }.to yield_with_args(ReplayApi.configuration)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ReplayApi
|
4
|
+
describe EventProperties do
|
5
|
+
subject(:properties) { EventProperties.new }
|
6
|
+
let(:clock) { double :clock, now: Time.now }
|
7
|
+
before { EventProperties.clock = clock }
|
8
|
+
after { EventProperties.clock = nil }
|
9
|
+
|
10
|
+
describe '#event_category' do
|
11
|
+
specify { expect(properties.event_category).to eq 'general' }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#past_event' do
|
15
|
+
specify { expect(properties.past_event).to eq 0 }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#timestamp' do
|
19
|
+
specify { expect(properties.timestamp).to eq clock.now.to_i }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ReplayApi
|
4
|
+
describe TraitProperties do
|
5
|
+
subject(:properties) { TraitProperties.new }
|
6
|
+
let(:clock) { double :clock, now: Time.now }
|
7
|
+
before { TraitProperties.clock = clock }
|
8
|
+
after { TraitProperties.clock = nil }
|
9
|
+
|
10
|
+
describe '#address' do
|
11
|
+
specify { expect(properties.address).to be_a(ReplayApi::Address) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#past_event' do
|
15
|
+
specify { expect(properties.past_event).to eq 0 }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#timestamp' do
|
19
|
+
specify { expect(properties.timestamp).to eq clock.now.to_i }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: replay_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Originate
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: typhoeus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday_middleware
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: virtus
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
description: Ruby SDK for Replay.io API
|
112
|
+
email:
|
113
|
+
- support@replay.io
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- lib/replay_api.rb
|
126
|
+
- lib/replay_api/address.rb
|
127
|
+
- lib/replay_api/client.rb
|
128
|
+
- lib/replay_api/compact_attributes.rb
|
129
|
+
- lib/replay_api/configuration.rb
|
130
|
+
- lib/replay_api/event.rb
|
131
|
+
- lib/replay_api/event_properties.rb
|
132
|
+
- lib/replay_api/event_properties_extensions.rb
|
133
|
+
- lib/replay_api/model.rb
|
134
|
+
- lib/replay_api/trait.rb
|
135
|
+
- lib/replay_api/trait_properties.rb
|
136
|
+
- lib/replay_api/trait_properties_extensions.rb
|
137
|
+
- lib/replay_api/version.rb
|
138
|
+
- replay_api.gemspec
|
139
|
+
- spec/feature/client_spec.rb
|
140
|
+
- spec/replay_api/client_spec.rb
|
141
|
+
- spec/replay_api/compact_attributes_spec.rb
|
142
|
+
- spec/replay_api/configuration_spec.rb
|
143
|
+
- spec/replay_api/event_properties_spec.rb
|
144
|
+
- spec/replay_api/event_spec.rb
|
145
|
+
- spec/replay_api/trait_properties_spec.rb
|
146
|
+
- spec/replay_api/trait_spec.rb
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
homepage: https://github.com/Originate/replay-gem
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.2.2
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Ruby SDK for Replay.io API
|
172
|
+
test_files:
|
173
|
+
- spec/feature/client_spec.rb
|
174
|
+
- spec/replay_api/client_spec.rb
|
175
|
+
- spec/replay_api/compact_attributes_spec.rb
|
176
|
+
- spec/replay_api/configuration_spec.rb
|
177
|
+
- spec/replay_api/event_properties_spec.rb
|
178
|
+
- spec/replay_api/event_spec.rb
|
179
|
+
- spec/replay_api/trait_properties_spec.rb
|
180
|
+
- spec/replay_api/trait_spec.rb
|
181
|
+
- spec/spec_helper.rb
|