jugyo-termtter 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
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.6'
13
+ VERSION = '0.3.7'
14
14
 
15
15
  class CommandNotFound < StandardError; end
16
16
 
@@ -147,7 +147,7 @@ module Termtter
147
147
  if key =~ text
148
148
  command_found = true
149
149
  begin
150
- command.call(self, $~)
150
+ command.call($~, self)
151
151
  rescue => e
152
152
  puts "Error: #{e}"
153
153
  puts e.backtrace.join("\n")
@@ -1,48 +1,48 @@
1
1
  class Termtter::Client
2
2
 
3
- add_command /^(update|u)\s+(.*)/ do |t, m|
3
+ add_command /^(update|u)\s+(.*)/ do |m, t|
4
4
  text = m[2]
5
5
  next if text.empty?
6
6
  t.update_status(text)
7
7
  puts "=> #{text}"
8
8
  end
9
9
 
10
- add_command /^(list|l)\s*$/ do |t, m|
10
+ add_command /^(list|l)\s*$/ do |m, t|
11
11
  t.list_friends_timeline()
12
12
  end
13
13
 
14
- add_command /^(list|l)\s+([^\s]+)/ do |t, m|
14
+ add_command /^(list|l)\s+([^\s]+)/ do |m, t|
15
15
  t.get_user_timeline(m[2])
16
16
  end
17
17
 
18
- add_command /^(search|s)\s+(.*)/ do |t, m|
18
+ add_command /^(search|s)\s+(.*)/ do |m, t|
19
19
  query = m[2]
20
20
  unless query.empty?
21
21
  t.search(query)
22
22
  end
23
23
  end
24
24
 
25
- add_command /^(replies|r)\s*$/ do |t, m|
25
+ add_command /^(replies|r)\s*$/ do |m, t|
26
26
  t.replies()
27
27
  end
28
28
 
29
- add_command /^show\s+([^\s]+)/ do |t, m|
29
+ add_command /^show\s+([^\s]+)/ do |m, t|
30
30
  t.show($1)
31
31
  end
32
32
 
33
- add_command /^pause\s*$/ do |t, m|
33
+ add_command /^pause\s*$/ do |m, t|
34
34
  t.pause
35
35
  end
36
36
 
37
- add_command /^resume\s*$/ do |t, m|
37
+ add_command /^resume\s*$/ do |m, t|
38
38
  t.resume
39
39
  end
40
40
 
41
- add_command /^exit\s*$/ do |t, m|
41
+ add_command /^exit\s*$/ do |m, t|
42
42
  t.exit
43
43
  end
44
44
 
45
- add_command /^help\s*$/ do |t, m|
45
+ add_command /^help\s*$/ do |m, t|
46
46
  puts <<-EOS
47
47
  exit Exit
48
48
  help Print this help message
@@ -57,7 +57,7 @@ show ID Show a single status
57
57
  EOS
58
58
  end
59
59
 
60
- add_command /^eval\s+(.*)$/ do |t, m|
60
+ add_command /^eval\s+(.*)$/ do |m, t|
61
61
  result = t.instance_eval m[1] unless m[1].empty?
62
62
  puts "=> #{result.inspect}"
63
63
  end
@@ -13,7 +13,7 @@ Termtter::Client.add_hook do |statuses, event|
13
13
  text = s.text.gsub("\n", '')
14
14
  color_num = colors[s.user_screen_name.hash % colors.size]
15
15
  status = "#{s.user_screen_name}: #{text}"
16
- unless s.in_reply_to_status_id && s.in_reply_to_status_id.nil?
16
+ unless s.in_reply_to_status_id.nil?
17
17
  status += " (reply to #{s.in_reply_to_status_id})"
18
18
  end
19
19
 
@@ -8,7 +8,7 @@ Termtter::Client.add_hook do |statuses, event, t|
8
8
  end
9
9
 
10
10
  class Termtter::Client
11
- add_command /^uri-open\s*$/ do |t, m|
11
+ add_command /^uri-open\s*$/ do |m, t|
12
12
  t.public_storage[:uris] ||= [] # It's not DRY
13
13
  t.public_storage[:uris].each do |uri|
14
14
  # FIXME: works only in OSX and other *NIXs
@@ -73,7 +73,7 @@ class TestTermtter < Test::Unit::TestCase
73
73
  def test_add_command
74
74
  command_text = nil
75
75
  matche_text = nil
76
- Termtter::Client.add_command /foo\s+(.*)/ do |termtter, matche|
76
+ Termtter::Client.add_command /foo\s+(.*)/ do |matche, termtter|
77
77
  command_text = matche[0]
78
78
  matche_text = matche[1]
79
79
  end
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.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo