facy 1.2.9 → 1.2.10.rc1

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: a32f826af6c9f06ebe58c5846e53fdeb15034a8d
4
- data.tar.gz: 1453e71ff411f397e59fa151209b055574f2b107
3
+ metadata.gz: d3eb2d20894254602ff05d10db9ca3688223cd66
4
+ data.tar.gz: e6d4f592528a3da0911aa1f4b663054fd7ade42c
5
5
  SHA512:
6
- metadata.gz: 35406d9de65a48ae4065a86e5acada022639cea92b1e86bb43d6a88f4554a6ccf787ec20f57acdd9ad8b5f60e670f6189e1c48071d7b64042eadad784a4711c7
7
- data.tar.gz: db9224cba4eff146cb9e1138191e33a653181bf79155c7c02a7bb4b069f6b52683788f6921ffb25082b680505d2e2f4d1a2db2ab7b0be437ab3170d776393bec
6
+ metadata.gz: 13daf2fbfbb2ba54105b3994c6cbb91a7eddbb9a529a72819c9700ed899f4da0f6252cea9a48dcc7211859f45c94b3c88275184dc0daee84b6f7d07511a196c8
7
+ data.tar.gz: d5ecbd1f7d3ffec32f0f39afc81c13001b4b03bd37a5b17440fa615e9b745ea9e0ac2be7993d0654ed9033304c69ead1cc773a145bd1ffd610d575feb59da1d1
data/README.md CHANGED
@@ -12,6 +12,11 @@ I recommend rvm to control the version of installed ruby.
12
12
 
13
13
  ![](http://i.gyazo.com/01de9c8da6191b79bcec201048361f58.png)
14
14
 
15
+ Imageview by asii-art also available by option config, however image quality is quite bad, so it seems quite useless.
16
+
17
+ ![](http://i.gyazo.com/ede1444083fda6d16c1ce2531a05aabf.png)
18
+
19
+
15
20
  ## Installation
16
21
  Install it yourself as:
17
22
  ```
data/bin/facy CHANGED
@@ -12,7 +12,7 @@ puts %q{
12
12
  print "\e[0m"
13
13
  require 'facy'
14
14
  Facy.parse(ARGV)
15
- puts "Fetching facebook stream at first time may takes a while ♩ ♪ ♫ ♬"
15
+ puts "Fetching facebook stream at first time may take a while ♩ ♪ ♫ ♬"
16
16
  puts ""
17
17
 
18
18
  Facy.start({})
data/facy.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '>= 1.9.3'
20
21
 
21
22
  spec.add_runtime_dependency "bundler", "~> 1.5"
22
23
  spec.add_runtime_dependency "koala", "~>1.10"
data/lib/facy.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  %w(
2
- rmagick
3
2
  koala
4
3
  readline
5
4
  yaml
@@ -11,6 +10,17 @@
11
10
  active_support/dependencies
12
11
  ).each { |lib| require lib }
13
12
 
13
+ begin
14
+ require "rmagick"
15
+ rescue LoadError
16
+ begin
17
+ require "RMagick"
18
+ rescue LoadError
19
+ p "can not require rmagick library in this computer"
20
+ exit
21
+ end
22
+ end
23
+
14
24
  Thread.abort_on_exception = true
15
25
  Encoding.default_external = Encoding.find('UTF-8')
16
26
 
data/lib/facy/command.rb CHANGED
@@ -95,11 +95,14 @@ module Facy
95
95
  help :comment, 'comment to a post,', ':comment [code] [content]'
96
96
 
97
97
  command :seen do |notif_code|
98
+ notif_code = "$#{notif_code}"
99
+ item = post_code_reverse_map[notif_code]
98
100
  async {
99
- ret = facebook_set_seen(notif_code)
101
+ ret = facebook_set_seen(item.id)
100
102
  instant_output(Item.new(info: :info, content: 'unseen success')) if ret
101
103
  }
102
104
  end
105
+ help :seen, "set a notification to seen", ":seen [code]"
103
106
 
104
107
  command :view_raw do |post_code|
105
108
  post_code = "$#{post_code}"
@@ -124,6 +127,7 @@ module Facy
124
127
  instant_output(Item.new(info: :error, content: "use facy -enable_img_view to enable image viewer"))
125
128
  end
126
129
  end
130
+ help :view_img, "view an image as ascii art", ":view_img [code]"
127
131
 
128
132
  command :view_comments do |post_code|
129
133
  post_code = "$#{post_code}"
@@ -136,7 +140,7 @@ module Facy
136
140
  end
137
141
  end
138
142
  end
139
- help :view_comments, "view a comment from a post", ":view_comments [code]"
143
+ help :view_comments, "view comments from a post", ":view_comments [code]"
140
144
 
141
145
  command :view_likes do |post_code|
142
146
  post_code = "$#{post_code}"
@@ -148,6 +152,7 @@ module Facy
148
152
  end
149
153
  end
150
154
  end
155
+ help :view_likes, "view likes detail from a post", ":view_likes [code]"
151
156
 
152
157
  command :dump_log do
153
158
  if config[:debug_log]
@@ -162,6 +167,18 @@ module Facy
162
167
  end
163
168
  help :dump_log, "dump debug log to file", ":dump_log"
164
169
 
170
+ command :reconfig do
171
+ begin
172
+ FileUtils.rm(config_file)
173
+ FileUtils.rm(session_file)
174
+ instant_output(Item.new(info: :info, content: "restart facy to reconfig"))
175
+ stop_process
176
+ rescue Exception => e
177
+ error e.message
178
+ end
179
+ end
180
+ help :reconfig, "reconfig app_id, app_secret access token", ":reconfig"
181
+
165
182
  command :commands do
166
183
  helps.each do |help|
167
184
  puts ":#{help[:target].to_s.colorize(38,5,8)} #{help[:usage]}"
@@ -169,6 +186,14 @@ module Facy
169
186
  end
170
187
  help :commands, "list all available commands", ":commands"
171
188
 
189
+ command :clear_cache do
190
+ sync {
191
+ printed_item.clear
192
+ #TODO clear also code table
193
+ }
194
+ end
195
+ help :clear_cache, "clear posts and notification cache and fetch again", ":clear_cache"
196
+
172
197
  completion_proc = proc {|s|
173
198
  commands
174
199
  .map{|c|c[:pattern]}
@@ -14,6 +14,7 @@ module Facy
14
14
  content: graph_item["title"],
15
15
  },
16
16
  date: graph_item["created_time"],
17
+ link: graph_item["link"]
17
18
  })
18
19
  else
19
20
  content =
@@ -31,7 +32,7 @@ module Facy
31
32
  when "video"
32
33
  "share a video: #{graph_item['message']}"
33
34
  when "link"
34
- "#{graph_item["message"]} #{graph_item["link"]}"
35
+ "#{graph_item["message"]} #{graph_item["link"]} #{graph_item["name"]}"
35
36
  end
36
37
 
37
38
  link =
data/lib/facy/core.rb CHANGED
@@ -12,6 +12,12 @@ module Facy
12
12
  inits << block
13
13
  end
14
14
 
15
+ def config_file
16
+ config_file_folder = "/tmp"
17
+ config_file_name = ".facy_config.yml"
18
+ File.expand_path(config_file_name, config_file_folder)
19
+ end
20
+
15
21
  def _init
16
22
  load_config
17
23
  login_flow
@@ -25,7 +31,10 @@ module Facy
25
31
  end
26
32
 
27
33
  def default_config
28
- config = YAML.load_file(File.expand_path("../../../config.yml", __FILE__))
34
+ default_conf_file = File.expand_path("../../../config.yml", __FILE__)
35
+ file = File.exist?(config_file) ? config_file : default_conf_file
36
+
37
+ config = YAML.load_file(file)
29
38
  {
30
39
  session_file_folder: "/tmp",
31
40
  session_file_name: ".facy_access_token.yml",
data/lib/facy/facebook.rb CHANGED
@@ -61,10 +61,11 @@ module Facy
61
61
  end
62
62
 
63
63
  def facebook_set_seen(notification_id)
64
- @graph.put_connection("#{notification_id}", "unread=false")
65
- rescue Koala::Facebook::ServerError
64
+ @graph.put_connections("#{notification_id}", "unread=false")
65
+ rescue Koala::Facebook::ServerError => e
66
66
  retry_wait
67
- rescue Koala::Facebook::APIError
67
+ rescue Koala::Facebook::APIError => e
68
+ error e.message
68
69
  expired_session
69
70
  rescue Exception => e
70
71
  error e
@@ -22,7 +22,7 @@ module Facy
22
22
  end
23
23
 
24
24
  def save_config_file
25
- File.open(File.expand_path('../../../config.yml', __FILE__), 'w') do |f|
25
+ File.open(config_file, 'w') do |f|
26
26
  conf = {
27
27
  "app_id" => config[:app_id],
28
28
  "app_secret" => config[:app_secret],
data/lib/facy/output.rb CHANGED
@@ -24,7 +24,7 @@ module Facy
24
24
  end
25
25
 
26
26
  def instant_output(item)
27
- printed_item << item.id if item.id
27
+ sync { printed_item << item.id if item.id }
28
28
  info = item.info
29
29
  print_registers.each do |pattern|
30
30
  if info == pattern[:name]
@@ -144,12 +144,13 @@ module Facy
144
144
  end
145
145
 
146
146
  print_register :notification do |item|
147
+ code = post_code(item).colorize(38,5,8).strip
147
148
  info = "☢ #{item.info.to_s.capitalize}".colorize(0,31)
148
149
  uname = item.data.user
149
150
  uname = uname.colorize(username_color(uname))
150
151
  content = item.data.content.colorize(0,55)
151
152
 
152
- puts "[#{info}] #{uname} #{content}"
153
+ puts "[#{code}][#{info}] #{uname} #{content}"
153
154
  end
154
155
 
155
156
  print_register :info do |item|
data/lib/facy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Facy
2
- VERSION = "1.2.9"
2
+ VERSION = "1.2.10.rc1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.10.rc1
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-19 00:00:00.000000000 Z
11
+ date: 2014-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,12 +137,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
- version: '0'
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
- version: '0'
145
+ version: 1.3.1
146
146
  requirements: []
147
147
  rubyforge_project:
148
148
  rubygems_version: 2.2.2