earthquake 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -37,17 +37,17 @@ Commands
37
37
 
38
38
  ### Show
39
39
 
40
- :status $xx
40
+ ⚡ $xx
41
41
 
42
42
  **$xx** is the alias of tweet id.
43
43
 
44
- ### Delete
44
+ ### Reply
45
45
 
46
- :delete $xx
46
+ ⚡ $xx hi!
47
47
 
48
- ### Reply
48
+ ### Delete
49
49
 
50
- ⚡ :reply $xx hi!
50
+ ⚡ :delete $xx
51
51
 
52
52
  ### Retweet
53
53
 
@@ -174,12 +174,12 @@ The 'm' is a MatchData.
174
174
  end
175
175
  end
176
176
 
177
- ### Defining filters
177
+ ### Defining filters for output
178
178
 
179
179
  #### Filtering by keywords
180
180
 
181
181
  Earthquake.init do
182
- filter do |item|
182
+ output_filter do |item|
183
183
  if item["_stream"] && item["text"]
184
184
  item["text"] =~ /ruby/i
185
185
  else
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
data/earthquake.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{earthquake}
8
- s.version = "0.5.3"
8
+ s.version = "0.5.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jugyo"]
@@ -20,7 +20,7 @@ module Earthquake
20
20
  end
21
21
 
22
22
  # update
23
- command %r|^[^:].*| do |m|
23
+ command %r|^[^:\$].*| do |m|
24
24
  async { twitter.update(m[0]) } if confirm("update '#{m[0]}'")
25
25
  end
26
26
 
@@ -34,11 +34,21 @@ module Earthquake
34
34
  end
35
35
  end
36
36
 
37
+ # $xx hi!
38
+ command %r|^(\$[^\s]+)\s+(.*)$| do |m|
39
+ input(":reply #{m[1..2].join(' ')}")
40
+ end
41
+
37
42
  command :status do |m|
38
43
  # TODO: show reply to statuses
39
44
  puts_items twitter.status(m[1]).tap { |s| s["_detail"] = true }
40
45
  end
41
46
 
47
+ # $xx
48
+ command %r|^(\$[^\s]+)$| do |m|
49
+ input(":status #{m[1]}")
50
+ end
51
+
42
52
  command :delete do |m|
43
53
  # TODO: confirm
44
54
  async { twitter.status_destroy(m[1]) }
@@ -61,12 +71,12 @@ module Earthquake
61
71
  end
62
72
 
63
73
  # :recent jugyo
64
- command %r|^:recent\s+([^\/\s]+)\s*$|, :as => :recent do |m|
74
+ command %r|^:recent\s+([^\/\s]+)$|, :as => :recent do |m|
65
75
  puts_items twitter.user_timeline(:screen_name => m[1])
66
76
  end
67
77
 
68
78
  # :recent yugui/ruby-committers
69
- command %r|^:recent\s+([^\s]+)\/([^\s]+)\s*$|, :as => :recent do |m|
79
+ command %r|^:recent\s+([^\s]+)\/([^\s]+)$|, :as => :recent do |m|
70
80
  puts_items twitter.list_statuses(m[1], m[2])
71
81
  end
72
82
 
@@ -29,7 +29,7 @@ module Earthquake
29
29
  begin
30
30
  text = text.gsub(/\$\w+/) do |var|
31
31
  var2id(var) || var
32
- end
32
+ end if text =~ %r|^:|
33
33
 
34
34
  if command = command(text)
35
35
  command[:block].call(command[:pattern].match(text))
@@ -94,13 +94,14 @@ module Earthquake
94
94
  completion do |text|
95
95
  results = []
96
96
  regexp = /^#{Regexp.quote(text)}/
97
- if Readline.line_buffer =~ /^\s*:\w*$/
98
- results += command_names.grep(regexp)
99
- end
97
+
98
+ results += command_names.grep(regexp)
99
+
100
100
  range = Readline::HISTORY.count >= 100 ? -100..-1 : 0..-1
101
101
  results += Readline::HISTORY.to_a[range].map { |line|
102
102
  line.gsub(/^\s*:\w/, '').split(/\s+/)
103
103
  }.flatten.grep(regexp)
104
+
104
105
  results
105
106
  end
106
107
  end
@@ -1,12 +1,12 @@
1
1
  # encoding: UTF-8
2
2
  module Earthquake
3
3
  module Output
4
- def filters
5
- @filters ||= []
4
+ def output_filters
5
+ @output_filters ||= []
6
6
  end
7
7
 
8
- def filter(&block)
9
- filters << block
8
+ def output_filter(&block)
9
+ output_filters << block
10
10
  end
11
11
 
12
12
  def outputs
@@ -29,7 +29,7 @@ module Earthquake
29
29
 
30
30
  def puts_items(items)
31
31
  [items].flatten.reverse_each do |item|
32
- next if filters.any? { |f| f.call(item) == false }
32
+ next if output_filters.any? { |f| f.call(item) == false }
33
33
  outputs.each do |o|
34
34
  begin
35
35
  o.call(item)
@@ -63,7 +63,7 @@ module Earthquake
63
63
 
64
64
  init do
65
65
  outputs.clear
66
- filters.clear
66
+ output_filters.clear
67
67
 
68
68
  config[:colors] ||= (31..36).to_a + (91..96).to_a
69
69
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earthquake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.3
5
+ version: 0.5.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - jugyo