facy 1.2.11 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa78d1e8d5b208cd05a28af845e724bd864b563e
4
- data.tar.gz: a0d3026f17d4bc092fe12a59c215eb3428c8a0de
3
+ metadata.gz: 6b4d2057ef1767d82df6907524af90ec1d3c2365
4
+ data.tar.gz: 103d0cf722d6365025654487e71cc1ed41e75324
5
5
  SHA512:
6
- metadata.gz: 0e482c8cc46a4a86123fcee6965364a4dd6182201a59f403feefaa6c38ac75c7cb5e0cfa1a270a4df978597f2fece1defb3bde6230ddea7338d7724145bc40f9
7
- data.tar.gz: d8fd9590296282755d060e9a9a72e0776e53c043319676baabb56c87debe7f58dddb18629e60cf93d5325c3a4d9f6386ece1081d97e5823d209e68a442049985
6
+ metadata.gz: bed82a630b4baf68c1139763424dbb1ddb6af794ffac0bcbf2e8a96dc9f18cefc726da26903078cd7020271e96c841c20dad296dd4bc638f23bda211fce44be0
7
+ data.tar.gz: 1d58a815b7b90e83ef17b7033d034630123942e3a79fd022121a1b53986e950bb80bf50399d8c5f87325dd2e63b138e9641419a76a584e6cd9977845be2772d2
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ facy (1.2.11)
5
+ activesupport (~> 4.0)
6
+ bundler (~> 1.5)
7
+ eventmachine (~> 1.0)
8
+ koala (~> 1.10)
9
+ launchy (~> 2.4)
10
+ rmagick (~> 2.13)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activesupport (4.1.5)
16
+ i18n (~> 0.6, >= 0.6.9)
17
+ json (~> 1.7, >= 1.7.7)
18
+ minitest (~> 5.1)
19
+ thread_safe (~> 0.1)
20
+ tzinfo (~> 1.1)
21
+ addressable (2.3.6)
22
+ eventmachine (1.0.3)
23
+ faraday (0.9.0)
24
+ multipart-post (>= 1.2, < 3)
25
+ i18n (0.6.11)
26
+ json (1.8.1)
27
+ koala (1.10.0)
28
+ addressable
29
+ faraday
30
+ multi_json
31
+ launchy (2.4.2)
32
+ addressable (~> 2.3)
33
+ minitest (5.4.0)
34
+ multi_json (1.10.1)
35
+ multipart-post (2.0.0)
36
+ rmagick (2.13.3)
37
+ thread_safe (0.3.4)
38
+ tzinfo (1.2.2)
39
+ thread_safe (~> 0.1)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ facy!
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 dxhuy1988
1
+ Copyright (c) 2014 dxhuy1988 (doxuanhuy@gmail.com)
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
1
  # Facy
2
+
3
+ ![](https://badge.fury.io/rb/facy.svg)
4
+
5
+ ![](http://i.gyazo.com/797434ffbf29ab5dc2b4aac542a75330.png)
6
+
2
7
  Facy is a terminal client for facebook, which support streaming-like feature.
3
8
  Only supports Ruby 1.9 and later.
4
9
  To install facy, we need ruby pre-installed, please refer to https://www.ruby-lang.org/en/installation/ to know how to install ruby.
@@ -1,5 +1,13 @@
1
1
  module Facy
2
2
  module Command
3
+ def aliasing(origin, with)
4
+ alias_commands[with] = origin
5
+ end
6
+
7
+ def alias_commands
8
+ @alias_commands ||= {}
9
+ end
10
+
3
11
  def commands
4
12
  @commands ||= []
5
13
  end
@@ -11,6 +19,9 @@ module Facy
11
19
  def execute(text)
12
20
  text.strip!
13
21
  rule, target = match_single_command(text) || match_target_command(text)
22
+ origin = alias_commands[rule.to_sym]
23
+ rule = origin.nil? ? rule : origin
24
+
14
25
  commands.each do |c|
15
26
  if rule.to_s == c[:pattern].to_s.split(":").first
16
27
  c[:block].call(target)
@@ -78,6 +89,7 @@ module Facy
78
89
  end
79
90
  end
80
91
  help :open, 'open a post in browser', ':open [code]'
92
+ aliasing :open, :op
81
93
 
82
94
  command :comment do |content|
83
95
  content = content.split(" ")
@@ -93,6 +105,7 @@ module Facy
93
105
  }
94
106
  end
95
107
  help :comment, 'comment to a post,', ':comment [code] [content]'
108
+ aliasing :comment, :cm
96
109
 
97
110
  command :seen do |notif_code|
98
111
  notif_code = "$#{notif_code}"
@@ -112,6 +125,7 @@ module Facy
112
125
  puts ""
113
126
  end
114
127
  help :view_raw, "view raw json output of a post", ":view_raw [post_code]"
128
+ aliasing :view_raw, :vr
115
129
 
116
130
  command :view_img do |post_code|
117
131
  if config[:enable_img_view]
@@ -128,6 +142,7 @@ module Facy
128
142
  end
129
143
  end
130
144
  help :view_img, "view an image as ascii art", ":view_img [code]"
145
+ aliasing :view_img, :vi
131
146
 
132
147
  command :view_comments do |post_code|
133
148
  post_code = "$#{post_code}"
@@ -141,6 +156,7 @@ module Facy
141
156
  end
142
157
  end
143
158
  help :view_comments, "view comments from a post", ":view_comments [code]"
159
+ aliasing :view_comments, :vc
144
160
 
145
161
  command :view_likes do |post_code|
146
162
  post_code = "$#{post_code}"
@@ -153,6 +169,7 @@ module Facy
153
169
  end
154
170
  end
155
171
  help :view_likes, "view likes detail from a post", ":view_likes [code]"
172
+ aliasing :view_likes, :vl
156
173
 
157
174
  command :dump_log do
158
175
  if config[:debug_log]
@@ -166,6 +183,7 @@ module Facy
166
183
  end
167
184
  end
168
185
  help :dump_log, "dump debug log to file", ":dump_log"
186
+ aliasing :dump_log, :dmp
169
187
 
170
188
  command :reconfig do
171
189
  begin
@@ -193,10 +211,13 @@ module Facy
193
211
  }
194
212
  end
195
213
  help :clear_cache, "clear posts and notification cache and fetch again", ":clear_cache"
214
+ aliasing :clear_cache, :cc
196
215
 
197
216
  command :mailbox do |target|
198
217
  if target
199
- threadnum, messagenum = target.split(" ").map(&:to_i)
218
+ targets = target.split(" ").map(&:to_i)
219
+ raise Exception.new("need two parameters") if targets.size != 2
220
+ threadnum, messagenum = targets
200
221
  mail = mailbox_cache[threadnum]
201
222
  instant_output(Item.new(info: :mail, content: {mail: mail, messagenum: messagenum}))
202
223
  else
@@ -208,6 +229,7 @@ module Facy
208
229
  end
209
230
  end
210
231
  help :mailbox, "read mailbox", ":mailbox [mail number]"
232
+ aliasing :mailbox, :m
211
233
 
212
234
  completion_proc = proc {|s|
213
235
  commands
@@ -1,5 +1,9 @@
1
1
  module Facy
2
2
  module Core
3
+ def me
4
+ @me
5
+ end
6
+
3
7
  def config
4
8
  @config ||= {}
5
9
  end
@@ -22,9 +26,14 @@ module Facy
22
26
  load_config
23
27
  login_flow
24
28
  inits.each { |block| class_eval(&block) }
29
+ set_me
25
30
  log(:info, "core module init success")
26
31
  end
27
32
 
33
+ def set_me
34
+ @me = facebook_me
35
+ end
36
+
28
37
  def load_config
29
38
  config.reverse_update(default_config)
30
39
  log(:info, "config loaded #{config.to_s}")
@@ -7,6 +7,16 @@ module Facy
7
7
  ERROR = 1
8
8
  SUSPENDED = 2
9
9
  end
10
+
11
+ def facebook_me
12
+ @graph.api("/me?fields=id,name")
13
+ rescue Koala::Facebook::ServerError
14
+ retry_wait
15
+ rescue Koala::Facebook::APIError
16
+ expired_session
17
+ rescue Exception => e
18
+ error e
19
+ end
10
20
 
11
21
  def facebook_status
12
22
  @status ||= ConnectionStatus::NORMAL
@@ -15,10 +15,12 @@ module Facy
15
15
  target = target.tap{|t|t.strip!}.gsub(':','').to_sym
16
16
  @helps.each do |h|
17
17
  if h[:target] == target
18
+ alias_cmds = alias_commands.select {|origin, with| with == target}.map{|k,v| k}
18
19
  instant_output(Item.new(
19
20
  info: :help,
20
21
  content: h[:usage],
21
- extra: h[:example]
22
+ extra: h[:example],
23
+ alias_cmds: alias_cmds
22
24
  ))
23
25
  end
24
26
  end
@@ -169,6 +169,7 @@ module Facy
169
169
  print_register :help do |item|
170
170
  puts item.content
171
171
  puts "example: #{item.extra}" if item.extra
172
+ puts "aliasing: #{item.alias_cmds}" if item.alias_cmds
172
173
  end
173
174
 
174
175
  print_register :comment do |item|
@@ -184,10 +185,12 @@ module Facy
184
185
  mails = mailbox_cache
185
186
  count = 0
186
187
  mails.each do |m|
187
- from = m["to"]["data"].first["name"].colorize(33)
188
- to = m["to"]["data"].last["name"].colorize(34)
188
+ from = m["to"]["data"].first["name"]
189
+ to = m["to"]["data"].last["name"]
190
+ actor = [from, to].keep_if{|m| m != me["name"]}.first.colorize(33)
189
191
  first_message = m["comments"]["data"].last["message"].short.colorize(37)
190
- puts " {#{count}} from: #{from} to: #{to} [#{first_message}]"
192
+
193
+ puts " {#{count}} from: #{actor} [#{first_message}]"
191
194
  count += 1
192
195
  end
193
196
  clear_line
@@ -1,3 +1,3 @@
1
1
  module Facy
2
- VERSION = "1.2.11"
2
+ VERSION = "1.2.12"
3
3
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.11
4
+ version: 1.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - dxhuy1988
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-22 00:00:00.000000000 Z
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: koala
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.10'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: launchy
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: eventmachine
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rmagick
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '2.13'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.13'
97
97
  description: 'facy: first colorful terminal client for facebook'
@@ -102,8 +102,9 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - ".gitignore"
105
+ - .gitignore
106
106
  - Gemfile
107
+ - Gemfile.lock
107
108
  - LICENSE.txt
108
109
  - README.md
109
110
  - Rakefile
@@ -135,17 +136,17 @@ require_paths:
135
136
  - lib
136
137
  required_ruby_version: !ruby/object:Gem::Requirement
137
138
  requirements:
138
- - - ">="
139
+ - - '>='
139
140
  - !ruby/object:Gem::Version
140
141
  version: 1.9.3
141
142
  required_rubygems_version: !ruby/object:Gem::Requirement
142
143
  requirements:
143
- - - ">="
144
+ - - '>='
144
145
  - !ruby/object:Gem::Version
145
146
  version: '0'
146
147
  requirements: []
147
148
  rubyforge_project:
148
- rubygems_version: 2.2.2
149
+ rubygems_version: 2.4.1
149
150
  signing_key:
150
151
  specification_version: 4
151
152
  summary: 'facy: terminal client for facebook'