twsh 0.2.0 → 0.3.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: 5e99332de6eb4f3191bd112bd4388084265644d5
4
- data.tar.gz: 280d9d88f41195430015d64f448940c9726a0507
3
+ metadata.gz: 7f33973323a6331bab9c01ba900fac35e3122ce7
4
+ data.tar.gz: 4a0e30ec5c5a1b175cf80ddf67f1586bc1ef1691
5
5
  SHA512:
6
- metadata.gz: c23ce3c0926f956ee7cdde58e07beb7ed5788ccf9f5764655cecdbac02ce6d04c1d0081d0f673e27dbafc1e59b0fab4629deaa28acb0ef64670540223e4af311
7
- data.tar.gz: 9b9adbbe08b9c4483c12d38336c699b921d038dd5b4eed0c2be2a89ce5b762055abe94b58448c923a856d4b71d71a57885be1ec6768c737dc3af75ca0dad87fc
6
+ metadata.gz: 970219ce79cf96fd847859fb4b289c5f6dcfabb903b6835e47b23c349e177d60cc163cd8f8b386d3ced86b1de4a8da31cc4cb7e9e09ceb240416041fba1c8e8c
7
+ data.tar.gz: 97cf1c016bd3dce4c9acc03588a73063ec7079048dd342683709ebbb019046b3357c79ad1c37ce8fc18cc87247f4cafe480ba4d4f66a610ce9e6d4adeaacd632
data/README.md CHANGED
@@ -23,5 +23,12 @@ Please access shown URL and permit, and input PIN code.
23
23
  # Commands
24
24
 
25
25
  ```
26
- $ ls # show your home-timeline (shown 30 charactors tweet text, and only 20 tweets count.)
26
+ $ tweet <post text>
27
+ # Tweet post text.
28
+
29
+ $ ls
30
+ # Show your home-timeline (shown 30 charactors tweet text, and only 20 tweets count.)
31
+
32
+ $ tail
33
+ # Realtime show your home-timeline
27
34
  ```
@@ -6,8 +6,8 @@ module Myun2
6
6
  class Client < TwitterOAuth::Client
7
7
  def initialize(params)
8
8
  super(
9
- consumer_key: Myun2::TwitterShell::TWITTER_CONSUMER_KEY,
10
- consumer_secret: Myun2::TwitterShell::TWITTER_CONSUMER_SECRET,
9
+ consumer_key: Myun2::TwitterShell::ConsumerKey::KEY,
10
+ consumer_secret: Myun2::TwitterShell::ConsumerKey::SECRET,
11
11
  token: params[:access_token],
12
12
  secret: params[:access_token_secret],
13
13
  )
@@ -1,6 +1,8 @@
1
1
  module Myun2
2
2
  class TwitterShell
3
- TWITTER_CONSUMER_KEY = 'UcYO0YhTahKinn2wtYjNK564f'
4
- TWITTER_CONSUMER_SECRET = 'GOXY9ViHxqsTBqiZAL9Sp8wbJbRIoEB4ciclB80gi2nQ1qAvGn'
3
+ module ConsumerKey
4
+ KEY = 'UcYO0YhTahKinn2wtYjNK564f'
5
+ SECRET = 'GOXY9ViHxqsTBqiZAL9Sp8wbJbRIoEB4ciclB80gi2nQ1qAvGn'
6
+ end
5
7
  end
6
8
  end
@@ -3,6 +3,7 @@ require 'myun2/twitter_shell/profile'
3
3
  require 'myun2/twitter_shell/client'
4
4
  require 'myun2/twitter_shell/login'
5
5
  require 'myun2/twitter_shell/ls'
6
+ require 'myun2/twitter_shell/tail'
6
7
 
7
8
  module Myun2
8
9
  class TwitterShell
@@ -21,11 +22,18 @@ module Myun2
21
22
  def tweet(*params)
22
23
  client.update params.join(" ")
23
24
  end
25
+ alias post tweet
26
+ alias update tweet
24
27
 
25
28
  def ls(*params)
26
29
  Ls.new(client, *params)
27
30
  end
28
31
 
32
+ def tail(*params)
33
+ #ls(*params)
34
+ Tail.new(@profile.data, *params)
35
+ end
36
+
29
37
  def prompt
30
38
  "twsh:$ "
31
39
  end
@@ -0,0 +1,29 @@
1
+ require 'twitter'
2
+ require 'myun2/twitter_shell/consumer_key'
3
+
4
+ module Myun2
5
+ class TwitterShell
6
+ class Tail
7
+ def initialize(profile, *params)
8
+ Tail.home_timeline_streaming(profile) do |o|
9
+ if o.is_a?(::Twitter::Tweet)
10
+ puts "<#{o.user.name}>: #{o.text}"
11
+ end
12
+ end
13
+ end
14
+
15
+ def self.streaming_client(profile)
16
+ @@client ||= ::Twitter::Streaming::Client.new(
17
+ consumer_key: Myun2::TwitterShell::ConsumerKey::KEY,
18
+ consumer_secret: Myun2::TwitterShell::ConsumerKey::SECRET,
19
+ access_token: profile[:access_token],
20
+ access_token_secret: profile[:access_token_secret],
21
+ )
22
+ end
23
+
24
+ def self.home_timeline_streaming(profile, &block)
25
+ streaming_client(profile).user({}, &block)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Myun2
2
2
  class TwitterShell
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twsh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - myun2
@@ -102,6 +102,7 @@ files:
102
102
  - lib/myun2/twitter_shell/ls.rb
103
103
  - lib/myun2/twitter_shell/profile.rb
104
104
  - lib/myun2/twitter_shell/shell.rb
105
+ - lib/myun2/twitter_shell/tail.rb
105
106
  - lib/myun2/twitter_shell/version.rb
106
107
  - lib/twsh.rb
107
108
  - twsh.gemspec