rangefinder-sst 0.0.1

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: 21cb37070985042c706ff3805aa52ebdf5235016
4
+ data.tar.gz: 86693f7621422f0cfa50696544446c463d9f9eb0
5
+ SHA512:
6
+ metadata.gz: 5ad2bf3a1bf6a6af1161b15608e2dfc60e907c493e8c419da819e2ce862e570b13db361285db43cc61970069131edd180ed6e796b57ef6bf986f214649838200
7
+ data.tar.gz: 60c2e624c0797742178427ab85b3c2d635f40cf44bf3ffbe075b034d290c141ef1ff16c9a6875da862a48ac86dfed04daaa02c2aa704cf17717c0b80b4c77119
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,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2014, Dirk Gadsden
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of Rangefinder nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL Dirk Gadsden BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Rangefinder::Ruby::Sst
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rangefinder-ruby-sst'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rangefinder-ruby-sst
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/rangefinder-ruby-sst/fork )
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
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Rangefinder
2
+ class SST
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,59 @@
1
+ require 'rangefinder/sst/version'
2
+ require 'addressable/uri'
3
+
4
+ module Rangefinder
5
+ class SST
6
+ DEFAULT_ENDPOINT = 'rangefinderapp.com'
7
+ DEFAULT_PORT = 8001
8
+ DEFAULT_SCRIPT = 'rangefinderapp.com/track1.js';
9
+
10
+ attr_accessor :site_key, :site_id,
11
+ :endpoint, :port, :script
12
+ attr_reader :server_id
13
+
14
+ @@rand = Proc.new { Kernel.rand 1000000 }
15
+ class << self
16
+ def rand; @@rand; end
17
+ # Change the random server ID generator.
18
+ # eg. Rangefinder::SST.rand = Proc.new { MySpecial.rand }
19
+ def rand=(r) @@rand = r; end
20
+ end
21
+
22
+ def initialize(opts = {})
23
+ @site_key = opts[:site_key] || ''
24
+ @site_id = opts[:site_id] || 0
25
+ @server_id = 0
26
+ @socket = nil
27
+
28
+ @script = opts[:script] || DEFAULT_SCRIPT
29
+ @endpoint = opts[:endpoint] || DEFAULT_ENDPOINT
30
+ @port = opts[:port] || DEFAULT_PORT
31
+ end
32
+
33
+ def track(visit)
34
+ connect unless @socket
35
+
36
+ @id = self.class.rand.call
37
+ packet = 'track:'+Addressable::URI.form_encode(
38
+ :key => @site_key,
39
+ :page => visit[:page],
40
+ :referrer => visit[:referrer],
41
+ :user_agent => visit[:user_agent],
42
+ :ipv4 => visit[:ipv4],
43
+ :time => Time.now.utc.to_i,
44
+ :id => @id
45
+ )+"\n"
46
+
47
+ if packet.length < 1499
48
+ @socket.send packet, 0
49
+ else
50
+ @id = -2 # Too long
51
+ end
52
+ return @id
53
+ end
54
+ def connect
55
+ @socket = UDPSocket.new
56
+ @socket.connect(@endpoint, @port)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rangefinder/sst/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rangefinder-sst"
8
+ spec.version = Rangefinder::SST::VERSION
9
+ spec.authors = ["Dirk Gadsden"]
10
+ spec.email = ["dirk@esherido.com"]
11
+ spec.summary = "Single-site tracking for Rangefinder"
12
+ spec.description = "Single-site tracking library for the Rangefinder web analytics app"
13
+ spec.homepage = "http://rangefinderapp.com"
14
+ spec.license = "New BSD"
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_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake", '~> 0'
23
+
24
+ spec.add_dependency "addressable", '~> 0'
25
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rangefinder-sst
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dirk Gadsden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-12 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: addressable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Single-site tracking library for the Rangefinder web analytics app
56
+ email:
57
+ - dirk@esherido.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - lib/rangefinder/sst.rb
68
+ - lib/rangefinder/sst/version.rb
69
+ - rangefinder-sst.gemspec
70
+ homepage: http://rangefinderapp.com
71
+ licenses:
72
+ - New BSD
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.2.0
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Single-site tracking for Rangefinder
94
+ test_files: []