twterm 1.0.7 → 1.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47e25077b5997ac024770d29a7faa63b0367d200
4
- data.tar.gz: 752e5cc8daf0a00ab054602a2bc1c437f98b80e1
3
+ metadata.gz: 9f8922ec344713188266282109b5d5a43a95948e
4
+ data.tar.gz: b1ac62bbd18b92a058b8f0753a1f34470b129fd0
5
5
  SHA512:
6
- metadata.gz: 40f134f4fd0eeaaed2998883330a9d132b4e99862c0aeebeb2a57326be3c76b08ed2899c83d9366172f82cc8c7b871226e284751645b4bd45df145e9416ac60c
7
- data.tar.gz: 7cba404740e73eefec2a29b5c64368d1cfd2882e58e9847c6aae858470bcca7e27c7b9fb7cbcbc588e206c7188df7b3b92fb0dae1ab15c4f27305ffde82057a8
6
+ metadata.gz: c08ff7689bd89c875051779cd9eda592c699df11a855a56dbe83fb4ac1a67728de75477ff8152332b36b632456169f7490759c81555542fe46dc546d0125392d
7
+ data.tar.gz: 6f920de275acdac03b647505fe37debe4defedd67f40dfb5c3eb9b0281a4382f688bd6266e4378c86411133b9ff4bd5197badf26c163fbb1f11775d2cfd86293
data/README.md CHANGED
@@ -1,10 +1,34 @@
1
- # Twterm
1
+ # twterm
2
2
 
3
- - A full-featured CLI Twitter client
4
- - http://twterm.ryota-ka.me/
3
+ A full-featured CLI Twitter client
4
+
5
+ ## Screenshot
6
+
7
+ ![screenshot](http://twterm.ryota-ka.me/screenshot.png)
8
+
9
+ ## Requirements
10
+
11
+ - Ruby (compiled with C Curses and Readline)
12
+ - C curses
13
+ - Readline
5
14
 
6
15
  ## Installation
7
16
 
8
17
  ```
9
- gem install twterm
18
+ $ gem install twterm
19
+ ```
20
+
21
+ ## Execution
22
+
23
+ ```
24
+ $ twterm
10
25
  ```
26
+
27
+ ## License
28
+
29
+ See the LICENSE file for license rights and limitations (MIT).
30
+
31
+ ## Links
32
+
33
+ - http://twterm.ryota-ka.me/
34
+ - https://rubygems.org/gems/twterm
data/lib/twterm/client.rb CHANGED
@@ -28,12 +28,25 @@ module Twterm
28
28
  @stream_client = TweetStream::Client.new
29
29
 
30
30
  @callbacks = {}
31
+
32
+ @mute_filter = -> _ { true }
33
+ fetch_muted_users do |muted_user_ids|
34
+ @mute_filter = lambda do |status|
35
+ !muted_user_ids.include?(status.user.id) &&
36
+ !(status.retweeted_status.is_a?(Twitter::NullObject) &&
37
+ muted_user_ids.include?(status.retweeted_status.user.id))
38
+ end
39
+ end
40
+
31
41
  @@instances << self
32
42
  end
33
43
 
34
44
  def stream
35
45
  @stream_client.on_friends do
46
+ break if @stream_connected
47
+
36
48
  Notifier.instance.show_message 'Connection established'
49
+ @stream_connected = true
37
50
  end
38
51
 
39
52
  @stream_client.on_timeline_status do |tweet|
@@ -53,6 +66,7 @@ module Twterm
53
66
  end
54
67
 
55
68
  @stream_client.on_no_data_received do
69
+ @stream_connected = false
56
70
  connect_stream
57
71
  end
58
72
 
@@ -87,19 +101,19 @@ module Twterm
87
101
 
88
102
  def home_timeline
89
103
  send_request do
90
- yield @rest_client.home_timeline(count: 100).map(&CREATE_STATUS_PROC)
104
+ yield @rest_client.home_timeline(count: 100).select(&@mute_filter).map(&CREATE_STATUS_PROC)
91
105
  end
92
106
  end
93
107
 
94
108
  def mentions
95
109
  send_request do
96
- yield @rest_client.mentions(count: 100).map(&CREATE_STATUS_PROC)
110
+ yield @rest_client.mentions(count: 100).select(&@mute_filter).map(&CREATE_STATUS_PROC)
97
111
  end
98
112
  end
99
113
 
100
114
  def user_timeline(user_id)
101
115
  send_request do
102
- yield @rest_client.user_timeline(user_id, count: 100).map(&CREATE_STATUS_PROC)
116
+ yield @rest_client.user_timeline(user_id, count: 100).select(&@mute_filter).map(&CREATE_STATUS_PROC)
103
117
  end
104
118
  end
105
119
 
@@ -112,13 +126,13 @@ module Twterm
112
126
  def list(list)
113
127
  fail ArgumentError, 'argument must be an instance of List class' unless list.is_a? List
114
128
  send_request do
115
- yield @rest_client.list_timeline(list.id, count: 100).map(&CREATE_STATUS_PROC)
129
+ yield @rest_client.list_timeline(list.id, count: 100).select(&@mute_filter).map(&CREATE_STATUS_PROC)
116
130
  end
117
131
  end
118
132
 
119
133
  def search(query)
120
134
  send_request do
121
- yield @rest_client.search(query, count: 100).map(&CREATE_STATUS_PROC)
135
+ yield @rest_client.search(query, count: 100).select(&@mute_filter).map(&CREATE_STATUS_PROC)
122
136
  end
123
137
  end
124
138
 
@@ -186,6 +200,13 @@ module Twterm
186
200
  end
187
201
  end
188
202
 
203
+ def fetch_muted_users
204
+ send_request do
205
+ @muted_user_ids = @rest_client.muted_ids.to_a
206
+ yield @muted_user_ids if block_given?
207
+ end
208
+ end
209
+
189
210
  def on_timeline_status(&block)
190
211
  fail ArgumentError, 'no block given' unless block_given?
191
212
  on(:timeline_status, &block)
@@ -3,7 +3,7 @@ module Twterm
3
3
  include Singleton
4
4
  include Curses
5
5
 
6
- COLORS = [:black, :white, :red, :green, :blue, :yellow, :cyan, :magenta]
6
+ COLORS = [:black, :white, :red, :green, :blue, :yellow, :cyan, :magenta, :transparent]
7
7
  CURSES_COLORS = {
8
8
  black: COLOR_BLACK,
9
9
  white: COLOR_WHITE,
@@ -12,13 +12,15 @@ module Twterm
12
12
  blue: COLOR_BLUE,
13
13
  yellow: COLOR_YELLOW,
14
14
  cyan: COLOR_CYAN,
15
- magenta: COLOR_MAGENTA
15
+ magenta: COLOR_MAGENTA,
16
+ transparent: -1
16
17
  }
17
18
 
18
19
  def initialize
19
20
  @colors = {
20
21
  black: {}, white: {}, red: {}, green: {},
21
- blue: {}, yellow: {}, cyan: {}, magenta: {}
22
+ blue: {}, yellow: {}, cyan: {}, magenta: {},
23
+ transparent: {}
22
24
  }
23
25
  @count = 0
24
26
  end
@@ -0,0 +1,37 @@
1
+ module Twterm
2
+ class CompletionManager
3
+ include Singleton
4
+
5
+ def initialize
6
+ Readline.basic_word_break_characters = " \t\n\"\\'`$><=;|&{("
7
+ Readline.completion_case_fold = false
8
+ end
9
+
10
+ def set_default_mode!
11
+ Readline.completion_append_character = ' '
12
+
13
+ Readline.completion_proc = proc do |str|
14
+ if str.start_with?('#')
15
+ History::Hashtag.instance.history
16
+ .map { |tag| "##{tag}" }
17
+ .select { |tag| tag.start_with?(str) }
18
+ elsif str.start_with?('@')
19
+ History::ScreenName.instance.history
20
+ .map { |name| "@#{name}" }
21
+ .select { |name| name.start_with?(str) }
22
+ else
23
+ []
24
+ end
25
+ end
26
+ end
27
+
28
+ def set_screen_name_mode!
29
+ Readline.completion_append_character = ''
30
+
31
+ Readline.completion_proc = proc do |str|
32
+ History::ScreenName.instance.history
33
+ .select { |name| name.start_with?(str) }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ class Curses::Window
2
+ def bold(&block)
3
+ attron(Curses::A_BOLD)
4
+ block.call
5
+ attroff(Curses::A_BOLD)
6
+ end
7
+
8
+ def with_color(fg, bg = :transparent, &block)
9
+ color_pair_index = Twterm::ColorManager.instance.get_color_pair_index(fg, bg)
10
+ attron(Curses.color_pair(color_pair_index))
11
+ block.call
12
+ attroff(Curses.color_pair(color_pair_index))
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def format
3
+ to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/, '\1,')
4
+ end
5
+ end
@@ -28,24 +28,3 @@ class String
28
28
  chunks
29
29
  end
30
30
  end
31
-
32
- class Integer
33
- def format
34
- to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/, '\1,')
35
- end
36
- end
37
-
38
- class Curses::Window
39
- def bold(&block)
40
- attron(Curses::A_BOLD)
41
- block.call
42
- attroff(Curses::A_BOLD)
43
- end
44
-
45
- def with_color(fg, bg = :black, &block)
46
- color_pair_index = Twterm::ColorManager.instance.get_color_pair_index(fg, bg)
47
- attron(Curses.color_pair(color_pair_index))
48
- block.call
49
- attroff(Curses.color_pair(color_pair_index))
50
- end
51
- end
data/lib/twterm/screen.rb CHANGED
@@ -10,6 +10,7 @@ module Twterm
10
10
  curs_set(0)
11
11
  stdscr.keypad(true)
12
12
  start_color
13
+ use_default_colors
13
14
  end
14
15
 
15
16
  def wait
@@ -23,6 +23,8 @@ module Twterm
23
23
  Screen.instance.refresh
24
24
  end
25
25
 
26
+ CompletionManager.instance.set_screen_name_mode!
27
+
26
28
  input_thread = Thread.new do
27
29
  close_screen
28
30
  puts "\nSearch user"
@@ -30,21 +30,7 @@ module Twterm
30
30
  puts "\nReply to @#{@in_reply_to.user.screen_name}'s tweet: \"#{@in_reply_to.text}\""
31
31
  end
32
32
 
33
- Readline.completion_append_character = ' '
34
- Readline.basic_word_break_characters = " \t\n\"\\'`$><=;|&{("
35
- Readline.completion_proc = proc do |str|
36
- if str.start_with?('#')
37
- History::Hashtag.instance.history
38
- .map { |tag| "##{tag}" }
39
- .select { |tag| tag.downcase.start_with?(str.downcase) }
40
- elsif str.start_with?('@')
41
- History::ScreenName.instance.history
42
- .map { |name| "@#{name}" }
43
- .select! { |name| name.downcase.start_with?(str.downcase) }
44
- else
45
- []
46
- end
47
- end
33
+ CompletionManager.instance.set_default_mode!
48
34
 
49
35
  loop do
50
36
  loop do
@@ -1,3 +1,3 @@
1
1
  module Twterm
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.8'
3
3
  end
data/lib/twterm.rb CHANGED
@@ -12,12 +12,15 @@ require 'twitter'
12
12
  require 'twitter-text'
13
13
  require 'yaml'
14
14
 
15
- require 'extentions'
16
15
  require 'twterm/app'
17
16
  require 'twterm/auth'
18
17
  require 'twterm/client'
19
18
  require 'twterm/color_manager'
19
+ require 'twterm/completion_mamanger'
20
20
  require 'twterm/config'
21
+ require 'twterm/extensions/curses/window'
22
+ require 'twterm/extensions/integer'
23
+ require 'twterm/extensions/string'
21
24
  require 'twterm/history/base'
22
25
  require 'twterm/history/hashtag'
23
26
  require 'twterm/history/screen_name'
@@ -51,6 +54,6 @@ require 'twterm/version'
51
54
 
52
55
  module Twterm
53
56
  class Conf
54
- REQUIRE_VERSION = '1.0.6'
57
+ REQUIRE_VERSION = '1.0.8'
55
58
  end
56
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Kameoka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -136,13 +136,16 @@ files:
136
136
  - README.md
137
137
  - Rakefile
138
138
  - bin/twterm
139
- - lib/extentions.rb
140
139
  - lib/twterm.rb
141
140
  - lib/twterm/app.rb
142
141
  - lib/twterm/auth.rb
143
142
  - lib/twterm/client.rb
144
143
  - lib/twterm/color_manager.rb
144
+ - lib/twterm/completion_mamanger.rb
145
145
  - lib/twterm/config.rb
146
+ - lib/twterm/extensions/curses/window.rb
147
+ - lib/twterm/extensions/integer.rb
148
+ - lib/twterm/extensions/string.rb
146
149
  - lib/twterm/history/base.rb
147
150
  - lib/twterm/history/hashtag.rb
148
151
  - lib/twterm/history/screen_name.rb