lib/command/list.rb in narou-2.8.3.1 vs lib/command/list.rb in narou-2.9.0
- old
+ new
@@ -59,10 +59,13 @@
Options:
EOS
@opt.on("-l", "--latest", "最近更新のあった順に小説を表示する") {
@options["latest"] = true
}
+ @opt.on("--gl", "更新日ではなく最新話掲載日を使用する") {
+ @options["general-lastup"] = true
+ }
@opt.on("-r", "--reverse", "逆順に表示する") {
@options["reverse"] = true
}
@opt.on("-u", "--url", "小説の掲載ページも表示する") {
@options["url"] = true
@@ -133,23 +136,29 @@
apply_sum == filters.count
end
def header
[
- " ID ", " 更新日 ",
+ " ID ",
+ @options["general-lastup"] ? " 掲載日 " : " 更新日 ",
@options["kind"] ? "種別" : nil,
@options["author"] ? "作者名" : nil,
@options["site"] ? "サイト名" : nil,
" タイトル"
].compact.join(" | ")
end
+ def view_date_type
+ @options["general-lastup"] ? "general_lastup" : "last_update"
+ end
+
def output_list(novels)
now = Time.now
today = now.strftime("%y/%m/%d")
filters = @options["filters"] || []
selected_lines = {}
+ view_date_type_key = view_date_type
novels.each do |novel|
novel_type = novel["novel_type"].to_i
id = novel["id"]
frozen = Narou.novel_frozen?(id)
@@ -163,11 +172,11 @@
disp_id = ((frozen ? "*" : "") + id.to_s).rjust(4)
disp_id = disp_id.sub("*", "<bold><cyan>*</cyan></bold>") if frozen
tags = novel["tags"] || []
selected_lines[id] = [
disp_id,
- novel["last_update"].strftime("%y/%m/%d").tap { |s|
+ novel[view_date_type_key].strftime("%y/%m/%d").tap { |s|
new_arrivals_date = novel["new_arrivals_date"]
last_update = novel["last_update"]
if new_arrivals_date && new_arrivals_date >= last_update \
&& new_arrivals_date + ANNOTATION_COLOR_TIME_LIMIT >= now
# 新着表示色
@@ -227,10 +236,10 @@
num = argv.first.to_i
else
num = database_values.size
end
if @options["latest"]
- database_values = Database.instance.sort_by_last_update
+ database_values = Database.instance.sort_by(view_date_type)
end
database_values.reverse! if @options["reverse"]
novels = database_values[0, num]
output_list(novels)
end