Commit 719fefc0f4068705bbbae6ddb5a43946d4d96ad4
1 parent
29c02e8d
Exists in
master
printing only the comment
Showing
3 changed files
with
55 additions
and
1 deletions
Show diff stats
tweeter_stream/Gemfile
@@ -2,6 +2,7 @@ source 'https://rubygems.org' | @@ -2,6 +2,7 @@ source 'https://rubygems.org' | ||
2 | 2 | ||
3 | gem 'jruby-openssl', :platforms => :jruby | 3 | gem 'jruby-openssl', :platforms => :jruby |
4 | gem 'rake' | 4 | gem 'rake' |
5 | +gem 'json' | ||
5 | 6 | ||
6 | group :test do | 7 | group :test do |
7 | gem 'coveralls', :require => false | 8 | gem 'coveralls', :require => false |
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +PATH | ||
2 | + remote: . | ||
3 | + specs: | ||
4 | + twurl (0.9.2) | ||
5 | + oauth (~> 0.4) | ||
6 | + | ||
7 | +GEM | ||
8 | + remote: https://rubygems.org/ | ||
9 | + specs: | ||
10 | + coveralls (0.7.0) | ||
11 | + multi_json (~> 1.3) | ||
12 | + rest-client | ||
13 | + simplecov (>= 0.7) | ||
14 | + term-ansicolor | ||
15 | + thor | ||
16 | + docile (1.1.3) | ||
17 | + json (1.8.1) | ||
18 | + mime-types (1.25.1) | ||
19 | + minitest (5.3.2) | ||
20 | + multi_json (1.9.2) | ||
21 | + oauth (0.4.7) | ||
22 | + rake (10.2.2) | ||
23 | + rest-client (1.6.7) | ||
24 | + mime-types (>= 1.16) | ||
25 | + rr (1.1.2) | ||
26 | + simplecov (0.8.2) | ||
27 | + docile (~> 1.1.0) | ||
28 | + multi_json | ||
29 | + simplecov-html (~> 0.8.0) | ||
30 | + simplecov-html (0.8.0) | ||
31 | + term-ansicolor (1.3.0) | ||
32 | + tins (~> 1.0) | ||
33 | + thor (0.19.1) | ||
34 | + tins (1.1.0) | ||
35 | + | ||
36 | +PLATFORMS | ||
37 | + ruby | ||
38 | + | ||
39 | +DEPENDENCIES | ||
40 | + bundler (~> 1.0) | ||
41 | + coveralls | ||
42 | + jruby-openssl | ||
43 | + json | ||
44 | + mime-types (~> 1.25) | ||
45 | + minitest (>= 5) | ||
46 | + rake | ||
47 | + rr (>= 1.1) | ||
48 | + simplecov | ||
49 | + twurl! |
tweeter_stream/lib/twurl/request_controller.rb
1 | +require "json" | ||
2 | + | ||
1 | module Twurl | 3 | module Twurl |
2 | class RequestController < AbstractCommandController | 4 | class RequestController < AbstractCommandController |
3 | NO_URI_MESSAGE = "No URI specified" | 5 | NO_URI_MESSAGE = "No URI specified" |
@@ -11,7 +13,9 @@ module Twurl | @@ -11,7 +13,9 @@ module Twurl | ||
11 | 13 | ||
12 | def perform_request | 14 | def perform_request |
13 | client.perform_request_from_options(options) { |response| | 15 | client.perform_request_from_options(options) { |response| |
14 | - response.read_body { |chunk| Stream.print chunk } | 16 | + response.read_body { |chunk| parsed = JSON.parse(chunk) |
17 | + print parsed["text"] + "\n" | ||
18 | + } | ||
15 | } | 19 | } |
16 | rescue URI::InvalidURIError | 20 | rescue URI::InvalidURIError |
17 | Stream.puts NO_URI_MESSAGE | 21 | Stream.puts NO_URI_MESSAGE |