rack-universal_analytics 0.0.1.alpha

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.
@@ -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
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'guard-rspec'
5
+ end
6
+
7
+ group :test do
8
+ gem 'rspec'
9
+ end
10
+
11
+ # Specify your gem's dependencies in rack-universal-analytics.gemspec
12
+ gemspec
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, all_after_pass: true, all_on_start: true do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Michael Deering
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,32 @@
1
+ h1. Rack::UniversalAnalytics
2
+
3
+ Going to steal most of this from https://github.com/kangguru/rack-google-analytics.
4
+ Would continue to use the rack-google-analytics gem but have multi-tenint CMS where
5
+ I need to mix and depricate sites slowly off of the ga.js and gpt.js retargeting
6
+ scripts.
7
+
8
+ h2. Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'rack-universal_analytics'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install rack-universal_analytics
21
+
22
+ h2. Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ h2. Contributing
27
+
28
+ # Fork it ( http://github.com/<my-github-username>/rack-universal_analytics/fork )
29
+ # Create your feature branch (`git checkout -b my-new-feature`)
30
+ # Commit your changes (`git commit -am 'Add some feature'`)
31
+ # Push to the branch (`git push origin my-new-feature`)
32
+ # Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ # Encoding: utf-8
2
+ require 'rack/universal_analytics/version'
3
+ require 'rack/universal_analytics/app'
@@ -0,0 +1,31 @@
1
+ # Encoding: utf-8
2
+ require "rack/universal_analytics/version"
3
+
4
+ module Rack
5
+ module UniversalAnalytics
6
+ class App
7
+
8
+ def initialize(app, options = {})
9
+ @app = app
10
+ end
11
+
12
+ # dup the middleware instance for thread safety
13
+ def call(env)
14
+ dup._call(env)
15
+ end
16
+
17
+ def _call(env)
18
+ @status, @headers, @body = @app.call(env)
19
+ @body.gsub!(/OK/, 'Rack::UniversalAnalytics was here!') if html?
20
+ [@status, @headers, @body]
21
+ end
22
+
23
+ private
24
+
25
+ def html?
26
+ @headers['Content-Type'] =~ /html/
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ # Encoding: utf-8
2
+ puts 'Version file'
3
+ module Rack
4
+ module UniversalAnalytics
5
+ VERSION = "0.0.1.alpha"
6
+ end
7
+ end
@@ -0,0 +1,24 @@
1
+ # Encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rack/universal_analytics/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rack-universal_analytics'
8
+ spec.version = Rack::UniversalAnalytics::VERSION
9
+ spec.authors = ['Michael Deering']
10
+ spec.email = ['mdeering@mdeering.com']
11
+ spec.summary = %q{Rack middleware for inserting Google Universal Analytics}
12
+ spec.description = %q{Rack middleware for inserting Google Universal Analytics and calling its API.}
13
+ spec.homepage = 'https://github.com/mdeering/rack-universal_analytics'
14
+ spec.license = 'MIT'
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 'rack-test'
23
+ spec.add_development_dependency 'rake'
24
+ end
@@ -0,0 +1,32 @@
1
+ # Encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Rack::UniversalAnalytics do
5
+
6
+ include Rack::Test::Methods
7
+
8
+ let(:dummy) { ->(env) { [200, env, 'OK']} }
9
+ let(:app) { Rack::UniversalAnalytics::App.new(dummy) }
10
+
11
+ context 'with an html request' do
12
+ let(:env) { {'Content-Type' => 'text/html'} }
13
+
14
+ it 'should augment the response body' do
15
+ get '/', {}, env
16
+ expect(last_response.body).to eq('Rack::UniversalAnalytics was here!')
17
+ end
18
+
19
+ end
20
+
21
+ context 'with non-HTML requests' do
22
+
23
+ let(:env) { {'Content-Type' => 'text/plain'} }
24
+
25
+ it 'passes the request through unchanged' do
26
+ get '/', {}, env
27
+ expect(last_response.body).to eq('OK')
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,21 @@
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
+ require 'rack/test'
7
+ require 'rack/universal_analytics'
8
+
9
+ #
10
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-universal_analytics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Michael Deering
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.5'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.5'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rack-test
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
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
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Rack middleware for inserting Google Universal Analytics and calling
63
+ its API.
64
+ email:
65
+ - mdeering@mdeering.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - .rspec
72
+ - Gemfile
73
+ - Guardfile
74
+ - LICENSE.txt
75
+ - README.textile
76
+ - Rakefile
77
+ - lib/rack/universal_analytics.rb
78
+ - lib/rack/universal_analytics/app.rb
79
+ - lib/rack/universal_analytics/version.rb
80
+ - rack-universal_analytics.gemspec
81
+ - spec/rack/universal_analytics_spec.rb
82
+ - spec/spec_helper.rb
83
+ homepage: https://github.com/mdeering/rack-universal_analytics
84
+ licenses:
85
+ - MIT
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ segments:
97
+ - 0
98
+ hash: 2832993106702876535
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>'
103
+ - !ruby/object:Gem::Version
104
+ version: 1.3.1
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 1.8.24
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: Rack middleware for inserting Google Universal Analytics
111
+ test_files:
112
+ - spec/rack/universal_analytics_spec.rb
113
+ - spec/spec_helper.rb