earthquake 0.4.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -35,10 +35,28 @@ Commands
35
35
 
36
36
  ⚡ Hello World!
37
37
 
38
+ ### Show
39
+
40
+ ⚡ :status $xx
41
+
42
+ **$xx** is the alias of tweet id.
43
+
44
+ ### Delete
45
+
46
+ ⚡ :delete $xx
47
+
48
+ ### Reply
49
+
50
+ ⚡ :reply $xx hi!
51
+
52
+ ### Retweet
53
+
54
+ ⚡ :retweet $xx
55
+
38
56
  ### Timeline
39
57
 
40
58
  ⚡ :recent
41
- ⚡ :recent twitter
59
+ ⚡ :recent jugyo
42
60
 
43
61
  ### Search
44
62
 
@@ -65,7 +83,7 @@ And there are more commands!
65
83
  Customize
66
84
  ----
67
85
 
68
- The config file is '~/.earthquake/config'.
86
+ The config file is **~/.earthquake/config**.
69
87
 
70
88
  ### Changing the colors
71
89
 
@@ -76,7 +94,7 @@ The blue is excluded.
76
94
  Plugin
77
95
  ----
78
96
 
79
- "~/.earthquake/plugin" is the directory for plugins.
97
+ **~/.earthquake/plugin** is the directory for plugins.
80
98
  At launch, Earthquake tries to load files under this directory.
81
99
  The block that is specified for Earthquake.init will be reloaded at any command line input.
82
100
 
@@ -158,10 +176,9 @@ The 'm' is a MatchData.
158
176
  TODO
159
177
  ----
160
178
 
161
- * dealing with direct messages
162
179
  * more intelligent completion
163
- * typable id
164
180
  * spec
181
+ * change the config dir by ARGV
165
182
 
166
183
  Copyright
167
184
  ----
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.9
1
+ 0.5.0
data/earthquake.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{earthquake}
8
- s.version = "0.4.9"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jugyo"]
12
- s.date = %q{2011-03-27}
12
+ s.date = %q{2011-03-28}
13
13
  s.default_executable = %q{earthquake}
14
14
  s.description = %q{Twitter Client on Terminal with Twitter Streaming API.}
15
15
  s.email = %q{jugyo.org@gmail.com}
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "lib/earthquake/core.rb",
36
36
  "lib/earthquake/ext.rb",
37
37
  "lib/earthquake/get_access_token.rb",
38
+ "lib/earthquake/id_var.rb",
38
39
  "lib/earthquake/input.rb",
39
40
  "lib/earthquake/output.rb",
40
41
  "lib/earthquake/twitter.rb",
@@ -59,7 +60,7 @@ Accordingly that, You should renew the access token if it is old.
59
60
  }
60
61
  s.require_paths = ["lib"]
61
62
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
62
- s.rubygems_version = %q{1.3.7}
63
+ s.rubygems_version = %q{1.6.0}
63
64
  s.summary = %q{Twitter Client on Terminal.}
64
65
  s.test_files = [
65
66
  "spec/earthquake_spec.rb",
@@ -67,7 +68,6 @@ Accordingly that, You should renew the access token if it is old.
67
68
  ]
68
69
 
69
70
  if s.respond_to? :specification_version then
70
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
71
71
  s.specification_version = 3
72
72
 
73
73
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
data/lib/earthquake.rb CHANGED
@@ -22,6 +22,7 @@
22
22
  get_access_token
23
23
  twitter
24
24
  commands
25
+ id_var
25
26
  ).each { |name| require_dependency File.expand_path("../earthquake/#{name}", __FILE__) }
26
27
 
27
28
  Thread.abort_on_exception = true
@@ -35,7 +35,8 @@ module Earthquake
35
35
  end
36
36
 
37
37
  command :status do |m|
38
- puts_items twitter.status(m[1])
38
+ # TODO: show reply to statuses
39
+ puts_items twitter.status(m[1]).tap { |s| s["_detail"] = true }
39
40
  end
40
41
 
41
42
  command :delete do |m|
@@ -0,0 +1,50 @@
1
+ module Earthquake
2
+ module IdVar
3
+ attr_accessor :id_var
4
+
5
+ def id2var(id)
6
+ id_var.id2var(id)
7
+ end
8
+
9
+ def var2id(var)
10
+ id_var.var2id(var)
11
+ end
12
+
13
+ class Gen
14
+ def initialize(vars = ('aa'..'zz').to_a, prefix = '$')
15
+ if not vars.kind_of?(Array)
16
+ raise ArgumentError, 'vars should be an Array'
17
+ elsif vars.empty?
18
+ raise ArgumentError, 'vars should not be empty'
19
+ end
20
+ @vars = vars.map { |var| prefix + var }
21
+ @table = {}
22
+ @rtable = {}
23
+ @prefix = prefix
24
+ end
25
+
26
+ def var2id(var)
27
+ @table[var]
28
+ end
29
+
30
+ def id2var(id)
31
+ @rtable[id] || self.next(id)
32
+ end
33
+
34
+ def next(id)
35
+ var = @vars.shift
36
+ @vars.push var
37
+ @rtable.delete(@table[var])
38
+ @table[var] = id
39
+ @rtable[id] = var
40
+ var
41
+ end
42
+ end
43
+ end
44
+
45
+ extend IdVar
46
+
47
+ init do
48
+ self.id_var ||= IdVar::Gen.new
49
+ end
50
+ end
@@ -27,6 +27,10 @@ module Earthquake
27
27
  end
28
28
 
29
29
  begin
30
+ text = text.gsub(/\$\w+/) do |var|
31
+ var2id(var) || var
32
+ end
33
+
30
34
  if command = command(text)
31
35
  command[:block].call(command[:pattern].match(text))
32
36
  elsif !text.empty?
@@ -70,20 +70,18 @@ module Earthquake
70
70
  output do |item|
71
71
  next unless item["text"]
72
72
 
73
+ info = []
73
74
  if item["in_reply_to_status_id"]
74
- misc = " (reply to #{item["in_reply_to_status_id"]})"
75
+ info << "(reply to #{id2var(item["in_reply_to_status_id"])})"
75
76
  elsif item["retweeted_status"]
76
- misc = " (retweet of #{item["retweeted_status"]["id"]})"
77
- else
78
- misc = ""
77
+ info << "(retweet of #{id2var(item["retweeted_status"]["id"])})"
79
78
  end
80
-
81
- statuses = ["[#{item["id"].to_s}]"]
82
- unless item["_stream"]
83
- statuses.insert(0, "[#{Time.parse(item["created_at"]).strftime('%Y.%m.%d %X')}]")
79
+ info << Time.parse(item["created_at"]).strftime('%m/%d/%y %H:%M %p')
80
+ if item["_detail"] && item["source"]
81
+ info << (item["source"].u =~ />(.*)</ ? $1 : 'web')
84
82
  end
85
83
 
86
- source = item["source"].u =~ />(.*)</ ? $1 : 'web' rescue ''
84
+ id = id2var(item["id"])
87
85
 
88
86
  text = item["text"].u
89
87
  text.gsub!(/@([0-9A-Za-z_]+)/) do |i|
@@ -102,20 +100,22 @@ module Earthquake
102
100
  end
103
101
  end
104
102
 
105
- mark = item["mark"] || ""
103
+ mark = item["_mark"] || ""
106
104
 
107
105
  status = [
108
- "#{mark}" + "#{statuses.join(" ")}".c(90),
106
+ "#{mark}" + "[#{id}]".c(90),
109
107
  "#{item["user"]["screen_name"].c(color_of(item["user"]["screen_name"]))}:",
110
108
  "#{text}",
111
- "#{misc} #{source}".c(90)
112
- ].join(" ")
109
+ (item["user"]["protected"] ? "[P]".c(31) : nil),
110
+ info.join(' - ').c(90)
111
+ ].compact.join(" ")
113
112
  puts status
114
113
  end
115
114
 
116
115
  output do |item|
117
116
  next unless item["event"]
118
117
 
118
+ # TODO: handle 'list_member_added' and 'list_member_removed'
119
119
  case item["event"]
120
120
  when "follow", "block", "unblock"
121
121
  puts "[#{item["event"]}]".c(42) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]}"
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: earthquake
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 4
8
- - 9
9
- version: 0.4.9
4
+ prerelease:
5
+ version: 0.5.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - jugyo
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-03-27 00:00:00 +09:00
13
+ date: 2011-03-28 00:00:00 +09:00
18
14
  default_executable: earthquake
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -24,8 +20,6 @@ dependencies:
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
23
  version: "0"
30
24
  type: :runtime
31
25
  prerelease: false
@@ -37,8 +31,6 @@ dependencies:
37
31
  requirements:
38
32
  - - ">="
39
33
  - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
34
  version: "0"
43
35
  type: :runtime
44
36
  prerelease: false
@@ -50,8 +42,6 @@ dependencies:
50
42
  requirements:
51
43
  - - ">="
52
44
  - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
45
  version: "0"
56
46
  type: :runtime
57
47
  prerelease: false
@@ -63,8 +53,6 @@ dependencies:
63
53
  requirements:
64
54
  - - ">="
65
55
  - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
56
  version: "0"
69
57
  type: :runtime
70
58
  prerelease: false
@@ -76,8 +64,6 @@ dependencies:
76
64
  requirements:
77
65
  - - ">="
78
66
  - !ruby/object:Gem::Version
79
- segments:
80
- - 0
81
67
  version: "0"
82
68
  type: :runtime
83
69
  prerelease: false
@@ -89,8 +75,6 @@ dependencies:
89
75
  requirements:
90
76
  - - ">="
91
77
  - !ruby/object:Gem::Version
92
- segments:
93
- - 0
94
78
  version: "0"
95
79
  type: :runtime
96
80
  prerelease: false
@@ -102,8 +86,6 @@ dependencies:
102
86
  requirements:
103
87
  - - ">="
104
88
  - !ruby/object:Gem::Version
105
- segments:
106
- - 0
107
89
  version: "0"
108
90
  type: :runtime
109
91
  prerelease: false
@@ -115,8 +97,6 @@ dependencies:
115
97
  requirements:
116
98
  - - ">="
117
99
  - !ruby/object:Gem::Version
118
- segments:
119
- - 0
120
100
  version: "0"
121
101
  type: :runtime
122
102
  prerelease: false
@@ -128,8 +108,6 @@ dependencies:
128
108
  requirements:
129
109
  - - ">="
130
110
  - !ruby/object:Gem::Version
131
- segments:
132
- - 0
133
111
  version: "0"
134
112
  type: :runtime
135
113
  prerelease: false
@@ -141,10 +119,6 @@ dependencies:
141
119
  requirements:
142
120
  - - ~>
143
121
  - !ruby/object:Gem::Version
144
- segments:
145
- - 2
146
- - 3
147
- - 0
148
122
  version: 2.3.0
149
123
  type: :development
150
124
  prerelease: false
@@ -156,10 +130,6 @@ dependencies:
156
130
  requirements:
157
131
  - - ~>
158
132
  - !ruby/object:Gem::Version
159
- segments:
160
- - 1
161
- - 0
162
- - 0
163
133
  version: 1.0.0
164
134
  type: :development
165
135
  prerelease: false
@@ -171,10 +141,6 @@ dependencies:
171
141
  requirements:
172
142
  - - ~>
173
143
  - !ruby/object:Gem::Version
174
- segments:
175
- - 1
176
- - 5
177
- - 2
178
144
  version: 1.5.2
179
145
  type: :development
180
146
  prerelease: false
@@ -205,6 +171,7 @@ files:
205
171
  - lib/earthquake/core.rb
206
172
  - lib/earthquake/ext.rb
207
173
  - lib/earthquake/get_access_token.rb
174
+ - lib/earthquake/id_var.rb
208
175
  - lib/earthquake/input.rb
209
176
  - lib/earthquake/output.rb
210
177
  - lib/earthquake/twitter.rb
@@ -228,23 +195,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
195
  requirements:
229
196
  - - ">="
230
197
  - !ruby/object:Gem::Version
231
- segments:
232
- - 1
233
- - 9
234
- - 1
235
198
  version: 1.9.1
236
199
  required_rubygems_version: !ruby/object:Gem::Requirement
237
200
  none: false
238
201
  requirements:
239
202
  - - ">="
240
203
  - !ruby/object:Gem::Version
241
- segments:
242
- - 0
243
204
  version: "0"
244
205
  requirements: []
245
206
 
246
207
  rubyforge_project:
247
- rubygems_version: 1.3.7
208
+ rubygems_version: 1.6.0
248
209
  signing_key:
249
210
  specification_version: 3
250
211
  summary: Twitter Client on Terminal.