totango 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cfe4fccbf204ce62c45abc038ec31cd4120cd4e6
4
+ data.tar.gz: 39463cc28e8e70a2e3f088498d3b58659cec7bce
5
+ SHA512:
6
+ metadata.gz: 400053aba95ccdcd2efa29dc61ed3dda30a21726f0b872b895a00bac1a1b657d0414e6702b9e6d44b2e6585cd3e6ff4f008e20f13c83c6e3969300141f2e0c3e
7
+ data.tar.gz: fbfe539ebcc2cdec0a3a67cc70dd60509a12144dd8531f59f47ec61b32d06dfad3ca6443ec7f2667b77e92fe0121cd5f59ed8af0013c2dd7e1d5f61f191dbbd2
@@ -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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in totango.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Matt Gillooly
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.
@@ -0,0 +1,29 @@
1
+ # Totango
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'totango'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install totango
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ require "totango/version"
2
+ require "totango/configuration"
3
+ require "totango/event"
4
+ require 'excon'
5
+
6
+ module Totango
7
+
8
+ class << self
9
+ attr_accessor :configuration
10
+
11
+ def configure
12
+ self.configuration ||= Configuration.new
13
+ yield(configuration)
14
+ end
15
+
16
+ def track(event_attributes)
17
+ Excon.get(build_event(event_attributes).to_url)
18
+ end
19
+
20
+ def build_event(event_attributes)
21
+ event = Event.new(event_attributes)
22
+ event.service_id = configuration.service_id if configuration
23
+ event
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,7 @@
1
+ module Totango
2
+
3
+ class Configuration
4
+ attr_accessor :service_id
5
+ end
6
+
7
+ end
@@ -0,0 +1,41 @@
1
+ module Totango
2
+
3
+ class Event
4
+
5
+ # http://help.totango.com/installing-totango/quick-start-http-api-server-side-integration/
6
+ #
7
+ # Sending an event to Totango
8
+ #
9
+ # The HTTP API can be used to track user-activity from anywhere in your web-app.
10
+ # Simply send the following parametrized HTTP request every time a user performs an important user-action.
11
+
12
+ attr_accessor :service_id, :username, :account_id, :account_name, :activity, :module
13
+
14
+ def initialize(options)
15
+ options.each do |option_name, option_value|
16
+ self.send("#{option_name}=", option_value)
17
+ end
18
+ end
19
+
20
+ def query_options
21
+ {
22
+ :sdr_s => service_id, # API identifier of your account on Totango
23
+ :sdr_u => username, # Email address of the username performing the action
24
+ :sdr_o => account_id, # Unique ID of the end-user’s account on your application
25
+ :sdr_odn => account_name, # A human readable name for the account (will be used on Totango’s UI and reports)
26
+ :sdr_a => activity, # Name of the activity the user performed
27
+ :sdr_m => self.module, # Name of the module the user is using within the application
28
+ }
29
+ end
30
+
31
+ def to_url
32
+ URI::HTTP.build({
33
+ :host => 'sdr.totango.com',
34
+ :path => '/pixel.gif/',
35
+ :query => URI.encode_www_form(query_options)
36
+ }).to_s
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,3 @@
1
+ module Totango
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require 'totango'
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Totango::Event do
4
+
5
+ subject {
6
+ described_class.new({
7
+ :service_id => "SP-xxxxyy",
8
+ :account_id => "u12214",
9
+ :account_name => "Barksdale+Industries",
10
+ :username => "avon@barksdale.com",
11
+ :activity => "Login",
12
+ :module => "Application"
13
+ })
14
+ }
15
+
16
+ describe "#query_options" do
17
+ it "builds a query hash for a Totango pixel URL" do
18
+ expect( subject.query_options ).to eq({
19
+ :sdr_s => "SP-xxxxyy",
20
+ :sdr_o => "u12214",
21
+ :sdr_odn => "Barksdale+Industries",
22
+ :sdr_u => "avon@barksdale.com",
23
+ :sdr_a => "Login",
24
+ :sdr_m => "Application"
25
+ })
26
+ end
27
+ end
28
+
29
+ describe "#to_url" do
30
+ it "builds a Totango pixel URL" do
31
+ url = URI.parse( subject.to_url )
32
+
33
+ expect( url.host ).to eq( 'sdr.totango.com' )
34
+ expect( url.path ).to eq( "/pixel.gif/" )
35
+
36
+ query_options = Hash[URI.decode_www_form(url.query)]
37
+ expect( query_options ).to eq({
38
+ "sdr_s" => "SP-xxxxyy",
39
+ "sdr_o" => "u12214",
40
+ "sdr_odn" => "Barksdale+Industries",
41
+ "sdr_u" => "avon@barksdale.com",
42
+ "sdr_a" => "Login",
43
+ "sdr_m" => "Application"
44
+ })
45
+ end
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Totango do
4
+
5
+ describe '.configure' do
6
+ let(:service_id) { 'my-service-id' }
7
+
8
+ it "sets service_id" do
9
+ expect( described_class.configuration ).to be_nil
10
+
11
+ described_class.configure do |config|
12
+ config.service_id = service_id
13
+ end
14
+
15
+ expect( described_class.configuration.service_id ).to eq( service_id )
16
+ end
17
+ end
18
+
19
+ describe '.track(event_attributes)' do
20
+ let(:event_attributes) { double }
21
+ let(:url) { double }
22
+
23
+ let(:event) { double(Totango::Event, to_url: url) }
24
+
25
+ before do
26
+ subject.stub(:build_event).with(event_attributes) { event }
27
+ end
28
+
29
+ it 'builds and posts an event' do
30
+ Excon.should_receive(:post).with(url)
31
+ subject.track(event_attributes)
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'totango/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "totango"
8
+ spec.version = Totango::VERSION
9
+ spec.authors = ["Matt Gillooly"]
10
+ spec.email = ["matt@swipely.com"]
11
+ spec.description = %q{Ruby client for sending events to Totango}
12
+ spec.summary = %q{Sends events from your application to Totango}
13
+ spec.homepage = "http://github.com/swipely/totango"
14
+ spec.license = "MIT"
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)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "excon"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: totango
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Gillooly
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: excon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: rspec
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
+ description: Ruby client for sending events to Totango
70
+ email:
71
+ - matt@swipely.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - .ruby-version
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/totango.rb
84
+ - lib/totango/configuration.rb
85
+ - lib/totango/event.rb
86
+ - lib/totango/version.rb
87
+ - spec/spec_helper.rb
88
+ - spec/totango/event_spec.rb
89
+ - spec/totango_spec.rb
90
+ - totango.gemspec
91
+ homepage: http://github.com/swipely/totango
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.0.3
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Sends events from your application to Totango
115
+ test_files:
116
+ - spec/spec_helper.rb
117
+ - spec/totango/event_spec.rb
118
+ - spec/totango_spec.rb