Skip to content

Commit

Permalink
Parses out '-' and puts it before ga:
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Stenqvist committed Jul 31, 2011
1 parent 9b6fb84 commit 371635d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/garb.rb
Expand Up @@ -61,7 +61,7 @@ def read_timeout
def to_google_analytics(thing)
return thing.to_google_analytics if thing.respond_to?(:to_google_analytics)

"ga:#{thing.to_s.camelize(:lower)}"
"#{$1}ga:#{$2}" if "#{thing.to_s.camelize(:lower)}" =~ /^(-)?(.*)$/
end
alias :to_ga :to_google_analytics

Expand Down
4 changes: 4 additions & 0 deletions test/unit/garb_test.rb
Expand Up @@ -6,6 +6,10 @@ class GarbTest < MiniTest::Unit::TestCase
assert_equal '-ga:bob', Garb.to_google_analytics(stub(:to_google_analytics => '-ga:bob'))
assert_equal 'ga:bob', Garb.to_google_analytics('bob')
end

should 'parse out - and put it before ga:' do
assert_equal '-ga:pageviews', Garb.to_google_analytics('-pageviews')
end

should 'remove ga: prefix' do
assert_equal 'bob', Garb.from_google_analytics('ga:bob')
Expand Down

0 comments on commit 371635d

Please sign in to comment.