analyticator 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTFmOGYwYTAzYTg2ZjgxMWI2NTM2MWQ4ZThmMzk0NmY5MmU3ZWRhYw==
5
+ data.tar.gz: !binary |-
6
+ N2YwYWE5M2FkODIxYjg3ZTg0MzE1ZTZmZDI3MTI5Y2JkMTZhNThhYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NGMxZDQzZTc4MzJkYTNjYmRjY2YxZmVhYmQwZTkzMzk1NmZiZTE4NmM0Yjhk
10
+ NWI3NWI5ZTkwODlhM2M2ZTA4YmJlOTU1ZjFkYmIyNTI5NTA0MjE5YzcxMzBk
11
+ MmVkZGU4NDY5ODZkOWZmM2FlN2RkZjM0NWNiN2Q3NDQ0Y2UyODQ=
12
+ data.tar.gz: !binary |-
13
+ ZjI1ZGI5MDRlNDhiOTg4Njk4NzQxNzg4M2YyYWI4OTYyYzQyZWRiOTQ5YjRk
14
+ ZWM2MWYwMTcwY2RjMDJjYzBkYzM2ZjFmYTM4NDMxN2UzMTY0MWEyN2E1NWY4
15
+ NjcxYTE2ZTcyYjNjYjE0ZDA1Nzg2OWFkMjFhNTY5NjhiZTk4OGE=
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ analyticator (0.0.1)
5
+ haml
6
+ sinatra
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ haml (4.0.2)
12
+ tilt
13
+ rack (1.5.2)
14
+ rack-protection (1.5.0)
15
+ rack
16
+ sinatra (1.4.2)
17
+ rack (~> 1.5, >= 1.5.2)
18
+ rack-protection (~> 1.4)
19
+ tilt (~> 1.3, >= 1.3.4)
20
+ tilt (1.3.7)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ analyticator!
27
+ bundler
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'analytics/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "analyticator"
9
+ spec.version = Analyticator::VERSION
10
+ spec.authors = ["Chris MacNaughton"]
11
+ spec.email = ["chris@elocal.com"]
12
+ spec.description = %q{ Emulate google analytics during development to test events }
13
+ spec.summary = %q{ Emulate google analytics during development }
14
+ spec.homepage = "http://nyancat.com"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = ['analyticator']
19
+ spec.default_executable = 'analyticator'
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler"
24
+
25
+ spec.add_runtime_dependency 'sinatra'
26
+ spec.add_runtime_dependency 'haml'
27
+ end
data/bin/.gitkeep ADDED
File without changes
data/bin/analyticator ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'analytics/analytics.rb'
@@ -0,0 +1,52 @@
1
+ require 'sinatra'
2
+
3
+ class Analytics < Sinatra::Base
4
+ configure do
5
+ set :static, true
6
+
7
+ set :views, File.expand_path('./views', __FILE__)
8
+ set :haml, { :format => :html5 }
9
+ set :port, 8080
10
+ @@events ||= []
11
+ end
12
+
13
+ get '/' do
14
+ @events = @@events
15
+ haml :index
16
+ end
17
+ get '/test' do
18
+ puts "#{@@events}"
19
+ end
20
+ get '/__utm.gif' do
21
+ unless params[:utmt].nil?
22
+ options = params[:utme] || ""
23
+ if params[:utmt] == "event"
24
+ options = options.split("(")
25
+ arr = []
26
+ options.each{|o| arr << o.split(")") }
27
+ arr = arr.flatten
28
+ arr.reject!{|o| o == '' }
29
+ details = arr[1].split("*")
30
+ options = {
31
+ :action => details[0],
32
+ :location => details[1],
33
+ :label => details[2],
34
+ :value => arr[2],
35
+ created_at: Time.now
36
+ }
37
+ @@events << options
38
+ end
39
+ end
40
+ content_type :gif
41
+ puts ""
42
+ end
43
+ get '/ga.js' do
44
+ uri = URI.parse("http://www.google-analytics.com/ga.js")
45
+ response = Net::HTTP.get_response(uri)
46
+ local = "http://" + self.request.host + ":" + self.request.port.to_s
47
+ body = response.body.gsub(/http(.*?)google-analytics.com/, local).gsub('www.google-analytics.com', local)
48
+ render js: body, :content_type => "text/javascript"
49
+ end
50
+ end
51
+
52
+ Analytics.run!