google_analytics_mailer 0.1.2 → 0.2.0

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzgzNzRjMDNlNDg2ODlhMTE2MGE3MGFjOTY5ZjU5Y2U1YTViNDY1OQ==
5
+ data.tar.gz: !binary |-
6
+ NzVmNmI0NjRhMzg0NmRkYjIwMDNhZTk0NDVhOTFiMzFkOTk5OGEwMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Y2IzMGI1ZTlmYmZjZDBiNDViNDhlN2JjMDIxM2NhMWY3Y2JlMTFjNTdkY2Zl
10
+ ZmRiYTllZTRiYWFjZDhiNTJkMWE5Y2I5YzRlODdlMWZiMThhMjI2OTE5ZGMy
11
+ NWUxZjZhNjYyMzZiYTdmODA5ODAzNTMyYzAxNzNhYjJmZmVlYmQ=
12
+ data.tar.gz: !binary |-
13
+ ZjRlM2M2MTBmOTk4ZTk5YzI4YmFkZmY0ZTcyZmY1ZjQ2OTlhYjY1NDM3N2Jl
14
+ MTMzMzhhZjRhOTRkNjMwN2E5OTg0ZmMxOTE3NDBmMTdkMDMzN2JjZjJjMTdi
15
+ ZGQyODE5MmRkNDJhOTMxOTA4MDI2M2U4NmI3Nzg1OTNmNzQwNWM=
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --main Readme.md
2
+ --files=Changelog.md
data/Changelog.md CHANGED
@@ -1,3 +1,13 @@
1
+ Not released changes
2
+
3
+ ## 0.2.0, released 2013-09-28
4
+
5
+ * Inserted rspec-rails as development dependency to allow easier testing of helper methods
6
+ * Now view helpers use output buffering to allow inline usage. It means that they must be used with equal sign in ERB templates
7
+ * Allow disabling gem for a block of code with helper `without_google_analytics_params`
8
+ * Allow usage also in controllers since they have the same structure of `ActionMailer::Base`
9
+ * Extracted uri parser in its own class
10
+
1
11
  ## 0.1.2, released 2013-09-26
2
12
 
3
13
  * Removed blank params from generated urls
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in google_analytics_mailer.gemspec
4
4
  gemspec
5
+
6
+ # used locally for documentation
7
+ gem 'redcarpet'
8
+ gem 'yard'
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # GoogleAnalyticsMailer [![Build Status](https://secure.travis-ci.org/fabn/google_analytics_mailer.png)](http://travis-ci.org/fabn/google_analytics_mailer)
2
2
 
3
- This gem automatically rewrites **absolute** links generated by ActionMailer. It intercepts all'`url_for` calls (so `link_to` calls are intercepted as well) and change the final url to add [Custom Campaign parameters](http://support.google.com/analytics/bin/answer.py?hl=en&answer=1033867) to your URLs.
3
+ This gem automatically rewrites **absolute** links generated by ActionMailer. It intercepts all'`url_for` calls (so `link_to` calls are intercepted as well)
4
+ and change the final url to add [Custom Campaign parameters](http://support.google.com/analytics/bin/answer.py?hl=en&answer=1033867) to your URLs.
4
5
 
5
6
  ## Installation
6
7
 
@@ -71,13 +72,45 @@ At view level you can override generated parameters using the `with_google_analy
71
72
 
72
73
  ```erb
73
74
  <div class="footer">
74
- <%- with_google_analytics_params(utm_term: 'footer') do -%>
75
+ <%= with_google_analytics_params(utm_term: 'footer') do -%>
75
76
  <!-- this will override other params and produces ?utm_medium=email&utm_source=newsletter&utm_term=footer -->
76
77
  <%= link_to('Read online', newsletter_url) -%>
77
78
  <%- end -%>
78
79
  </div>
79
80
  ```
80
81
 
82
+ or you can disable them for a specific block
83
+
84
+ ```erb
85
+ <div class="footer">
86
+ <%= without_google_analytics_params do -%>
87
+ <!-- this will output link with no analytics params at all -->
88
+ <%= link_to('Read online', newsletter_url) -%>
89
+ <%- end -%>
90
+ </div>
91
+ ```
92
+
93
+ ## Action Controller integration
94
+
95
+ Since ActionMailer and ActionController use the same code base to provide view rendering this gem can be used in the
96
+ same way in any action controller which inherits from `ActionController::Base` (i.e. almost every controller in a
97
+ Rails application). The alias `google_analytics_controller` is provided for better compatibility thus in a controller
98
+
99
+ ```ruby
100
+ class UserController < ApplicationController
101
+
102
+ # declare url parameters for this controller. Absolute links in this controller will be tagged with GA parameters
103
+ google_analytics_controller utm_source: 'some site', utm_medium: 'web' # etc
104
+
105
+ # Override for single action
106
+ def index
107
+ google_analytics_params(utm_source: 'index page', utm_term: 'foo bar')
108
+ end
109
+ end
110
+ ```
111
+
112
+ View syntax is obviously the same as in mailer.
113
+
81
114
  ## Contributing
82
115
 
83
116
  1. Fork it
@@ -4,27 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'google_analytics_mailer/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "google_analytics_mailer"
7
+ gem.name = 'google_analytics_mailer'
8
8
  gem.version = GoogleAnalyticsMailer::VERSION
9
- gem.authors = ["Fabio Napoleoni"]
10
- gem.email = ["f.napoleoni@gmail.com"]
9
+ gem.authors = ['Fabio Napoleoni']
10
+ gem.email = ['f.napoleoni@gmail.com']
11
11
  gem.description = %q{This gem add google analytics campagin tags to every link in your action mailer}
12
12
  gem.summary = %q{This gem provides automatic Google Analytics tagged links in ActionMailer generated emails}
13
- gem.homepage = "https://github.com/fabn/google_analytics_mailer"
13
+ gem.homepage = 'https://github.com/fabn/google_analytics_mailer'
14
14
  gem.license = 'MIT'
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ["lib"]
19
+ gem.require_paths = ['lib']
20
20
 
21
21
  # gem dependencies for runtime
22
- gem.add_runtime_dependency "addressable", "~> 2.3.0"
23
- gem.add_runtime_dependency "actionmailer", ">= 3.2.0"
22
+ gem.add_runtime_dependency 'addressable', '~> 2.3.0'
23
+ gem.add_runtime_dependency 'actionmailer', '>= 3.2.0'
24
24
 
25
25
  # gem dependencies for development
26
- gem.add_development_dependency "rake"
27
- gem.add_development_dependency "rspec", "~> 2.12.0"
28
- gem.add_development_dependency "email_spec", "~> 1.2.0"
26
+ gem.add_development_dependency 'rake'
27
+ gem.add_development_dependency 'rails', '>= 3.2.0'
28
+ gem.add_development_dependency 'rspec-rails', '~> 2.13.0'
29
+ gem.add_development_dependency 'email_spec', '~> 1.2.0'
29
30
  gem.add_development_dependency 'appraisal'
30
31
  end
@@ -0,0 +1,25 @@
1
+ require 'addressable/uri'
2
+
3
+ # Class used to do the actual insertion of parameters
4
+ class GoogleAnalyticsMailer::UriBuilder
5
+
6
+ # Append google analytics params to the given uri
7
+ # @param [String] uri the original uri
8
+ # @param [Hash] params options for url to build
9
+ # @option params [String] :utm_campaign required is the main GA param
10
+ # @option params [String] :utm_content content of the campaign
11
+ # @option params [String] :utm_source campaign source
12
+ # @option params [String] :utm_medium campaign medium
13
+ # @option params [String] :utm_term keyword for this campaign
14
+ def build(uri, params)
15
+ # remove empty GA params
16
+ params.delete_if { |_, v| v.blank? }
17
+ # if no params return untouched url
18
+ return uri if params.empty?
19
+ # build the final url
20
+ ::Addressable::URI.parse(uri).tap do |parsed|
21
+ parsed.query_values = (parsed.query_values || {}).reverse_merge(params) if parsed.absolute?
22
+ end.to_s.html_safe
23
+ end
24
+
25
+ end
@@ -1,5 +1,3 @@
1
- require "addressable/uri"
2
-
3
1
  module GoogleAnalyticsMailer # :nodoc:
4
2
 
5
3
  # This module is added as helper to ActionMailer objects and override
@@ -14,27 +12,69 @@ module GoogleAnalyticsMailer # :nodoc:
14
12
  params_to_add = controller.computed_analytics_params.with_indifferent_access
15
13
  # temporary override coming from with_google_analytics_params method
16
14
  params_to_add.merge!(@_override_ga_params) if @_override_ga_params.try(:any?)
17
- # remove empty GA params
18
- params_to_add.delete_if { |_, v| v.blank? }
19
- # if there are no parameters return super value
20
- if params_to_add.empty?
21
- super(original_url)
22
- else
23
- # else parse the url and append given parameters
24
- ::Addressable::URI.parse(super(original_url)).tap do |url|
25
- url.query_values = (url.query_values || {}).reverse_merge(params_to_add) if url.absolute?
26
- end.to_s.html_safe
27
- end
15
+ # Avoid parse if params not given
16
+ params_to_add.empty? ? super(original_url) : builder.build(super(original_url), params_to_add)
28
17
  end
29
18
 
30
- # Allow to override Google Analytics params for a given block in views
31
- # @return [String]
32
- def with_google_analytics_params(params)
33
- raise ArgumentError, "Missing block" unless block_given?
19
+ # Acts as an around filter from the given block and return its content
20
+ # by merging the given analytics parameters to current ones
21
+ #
22
+ # @param [Hash] params options for url to build
23
+ # @option params [String] :utm_campaign required is the main GA param
24
+ # @option params [String] :utm_content content of the campaign
25
+ # @option params [String] :utm_source campaign source
26
+ # @option params [String] :utm_medium campaign medium
27
+ # @option params [String] :utm_term keyword for this campaign
28
+ #
29
+ # @yield The given block is executed with overridden analytics parameters
30
+ # @yieldreturn [String] content returned from the block with filtered parameters
31
+ #
32
+ # @example in an ERB template
33
+ # <%= with_google_analytics_params(utm_content: 'foo') do -%>
34
+ # <%= link_to 'foo', 'http://example.com' -%>
35
+ # <%- end -%>
36
+ #
37
+ # @example Inline usage now possible because of captured output
38
+ # <%= with_google_analytics_params(utm_content: 'foo') { link_to ... } -%>
39
+ #
40
+ # @return [String] the output returned by block
41
+ def with_google_analytics_params(params, &block)
42
+ raise ArgumentError, 'Missing block' unless block_given?
34
43
  @_override_ga_params = params
35
- yield
44
+ capture(&block)
45
+ ensure
46
+ @_override_ga_params = nil
47
+ end
48
+
49
+ # Acts as an around filter from the given block and return its content
50
+ # without inserting any analytics tag
51
+ #
52
+ # @yield The given block is executed with appeding analytics parameters
53
+ # @yieldreturn [String] content returned from the block with no parameters appended
54
+ #
55
+ # @example in an ERB template
56
+ # <%= without_google_analytics_params(utm_content: 'foo') do -%>
57
+ # <%= link_to 'foo', 'http://example.com' -%>
58
+ # <%- end -%>
59
+ #
60
+ # @example Inline usage now possible because of captured output
61
+ # <%= without_google_analytics_params(utm_content: 'foo') { link_to ... } -%>
62
+ #
63
+ # @return [String] the output of the block executed without analytics params
64
+ def without_google_analytics_params(&block)
65
+ raise ArgumentError, 'Missing block' unless block_given?
66
+ @_override_ga_params = Hash[VALID_ANALYTICS_PARAMS.zip([nil])]
67
+ capture(&block)
68
+ ensure
36
69
  @_override_ga_params = nil
37
- nil # do not return any value
70
+ end
71
+
72
+ private
73
+
74
+ # Return a UriBuilder instance
75
+ # @return [UriBuilder]
76
+ def builder
77
+ @_builder ||= UriBuilder.new
38
78
  end
39
79
 
40
80
  end
@@ -1,3 +1,4 @@
1
1
  module GoogleAnalyticsMailer
2
- VERSION = "0.1.2"
2
+ # Application version
3
+ VERSION = '0.2.0'
3
4
  end
@@ -1,18 +1,25 @@
1
- require "google_analytics_mailer/version"
2
- require "google_analytics_mailer/url_for"
3
- require "action_mailer"
4
- require "active_support/concern"
1
+ require 'google_analytics_mailer/version'
2
+ require 'google_analytics_mailer/url_for'
3
+ require 'google_analytics_mailer/uri_builder'
4
+ require 'action_mailer'
5
+ require 'active_support/concern'
5
6
 
6
7
  # This module declares the main class method which is then callable from every
7
- # ActionMailer class
8
+ # ActionMailer class and in ActionController::Base if available.
8
9
  module GoogleAnalyticsMailer
9
10
 
10
11
  # These are the currently GA allowed get params for link tagging
11
- VALID_ANALYTICS_PARAMS = [:utm_source, :utm_medium, :utm_campaign,
12
- :utm_term, :utm_content]
12
+ VALID_ANALYTICS_PARAMS = [:utm_source, :utm_medium, :utm_campaign, :utm_term, :utm_content]
13
13
 
14
- # Enable google analytics link tagging for the mailer which call this method
15
- def google_analytics_mailer params = {}
14
+ # Enable google analytics link tagging for the mailer (or controller) which call this method
15
+ #
16
+ # @param [Hash] params options for url to build
17
+ # @option params [String] :utm_campaign required is the main GA param
18
+ # @option params [String] :utm_content content of the campaign
19
+ # @option params [String] :utm_source campaign source
20
+ # @option params [String] :utm_medium campaign medium
21
+ # @option params [String] :utm_term keyword for this campaign
22
+ def google_analytics_mailer(params = {})
16
23
  if (params.keys - VALID_ANALYTICS_PARAMS).any?
17
24
  raise ArgumentError, "Invalid parameters keys #{params.keys - VALID_ANALYTICS_PARAMS}"
18
25
  end
@@ -25,6 +32,9 @@ module GoogleAnalyticsMailer
25
32
 
26
33
  end
27
34
 
35
+ # Allow usage also in controllers since they have the same structure of ActionMailer
36
+ alias_method :google_analytics_controller, :google_analytics_mailer
37
+
28
38
  # This module provides methods to deal with parameter merging and similar stuff
29
39
  module GoogleAnalytics
30
40
 
@@ -53,4 +63,7 @@ module GoogleAnalyticsMailer
53
63
  end
54
64
 
55
65
  # Add the class method to ActionMailer::Base
56
- ActionMailer::Base.send :extend, GoogleAnalyticsMailer
66
+ ActionMailer::Base.send :extend, GoogleAnalyticsMailer
67
+
68
+ # Allow usage also in application controller if required in dependencies
69
+ ActionController::Base.send :extend, GoogleAnalyticsMailer if defined?(ActionController::Base)
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoogleAnalyticsMailer::UrlFor do
4
+
5
+ before(:each) do
6
+ controller.stub(computed_analytics_params: {utm_source: 'foo'})
7
+ end
8
+
9
+ describe '#with_google_analytics_params' do
10
+
11
+ it 'should override used parameters while in the block' do
12
+ helper.with_google_analytics_params utm_source: 'bar' do
13
+ helper.url_for('http://www.example.com').should include 'utm_source=bar'
14
+ end
15
+ helper.url_for('http://www.example.com').should include 'utm_source=foo'
16
+ end
17
+
18
+ end
19
+
20
+ describe '#without_google_analytics_params' do
21
+
22
+ it 'should ignore analytic params in the block' do
23
+ helper.without_google_analytics_params do
24
+ helper.url_for('http://www.example.com').should == 'http://www.example.com'
25
+ end
26
+ helper.url_for('http://www.example.com').should include 'utm_source=foo'
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -2,27 +2,31 @@ require 'spec_helper'
2
2
 
3
3
  describe GoogleAnalyticsMailer do
4
4
 
5
- it "ActionMailer::Base should extend GoogleAnalyticsMailer" do
5
+ it 'ActionMailer::Base should extend GoogleAnalyticsMailer' do
6
6
  (class << ActionMailer::Base; self end).included_modules.should include(GoogleAnalyticsMailer)
7
7
  end
8
8
 
9
- describe ".google_analytics_mailer" do
9
+ describe '.google_analytics_mailer' do
10
10
 
11
11
  class TestMailer1 < ActionMailer::Base
12
12
  end
13
13
 
14
- it "should raise on invalid options for GA params" do
14
+ it 'should raise on invalid options for GA params' do
15
15
  expect {
16
16
  ActionMailer::Base.google_analytics_mailer(foo: 'bar')
17
17
  }.to raise_error(ArgumentError, /:foo/)
18
18
  end
19
19
 
20
- it "should assign given parameters to a class variable" do
20
+ it 'should assign given parameters to a class variable' do
21
21
  params = {utm_source: 'newsletter', utm_medium: 'email'}
22
22
  TestMailer1.google_analytics_mailer(params)
23
23
  TestMailer1.google_analytics_class_params.should == params
24
24
  end
25
25
 
26
+ it 'should be aliased to google_analytics_controller' do
27
+ ActionMailer::Base.should respond_to :google_analytics_controller
28
+ end
29
+
26
30
  end
27
31
 
28
32
  class UserMailer < ActionMailer::Base
@@ -59,41 +63,41 @@ describe GoogleAnalyticsMailer do
59
63
  describe UserMailer do
60
64
 
61
65
  # see view in spec/support/views/user_mailer/welcome.html.erb
62
- describe "#welcome" do
66
+ describe '#welcome' do
63
67
 
64
68
  subject { UserMailer.welcome }
65
69
 
66
- it "should have analytics link with params taken from class definition" do
70
+ it 'should have analytics link with params taken from class definition' do
67
71
  subject.should have_body_text 'http://www.example.com/newsletter?utm_medium=email&utm_source=newsletter'
68
72
  end
69
73
 
70
- it "should have analytics link with overridden params" do
74
+ it 'should have analytics link with overridden params' do
71
75
  subject.should have_body_text 'http://www.example.com/newsletter?utm_medium=email&utm_source=my_newsletter'
72
76
  end
73
77
 
74
78
  end
75
79
 
76
80
  # see view in spec/support/views/user_mailer/welcome2.html.erb
77
- describe "#welcome2" do
81
+ describe '#welcome2' do
78
82
 
79
83
  subject { UserMailer.welcome2 }
80
84
 
81
- it "should have analytics link with params taken from instance" do
85
+ it 'should have analytics link with params taken from instance' do
82
86
  subject.should have_body_text 'http://www.example.com/newsletter?utm_medium=email&utm_source=second_newsletter&utm_term=welcome2'
83
87
  end
84
88
 
85
- it "should have analytics link with overridden params" do
89
+ it 'should have analytics link with overridden params' do
86
90
  subject.should have_body_text 'http://www.example.com/newsletter?utm_medium=email&utm_source=my_newsletter&utm_term=welcome2'
87
91
  end
88
92
 
89
93
  end
90
94
 
91
95
  # see view in spec/support/views/user_mailer/welcome3.html.erb
92
- describe "#welcome3" do
96
+ describe '#welcome3' do
93
97
 
94
98
  subject { UserMailer.welcome3 }
95
99
 
96
- it "should have analytics link with params taken from view" do
100
+ it 'should have analytics link with params taken from view' do
97
101
  subject.should have_body_text 'http://www.example.com/newsletter?utm_medium=email&utm_source=newsletter&utm_term=footer'
98
102
  end
99
103
 
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoogleAnalyticsMailer::UriBuilder do
4
+
5
+ describe '#build' do
6
+
7
+ it 'should not include blank GA params' do
8
+ subject.build('http://www.example.com', utm_campaign: nil).should_not include 'utm_campaign'
9
+ end
10
+
11
+ it 'should uri encode GA parameter values' do
12
+ subject.build('http://www.example.com', utm_campaign: 'Foo Bar').should include 'utm_campaign=Foo%20Bar'
13
+ end
14
+
15
+ it 'should not add GA parameters if uri is not absolute' do
16
+ subject.build('/some/path', utm_campaign: 'abc').should == '/some/path'
17
+ end
18
+
19
+ it 'should not touch uri with empty params' do
20
+ subject.build('http://www.example.com', {}).should == 'http://www.example.com'
21
+ end
22
+
23
+ end
24
+
25
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,16 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
3
 
4
4
  # Gem main file
5
5
  require 'google_analytics_mailer'
6
6
  require 'active_support/all'
7
7
  require 'email_spec'
8
+ require 'rails/all'
9
+ require 'rspec/rails'
8
10
 
9
11
  # Requires supporting ruby files with custom matchers and macros, etc,
10
12
  # in spec/support/ and its subdirectories.
11
- Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }
13
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
12
14
 
13
15
  # Configure action mailer for test deliveries
14
16
  ActionMailer::Base.delivery_method = :test
@@ -3,7 +3,7 @@
3
3
  <p>Lorem ipsum</p>
4
4
  </div>
5
5
  <div class="footer">
6
- <%- with_google_analytics_params(utm_term: 'footer') do -%>
6
+ <%= with_google_analytics_params(utm_term: 'footer') do -%>
7
7
  <!-- this will override params and produces ?utm_medium=email&utm_source=newsletter&utm_term=footer -->
8
8
  <%= link_to('Read online', newsletter_url) -%>
9
9
  <%- end -%>
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_analytics_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fabio Napoleoni
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2013-09-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: addressable
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: actionmailer
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,31 +48,41 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
- name: rspec
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
73
  - - ~>
68
74
  - !ruby/object:Gem::Version
69
- version: 2.12.0
75
+ version: 2.13.0
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
80
  - - ~>
76
81
  - !ruby/object:Gem::Version
77
- version: 2.12.0
82
+ version: 2.13.0
78
83
  - !ruby/object:Gem::Dependency
79
84
  name: email_spec
80
85
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
86
  requirements:
83
87
  - - ~>
84
88
  - !ruby/object:Gem::Version
@@ -86,7 +90,6 @@ dependencies:
86
90
  type: :development
87
91
  prerelease: false
88
92
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
93
  requirements:
91
94
  - - ~>
92
95
  - !ruby/object:Gem::Version
@@ -94,7 +97,6 @@ dependencies:
94
97
  - !ruby/object:Gem::Dependency
95
98
  name: appraisal
96
99
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
100
  requirements:
99
101
  - - ! '>='
100
102
  - !ruby/object:Gem::Version
@@ -102,7 +104,6 @@ dependencies:
102
104
  type: :development
103
105
  prerelease: false
104
106
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
107
  requirements:
107
108
  - - ! '>='
108
109
  - !ruby/object:Gem::Version
@@ -119,6 +120,7 @@ files:
119
120
  - .rspec
120
121
  - .rvmrc
121
122
  - .travis.yml
123
+ - .yardopts
122
124
  - Appraisals
123
125
  - Changelog.md
124
126
  - Gemfile
@@ -129,10 +131,12 @@ files:
129
131
  - gemfiles/actionmailer4_0.gemfile
130
132
  - google_analytics_mailer.gemspec
131
133
  - lib/google_analytics_mailer.rb
134
+ - lib/google_analytics_mailer/uri_builder.rb
132
135
  - lib/google_analytics_mailer/url_for.rb
133
136
  - lib/google_analytics_mailer/version.rb
137
+ - spec/helpers/url_for_spec.rb
134
138
  - spec/lib/google_analytics_mailer_spec.rb
135
- - spec/lib/url_for_spec.rb
139
+ - spec/lib/uri_builder_spec.rb
136
140
  - spec/spec_helper.rb
137
141
  - spec/support/views/user_mailer/welcome.html.erb
138
142
  - spec/support/views/user_mailer/welcome2.html.erb
@@ -140,33 +144,34 @@ files:
140
144
  homepage: https://github.com/fabn/google_analytics_mailer
141
145
  licenses:
142
146
  - MIT
147
+ metadata: {}
143
148
  post_install_message:
144
149
  rdoc_options: []
145
150
  require_paths:
146
151
  - lib
147
152
  required_ruby_version: !ruby/object:Gem::Requirement
148
- none: false
149
153
  requirements:
150
154
  - - ! '>='
151
155
  - !ruby/object:Gem::Version
152
156
  version: '0'
153
157
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
158
  requirements:
156
159
  - - ! '>='
157
160
  - !ruby/object:Gem::Version
158
161
  version: '0'
159
162
  requirements: []
160
163
  rubyforge_project:
161
- rubygems_version: 1.8.25
164
+ rubygems_version: 2.1.5
162
165
  signing_key:
163
- specification_version: 3
166
+ specification_version: 4
164
167
  summary: This gem provides automatic Google Analytics tagged links in ActionMailer
165
168
  generated emails
166
169
  test_files:
170
+ - spec/helpers/url_for_spec.rb
167
171
  - spec/lib/google_analytics_mailer_spec.rb
168
- - spec/lib/url_for_spec.rb
172
+ - spec/lib/uri_builder_spec.rb
169
173
  - spec/spec_helper.rb
170
174
  - spec/support/views/user_mailer/welcome.html.erb
171
175
  - spec/support/views/user_mailer/welcome2.html.erb
172
176
  - spec/support/views/user_mailer/welcome3.html.erb
177
+ has_rdoc:
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # Mock helper used to test module methods
4
- # @see http://stackoverflow.com/questions/5944278/overriding-method-by-another-defined-in-module
5
- class MockHelper
6
- # No op implementation of url_for
7
- def url_for(url)
8
- url
9
- end
10
-
11
- # Used by implementation
12
- def controller
13
- self
14
- end
15
-
16
- def computed_analytics_params
17
- {}.with_indifferent_access
18
- end
19
- end
20
-
21
- describe GoogleAnalyticsMailer::UrlFor do
22
-
23
- let(:dummy_class) { Class.new(MockHelper) { include GoogleAnalyticsMailer::UrlFor } }
24
- let(:subject) { dummy_class.new }
25
-
26
- describe '#url_for' do
27
-
28
- it 'should not include blank GA params' do
29
- subject.stub(computed_analytics_params: {utm_campaign: nil})
30
- subject.url_for('http://www.example.com').should_not include 'utm_campaign'
31
- end
32
-
33
- it 'should uri encode GA parameter values' do
34
- subject.stub(computed_analytics_params: {utm_campaign: 'Foo Bar'})
35
- subject.url_for('http://www.example.com').should include 'utm_campaign=Foo%20Bar'
36
- end
37
-
38
- end
39
-
40
- end