diff --git a/.gitignore b/.gitignore index 00c0b86..f7e5f18 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ coverage rdoc pkg +Gemfile.lock diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e0a7662 --- /dev/null +++ b/Gemfile @@ -0,0 +1 @@ +gemspec diff --git a/README.markdown b/README.markdown index 5260628..a16b69c 100644 --- a/README.markdown +++ b/README.markdown @@ -10,10 +10,17 @@ Installation Dependencies ------------ -* active_support -* [shoulda](http://github.com/thoughtbot/shoulda/) (used in tests only) -* [matchy](http://github.com/jeremymcanally/matchy/) (used in tests only) +A `Gemfile` pointing to `gemspec` has been added so that bundler can be used to update dependencies. Just run + bundler install + +Running Tests +------------- + +Run `bundle install` to make sure you have all the dependencies. In some cases it may be necessary to install +ActiveSupport by hand, `gem install activesupport`. Once that's done, run: + + rake test Usage ----- diff --git a/Rakefile b/Rakefile index 82161a9..ef3d057 100644 --- a/Rakefile +++ b/Rakefile @@ -14,9 +14,10 @@ http://www.maxmind.com/app/ccv_overview gem.email = "tm@iprog.com" gem.homepage = "http://github.com/zarqman/maxmind" gem.authors = ["Adam Daniels", "Tinu Cleatus", 't.e.morgan'] - gem.add_dependency 'activesupport', '>= 2.3' - gem.add_development_dependency('shoulda') - gem.add_development_dependency('matchy') + gem.add_dependency 'activesupport', '>= 3.0.0' + gem.add_development_dependency('shoulda', '>= 2.11.3') + gem.add_development_dependency('mcmire-matchy', '>= 0.5.2') + gem.add_development_dependency('fakeweb', '>= 1.3.0') # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings end Jeweler::GemcutterTasks.new diff --git a/lib/maxmind.rb b/lib/maxmind.rb index a9c8730..6bfed4a 100644 --- a/lib/maxmind.rb +++ b/lib/maxmind.rb @@ -1,5 +1,7 @@ -# require 'rubygems' require 'active_support' +unless Module.respond_to?(:mattr_accessor) + require 'active_support/core_ext/module/attribute_accessors'# rescue nil # this may be needed for ActiveSupport versions >= 3.x +end require 'net/http' require 'net/https' require 'uri' diff --git a/lib/maxmind/request.rb b/lib/maxmind/request.rb index 388c1a1..a160664 100644 --- a/lib/maxmind/request.rb +++ b/lib/maxmind/request.rb @@ -113,7 +113,7 @@ def query # Upon a failure at the first URL, will automatically retry with the second one before finally raising an exception def post(query_params) - servers ||= ["https://minfraud1.maxmind.com/app/ccv2r", "https://minfraud3.maxmind.com/app/ccv2r"] + servers ||= ["https://minfraud2.maxmind.com/app/ccv2r", "https://minfraud1.maxmind.com/app/ccv2r", "https://minfraud3.maxmind.com/app/ccv2r"] url = URI.parse(servers.shift) # req = Net::HTTP::Get.new("#{url.path}?#{query_string}") @@ -142,4 +142,4 @@ def validate raise ArgumentError, 'Country is required' unless country end end -end \ No newline at end of file +end diff --git a/lib/maxmind/response.rb b/lib/maxmind/response.rb index fa24b36..c4baf53 100644 --- a/lib/maxmind/response.rb +++ b/lib/maxmind/response.rb @@ -19,7 +19,7 @@ def initialize(response = nil) def attributes_from_response hash_to_return = {} self.instance_variables.each do |var| - hash_to_return[var.gsub("@","")] = self.instance_variable_get(var) + hash_to_return[var.to_s.gsub("@","")] = self.instance_variable_get(var) end return hash_to_return end diff --git a/maxmind-rb.gemspec b/maxmind-rb.gemspec index a549990..1c7a4a1 100644 --- a/maxmind-rb.gemspec +++ b/maxmind-rb.gemspec @@ -1,67 +1,64 @@ # Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{maxmind-rb} + s.name = "maxmind-rb" s.version = "0.4.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Adam Daniels", "Tinu Cleatus", "t.e.morgan"] - s.date = %q{2010-03-06} - s.description = %q{A wrapper around MaxMind's minFraud anti-fraud service. - -http://www.maxmind.com/app/ccv_overview -} - s.email = %q{tm@iprog.com} + s.date = "2011-11-12" + s.description = "A wrapper around MaxMind's minFraud anti-fraud service. \n\nhttp://www.maxmind.com/app/ccv_overview\n" + s.email = "tm@iprog.com" s.extra_rdoc_files = [ "LICENSE", - "README.markdown" + "README.markdown" ] s.files = [ ".document", - ".gitignore", - "LICENSE", - "README.markdown", - "Rakefile", - "VERSION", - "examples/example.rb", - "lib/maxmind.rb", - "lib/maxmind/request.rb", - "lib/maxmind/response.rb", - "test/fixtures/response.txt", - "test/maxmind_test.rb", - "test/test_helper.rb" - ] - s.homepage = %q{http://github.com/zarqman/maxmind} - s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.4} - s.summary = %q{Wrapper for MaxMind's minFraud service} - s.test_files = [ + "Gemfile", + "LICENSE", + "README.markdown", + "Rakefile", + "VERSION", + "examples/example.rb", + "lib/maxmind.rb", + "lib/maxmind/request.rb", + "lib/maxmind/response.rb", + "maxmind-rb.gemspec", + "test/fixtures/response.txt", "test/maxmind_test.rb", - "test/test_helper.rb", - "examples/example.rb" + "test/test_helper.rb" ] + s.homepage = "http://github.com/zarqman/maxmind" + s.require_paths = ["lib"] + s.rubygems_version = "1.8.10" + s.summary = "Wrapper for MaxMind's minFraud service" if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION s.specification_version = 3 - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 2.3"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 3.0.0"]) + s.add_development_dependency(%q, [">= 2.11.3"]) + s.add_development_dependency(%q, [">= 0.5.2"]) + s.add_development_dependency(%q, [">= 1.3.0"]) else - s.add_dependency(%q, [">= 2.3"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 3.0.0"]) + s.add_dependency(%q, [">= 2.11.3"]) + s.add_dependency(%q, [">= 0.5.2"]) + s.add_dependency(%q, [">= 1.3.0"]) end else - s.add_dependency(%q, [">= 2.3"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 3.0.0"]) + s.add_dependency(%q, [">= 2.11.3"]) + s.add_dependency(%q, [">= 0.5.2"]) + s.add_dependency(%q, [">= 1.3.0"]) end end