birdgrinder 0.1.4.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,22 +27,30 @@ BirdGrinder::Application.processing(ARGV) do |a|
27
27
  template 'rakefile.erb', 'Rakefile'
28
28
  end
29
29
 
30
- a.add("authorize", "Gets oauth access token information making it possible to use oauth authentication") do |options|
30
+ a.add("authorize [PATH]", "Gets oauth access token information making it possible to use oauth authentication, optionally pointing to an application") do |*args|
31
+ # Use the correct application path
32
+ options = args.extract_options!
33
+ BirdGrinder::Settings.root = File.expand_path(args[0] || ".")
34
+ # Run with a nonexistant controller.
35
+ BirdGrinder::Loader.run!(:authorizer)
36
+ # Ask the user what to do
31
37
  puts "First, you need to create a twitter application and get a consumer key and secret."
32
38
  puts "To do this, visit http://twitter.com/apps/new"
33
39
  system("open", "http://twitter.com/apps/new") if yes?("Are you running OSX and wish to open this url now?")
34
40
  consumer_key, consumer_secret = "", ""
35
- consumer_key = ask("What is your applications consumer key?", "") while consumer_key.blank?
36
- consumer_secret = ask("What is your applications consumer secret?", "") while consumer_secret.blank?
37
- BirdGrinder::Settings.oauth.consumer_key = consumer_key
38
- BirdGrinder::Settings.oauth.consumer_secret = consumer_secret
39
- oauth = BirdGrinder::Tweeter::OAuthAuthentication
41
+ consumer_key = ask("What is your applications consumer key?") while consumer_key.blank?
42
+ consumer_secret = ask("What is your applications consumer secret?") while consumer_secret.blank?
43
+ settings = BirdGrinder::Settings
44
+ settings.oauth = BirdGrinder::Nash.new unless settings.oauth.is_a?(BirdGrinder::Nash)
45
+ settings.oauth.consumer_key = consumer_key
46
+ settings.oauth.consumer_secret = consumer_secret
47
+ oauth = BirdGrinder::Tweeter::OAuthAuthorization
40
48
  rtoken = oauth.request_token
41
49
  token, secret = rtoken.token, rtoken.secret
42
50
  puts "To get a pin for your account, please visit: #{rtoken.authorize_url}"
43
51
  system("open", rtoken.authorize_url) if yes?("Are you running OSX and wish to open this url now?")
44
52
  value = ""
45
- value = ask("What is the PIN twitter gave you?", "") while value.blank?
53
+ value = ask("What is the PIN twitter gave you?") while value.blank?
46
54
  puts "Updating settings..."
47
55
  oauth.retrieve_access_token!(token, secret, value)
48
56
  puts "Done! - Your access token should now be stored"
@@ -8,7 +8,7 @@ require 'em-http'
8
8
  module BirdGrinder
9
9
  include Perennial
10
10
 
11
- VERSION = [0, 1, 4, 0]
11
+ VERSION = [0, 1, 5, 0]
12
12
 
13
13
  def self.version(include_minor = false)
14
14
  VERSION[0, (include_minor ? 4 : 3)].join(".")
@@ -13,11 +13,6 @@ module BirdGrinder
13
13
  @basic_auth_credentials
14
14
  end
15
15
 
16
- protected
17
-
18
- def generate_header!
19
- end
20
-
21
16
  end
22
17
  end
23
18
  end
@@ -1,3 +1,5 @@
1
+ # Force the correct version of oauth if it's available.
2
+ gem 'sutto-oauth' if respond_to?(:gem)
1
3
  require 'oauth'
2
4
  require 'em-http-oauth-request'
3
5
 
@@ -45,7 +45,7 @@ module BirdGrinder
45
45
  logger.debug "Preparing to start stream"
46
46
  @stream_processor = nil
47
47
  type = request_method
48
- http = EventMachine::HttpRequest.new(full_url).send(type, http_options(type, request))
48
+ http = EventMachine::HttpRequest.new(full_url).send(type, http_options(type))
49
49
  authorization_method.add_header_to(http)
50
50
  # Handle failures correctly so we can back off
51
51
  @current_request = http
@@ -101,7 +101,7 @@ module BirdGrinder
101
101
  # what method is used to send the request. It's important that
102
102
  # this is used for credentials as well as making sure there is
103
103
  # no timeout on the connection
104
- def default_request_options(r)
104
+ def default_request_options
105
105
  {:timeout => 0, :head => {}}
106
106
  end
107
107
 
@@ -109,8 +109,7 @@ module BirdGrinder
109
109
  # on top of default_request_options and a few other details.
110
110
  #
111
111
  # @param [Symbol] type the type of request - :post or :get
112
- # @param [EventMachine::HttpRequest] the request itself
113
- def http_options(type, request)
112
+ def http_options(type)
114
113
  base = self.default_request_options
115
114
  if @options.present?
116
115
  if type == :get
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birdgrinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-29 00:00:00 +08:00
12
+ date: 2010-01-14 00:00:00 +08:00
13
13
  default_executable: birdgrinder
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.1.0
23
+ version: 1.2.5
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: eventmachine
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.12.8
33
+ version: 0.12.10
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: yajl-ruby
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.6.3
43
+ version: 0.6.8
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: em-http-request
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.1.8
53
+ version: 0.2.6
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: moneta
@@ -63,14 +63,14 @@ dependencies:
63
63
  version: 0.6.0
64
64
  version:
65
65
  - !ruby/object:Gem::Dependency
66
- name: em-http-oauth-request
66
+ name: sutto-oauth
67
67
  type: :runtime
68
68
  version_requirement:
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 0.1.0
73
+ version: 0.3.6
74
74
  version:
75
75
  description:
76
76
  email: sutto@sutto.net