rest-segment 0.0.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 ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rest-segment.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Florian Günther
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,46 @@
1
+ # REST Segment
2
+
3
+ A simple api wrapper for http://segment.io/ (Web analytics with radically improved user segmentation.)
4
+
5
+ Find the api docs here: https://segment.io/docs/rest-api
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'rest-segment'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rest-segment
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+
25
+ api = Segment::API.new('YOUR_API_KEY_GOES_HERE')
26
+
27
+ api.identify userId: "me@florianguenther.com", traits: {
28
+ "Attractiveness" : "high",
29
+ "Age" : 28
30
+ }
31
+
32
+ api.track userId: "me@florianguenther.com", event: "Upgraded Account", properties: {
33
+ "plan" : "pro"
34
+ }
35
+
36
+ ````
37
+
38
+ Read the segment.io api docs for more information: https://segment.io/docs/rest-api
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/*_test.rb'
7
+ test.verbose = true
8
+ end
@@ -0,0 +1,5 @@
1
+
2
+ module Segment
3
+ VERSION = "0.0.1"
4
+ end
5
+
@@ -0,0 +1,39 @@
1
+ require "rest-segment/version"
2
+ require "httparty"
3
+ require "active_support/core_ext"
4
+
5
+ module Segment
6
+ class API
7
+ include HTTParty
8
+
9
+ @@api_endpoint = "https://api.segment.io/v2/"
10
+ attr_accessor :api_key
11
+
12
+
13
+ def initialize(api_key)
14
+ @api_key = api_key
15
+ end
16
+
17
+ def post_with_api_key(method, params = {})
18
+ post api_endpoint(method), params.merge({
19
+ apiKey: self.api_key
20
+ })
21
+ end
22
+
23
+ private
24
+ def method_missing(m, *args, &block)
25
+ args = args.unshift(m)
26
+ send :post_with_api_key, *args
27
+ end
28
+
29
+ def api_endpoint(method)
30
+ # add version if needed
31
+ [@@api_endpoint, method.to_s].join
32
+ end
33
+
34
+ def post(url, params)
35
+ self.class.post url, body: params.to_json, headers: {'Content-Type' => 'application/json'}
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rest-segment/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rest-segment"
8
+ gem.version = Segment::VERSION
9
+ gem.authors = ["Florian Guenther"]
10
+ gem.email = ["me@florianguenther.com"]
11
+ gem.description = %q{REST API wrapper for segment.io}
12
+ gem.summary = %q{Simply wraps the JSON RESTP API calls to segment.io}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "httparty"
21
+ gem.add_dependency "active_support"
22
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ require 'rest-segment'
7
+
8
+ class Test::Unit::TestCase
9
+
10
+ end
data/test.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require File.join File.dirname(__FILE__), 'lib/rest-segment.rb'
3
+
4
+ puts Segment::API.new
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rest-segment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Florian Guenther
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: active_support
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: REST API wrapper for segment.io
47
+ email:
48
+ - me@florianguenther.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/rest-segment.rb
59
+ - lib/rest-segment/version.rb
60
+ - rest-segment.gemspec
61
+ - test.rb
62
+ - test/test_helper.rb
63
+ homepage: ''
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.24
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Simply wraps the JSON RESTP API calls to segment.io
87
+ test_files:
88
+ - test/test_helper.rb