Class: Command::Inspect

Inherits:
CommandBase show all
Defined in:
lib/command/inspect.rb

Instance Method Summary collapse

Methods inherited from CommandBase

execute_and_rescue_exit, #load_local_settings

Constructor Details

#initializeInspect

Returns a new instance of Inspect.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/command/inspect.rb', line 18

def initialize
  super("[<target> ...]")
  @opt.separator <<-EOS

  ・引数を指定しなかった場合は直前に変換した小説の状態調査状況ログを表示します。
  ・小説を指定した場合はその小説のログを表示します。
  ・narou setting convert.inspect=true とすれば変換時に常に表示されるようになります。

  Example:
narou inspect     # 直前の変換時のログを表示
narou inspect 6   # ログを表示したい小説を指定する
  EOS
end

Instance Method Details

#display_log(title) ⇒ Object



53
54
55
56
57
# File 'lib/command/inspect.rb', line 53

def display_log(title)
  puts "(#{title} の小説状態調査状況ログ)"
  novel_setting = NovelSetting.load(title)
  puts Inspector.read_messages(novel_setting) || "調査ログがまだ無いようです"
end

#execute(argv) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/command/inspect.rb', line 32

def execute(argv)
  super
  if argv.empty?
    latest_id = LocalSetting.get["latest_convert"]["id"]
    if latest_id
      data = Downloader.get_data_by_target(latest_id)
      display_log(data["title"])
    end
    return
  end
  argv.each_with_index do |target, i|
    Helper.print_horizontal_rule if i > 0
    data = Downloader.get_data_by_target(target)
    unless data
      error "#{target} は存在しません"
      next
    end
    display_log(data["title"])
  end
end

#oneline_helpObject



14
15
16
# File 'lib/command/inspect.rb', line 14

def oneline_help
  "小説状態の調査状況ログを表示します"
end