Skip to content
Browse files

Cherry picked changes by mathieuravaux: Don't monkey-patch anymore, t…

…o solve ActiveSupport conflicts.
  • Loading branch information...
2 parents 5a33af7 + 15f15e2 commit c4f02daac205fd1b0670c94a89f8b7e4f77a8682 Chris Le committed May 31, 2011
Showing with 50 additions and 35 deletions.
  1. +2 −0 Gemfile
  2. +2 −1 Rakefile
  3. +1 −1 VERSION.yml
  4. +22 −6 gattica.gemspec
  5. +1 −1 lib/gattica.rb
  6. +1 −0 lib/gattica/auth.rb
  7. +1 −1 lib/gattica/convertible.rb
  8. +0 −25 lib/gattica/core_extensions.rb
  9. +20 −0 lib/gattica/hash_extensions.rb
View
2 Gemfile
@@ -0,0 +1,2 @@
+source "http://rubygems.org"
+gemspec
View
3 Rakefile
@@ -11,7 +11,8 @@ begin
gemspec.homepage = "http://github.com/chrisle/gattica"
gemspec.description = "Gattica is a easy to use Ruby Gem for getting data from the Google Analytics API. It supports metrics, dimensions, sort, filters, goals, and segments. It can handle accounts with 1000+ profiles, and can return data in CSV, Hash, or JSON"
gemspec.authors = ["Christopher Le, et all"]
- gemspec.add_dependency 'hpricot', '>=0.8.4'
+ gemspec.add_dependency 'hpricot'
+ gemspec.add_development_dependency 'mocha'
end
rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install jeweler"
View
2 VERSION.yml
@@ -1,5 +1,5 @@
---
:major: 0
:minor: 4
-:patch: 4
+:patch: 5
:build:
View
28 gattica.gemspec
@@ -5,18 +5,19 @@
Gem::Specification.new do |s|
s.name = %q{gattica}
- s.version = "0.4.3"
+ s.version = "0.4.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Christopher Le, et all"]
- s.date = %q{2011-05-29}
+ s.date = %q{2011-05-31}
s.description = %q{Gattica is a easy to use Ruby Gem for getting data from the Google Analytics API. It supports metrics, dimensions, sort, filters, goals, and segments. It can handle accounts with 1000+ profiles, and can return data in CSV, Hash, or JSON}
s.email = %q{chrisl@seerinteractive.com}
s.extra_rdoc_files = [
"LICENSE",
"README.md"
]
s.files = [
+ "Gemfile",
"LICENSE",
"README.md",
"Rakefile",
@@ -26,11 +27,11 @@ Gem::Specification.new do |s|
"lib/gattica/account.rb",
"lib/gattica/auth.rb",
"lib/gattica/convertible.rb",
- "lib/gattica/core_extensions.rb",
"lib/gattica/data_point.rb",
"lib/gattica/data_set.rb",
"lib/gattica/engine.rb",
"lib/gattica/exceptions.rb",
+ "lib/gattica/hash_extensions.rb",
"lib/gattica/segment.rb",
"lib/gattica/settings.rb",
"lib/gattica/user.rb",
@@ -51,12 +52,27 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<hpricot>, [">= 0.8.4"])
+ s.add_runtime_dependency(%q<gattica>, [">= 0"])
+ s.add_development_dependency(%q<mocha>, [">= 0"])
+ s.add_development_dependency(%q<rake>, [">= 0"])
+ s.add_development_dependency(%q<mocha>, [">= 0"])
+ s.add_runtime_dependency(%q<hpricot>, [">= 0"])
+ s.add_development_dependency(%q<mocha>, [">= 0"])
else
- s.add_dependency(%q<hpricot>, [">= 0.8.4"])
+ s.add_dependency(%q<gattica>, [">= 0"])
+ s.add_dependency(%q<mocha>, [">= 0"])
+ s.add_dependency(%q<rake>, [">= 0"])
+ s.add_dependency(%q<mocha>, [">= 0"])
+ s.add_dependency(%q<hpricot>, [">= 0"])
+ s.add_dependency(%q<mocha>, [">= 0"])
end
else
- s.add_dependency(%q<hpricot>, [">= 0.8.4"])
+ s.add_dependency(%q<gattica>, [">= 0"])
+ s.add_dependency(%q<mocha>, [">= 0"])
+ s.add_dependency(%q<rake>, [">= 0"])
+ s.add_dependency(%q<mocha>, [">= 0"])
+ s.add_dependency(%q<hpricot>, [">= 0"])
+ s.add_dependency(%q<mocha>, [">= 0"])
end
end
View
2 lib/gattica.rb
@@ -12,7 +12,7 @@
require 'gattica/engine'
require 'gattica/settings'
require 'gattica/version'
-require 'gattica/core_extensions'
+require 'gattica/hash_extensions'
require 'gattica/convertible'
require 'gattica/exceptions'
require 'gattica/user'
View
1 lib/gattica/auth.rb
@@ -18,6 +18,7 @@ class Auth
# Try to authenticate the user
def initialize(http, user)
options = OPTIONS.merge(user.to_h)
+ options.extend HashExtensions
response, data = http.post(SCRIPT_NAME, options.to_query, HEADERS)
if response.code != '200'
View
2 lib/gattica/convertible.rb
@@ -10,7 +10,7 @@ def to_h
instance_variables.each do |var|
output.merge!({ var[1..-1] => instance_variable_get(var) }) unless var == '@xml' # exclude the whole XML dump
end
- output
+ output.tap { |h| h.include HashExtensions }
end
# output nice inspect syntax
View
25 lib/gattica/core_extensions.rb
@@ -1,25 +0,0 @@
-class Hash
-
- def to_query
- require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
- self.collect do |key, value|
- "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
- end.sort * '&'
- end
-
- def key
- self.keys.first if self.length == 1
- end
-
- def value
- self.values.first if self.length == 1
- end
-
- def stringify_keys
- inject({}) do |options, (key, value)|
- options[key.to_s] = value
- options
- end
- end
-
-end
View
20 lib/gattica/hash_extensions.rb
@@ -0,0 +1,20 @@
+module Gattica
+ module HashExtensions
+
+ def to_query
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
+ self.collect do |key, value|
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
+ end.sort * '&'
+ end
+
+ def key
+ self.keys.first if self.length == 1
+ end
+
+ def value
+ self.values.first if self.length == 1
+ end
+
+ end
+end

0 comments on commit c4f02da

Please sign in to comment.
Something went wrong with that request. Please try again.