Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.7.0

* [ENHANCEMENT] support frozen string literals (also: avoid RuntimeError in Rack::Tracker#inject #114 thx @zpfled)

# 1.6.0

* [BUGFIX] set wildcard to non-greedy for GTM body insertion #107
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require 'rspec/core/rake_task'

Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rack"
require "tilt"
require "active_support/core_ext/class/attribute"
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Rack
class Tracker
module Controller
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/criteo/criteo.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::Criteo < Rack::Tracker::Handler

TRACKER_EVENTS = {
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/extensions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'ostruct'

# Backport of 2.0.0 stdlib ostruct#to_h
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/facebook/facebook.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::Facebook < Rack::Tracker::Handler
class Event < OpenStruct
def write
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/facebook_pixel/facebook_pixel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::FacebookPixel < Rack::Tracker::Handler
self.position = :body
self.allowed_tracker_options = [:id]
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/go_squared/go_squared.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::GoSquared < Rack::Tracker::Handler
class VisitorName < OpenStruct
def write
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::GoogleAdwordsConversion < Rack::Tracker::Handler
class Conversion < OpenStruct
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/google_analytics/google_analytics.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::GoogleAnalytics < Rack::Tracker::Handler

self.allowed_tracker_options = [:cookie_domain, :user_id]
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/google_tag_manager/google_tag_manager.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::GoogleTagManager < Rack::Tracker::Handler

class Push < OpenStruct
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::Handler
class << self
def process_track(env, method_name, *args, &block)
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/handler_delegator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::HandlerDelegator
class << self
def handler(method_name)
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/hotjar/hotjar.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class Rack::Tracker::Hotjar < Rack::Tracker::Handler
end
6 changes: 4 additions & 2 deletions lib/rack/tracker/javascript_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This module is extracted from Rails to provide reliable javascript escaping.
#
# @see https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/javascript_helper.rb
Expand All @@ -13,8 +15,8 @@ module Rack::Tracker::JavaScriptHelper
"'" => "\\'"
}

JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = '&#x2028;'
JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = '&#x2029;'
JS_ESCAPE_MAP["\342\200\250".dup.force_encoding(Encoding::UTF_8).encode!] = '&#x2028;'
JS_ESCAPE_MAP["\342\200\251".dup.force_encoding(Encoding::UTF_8).encode!] = '&#x2029;'

# Escapes carriage returns and single and double quotes for JavaScript segments.
#
Expand Down
2 changes: 2 additions & 0 deletions lib/rack/tracker/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Rack
class Tracker
class Railtie < ::Rails::Railtie
Expand Down
4 changes: 3 additions & 1 deletion lib/rack/tracker/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module Rack
class Tracker
VERSION = '1.6.0'
VERSION = '1.7.0'
end
end
2 changes: 2 additions & 0 deletions lib/rack/tracker/vwo/vwo.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class Rack::Tracker::Vwo < Rack::Tracker::Handler
end
2 changes: 2 additions & 0 deletions lib/rack/tracker/zanox/zanox.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Rack::Tracker::Zanox < Rack::Tracker::Handler

# name of the handler
Expand Down
2 changes: 2 additions & 0 deletions spec/benchmark/tracker_injection_benchmark.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'
require 'benchmark'

Expand Down
2 changes: 2 additions & 0 deletions spec/handler/criteo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::Criteo do

describe Rack::Tracker::Criteo::Event do
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/facebook_pixel_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::FacebookPixel do
def env
{ 'PIXEL_ID' => 'DYNAMIC_PIXEL_ID' }
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/facebook_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::Facebook do
describe Rack::Tracker::Facebook::Event do

Expand Down
2 changes: 2 additions & 0 deletions spec/handler/go_squared_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::GoSquared do

def env
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/google_adwords_conversion_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::GoogleAdwordsConversion do

def env
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/google_analytics_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::GoogleAnalytics do
def env
{
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/google_tag_manager_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::GoogleTagManager do

def env
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/handler_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::Handler do
def env
{ misc: 'foobar' }
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/hotjar_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::Hotjar do
def env
{ foo: 'bar' }
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/vwo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::Vwo do

def env
Expand Down
2 changes: 2 additions & 0 deletions spec/handler/zanox_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker::Zanox do

describe Rack::Tracker::Zanox::Sale do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/criteo_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Criteo Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/facebook_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Facebook Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/facebook_pixel_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Facebook Pixel Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/go_squared_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "GoSquared Integration" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Google Adwords Conversion Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/google_analytics_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Google Analytics Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/google_tag_manager_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Google Tag Manager Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/hotjar_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Hotjar Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/rails_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Rails Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/vwo_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "VWO Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/zanox_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/capybara_app_helper'

RSpec.describe "Zanox Integration" do
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

Expand Down
2 changes: 2 additions & 0 deletions spec/support/capybara_app_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'support/metal_controller'

# helper to configure the middleware stack with custom handlers
Expand Down
2 changes: 2 additions & 0 deletions spec/support/fake_handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class TrackAllTheThings < Rack::Tracker::Handler
def render
Tilt.new( File.join( File.dirname(__FILE__), '../fixtures/track_all_the_things.erb') ).render(self)
Expand Down
2 changes: 2 additions & 0 deletions spec/support/metal_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'action_controller'

class MetalController < ActionController::Metal
Expand Down
2 changes: 2 additions & 0 deletions spec/tracker/controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

TestController = Struct.new(:env) do
include Rack::Tracker::Controller

Expand Down
2 changes: 2 additions & 0 deletions spec/tracker/handler_delegator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Foo = Class.new
Bar = Class.new

Expand Down
2 changes: 2 additions & 0 deletions spec/tracker/handler_set_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Dummy < Rack::Tracker::Handler
end

Expand Down
10 changes: 5 additions & 5 deletions spec/tracker/javascript_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Rack::Tracker do

let(:escaper) do
Expand Down Expand Up @@ -39,13 +41,11 @@
it { should escape(%(This "thing" is really\n netos')).to %(This \\"thing\\" is really\\n netos\\') }
it { should escape(%(backslash\\test)).to %(backslash\\\\test) }
it { should escape(%(dont </close> tags)).to %(dont <\\/close> tags) }
it { should escape(%(unicode \342\200\250 newline).force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2028; newline) }
it { should escape(%(unicode \342\200\251 newline).force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2029; newline) }
it { should escape(%(unicode \342\200\250 newline).dup.force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2028; newline) }
it { should escape(%(unicode \342\200\251 newline).dup.force_encoding(Encoding::UTF_8).encode!).to %(unicode &#x2029; newline) }

it 'works with symbols' do
expect(subject).to escape(:dimension1).to 'dimension1'
end

end

end
end
1 change: 1 addition & 0 deletions spec/tracker/tracker_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class DummyHandler < Rack::Tracker::Handler
def render
Tilt.new( File.join( File.dirname(__FILE__), '../fixtures/dummy.erb') ).render(self)
Expand Down