rack-avvo_ignite 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: 0a7833fa77adb8e61c450ee7231f47e138bd6466
4
+ data.tar.gz: 83e6a2ca50b1be27664301c5d088ab11f6879fc3
5
+ SHA512:
6
+ metadata.gz: e8576277af4aeed16c5b4db7fd170ffa6a34df2527d7bf5f3ea1ed5d5ab11273d5c509d181c823fe68b7534c38d2c51c40d014d6d269a2cfbb61e62991947357
7
+ data.tar.gz: 9d6dfd84c773f1fdba0a3e4f1e3f215b31b0be82bcbe7d852453856eebad1bd8a4166fd83d13ee7abe0a9d53f793701f389cc2fc62be115a1be3912fb01b5b9b
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Rack::AvvoIgnite
2
+ This Rack middleware will easily integrate your Rack-based app with Avvo Ignite's website tracking feature.
3
+
4
+ ## Usage
5
+
6
+ ### Rails
7
+ In your `application.rb`:
8
+
9
+ ```
10
+ config.middleware.use Rack::AvvoIgnite, {code: [YOUR_TRACKING_CODE]}
11
+ ```
12
+
13
+ ### Generic Rack app
14
+ In your `config.ru`:
15
+
16
+ ```
17
+ require 'rack-avvo_ignite'
18
+ use Rack::AvvoIgnite, {code: [YOUR_TRACKING_CODE]}
19
+ ```
20
+
21
+ ## What's my tracking code?
22
+
23
+ If you were given a javascript url to include you can find it embedded in the javascript url. For example, `//ia.avvo.com/tracker/FOO.js` would mean `FOO` is your tracking code.
24
+
@@ -0,0 +1,28 @@
1
+ module Rack
2
+ class AvvoIgnite
3
+
4
+ def initialize(app, options = {})
5
+ @app = app
6
+ @ignite_host = options[:host] || "ia.avvo.com"
7
+ @tracker_code = options[:code]
8
+ end
9
+
10
+ def call(env)
11
+ status, headers, response = @app.call(env)
12
+
13
+ if headers['Content-Type'].to_s.include?('text/html') # Only update HTML bodies
14
+ response.body = response.body.gsub('</body>', message + '</body>')
15
+ headers['Content-Length'] = Rack::Utils.bytesize(response.body.to_s).to_s
16
+ end
17
+
18
+ [status, headers, response]
19
+ end
20
+
21
+ private
22
+
23
+ def message
24
+ %{<script type="text/javascript">(function(){setTimeout(function(){var s = document.createElement('script');s.type="text/javascript";s.async=true;s.src="//#{@ignite_host}/tracker/#{@tracker_code}.js";var x=document.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);},1)})();</script>}
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ require 'rack/avvo_ignite'
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "rack-avvo_ignite"
3
+ s.version = "0.0.1"
4
+ s.description = "Integrate Avvo Ignite tracking into your Rack-based application"
5
+ s.summary = "Integrate Avvo Ignite tracking into your Rack-based application"
6
+ s.add_dependency "rack"
7
+
8
+ s.author = "Jeff Ching"
9
+ s.email = "jeff@chingr.com"
10
+ s.homepage = "http://github.com/chingor13/rack-avvo_ignite"
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.require_paths = ["lib"]
15
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-avvo_ignite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Ching
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
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
+ description: Integrate Avvo Ignite tracking into your Rack-based application
28
+ email: jeff@chingr.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - Gemfile
34
+ - README.md
35
+ - lib/rack-avvo_ignite.rb
36
+ - lib/rack/avvo_ignite.rb
37
+ - rack-avvo_ignite.gemspec
38
+ homepage: http://github.com/chingor13/rack-avvo_ignite
39
+ licenses: []
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 2.0.3
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Integrate Avvo Ignite tracking into your Rack-based application
61
+ test_files: []