hayesdavis-grackle 0.1.1 → 0.1.2

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/grackle.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{grackle}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Hayes Davis"]
@@ -83,7 +83,6 @@ module Grackle
83
83
 
84
84
  #Basic OAuth information needed to communicate with Twitter
85
85
  TWITTER_OAUTH_SPEC = {
86
- :site=>'http://twitter.com',
87
86
  :request_token_path=>'/oauth/request_token',
88
87
  :access_token_path=>'/oauth/access_token',
89
88
  :authorize_path=>'/oauth/authorize'
@@ -59,7 +59,7 @@ module Grackle
59
59
  if options[:auth][:type] == :basic
60
60
  add_basic_auth(req,options[:auth])
61
61
  elsif options[:auth][:type] == :oauth
62
- add_oauth(req,options[:auth])
62
+ add_oauth(http,req,options[:auth])
63
63
  end
64
64
  end
65
65
  dump_request(req) if debug
@@ -151,16 +151,27 @@ module Grackle
151
151
  end
152
152
  end
153
153
 
154
- def add_oauth(req,auth)
154
+ def add_oauth(conn,req,auth)
155
155
  options = auth.reject do |key,value|
156
156
  [:type,:consumer_key,:consumer_secret,:token,:token_secret].include?(key)
157
157
  end
158
+ unless options.has_key?(:site)
159
+ options[:site] = oauth_site(conn,req)
160
+ end
158
161
  consumer = OAuth::Consumer.new(auth[:consumer_key],auth[:consumer_secret],options)
159
162
  access_token = OAuth::AccessToken.new(consumer,auth[:token],auth[:token_secret])
160
163
  consumer.sign!(req,access_token)
161
164
  end
162
165
 
163
166
  private
167
+ def oauth_site(conn,req)
168
+ site = "#{(conn.use_ssl? ? "https" : "http")}://#{conn.address}"
169
+ if (conn.use_ssl? && conn.port != 443) || (!conn.use_ssl? && conn.port != 80)
170
+ site << ":#{conn.port}"
171
+ end
172
+ site
173
+ end
174
+
164
175
  def dump_request(req)
165
176
  puts "Sending Request"
166
177
  puts"#{req.method} #{req.path}"
data/lib/grackle.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Grackle
2
2
 
3
3
  # :stopdoc:
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
7
  # :startdoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hayesdavis-grackle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hayes Davis