remetric 0.0.13 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f32b1eadb941c5b96a0f213218d60408347825e4
4
- data.tar.gz: a564d61239c81596d531567b0c87a263ed7ff08a
3
+ metadata.gz: 126146869bea224d84523a2be545dc5b5c58a7f9
4
+ data.tar.gz: 931599e907e108a65798e346d1fa5644e5f4c2f0
5
5
  SHA512:
6
- metadata.gz: 2a98e5b467fd03f1dcf2f261c5984974d2808a555b5010699560bf0f7a5ed97669100dcc684ee892040d899d27469639b96064cc1b08980bec9f4735e07710d8
7
- data.tar.gz: fb36c300a78c94f2df3e974d21267beb91516542265e648c487b8410cd04a4f807cb7cbf1ee9e0d746a7f010cddb89bb73dc770122e1e9e77ae978856ad3299a
6
+ metadata.gz: 1c37dc322bf4b82d06232e5954ca003886766ab0003a4b57e17accbc72e54230bdab75b7dcde559b396d33e477908a8a5d56c51ae813ff529ec092493f688bb7
7
+ data.tar.gz: e6db2c780a24113edc5e1203b61e2a8e06609cd5311eb65bd6c616a61ed10811782b52ecef15df0884216d3381b740936bcd593ee734cf183964260d00b753cb
data/.gitignore CHANGED
@@ -1 +1,9 @@
1
- *.gem
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in remetric.gemspec
4
4
  gemspec
5
-
6
- gem 'rest-client'
data/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # Remetric
2
2
 
3
- Remetric tracks your user data in a snap!
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/remetric`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- This gem interacts with our API.
5
+ TODO: Delete this and the text above, and describe your gem
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'remetric'
11
+ ```ruby
12
+ gem 'remetric'
13
+ ```
12
14
 
13
15
  And then execute:
14
16
 
@@ -20,30 +22,15 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- `Key` is always required!
25
+ TODO: Write usage instructions here
24
26
 
25
- ```
26
- r = Remetric.new "#{remetric_api_token}"
27
-
28
- r.track "{{ name }} signed in with {{ email }}.", {
29
- key: user.id,
30
- email: user.email,
31
- name: user.name,
32
- last_sign_in: Time.now.to_i,
33
- comments: user.comments.count
34
- }
35
-
36
- r.save_contact({
37
- key: user.id,
38
- email: user.email,
39
- name: user.name
40
- })
41
- ```
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
32
 
43
33
  ## Contributing
44
34
 
45
- 1. Fork it
46
- 2. Create your feature branch (`git checkout -b my-new-feature`)
47
- 3. Commit your changes (`git commit -am 'Add some feature'`)
48
- 4. Push to the branch (`git push origin my-new-feature`)
49
- 5. Create new Pull Request
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/remetric.
36
+
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
+ task :default => :spec
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'test'
8
+ end
9
+
10
+ desc "Run tests"
11
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "remetric"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,42 +1,9 @@
1
1
  require "remetric/version"
2
- require "base64"
3
- require "json"
4
- require "rest_client"
2
+ require "remetric/client"
3
+ require "remetric/http"
4
+ require "remetric/endpoints/endpoint"
5
+ require "remetric/endpoints/rest"
6
+ require "remetric/endpoints/user"
5
7
 
6
- class Remetric
7
- def initialize api_key, sandbox = false
8
- @rm_api_key = api_key
9
- @rm_sandbox = sandbox
10
- end
11
-
12
- def api_key
13
- @rm_api_key
14
- end
15
-
16
- def track data = {}
17
- begin
18
- RestClient.get "#{endpoint}/track/img/#{to_base64 data}"
19
- rescue
20
- { errors: "You are unauthorized." }
21
- end
22
- end
23
-
24
- def img data = {}
25
- src = "#{endpoint}/track/img/#{to_base64 data}"
26
- img = "<img src=\"#{src}\" style=\"display: none; \">"
27
- img
28
- end
29
-
30
- def redirect data = {}
31
- "#{endpoint}/track/redirect/#{to_base64 data}"
32
- end
33
-
34
- def to_base64 data = {}
35
- data["publishable_key"] = api_key
36
- URI.escape Base64.encode64(JSON.generate(data))
37
- end
38
-
39
- def endpoint
40
- @rm_sandbox ? "http://localhost:3000" : "https://secure.remetric.com"
41
- end
8
+ module Remetric
42
9
  end
@@ -0,0 +1,71 @@
1
+ module Remetric
2
+ class Client
3
+ def initialize(opts = {})
4
+ @account = opts[:account]
5
+ @api_token = opts[:api_token]
6
+ @secret_key = opts[:secret_key]
7
+ @debug = opts[:debug]
8
+ end
9
+
10
+ def account
11
+ @account
12
+ end
13
+
14
+ def account=(account)
15
+ @account = account
16
+ end
17
+
18
+ def api_token
19
+ @api_token
20
+ end
21
+
22
+ def api_token=(api_token)
23
+ @api_token = api_token
24
+ end
25
+
26
+ def secret_key
27
+ @secret_key
28
+ end
29
+
30
+ def secret_key=(secret_key)
31
+ @secret_key = secret_key
32
+ end
33
+
34
+ def debug
35
+ @debug
36
+ end
37
+
38
+ def debug=(debug)
39
+ @debug = debug
40
+ end
41
+
42
+ def to_json
43
+ {
44
+ account: @account,
45
+ api_token: @api_token,
46
+ secret_key: @secret_key,
47
+ debug: @debug
48
+ }
49
+ end
50
+
51
+ def http
52
+ Remetric::HTTP.new self
53
+ end
54
+
55
+ def user
56
+ @user ||= Remetric::UserEndpoint.new self
57
+ end
58
+
59
+ def events
60
+ @events ||= Remetric::RESTEndpoint.new :events, self
61
+ end
62
+
63
+ def sequences
64
+ @events ||= Remetric::RESTEndpoint.new :events, self
65
+ end
66
+
67
+ def ctas
68
+ @ctas ||= Remetric::RESTEndpoint.new :ctas, self
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,19 @@
1
+ module Remetric
2
+ class Endpoint
3
+ def initialize(client)
4
+ @client = client
5
+ end
6
+
7
+ def client
8
+ @client
9
+ end
10
+
11
+ def client=(client)
12
+ @client = client
13
+ end
14
+
15
+ def http
16
+ client.http
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,36 @@
1
+ module Remetric
2
+ class RESTEndpoint < Remetric::Endpoint
3
+ def initialize(resource, client)
4
+ @resource = resource
5
+ @client = client
6
+ end
7
+
8
+ def resource
9
+ @resource
10
+ end
11
+
12
+ def resource=(resource)
13
+ @resource = resource
14
+ end
15
+
16
+ def list(args = {})
17
+ http.get "/#{client.account}/#{resource}", args
18
+ end
19
+
20
+ def show(id)
21
+ http.get "/#{client.account}/#{resource}/#{id}"
22
+ end
23
+
24
+ def create(args = {})
25
+ http.post "/#{client.account}/#{resource}", { event: args }
26
+ end
27
+
28
+ def update(id, args = {})
29
+ http.patch "/#{client.account}/#{resource}/#{id}", { event: args }
30
+ end
31
+
32
+ def destroy(id)
33
+ http.delete "/#{client.account}/#{resource}/#{id}"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ module Remetric
2
+ class UserEndpoint < Remetric::Endpoint
3
+ def identify(args = {})
4
+ if args.keys.length > 0
5
+ http.patch '/', { user: args }
6
+ else
7
+ http.get '/'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,61 @@
1
+ require 'rest-client'
2
+ require 'base64'
3
+ require 'json'
4
+
5
+ module Remetric
6
+ class HTTP
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def client
12
+ @client
13
+ end
14
+
15
+ def root_url
16
+ # return "http://localhost:3000"
17
+ "https://api.remetric.com"
18
+ end
19
+
20
+ def rc
21
+ @rc ||= RestClient
22
+ end
23
+
24
+ def headers
25
+ {
26
+ Authorization: "Basic #{Base64.encode64("#{client.api_token}:#{client.secret_key}")}"
27
+ }
28
+ end
29
+
30
+ def opts
31
+ {
32
+ content_type: :json,
33
+ accept: :json
34
+ }
35
+ end
36
+
37
+ def parse(response)
38
+ JSON.parse response.body
39
+ end
40
+
41
+ def get(path, args = {})
42
+ response = rc.get "#{root_url}#{path}", headers.merge(params: args)
43
+ parse response
44
+ end
45
+
46
+ def post(path, args = {})
47
+ response = rc.post "#{root_url}#{path}", args, headers
48
+ parse response
49
+ end
50
+
51
+ def patch(path, args = {})
52
+ response = rc.patch "#{root_url}#{path}", args, headers
53
+ parse response
54
+ end
55
+
56
+ def delete(path)
57
+ response = rc.delete "#{root_url}#{path}", headers
58
+ parse response
59
+ end
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
- class Remetric
2
- VERSION = "0.0.13"
1
+ module Remetric
2
+ VERSION = "1.0.0"
3
3
  end
@@ -7,17 +7,20 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "remetric"
8
8
  spec.version = Remetric::VERSION
9
9
  spec.authors = ["Dallas Read"]
10
- spec.email = ["dallas@excitereative.ca"]
11
- spec.description = %q{Remetric tracks your user data in a snap!}
12
- spec.summary = %q{Remetric tracks your user data in a snap!}
10
+ spec.email = ["dallas@excitecreative.ca"]
11
+
12
+ spec.summary = %q{Interact with the Remetric API.}
13
+ spec.description = %q{Interact with the Remetric API.}
13
14
  spec.homepage = "http://www.remetric.com"
14
- spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
21
  spec.require_paths = ["lib"]
20
22
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "bundler", "~> 1.14"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_dependency "rest-client", "~> 2.0.0"
23
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remetric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dallas Read
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-06-14 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,46 +16,65 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.14'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '1.14'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
41
- description: Remetric tracks your user data in a snap!
54
+ version: 2.0.0
55
+ description: Interact with the Remetric API.
42
56
  email:
43
- - dallas@excitereative.ca
57
+ - dallas@excitecreative.ca
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - ".gitignore"
49
63
  - Gemfile
50
- - LICENSE.txt
51
64
  - README.md
52
65
  - Rakefile
66
+ - bin/console
67
+ - bin/setup
53
68
  - lib/remetric.rb
69
+ - lib/remetric/client.rb
70
+ - lib/remetric/endpoints/endpoint.rb
71
+ - lib/remetric/endpoints/rest.rb
72
+ - lib/remetric/endpoints/user.rb
73
+ - lib/remetric/http.rb
54
74
  - lib/remetric/version.rb
55
75
  - remetric.gemspec
56
76
  homepage: http://www.remetric.com
57
- licenses:
58
- - MIT
77
+ licenses: []
59
78
  metadata: {}
60
79
  post_install_message:
61
80
  rdoc_options: []
@@ -73,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
92
  version: '0'
74
93
  requirements: []
75
94
  rubyforge_project:
76
- rubygems_version: 2.2.2
95
+ rubygems_version: 2.5.2
77
96
  signing_key:
78
97
  specification_version: 4
79
- summary: Remetric tracks your user data in a snap!
98
+ summary: Interact with the Remetric API.
80
99
  test_files: []
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Dallas Read
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.