Method: Command::Diff#get_diff_list

Defined in:
lib/command/diff.rb

#get_diff_list(id) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/command/diff.rb', line 243

def get_diff_list(id)
  list = {
    id: id,
    title: @novel_data["title"],
    list: []
  }
  cache_list = get_sorted_cache_list(id)
  return list if cache_list.empty?
  cache_list.each.with_index(1) do |cache_path, i|
    objects = []
    version_string = File.basename(cache_path)
    data = {
      number: i,
      version_string: version_string,
      time: version_string_to_time(version_string),
      objects: objects
    }
    list[:list].push(data)
    cache_section_list = Dir.glob(File.join(cache_path, "*.yaml"))
    if cache_section_list.length > 0
      cache_section_list.map { |section_path|
        File.basename(section_path, ".yaml").split(" ", 2)
      }.sort_by { |v| v[0].to_i }.each { |index, subtitle|
        objects.push({ index: index, subtitle: subtitle })
      }
    end
  end
  list
end