binged 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem "hashie"
4
+ gem 'faraday'
4
5
  gem 'activesupport', '>= 3.0.0'
5
6
 
6
7
  group :development do
data/HISTORY CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.1.0 2012-10-06
2
+ * Switch from net/http to faraday for pluggable http requests.
3
+
1
4
  == 1.0.1 2012-10-06
2
5
  * Declare me a co-author and make my repo the official.
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "binged"
8
- s.version = "1.0.1"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kevin Faustino", "Ben Woosley"]
@@ -57,12 +57,14 @@ Gem::Specification.new do |s|
57
57
 
58
58
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
59
  s.add_runtime_dependency(%q<hashie>, [">= 0"])
60
+ s.add_runtime_dependency(%q<faraday>, [">= 0"])
60
61
  s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
61
62
  s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
62
63
  s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
63
64
  s.add_development_dependency(%q<yard>, [">= 0"])
64
65
  else
65
66
  s.add_dependency(%q<hashie>, [">= 0"])
67
+ s.add_dependency(%q<faraday>, [">= 0"])
66
68
  s.add_dependency(%q<activesupport>, [">= 3.0.0"])
67
69
  s.add_dependency(%q<rspec>, [">= 1.3.0"])
68
70
  s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
@@ -70,6 +72,7 @@ Gem::Specification.new do |s|
70
72
  end
71
73
  else
72
74
  s.add_dependency(%q<hashie>, [">= 0"])
75
+ s.add_dependency(%q<faraday>, [">= 0"])
73
76
  s.add_dependency(%q<activesupport>, [">= 3.0.0"])
74
77
  s.add_dependency(%q<rspec>, [">= 1.3.0"])
75
78
  s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
@@ -1,7 +1,7 @@
1
1
  require 'active_support/core_ext/object/to_query'
2
2
  require 'json'
3
3
  require 'hashie'
4
- require 'net/https'
4
+ require 'faraday'
5
5
  require 'uri'
6
6
 
7
7
  require 'binged/hashie_extensions'
@@ -55,6 +55,12 @@ module Binged
55
55
  @fetch
56
56
  end
57
57
 
58
+ def connection
59
+ Faraday.new.tap do |faraday|
60
+ faraday.basic_auth(@client.account_key, @client.account_key)
61
+ end
62
+ end
63
+
58
64
  # Performs a GET call to Bing API
59
65
  #
60
66
  # @return [Hash] Hash of Bing API response
@@ -69,11 +75,10 @@ module Binged
69
75
  query_options = default_options.merge(query).to_query
70
76
  query_options.gsub! '%2B', '+'
71
77
  url.query = query_options
72
- request = Net::HTTP::Get.new(url.request_uri)
73
- request.basic_auth(@client.account_key, @client.account_key)
74
- response = Net::HTTP.start(url.hostname, url.port, :use_ssl => true) {|http|
75
- http.request(request)
76
- }
78
+
79
+
80
+
81
+ response = connection.get(url)
77
82
  begin
78
83
  JSON.parse(response.body)
79
84
  rescue JSON::ParserError => e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binged
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -28,6 +28,22 @@ dependencies:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: faraday
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
31
47
  - !ruby/object:Gem::Dependency
32
48
  name: activesupport
33
49
  requirement: !ruby/object:Gem::Requirement