Sha256: 98b4e64312e963376e43ca8e5cf5adc56051b70bb89063ba8dbc5cb39af68512
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module Reaver class MetaData attr_accessor :info def initialize(dirname, collection) @dirname = dirname @collection = collection @file = "#{@dirname}/metadata.yml" @info = { 'changed' => false, 'next' => Time.new } end def load_yaml if File.exist? @file #puts "loading metadata #{@file}..." if RUBY_VERSION >= '3.0' @info = YAML.load_file(@file, permitted_classes: [Time, Symbol]) else @info = YAML.load_file(@file) end # puts @info.inspect else File.open(@file, 'w') { |f| YAML.dump(@info, f) } end end def save_yaml update_time File.open(@file, 'w') { |f| YAML.dump(@info, f) } end private def update_time return unless @collection.tasks['things'].length >= 1 now = Time.new n = @collection.tasks['time'] if @collection.tasks['time'].is_a?(Integer) @info['next'] = now + n ||= now @info['last_download'] = now end end end
Version data entries
9 entries across 9 versions & 1 rubygems