lifecycle_api 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b67df50c169c5e728d13ac39b3c17573189b00e1
4
+ data.tar.gz: 9984a6f270a068884d58e30e60710f02f5172401
5
+ SHA512:
6
+ metadata.gz: df54d8b289de83f6cec8f260d3fb5596d333af0eb6f40ae165132ea35d65ad6f12fb094c4924a6325d0d375d7b4d7a132078e02cc86439a69e31ea8468149a8c
7
+ data.tar.gz: 7b9081495d4b1ac4f2240f2af09e994dc4ed2b53aa9a44bd5f2576d68babbf466b98665b8146e00c477567db4b3e3512f60adea2bf7053e6e0a20049e81f38cd
data/.DS_Store ADDED
Binary file
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ script: 'bundle exec rspec spec'
5
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lifecycle_api.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jake Mooney
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ [![Build Status](https://travis-ci.org/TeamLifecycle/lifecycle-ruby.svg?branch=master)](https://travis-ci.org/TeamLifecycle/lifecycle-ruby) [![Coverage Status](https://coveralls.io/repos/TeamLifecycle/lifecycle-ruby/badge.svg?branch=master&service=github)](https://coveralls.io/github/TeamLifecycle/lifecycle-ruby?branch=master)
2
+ # Lifecycle-Ruby
3
+
4
+ Welcome to Lifecycle. If you are unfamiliar with who we are and what we do, check us out at [lifecycle.io](https://lifecycle.io).
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'lifecycle_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install lifecycle_api
20
+
21
+ ## Usage
22
+ To use, simply create an instance of the client and identify and track away!
23
+
24
+ ```ruby
25
+ require 'lifecycle_api'
26
+
27
+ lifecycle = Lifecycle::Client.new 'YOUR_LIFECYCLE_API_KEY'
28
+ ```
29
+
30
+ TO IDENTIFY:
31
+ ```ruby
32
+ lifecycle.identify params #(see example of params)
33
+ ```
34
+
35
+ TO TRACK:
36
+ ```ruby
37
+ lifecycle.track 'event_id', 'unique_id'
38
+ ```
39
+
40
+
41
+ ```ruby
42
+ #Example of params variable to use with identify call
43
+ params = {:unique_id => "1234",
44
+ :first_name => "Nathan",
45
+ :last_name => "Mooney",
46
+ :email_address => "someone@lifecycle.io",
47
+ :phone_number => "12345678913"
48
+ }
49
+ ```
50
+ Use this gem to interact with your Lifecycle account. Easily identify users and track users with minimal code. If you are looking for packages in a language other than ruby, check out the TeamLifecycle organization for your desired language. It is our hope that by providing this gem, integration and usage of Lifecycle will be quick and easy.
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ 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).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lifecycle-ruby.
61
+
62
+
63
+ ## License
64
+
65
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['spec/*_spec.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lifecycle/api"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ lifecycle-api-key: "56519ba0c97ff5e67c6e9d4f"
data/example.rb ADDED
@@ -0,0 +1 @@
1
+ puts "Hello World!";
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,17 @@
1
+ # module Lifecycle
2
+ # class Client
3
+ # attr_accessor *Configuration::VALID_CONFIG_KEYS
4
+ #
5
+ # def initialize(api_key = :api_key)
6
+ # # Merge the config values from the module and those passed
7
+ # # to the client.
8
+ # merged_options = Lifecycle.options.merge(:api_key => api_key)
9
+ #
10
+ # # Copy the merged values to this client and ignore those
11
+ # # not part of our configuration
12
+ # Configuration::VALID_CONFIG_KEYS.each do |key|
13
+ # send("#{key}=", merged_options[key])
14
+ # end
15
+ # end
16
+ # end
17
+ # end
@@ -0,0 +1,40 @@
1
+ module Lifecycle
2
+ module Configuration
3
+ VALID_CONNECTION_KEYS = [:endpoint, :user_agent, :method].freeze
4
+ VALID_OPTIONS_KEYS = [:api_key, :format].freeze
5
+ VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
6
+
7
+ # DEFAULT_ENDPOINT = 'http://api-test.lifecycle.io/v1'
8
+ DEFAULT_ENDPOINT = 'http://localhost:3400'
9
+ DEFAULT_METHOD = :post
10
+ DEFAULT_USER_AGENT = "Lifecycle API Ruby Gem #{Lifecycle::VERSION}".freeze
11
+
12
+ DEFAULT_API_KEY = nil
13
+ DEFAULT_FORMAT = :json
14
+
15
+ # Build accessor methods for every config options so we can do this, for example:
16
+ # Awesome.format = :xml
17
+ attr_accessor *VALID_CONFIG_KEYS
18
+
19
+ # Make sure we have the default values set when we get 'extended'
20
+ def self.extended(base)
21
+ base.reset
22
+ end
23
+
24
+ def reset
25
+ self.endpoint = DEFAULT_ENDPOINT
26
+ self.method = DEFAULT_METHOD
27
+ self.user_agent = DEFAULT_USER_AGENT
28
+
29
+ self.api_key = DEFAULT_API_KEY
30
+ self.format = DEFAULT_FORMAT
31
+ end
32
+ def configure
33
+ yield self
34
+ end
35
+ def options
36
+ Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
37
+ end
38
+
39
+ end # Configuration
40
+ end
@@ -0,0 +1,45 @@
1
+ require "lifecycle_api/version"
2
+ require "lifecycle_api/configuration"
3
+ require "lifecycle_api/client"
4
+ require "unirest"
5
+
6
+ module Lifecycle
7
+ extend Configuration
8
+ class Client
9
+ attr_accessor *Configuration::VALID_CONFIG_KEYS
10
+
11
+ def initialize(api_key = :api_key)
12
+ # Merge the config values from the module and those passed
13
+ # to the client.
14
+ merged_options = Lifecycle.options.merge(:api_key => api_key)
15
+
16
+ # Copy the merged values to this client and ignore those
17
+ # not part of our configuration
18
+ Configuration::VALID_CONFIG_KEYS.each do |key|
19
+ send("#{key}=", merged_options[key])
20
+ end
21
+ end
22
+ def identify(params)
23
+ # response = Unirest.post "http://lifecycle.io/v1/identify",
24
+ response = Unirest.post "http://localhost:3400/v1/identify",
25
+ headers:{ "Content-Type" => "application/json", "lifecycle-api-key" => self.api_key },
26
+ parameters: params
27
+ response.code # Status code
28
+ response.headers # Response headers
29
+ response.body # Parsed body
30
+ response.raw_body # Unparsed body
31
+ return response
32
+ end
33
+ def track(event_id, unique_id)
34
+ # response = Unirest.post "http://lifecycle.io/v1/track",
35
+ response = Unirest.post "http://localhost:3400/v1/track",
36
+ headers:{ "Content-Type" => "application/json", "lifecycle-api-key" => self.api_key },
37
+ parameters: { :event_id => event_id, :unique_id => unique_id }
38
+ puts response.code # Status code
39
+ response.headers # Response headers
40
+ response.body # Parsed body
41
+ response.raw_body # Unparsed body
42
+ return response
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module Lifecycle
2
+ VERSION = "1.1.2"
3
+ end
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lifecycle_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lifecycle_api"
8
+ spec.version = Lifecycle::VERSION
9
+ spec.authors = ["Jake Mooney"]
10
+ spec.email = ["jrmooney@gmail.com"]
11
+
12
+ spec.summary = %q{Write a short summary, because Rubygems requires one.}
13
+ spec.description = %q{Write a longer description or delete this line.}
14
+ spec.homepage = "https://www.lifecycle.io/"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ spec.add_development_dependency "guard"
34
+ spec.add_development_dependency "guard-rspec"
35
+ spec.add_development_dependency "coveralls"
36
+
37
+ spec.add_dependency "unirest"
38
+
39
+
40
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lifecycle_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Jake Mooney
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: unirest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Write a longer description or delete this line.
112
+ email:
113
+ - jrmooney@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".DS_Store"
119
+ - ".coveralls.yml"
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
+ - Gemfile
124
+ - Guardfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - config/lifecycle_api.yml
131
+ - example.rb
132
+ - lib/.DS_Store
133
+ - lib/lifecycle_api/client.rb
134
+ - lib/lifecycle_api/configuration.rb
135
+ - lib/lifecycle_api/lifecycle.rb
136
+ - lib/lifecycle_api/version.rb
137
+ - lifecycle_api.gemspec
138
+ homepage: https://www.lifecycle.io/
139
+ licenses:
140
+ - MIT
141
+ metadata:
142
+ allowed_push_host: https://rubygems.org
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.4.3
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Write a short summary, because Rubygems requires one.
163
+ test_files: []