kelredd-useful 0.3.2 → 0.3.3
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.
- data/lib/useful/erb_helpers/analytics.rb +30 -0
- data/lib/useful/ruby_extensions/string.rb +13 -0
- data/lib/useful/version.rb +1 -1
- metadata +4 -3
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'useful/erb_helpers/common'
|
2
|
+
|
3
|
+
module Useful; end
|
4
|
+
module Useful::ErbHelpers; end
|
5
|
+
|
6
|
+
module Useful::ErbHelpers::Analytics
|
7
|
+
|
8
|
+
include Useful::ErbHelpers::Common
|
9
|
+
|
10
|
+
# Use the keyed google analytics account
|
11
|
+
def google_analytics(key)
|
12
|
+
%{
|
13
|
+
<script type="text/javascript">
|
14
|
+
var _gaq = _gaq || [];
|
15
|
+
_gaq.push(['_setAccount', '#{key}']);
|
16
|
+
_gaq.push(['_trackPageview']);
|
17
|
+
|
18
|
+
(function() {
|
19
|
+
var ga = document.createElement('script');
|
20
|
+
ga.src = ('https:' == document.location.protocol ?
|
21
|
+
'https://ssl' : 'http://www') +
|
22
|
+
'.google-analytics.com/ga.js';
|
23
|
+
ga.setAttribute('async', 'true');
|
24
|
+
document.documentElement.firstChild.appendChild(ga);
|
25
|
+
})();
|
26
|
+
</script>
|
27
|
+
} if production?
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -173,6 +173,15 @@ module Useful::RubyExtensions::String
|
|
173
173
|
underscored_word.gsub(/_/, '-')
|
174
174
|
end unless ::String.respond_to?('dasherize')
|
175
175
|
|
176
|
+
# makes string suitable for a dashed url parameter string
|
177
|
+
#
|
178
|
+
# Example:
|
179
|
+
# "ActiveRecord" # => "active-record"
|
180
|
+
# "Active Record is_awesome" # => "active-record-is-awesome"
|
181
|
+
def parameterize(phrase)
|
182
|
+
phrase.underscore.gsub(/\s+/, '_').dasherize
|
183
|
+
end unless ::String.respond_to?('parameterize')
|
184
|
+
|
176
185
|
# Removes the module part from the expression in the string.
|
177
186
|
#
|
178
187
|
# Examples:
|
@@ -257,6 +266,10 @@ module Useful::RubyExtensions::String
|
|
257
266
|
self.class.dasherize(self)
|
258
267
|
end unless "".respond_to?('dasherize')
|
259
268
|
|
269
|
+
def parameterize
|
270
|
+
self.class.parameterize(self)
|
271
|
+
end unless "".respond_to?('parameterize')
|
272
|
+
|
260
273
|
def demodulize
|
261
274
|
self.class.demodulize(self)
|
262
275
|
end unless "".respond_to?('demodulize')
|
data/lib/useful/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kelly Redding
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-16 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/useful/cap_tasks/passenger_deploy.rb
|
51
51
|
- lib/useful/cap_tasks/rack_cache.rb
|
52
52
|
- lib/useful/cap_tasks.rb
|
53
|
+
- lib/useful/erb_helpers/analytics.rb
|
53
54
|
- lib/useful/erb_helpers/common.rb
|
54
55
|
- lib/useful/erb_helpers/forms.rb
|
55
56
|
- lib/useful/erb_helpers/links.rb
|