185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/command/diff.rb', line 185
def create_temp_files(id)
if @options["view_diff_version"]
cache_root_dir = Downloader.get_cache_root_dir(id)
if cache_root_dir
cache_dir = File.join(cache_root_dir, @options["view_diff_version"])
cache_dir = nil unless File.exist?(cache_dir)
end
else
nth = @options["number"]
list = get_sorted_cache_list(id)
cache_dir = list ? list[nth - 1] : nil
end
unless cache_dir
puts "#{@novel_data["title"]} の差分データがありません"
return nil
end
cache_section_list = Dir.glob("#{cache_dir}/*.yaml").sort_by { |path|
File.basename(path, ".yaml").split(" ", 2)[0].to_i
}
if cache_section_list.length == 0
puts "#{@novel_data["title"]} は最新話のみのアップデートのようです"
return nil
end
novel_dir = Downloader.get_novel_section_save_dir(Downloader.get_novel_data_dir_by_target(id))
latest_novel_sections = []
cache_sections = []
cache_section_list.each do |path|
match_latest_path = File.join(novel_dir, File.basename(path))
latest_novel_sections << YAML.load_file(match_latest_path) if File.exist?(match_latest_path)
cache_sections << YAML.load_file(path)
end
novel_info = Database.instance[id]
temp_old = create_temp_by_sections("old", cache_sections, novel_info)
temp_new = create_temp_by_sections("new", latest_novel_sections, novel_info)
[temp_old, temp_new]
end
|