twterm 1.0.3 → 1.0.4
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 +4 -4
- data/lib/twterm/app.rb +4 -0
- data/lib/twterm/config.rb +1 -1
- data/lib/twterm/history/base.rb +36 -0
- data/lib/twterm/history/hashtag.rb +13 -0
- data/lib/twterm/history/screen_name.rb +13 -0
- data/lib/twterm/status.rb +7 -0
- data/lib/twterm/tab/new/list.rb +2 -2
- data/lib/twterm/tab/new/search.rb +1 -1
- data/lib/twterm/tab/new/user.rb +1 -1
- data/lib/twterm/tweetbox.rb +32 -2
- data/lib/twterm/user.rb +3 -0
- data/lib/twterm/version.rb +1 -1
- data/lib/twterm.rb +4 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ffcecd46a9f09aacf0db6c809ce6f5fe71e874
|
4
|
+
data.tar.gz: f1340022b9fd1628be5bba96839321d381fdc94d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b0732ac89eb6cdf4fc7475f8a47bbcdca9906cba71bffb3cad63ccbbaa7b298a9000ba82efa1e6353e776e8bd41b833e8343b8c63db495333263bf2bed7917c
|
7
|
+
data.tar.gz: 0451fec8a057f15b113785797673117cb99ca13eb25b7605af87657eeb2ae7f6048fb3f4ab7740ebffa2a0bf7e45ab2254b605cc1fe39228aaf2681532f0f1e6
|
data/lib/twterm/app.rb
CHANGED
data/lib/twterm/config.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Twterm
|
2
|
+
module History
|
3
|
+
module Base
|
4
|
+
MAX_HISTORY_SIZE = 500
|
5
|
+
|
6
|
+
attr_reader :history
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
unless File.exist?(history_file)
|
10
|
+
@history = []
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
14
|
+
@history = YAML.load(File.read(history_file)) || []
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(hashtag)
|
18
|
+
@history.unshift(hashtag)
|
19
|
+
@history = @history.uniq.take(MAX_HISTORY_SIZE)
|
20
|
+
save
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def save
|
26
|
+
File.open(history_file, 'w', 0600) do |f|
|
27
|
+
f.write @history.to_yaml
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def history_file
|
32
|
+
fail NotImplementedError, 'history_file method must be implemented'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/twterm/status.rb
CHANGED
@@ -42,6 +42,10 @@ module Twterm
|
|
42
42
|
|
43
43
|
@touched_at = Time.now
|
44
44
|
|
45
|
+
tweet.hashtags.each do |hashtag|
|
46
|
+
History::Hashtag.instance.add(hashtag.text)
|
47
|
+
end
|
48
|
+
|
45
49
|
@@instances[id] = self
|
46
50
|
end
|
47
51
|
|
@@ -64,14 +68,17 @@ module Twterm
|
|
64
68
|
end
|
65
69
|
|
66
70
|
def favorite!
|
71
|
+
@favorite_count += 1
|
67
72
|
@favorited = true
|
68
73
|
end
|
69
74
|
|
70
75
|
def unfavorite!
|
76
|
+
@favorite_count -= 1
|
71
77
|
@favorited = false
|
72
78
|
end
|
73
79
|
|
74
80
|
def retweet!
|
81
|
+
@retweet_count += 1
|
75
82
|
@retweeted = true
|
76
83
|
end
|
77
84
|
|
data/lib/twterm/tab/new/list.rb
CHANGED
@@ -48,10 +48,10 @@ module Twterm
|
|
48
48
|
Thread.new do
|
49
49
|
Notifier.instance.show_message('Loading lists ...')
|
50
50
|
Client.current.lists do |lists|
|
51
|
-
@@lists = lists
|
51
|
+
@@lists = lists.sort_by(&:full_name)
|
52
52
|
show_lists
|
53
53
|
update_scrollbar_length
|
54
|
-
@window.refresh
|
54
|
+
@window.refresh if TabManager.instance.current_tab == self
|
55
55
|
end
|
56
56
|
end if @@lists.nil?
|
57
57
|
|
@@ -26,7 +26,7 @@ module Twterm
|
|
26
26
|
input_thread = Thread.new do
|
27
27
|
close_screen
|
28
28
|
puts "\ninput search query"
|
29
|
-
query = readline('input query > ').strip
|
29
|
+
query = (readline('input query > ') || '').strip
|
30
30
|
resetter.call
|
31
31
|
|
32
32
|
tab = query.nil? || query.empty? ? Tab::New::Start.new : Tab::SearchTab.new(query)
|
data/lib/twterm/tab/new/user.rb
CHANGED
data/lib/twterm/tweetbox.rb
CHANGED
@@ -23,12 +23,42 @@ module Twterm
|
|
23
23
|
|
24
24
|
thread = Thread.new do
|
25
25
|
close_screen
|
26
|
+
|
26
27
|
if @in_reply_to.nil?
|
27
28
|
puts "\nCompose new tweet:"
|
28
29
|
else
|
29
30
|
puts "\nReply to @#{@in_reply_to.user.screen_name}'s tweet: \"#{@in_reply_to.text}\""
|
30
31
|
end
|
31
|
-
|
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
|
48
|
+
|
49
|
+
loop do
|
50
|
+
msg = @in_reply_to.nil? || !@status.empty? ? '> ' : "> @#{in_reply_to.user.screen_name} "
|
51
|
+
line = (readline(msg, true) || '').strip
|
52
|
+
break if line.empty?
|
53
|
+
|
54
|
+
if line.end_with?('\\')
|
55
|
+
@status << line.chop.lstrip + "\n"
|
56
|
+
else
|
57
|
+
@status << line
|
58
|
+
break
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
32
62
|
resetter.call
|
33
63
|
post
|
34
64
|
end
|
@@ -44,7 +74,7 @@ module Twterm
|
|
44
74
|
end
|
45
75
|
|
46
76
|
def post
|
47
|
-
return if @status.nil?
|
77
|
+
return if @status.nil? || @status.empty?
|
48
78
|
|
49
79
|
Client.current.post(@status, @in_reply_to)
|
50
80
|
clear
|
data/lib/twterm/user.rb
CHANGED
data/lib/twterm/version.rb
CHANGED
data/lib/twterm.rb
CHANGED
@@ -17,6 +17,9 @@ require 'twterm/auth'
|
|
17
17
|
require 'twterm/client'
|
18
18
|
require 'twterm/color_manager'
|
19
19
|
require 'twterm/config'
|
20
|
+
require 'twterm/history/base'
|
21
|
+
require 'twterm/history/hashtag'
|
22
|
+
require 'twterm/history/screen_name'
|
20
23
|
require 'twterm/list'
|
21
24
|
require 'twterm/notification/base'
|
22
25
|
require 'twterm/notification/message'
|
@@ -47,6 +50,6 @@ require 'twterm/version'
|
|
47
50
|
|
48
51
|
module Twterm
|
49
52
|
class Conf
|
50
|
-
REQUIRE_VERSION = '1.0.
|
53
|
+
REQUIRE_VERSION = '1.0.4'
|
51
54
|
end
|
52
55
|
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.
|
4
|
+
version: 1.0.4
|
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-03-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -129,6 +129,9 @@ files:
|
|
129
129
|
- lib/twterm/client.rb
|
130
130
|
- lib/twterm/color_manager.rb
|
131
131
|
- lib/twterm/config.rb
|
132
|
+
- lib/twterm/history/base.rb
|
133
|
+
- lib/twterm/history/hashtag.rb
|
134
|
+
- lib/twterm/history/screen_name.rb
|
132
135
|
- lib/twterm/list.rb
|
133
136
|
- lib/twterm/notification/base.rb
|
134
137
|
- lib/twterm/notification/error.rb
|