flumtter 5.9.0 → 5.9.1

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: e7bccd88a92ccf666c865cf935c59081731b376b
4
- data.tar.gz: e015b1507854aa262a43b4f2bf902cb27cf93799
3
+ metadata.gz: 156f65c65db5ef313d2d8faf580365d26c407d79
4
+ data.tar.gz: 85bd0502b9aedf977fac5c3b83ac2b6c52547efa
5
5
  SHA512:
6
- metadata.gz: 2ca9c23c0845eeaded563f009ed8c3ad2bf04dbe2e37e21786d245c1e449f8bc1065075f37fec43fa6d3f5ed9e298357213131ddcd76e311837e6cb1ba0d2760
7
- data.tar.gz: 0600975f192ced2aa1a81b927119ecb361b4dbb93e88780c3febda58c73c1668121b8c25e4f78111552a3002379b46a77975e1218666e2a168c758369d186cfb
6
+ metadata.gz: a2e8eea4c8236284e7738f3487dc8ce765bd1b658ee415f0514f4e517646340386038dd92537481499270d37a2035fcbb939fa5d64545fab1da2ae9d6a1df25f
7
+ data.tar.gz: 724c7d1536ed2f6aa86d27432902d485147d4989f8ac8f1927a646ba083f2be653d1272fdda50dc96fa37c7aaf2da174588c3f177910a365f13dccf1cd9cb632
@@ -1,7 +1,9 @@
1
1
  require 'pry'
2
2
  require 'json'
3
+ require 'logger'
3
4
 
4
5
  module Flumtter
6
+ StartTime = Time.now
5
7
  SourcePath = File.expand_path('../../', __FILE__)
6
8
  UserPath = File.expand_path('~/.flumtter')
7
9
  [SourcePath, UserPath].each do |path|
@@ -13,6 +15,12 @@ module Flumtter
13
15
  FileUtils.cp_r(SourcePath.join(".flumtter"), UserPath)
14
16
  end
15
17
 
18
+ Logger = Logger.new(UserPath.join('flumtter.log'))
19
+ Logger.level = ARGV.include?('--debug') ? ::Logger::DEBUG : ::Logger::INFO
20
+ Logger.datetime_format = "%Y-%m-%d %H:%M:%S.%L "
21
+
22
+ Logger.debug("Start: #{ARGV.join(" ")}")
23
+
16
24
  data_path = UserPath.join("data", "data.bin")
17
25
  Config = Marshal.load(File.read(data_path)) rescue {}
18
26
  at_exit {
@@ -22,14 +30,24 @@ module Flumtter
22
30
  Thread.abort_on_exception = true
23
31
 
24
32
  module_function
25
- def sarastire(path, file=nil)
26
- path = file.nil? ? SourcePath.join(path, '*.rb') : SourcePath.join(path, file)
27
- Dir.glob(path).each{|plugin|require plugin}
33
+ def logger
34
+ Logger
35
+ end
36
+
37
+ def load_plugin(source, path, file=nil)
38
+ path = file.nil? ? source.join(path, '*.rb') : source.join(path, file)
39
+ Dir.glob(path).each do |plugin|
40
+ logger.debug("Load: #{plugin}")
41
+ require plugin
42
+ end
28
43
  end
29
44
 
30
- def sarastire_user(path, file=nil)
31
- path = file.nil? ? UserPath.join(path, '*.rb') : UserPath.join(path, file)
32
- Dir.glob(path).each{|plugin|require plugin}
45
+ def sarastire(*args)
46
+ load_plugin(SourcePath, *args)
47
+ end
48
+
49
+ def sarastire_user(*args)
50
+ load_plugin(UserPath, *args)
33
51
  end
34
52
 
35
53
  @events = Hash.new{|h,k|h[k] = []}
@@ -49,12 +67,22 @@ module Flumtter
49
67
  sarastire 'plugins'
50
68
  sarastire_user 'plugins'
51
69
 
70
+ logger.debug("Plugin load complete.")
71
+
52
72
  TITLE.terminal_title
53
73
 
74
+ logger.debug("Initialization time(#{Time.now-StartTime}s)")
75
+
54
76
  def start
55
77
  options = Initializer.optparse
56
78
  Setting.merge!(options)
57
79
  Client.new AccountSelector.select(options)
58
80
  rescue Interrupt
81
+ rescue Exception => ex
82
+ logger.fatal(<<~EOS)
83
+ #{ex.backtrace.shift}: #{ex.message} (#{ex.class})
84
+ #{ex.backtrace.join("\n")}
85
+ EOS
86
+ raise ex
59
87
  end
60
88
  end
@@ -5,10 +5,13 @@ module Flumtter
5
5
 
6
6
  module Util
7
7
  def error(e)
8
- print <<~EOF.color(Setting[:color][:error])
8
+ text = <<~EOF
9
9
  #{e.backtrace.shift}: #{e.message} (#{e.class})
10
10
  #{e.backtrace.join("\n")}
11
11
  EOF
12
+ e.class.ancestors.include?(StandardError) ? logger.error(text) : logger.fatal(text)
13
+ print text.color(Setting[:color][:error])
14
+
12
15
  end
13
16
 
14
17
  def parse_time(time)
@@ -102,6 +105,10 @@ module Flumtter
102
105
  end
103
106
  end
104
107
 
108
+ def logger
109
+ Flumtter.logger
110
+ end
111
+
105
112
  def sarastire(*args)
106
113
  Flumtter.sarastire(*args)
107
114
  end
@@ -1,3 +1,3 @@
1
1
  module Flumtter
2
- VERSION = "5.9.0"
2
+ VERSION = "5.9.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flumtter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.0
4
+ version: 5.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - flum1025