jugyo-termtter 0.3.5 → 0.3.6
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.
- data/Manifest.txt +1 -0
- data/README.rdoc +1 -1
- data/lib/termtter/uri-open.rb +30 -0
- data/lib/termtter.rb +4 -3
- metadata +2 -1
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Termtter::Client.add_hook do |statuses, event, t|
|
|
2
|
+
t.public_storage[:uris] ||= []
|
|
3
|
+
if !statuses.empty? && event == :update_friends_timeline
|
|
4
|
+
statuses.each do |s|
|
|
5
|
+
t.public_storage[:uris] += s.text.scan(%r|https?://[^\s]+|)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Termtter::Client
|
|
11
|
+
add_command /^uri-open\s*$/ do |t, m|
|
|
12
|
+
t.public_storage[:uris] ||= [] # It's not DRY
|
|
13
|
+
t.public_storage[:uris].each do |uri|
|
|
14
|
+
# FIXME: works only in OSX and other *NIXs
|
|
15
|
+
if /linux/ =~ RUBY_PLATFORM
|
|
16
|
+
system 'firefox', uri
|
|
17
|
+
else
|
|
18
|
+
system 'open', uri
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
t.public_storage[:uris].clear
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
# ~/.termtter
|
|
25
|
+
# require 'termtter/uri-open'
|
|
26
|
+
#
|
|
27
|
+
# see also: http://ujihisa.nowa.jp/entry/c3dd00c4e0
|
|
28
|
+
#
|
|
29
|
+
# KNOWN BUG
|
|
30
|
+
# * In Debian, exit or C-c in the termtter kills your firefox.
|
data/lib/termtter.rb
CHANGED
|
@@ -10,7 +10,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
|
10
10
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
11
11
|
|
|
12
12
|
module Termtter
|
|
13
|
-
VERSION = '0.3.
|
|
13
|
+
VERSION = '0.3.6'
|
|
14
14
|
|
|
15
15
|
class CommandNotFound < StandardError; end
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ module Termtter
|
|
|
35
35
|
@@commands.clear
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
attr_reader :since_id
|
|
38
|
+
attr_reader :since_id, :public_storage
|
|
39
39
|
|
|
40
40
|
def initialize
|
|
41
41
|
configatron.set_default(:update_interval, 300)
|
|
@@ -44,6 +44,7 @@ module Termtter
|
|
|
44
44
|
@password = configatron.password
|
|
45
45
|
@update_interval = configatron.update_interval
|
|
46
46
|
@debug = configatron.debug
|
|
47
|
+
@public_storage = {}
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def update_status(status)
|
|
@@ -107,7 +108,7 @@ module Termtter
|
|
|
107
108
|
def call_hooks(statuses, event)
|
|
108
109
|
@@hooks.each do |h|
|
|
109
110
|
begin
|
|
110
|
-
h.call(statuses.dup, event)
|
|
111
|
+
h.call(statuses.dup, event, self)
|
|
111
112
|
rescue => e
|
|
112
113
|
puts "Error: #{e}"
|
|
113
114
|
puts e.backtrace.join("\n")
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jugyo-termtter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jugyo
|
|
@@ -62,6 +62,7 @@ files:
|
|
|
62
62
|
- lib/termtter/stdout.rb
|
|
63
63
|
- lib/termtter/notify-send.rb
|
|
64
64
|
- lib/termtter/standard_commands.rb
|
|
65
|
+
- lib/termtter/uri-open.rb
|
|
65
66
|
- test/test_termtter.rb
|
|
66
67
|
has_rdoc: true
|
|
67
68
|
homepage: http://github.com/jugyo/termtter
|