twurl 0.6.7 → 0.7.0
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/lib/twurl/cli.rb +2 -0
- data/lib/twurl/oauth_client.rb +16 -15
- data/lib/twurl/request_controller.rb +3 -2
- data/lib/twurl/version.rb +2 -2
- data/test/oauth_client_test.rb +3 -1
- data/test/request_controller_test.rb +2 -2
- metadata +3 -3
data/lib/twurl/cli.rb
CHANGED
@@ -92,10 +92,12 @@ module Twurl
|
|
92
92
|
|
93
93
|
def print(*args, &block)
|
94
94
|
output.print(*args, &block)
|
95
|
+
output.flush if output.respond_to?(:flush)
|
95
96
|
end
|
96
97
|
|
97
98
|
def puts(*args, &block)
|
98
99
|
output.puts(*args, &block)
|
100
|
+
output.flush if output.respond_to?(:flush)
|
99
101
|
end
|
100
102
|
|
101
103
|
def prompt_for(label)
|
data/lib/twurl/oauth_client.rb
CHANGED
@@ -62,21 +62,22 @@ module Twurl
|
|
62
62
|
configure_http!
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
65
|
+
METHODS = {
|
66
|
+
:post => Net::HTTP::Post,
|
67
|
+
:get => Net::HTTP::Get,
|
68
|
+
:put => Net::HTTP::Put,
|
69
|
+
:delete => Net::HTTP::Delete,
|
70
|
+
:options => Net::HTTP::Options,
|
71
|
+
:head => Net::HTTP::Head,
|
72
|
+
:copy => Net::HTTP::Copy
|
73
|
+
}
|
74
|
+
|
75
|
+
def perform_request_from_options(options, &block)
|
76
|
+
request_class = METHODS.fetch(options.request_method.to_sym)
|
77
|
+
request = request_class.new(options.path, options.headers)
|
78
|
+
request.set_form_data(options.data) if options.data
|
79
|
+
request.oauth!(consumer.http, consumer, access_token)
|
80
|
+
consumer.http.request(request, &block)
|
80
81
|
end
|
81
82
|
|
82
83
|
def exchange_credentials_for_access_token
|
@@ -10,8 +10,9 @@ module Twurl
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def perform_request
|
13
|
-
|
14
|
-
|
13
|
+
client.perform_request_from_options(options) { |response|
|
14
|
+
response.read_body { |chunk| CLI.print chunk }
|
15
|
+
}
|
15
16
|
rescue URI::InvalidURIError
|
16
17
|
CLI.puts NO_URI_MESSAGE
|
17
18
|
end
|
data/lib/twurl/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Twurl
|
2
2
|
module VERSION
|
3
3
|
MAJOR = '0' unless defined? MAJOR
|
4
|
-
MINOR = '
|
5
|
-
PATCH = '
|
4
|
+
MINOR = '7' unless defined? MINOR
|
5
|
+
PATCH = '0' unless defined? PATCH
|
6
6
|
BETA = nil unless defined? BETA # Time.now.to_i.to_s
|
7
7
|
end
|
8
8
|
|
data/test/oauth_client_test.rb
CHANGED
@@ -135,7 +135,9 @@ end
|
|
135
135
|
class Twurl::OAuthClient::PerformingRequestsFromOptionsTest < Twurl::OAuthClient::AbstractOAuthClientTest
|
136
136
|
def test_request_is_made_using_request_method_and_path_and_data_in_options
|
137
137
|
client = Twurl::OAuthClient.test_exemplar
|
138
|
-
mock(client).
|
138
|
+
mock(client.consumer.http).request(satisfy { |req|
|
139
|
+
req.is_a?(Net::HTTP::Get) && (req.path == options.path)
|
140
|
+
})
|
139
141
|
|
140
142
|
client.perform_request_from_options(options)
|
141
143
|
end
|
@@ -41,8 +41,8 @@ class Twurl::RequestController::RequestTest < Twurl::RequestController::Abstract
|
|
41
41
|
def test_request_response_is_written_to_output
|
42
42
|
expected_body = 'this is a fake response body'
|
43
43
|
response = Object.new
|
44
|
-
mock(response).
|
45
|
-
mock(client).perform_request_from_options(options).times(1) { response }
|
44
|
+
mock(response).read_body { |block| block.call expected_body }
|
45
|
+
mock(client).perform_request_from_options(options).times(1) { |options, block| block.call(response) }
|
46
46
|
|
47
47
|
controller.perform_request
|
48
48
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twurl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-04
|
13
|
+
date: 2012-05-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: oauth
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: 1.3.6
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project: twurl
|
165
|
-
rubygems_version: 1.8.
|
165
|
+
rubygems_version: 1.8.24
|
166
166
|
signing_key:
|
167
167
|
specification_version: 3
|
168
168
|
summary: Curl for the Twitter API
|