liquid-google-analytics 1.0.2 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7c273aa60e52b1088e7b169a0303d266a0f7d3f
4
- data.tar.gz: 477623cbe78725cb3c9270a36a349950643fdf59
3
+ metadata.gz: 64ca365e7fd75238fbf47bed6e2ea4433497a3bc
4
+ data.tar.gz: ddce2d7e49b77b1acb6197de0f1f33d805e93b70
5
5
  SHA512:
6
- metadata.gz: aa7ad8424e9ffc9144b5e7a9745059799cc9faba2a927d41a98247731c2936b78fb333d2aa0b19bdd176416a7b42b1aa10c4f367b5cc326f42d22b1dd7e1d685
7
- data.tar.gz: 662152dbf0b1058fb57fa5a74727b2ceb1593c8a49a7ba3d1ef5c8f7c17bef8a81095d4eed16cc577456526499dee651514a6be1439c4b184c8d971d9005b7f4
6
+ metadata.gz: e5e498809aaa1955e730316fef4b695e91797cb0a78bee7a61c5c23738b48ab71d890c3cb6ceabcd102f953e2230e6eccb1f122cf4f66496e617e2ff38eb579d
7
+ data.tar.gz: 55ac4295ca2790824d3b9b18ada967274202c7ac589936b65642077d94a4ba7165567f6138d1854534934afcdfd33423858dcce23234280ab02c921984ec3be0
data/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Rohan Sakhale
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Rohan Sakhale
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,46 +1,60 @@
1
- # Liquid Google Analytics Tag
2
-
3
- This plugin helps generate Google Analytics code snippet easily as a Liquid Tag call
4
-
5
- ### Installation
6
-
7
- This plugin is available as a [RubyGem](https://rubygems.org/gems/liquid-google-analytics/)
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```
12
- gem 'liquid-google-analytics'
13
- ```
14
-
15
- And then execute the `bundle install` command to install the gem.
16
-
17
- Alternatively, you can also manually install the gem using the following command:
18
-
19
- ```
20
- $ gem install liquid-google-analytics
21
- ```
22
-
23
- For Jekyll Users, after the plugin has been installed successfully, add the following lines to your _config.yml in order to tell Jekyll to use the plugin:
24
-
25
- ```yaml
26
- gems:
27
- - liquid-google-analytics
28
- ```
29
-
30
- ### Usage
31
-
32
- You need to use `google_analytics` as liquid tag and pass the Tracking Code as parameter shown below
33
-
34
- ```
35
- {{ google_analytics UA-12345 }}
36
- ```
37
-
38
- ### Contribute
39
-
40
- Fork this repository, make your changes and then issue a pull request. If you find bugs or have new ideas that you do not want to implement yourself, file a bug report.
41
-
42
- ### Copyright
43
-
44
- Copyright (c) 2015 Rohan Sakhale
45
-
46
- License: MIT
1
+ # Liquid Google Analytics Tag [![build status](https://gitlab.com/SaiAshirwadInformatia/LiquidGoogleAnalytics/badges/master/build.svg)](https://gitlab.com/SaiAshirwadInformatia/LiquidGoogleAnalytics/commits/master) [![Gem Version](https://badge.fury.io/rb/liquid-google-analytics.svg)](https://badge.fury.io/rb/liquid-google-analytics) [![coverage report](https://gitlab.com/SaiAshirwadInformatia/LiquidGoogleAnalytics/badges/master/coverage.svg)](https://gitlab.com/SaiAshirwadInformatia/LiquidGoogleAnalytics/commits/master)
2
+
3
+ This plugin helps generate Google Analytics code snippet easily with the help of Liquid Tag or Liquid Variable Filter
4
+
5
+ ### Installation
6
+
7
+ This plugin is available as a [RubyGem](https://rubygems.org/gems/liquid-google-analytics/)
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```
12
+ gem 'liquid-google-analytics'
13
+ ```
14
+
15
+ And then execute the `bundle install` command to install the gem.
16
+
17
+ Alternatively, you can also manually install the gem using the following command:
18
+
19
+ ```
20
+ $ gem install liquid-google-analytics
21
+ ```
22
+
23
+ For Jekyll Users, after the plugin has been installed successfully, add the following lines to your _config.yml in order to tell Jekyll to use the plugin:
24
+
25
+ ```yaml
26
+ gems:
27
+ - liquid-google-analytics
28
+ ```
29
+
30
+ ### Usage
31
+
32
+ You need to use `google_analytics` as liquid tag and pass the Tracking Code as parameter shown below
33
+
34
+ ```
35
+ {% google_analytics UA-12345 %}
36
+ ```
37
+
38
+ ### Alternate
39
+
40
+ Optionally now you can also maintain Google Analytics code in config and use filter for variable as below
41
+
42
+ ```yaml
43
+ ga_code: UA-12345
44
+ ```
45
+
46
+ ```
47
+ {{ site.ga_code | google_analytics }}
48
+ ```
49
+
50
+ ### Contribute
51
+
52
+ Fork this repository, create your branch, make changes and then issue a pull request.
53
+
54
+ If you find bugs or have new ideas that you do not want to implement yourself, file a bug report.
55
+
56
+ ### Copyright
57
+
58
+ Copyright (c) 2016 Rohan Sakhale
59
+
60
+ License: [MIT](LICENSE.md)
@@ -1,5 +1,6 @@
1
- # Generate script code for Google Analytics with Liquid Tag
2
- require 'liquid'
3
- require 'liquid/google_analytics'
4
-
5
- Liquid::Template.register_tag 'google_analytics', Liquid::GoogleAnalytics
1
+ # Generate script code for Google Analytics with Liquid Tag
2
+ require 'liquid'
3
+ require 'liquid/google_analytics'
4
+
5
+ Liquid::Template.register_tag 'google_analytics', Liquid::GoogleAnalyticsTag
6
+ Liquid::Template.register_filter(GoogleAnalyticsFilterModule)
@@ -1,30 +1,50 @@
1
-
2
- module Liquid
3
- class GoogleAnalytics < Liquid::Tag
4
- TEMPLATE = <<-EOF
5
- <script>
6
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
7
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
8
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
9
- })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
10
-
11
- ga('create', '%s', 'auto');
12
- ga('send', 'pageview');
13
-
14
- </script>
15
- EOF
16
-
17
- def initialize(tag_name, tracking_code, tokens)
18
- super
19
- @tracking_code = tracking_code.to_s.strip
20
- end
21
-
22
- def render(context)
23
- code = ""
24
- if @tracking_code
25
- code = format(TEMPLATE, @tracking_code)
26
- end
27
- code
28
- end
29
- end
1
+ module LiquidGoogleAnalytics
2
+ TEMPLATE = <<-EOF
3
+ <script>
4
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
8
+
9
+ ga('create', '%s', 'auto');
10
+ ga('send', 'pageview');
11
+
12
+ </script>
13
+ EOF
14
+ end
15
+ module GoogleAnalyticsFilterModule
16
+
17
+ def google_analytics(input)
18
+ code = ""
19
+ code = format(LiquidGoogleAnalytics::TEMPLATE, input)
20
+ code
21
+ end
22
+ end
23
+
24
+ module Liquid
25
+
26
+ class GoogleAnalyticsTag < Liquid::Tag
27
+
28
+ def initialize(tag_name, markup, options)
29
+ super
30
+ tracking_parsed_code = Liquid::Template.parse(markup.to_s.strip).render
31
+ unless tracking_parsed_code
32
+ tracking_parsed_code = markup.to_s.strip
33
+ end
34
+ @tracking_code = tracking_parsed_code
35
+ end
36
+
37
+ def render(context)
38
+ code = ""
39
+ if context['code']
40
+ @tracking_code = context['code']
41
+ elsif context['tracking_code']
42
+ @tracking_code = context['tracking_code']
43
+ end
44
+ if @tracking_code
45
+ code = format(LiquidGoogleAnalytics::TEMPLATE, @tracking_code)
46
+ end
47
+ code
48
+ end
49
+ end
30
50
  end
@@ -1,6 +1,6 @@
1
-
2
- module Liquid
3
- class GoogleAnalytics
4
- VERSION = "1.0.2".freeze
5
- end
1
+
2
+ module Liquid
3
+ class GoogleAnalytics
4
+ VERSION = "1.1.0".freeze
5
+ end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid-google-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rohan Sakhale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-18 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: 3.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: 3.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 5.9.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.12.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.12.0
69
83
  description: Generate Google Analytics Script code with simple Liquid Tag
70
84
  email: rohansakhale@gmail.com
71
85
  executables: []
@@ -98,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
112
  version: '0'
99
113
  requirements: []
100
114
  rubyforge_project:
101
- rubygems_version: 2.4.5
115
+ rubygems_version: 2.5.1
102
116
  signing_key:
103
117
  specification_version: 4
104
118
  summary: Generate Google Analytics Script code with simple Liquid Tag