tw 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebdae18e1fd9f00e03f4437929a2669d65429793
4
- data.tar.gz: 022a895933f19e28e2c3e00dbf5bed491d7241b4
3
+ metadata.gz: 5cbca5d6d9424b6bc4b14c75b1b0516c133a6c1b
4
+ data.tar.gz: a30d27fc896def18a7d7bfb419c8849836d65f8b
5
5
  SHA512:
6
- metadata.gz: 13d724acd45d97df4ae4a93e316885c32aee8b6f126ebeca76b350b916cdde1070b3f041fc72c42b30588f76024c4923d3c64618bcf3e313f78b07c464ce1336
7
- data.tar.gz: 91aa0ac3a46a43df3caa3666b26b29d0c49252ad75c42c52947d27cc6f293206f7804c8629061ca4776776c25c60f114c968a80929b318b0de217143f41d5d0c
6
+ metadata.gz: b60705bad682626dafa97d50241b68c4bd19826776e9df556b8443d1e08480ffe7514056280422134cfd3c22ea1bfe7c9d96f31644fe456dcc95fabbe1d66212
7
+ data.tar.gz: 3fc301af0cde6adaaa0142bae1138114ccd968741b3316d0970805bfac3377d85dc4a1897b61fe9f551f78923fa60b29c10014b312a8b344f2cb24e067d18326
@@ -1,3 +1,7 @@
1
+ === 1.2.0 2017-08-20
2
+
3
+ * fix --stream option (#73)
4
+
1
5
  === 1.1.0 2017-07-02
2
6
 
3
7
  * update rubygems - parallel, rainbow, launchy #72
data/lib/tw.rb CHANGED
@@ -4,7 +4,6 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'oauth'
5
5
  require 'twitter'
6
6
  require 'time'
7
- require 'user_stream'
8
7
  require 'yaml'
9
8
  require 'time'
10
9
  require 'cgi'
@@ -3,41 +3,39 @@ module Tw
3
3
  class Client::Stream
4
4
  def initialize(user=nil)
5
5
  user = Tw::Auth.get_or_regist_user user
6
- UserStream.configure do |config|
6
+ @client = Twitter::Streaming::Client.new do |config|
7
7
  config.consumer_key = Conf['consumer_key']
8
8
  config.consumer_secret = Conf['consumer_secret']
9
- config.oauth_token = user['access_token']
10
- config.oauth_token_secret = user['access_secret']
9
+ config.access_token = user['access_token']
10
+ config.access_token_secret = user['access_secret']
11
11
  end
12
-
13
- @client = UserStream::Client.new
14
12
  end
15
13
 
16
14
  def user_stream(&block)
17
15
  raise ArgumentError, 'block not given' unless block_given?
18
- @client.user do |m|
19
- if data = tweet?(m)
20
- yield data
16
+ @client.user do |chunk|
17
+ if tweet = get_if_tweet(chunk)
18
+ yield tweet
21
19
  end
22
20
  end
23
21
  end
24
22
 
25
23
  def filter(*track_words, &block)
26
24
  raise ArgumentError, 'block not given' unless block_given?
27
- @client.filter :track => track_words.join(',') do |m|
28
- if data = tweet?(m)
29
- yield data
25
+ @client.filter :track => track_words.join(',') do |chunk|
26
+ if tweet = get_if_tweet(chunk)
27
+ yield tweet
30
28
  end
31
29
  end
32
30
  end
33
31
 
34
32
  private
35
- def tweet?(chunk)
36
- return false unless chunk.user and chunk.user.screen_name and chunk.text and chunk.created_at and chunk.id
33
+ def get_if_tweet(chunk)
34
+ return nil unless chunk.kind_of? Twitter::Tweet
37
35
  Tw::Tweet.new(:id => chunk.id,
38
36
  :user => chunk.user.screen_name,
39
37
  :text => chunk.text,
40
- :time => (Time.parse chunk.created_at))
38
+ :time => chunk.created_at)
41
39
  end
42
40
 
43
41
  end
@@ -1,3 +1,3 @@
1
1
  module Tw
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
data/tw.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency 'twitter', '>= 5.15.0'
21
- gem.add_dependency 'userstream', '>= 1.2.0', '< 1.3.0'
21
+ gem.add_dependency 'oauth', '>= 0.5.3'
22
22
  gem.add_dependency 'json', '>= 2.1.0'
23
23
  gem.add_dependency 'yajl-ruby', '>= 1.3.0'
24
24
  gem.add_dependency 'rainbow', '>= 2.2.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
11
+ date: 2017-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twitter
@@ -25,25 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.15.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: userstream
28
+ name: oauth
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.0
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: 1.3.0
33
+ version: 0.5.3
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: 1.2.0
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: 1.3.0
40
+ version: 0.5.3
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: json
49
43
  requirement: !ruby/object:Gem::Requirement