facy 1.2.10 → 1.2.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8e26a6c24152454a71b79f8a5db6de2e73bf058
4
- data.tar.gz: 5a2f61f2e2c95757e38a2ca20e149757e5807d61
3
+ metadata.gz: aa78d1e8d5b208cd05a28af845e724bd864b563e
4
+ data.tar.gz: a0d3026f17d4bc092fe12a59c215eb3428c8a0de
5
5
  SHA512:
6
- metadata.gz: a261b36d0fa4e7bb6635898964b8c5a4f027d509edf84e01e232e8b05e67252a468a245832c6db0aa6fef86b72850228918470fdee4b8abc04bb4e91cf0405d3
7
- data.tar.gz: 583fe3a0c7a26b422cad445e98205b6734d8681494c7a7bbf84b190dbc025f0d5523860810617075181499326195c96894739ba1d12d320d90bb8914000eab37
6
+ metadata.gz: 0e482c8cc46a4a86123fcee6965364a4dd6182201a59f403feefaa6c38ac75c7cb5e0cfa1a270a4df978597f2fece1defb3bde6230ddea7338d7724145bc40f9
7
+ data.tar.gz: d8fd9590296282755d060e9a9a72e0776e53c043319676baabb56c87debe7f58dddb18629e60cf93d5325c3a4d9f6386ece1081d97e5823d209e68a442049985
data/config.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  app_id:
3
- permission: friends_status,manage_notifications,publish_actions,read_friendlists,read_stream,user_status
3
+ permission: friends_status,manage_notifications,publish_actions,read_friendlists,read_stream,user_status,read_mailbox
4
4
  granted:
@@ -194,6 +194,21 @@ module Facy
194
194
  end
195
195
  help :clear_cache, "clear posts and notification cache and fetch again", ":clear_cache"
196
196
 
197
+ command :mailbox do |target|
198
+ if target
199
+ threadnum, messagenum = target.split(" ").map(&:to_i)
200
+ mail = mailbox_cache[threadnum]
201
+ instant_output(Item.new(info: :mail, content: {mail: mail, messagenum: messagenum}))
202
+ else
203
+ async {
204
+ mails = facebook_mailbox
205
+ mails.each {|m| mailbox_cache << m} if mails && !mails.empty?
206
+ instant_output(Item.new(info: :mails))
207
+ }
208
+ end
209
+ end
210
+ help :mailbox, "read mailbox", ":mailbox [mail number]"
211
+
197
212
  completion_proc = proc {|s|
198
213
  commands
199
214
  .map{|c|c[:pattern]}
@@ -3,7 +3,11 @@ class String
3
3
  "\e[#{code.join(";")}m#{self}\e[0m"
4
4
  end
5
5
 
6
- def strip
7
- self.truncate(50)
6
+ def short
7
+ if self.size > 50
8
+ self.truncate(50) + "..."
9
+ else
10
+ self
11
+ end
8
12
  end
9
13
  end
@@ -71,6 +71,17 @@ module Facy
71
71
  error e
72
72
  end
73
73
 
74
+ def facebook_mailbox
75
+ @graph.get_connections("me", "inbox")
76
+ rescue Koala::Facebook::ServerError => e
77
+ retry_wait
78
+ rescue Koala::Facebook::APIError => e
79
+ error e.message
80
+ expired_session
81
+ rescue Exception => e
82
+ error e
83
+ end
84
+
74
85
 
75
86
  def facebook_comment(post_id, comment)
76
87
  @graph.put_comment(post_id, comment)
@@ -85,7 +96,7 @@ module Facy
85
96
  def expired_session
86
97
  FileUtils.rm(session_file)
87
98
  instant_output(Item.new(info: :info, content: "Please restart facy to obtain new access token!"))
88
- exit
99
+ stop_process
89
100
  end
90
101
 
91
102
  def retry_wait
@@ -19,7 +19,11 @@ module Facy
19
19
  def insert_lock
20
20
  @insert_lock ||= Monitor.new
21
21
  end
22
-
22
+
23
+ def mailbox_cache
24
+ @mailbox_cache ||= []
25
+ end
26
+
23
27
  def insert_item(item)
24
28
  insert_lock.synchronize do
25
29
  _insert_item(item)
@@ -178,6 +178,32 @@ module Facy
178
178
  print_register :like do |item|
179
179
  puts " ♥ #{item.from}"
180
180
  end
181
+
182
+ print_register :mails do
183
+ new_line
184
+ mails = mailbox_cache
185
+ count = 0
186
+ mails.each do |m|
187
+ from = m["to"]["data"].first["name"].colorize(33)
188
+ to = m["to"]["data"].last["name"].colorize(34)
189
+ first_message = m["comments"]["data"].last["message"].short.colorize(37)
190
+ puts " {#{count}} from: #{from} to: #{to} [#{first_message}]"
191
+ count += 1
192
+ end
193
+ clear_line
194
+ end
195
+
196
+ print_register :mail do |item|
197
+ new_line
198
+ num = item.content.messagenum
199
+ comments = item.content.mail["comments"]["data"][-num, num]
200
+
201
+ comments.each do |comment|
202
+ created = DateTime.parse(comment["created_time"])
203
+ message = comment["message"]
204
+ puts " #{created.strftime('%m/%d %H:%M').colorize(90)} #{message}"
205
+ end
206
+ end
181
207
  end
182
208
 
183
209
  extend Output
@@ -1,3 +1,3 @@
1
1
  module Facy
2
- VERSION = "1.2.10"
2
+ VERSION = "1.2.11"
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.10
4
+ version: 1.2.11
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-21 00:00:00.000000000 Z
11
+ date: 2014-08-22 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,7 +102,7 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - .gitignore
105
+ - ".gitignore"
106
106
  - Gemfile
107
107
  - LICENSE.txt
108
108
  - README.md
@@ -135,17 +135,17 @@ require_paths:
135
135
  - lib
136
136
  required_ruby_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - '>='
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: 1.9.3
141
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.4.1
148
+ rubygems_version: 2.2.2
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: 'facy: terminal client for facebook'