exvo_helpers 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Note, that only significant changes are listed.
4
4
 
5
+ ## 0.3.0 (2012-04-18)
6
+
7
+ * different syntax for `google_analytics` view helper
8
+
5
9
  ## 0.2.2 (2012-01-30)
6
10
 
7
11
  * `google_analytics` view helper
data/README.md CHANGED
@@ -145,14 +145,16 @@ Note, that this helper does not support full API of Rails' `stylesheet_link_tag`
145
145
  ```
146
146
 
147
147
 
148
- ### google_analytics(domain, account)
148
+ ### google_analytics(account, opts = {})
149
149
 
150
150
  New, asynchronous Google Analytics javascript snippet to track page views. Note, that it will output the javascript analytics snippet only in production environment.
151
151
 
152
152
  ```ruby
153
- = google_analytics('exvo.com', 'UA-2491324-1')
153
+ = google_analytics('UA-2491324-1', :domain => 'none', :track_hash_changes => true)
154
154
  ```
155
155
 
156
+ =>
157
+
156
158
  ```html
157
159
  <script type="text/javascript">
158
160
  var _gaq = _gaq || [];
data/exvo_helpers.gemspec CHANGED
@@ -4,7 +4,7 @@ require "exvo_helpers/version"
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "exvo_helpers"
7
- gem.version = ExvoHelpers::VERSION
7
+ gem.version = Exvo::Helpers::VERSION
8
8
  gem.authors = ["Paweł Gościcki"]
9
9
  gem.email = ["pawel.goscicki@gmail.com"]
10
10
  gem.homepage = "https://github.com/Exvo/exvo_helpers/"
@@ -1,3 +1,5 @@
1
- module ExvoHelpers
2
- VERSION = "0.2.2"
1
+ module Exvo
2
+ module Helpers
3
+ VERSION = "0.3.0"
4
+ end
3
5
  end
@@ -27,12 +27,23 @@ module Exvo
27
27
  image_tag(Exvo::Helpers.themes_uri + '/stylesheets/images' + path, options)
28
28
  end
29
29
 
30
- def google_analytics(domain, account)
31
- script = <<END
30
+ def google_analytics(account, opts = {})
31
+ domain = opts.delete(:domain)
32
+ track_hash_changes = opts.delete(:track_hash_changes)
33
+
34
+ out = <<END
32
35
  <script type="text/javascript">
33
36
  var _gaq = _gaq || [];
34
37
  _gaq.push(['_setAccount', '#{account}']);
38
+ END
39
+
40
+ if domain
41
+ out += <<END
35
42
  _gaq.push(['_setDomainName', '#{domain}']);
43
+ END
44
+ end
45
+
46
+ out += <<END
36
47
  _gaq.push(['_setAllowLinker', true]);
37
48
  _gaq.push(['_trackPageview']);
38
49
 
@@ -41,6 +52,10 @@ module Exvo
41
52
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
42
53
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
43
54
  })();
55
+ END
56
+
57
+ if track_hash_changes
58
+ out += <<END
44
59
 
45
60
  var current_location_hash = window.location.hash;
46
61
  var update_hash = function() {
@@ -50,11 +65,15 @@ module Exvo
50
65
  }
51
66
  }
52
67
  setInterval(update_hash, 500);
68
+ END
69
+ end
70
+
71
+ out += <<END
53
72
  </script>
54
73
  END
55
74
 
56
75
  if Exvo::Helpers.env.to_sym == :production
57
- script.respond_to?(:html_safe) ? script.html_safe : script
76
+ out.respond_to?(:html_safe) ? out.html_safe : out
58
77
  end
59
78
  end
60
79
 
@@ -30,12 +30,12 @@ describe Exvo::ViewHelpers do
30
30
  end
31
31
 
32
32
  describe "#google_analytics" do
33
- let(:snippet) { view_helper.google_analytics("exvo.com", "123") }
33
+ let(:snippet) { view_helper.google_analytics("123", :domain => 'exvo.com', :track_hash_changes => true) }
34
34
 
35
- specify { snippet.should match('<script type="text/javascript">') }
36
- specify { snippet.should match("['_setAccount', 'exvo.com']") }
37
- specify { snippet.should match("['_setDomainName', '123']") }
38
- specify { snippet.should match("window.location.hash") }
35
+ specify { snippet.should match(/<script type="text\/javascript">/) }
36
+ specify { snippet.should match(/'_setAccount', '123'/) }
37
+ specify { snippet.should match(/'_setDomainName', 'exvo.com'/) }
38
+ specify { snippet.should match(/window.location.hash/) }
39
39
  end
40
40
 
41
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exvo_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-30 00:00:00.000000000Z
12
+ date: 2012-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &72764340 !ruby/object:Gem::Requirement
16
+ requirement: &29942880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.8'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *72764340
24
+ version_requirements: *29942880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard
27
- requirement: &72725620 !ruby/object:Gem::Requirement
27
+ requirement: &29942360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.10.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *72725620
35
+ version_requirements: *29942360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard-rspec
38
- requirement: &72722530 !ruby/object:Gem::Requirement
38
+ requirement: &29941880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *72722530
46
+ version_requirements: *29941880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rb-fsevent
49
- requirement: &72636770 !ruby/object:Gem::Requirement
49
+ requirement: &29941500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *72636770
57
+ version_requirements: *29941500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rb-inotify
60
- requirement: &72634350 !ruby/object:Gem::Requirement
60
+ requirement: &29941040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *72634350
68
+ version_requirements: *29941040
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &72633850 !ruby/object:Gem::Requirement
71
+ requirement: &29940620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *72633850
79
+ version_requirements: *29940620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov-rcov
82
- requirement: &72633250 !ruby/object:Gem::Requirement
82
+ requirement: &29940200 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *72633250
90
+ version_requirements: *29940200
91
91
  description: Ruby gem providing various helper methods, like auth_host, auth_uri,
92
92
  auth_require_ssl, cdn_host, etc.
93
93
  email:
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 1.8.10
134
+ rubygems_version: 1.8.16
135
135
  signing_key:
136
136
  specification_version: 3
137
137
  summary: Collection of helper methods for various Exvo related apps/services