Class: Reaver::Collection
- Inherits:
-
Object
- Object
- Reaver::Collection
- Defined in:
- lib/reaver/collection.rb
Overview
Loading collection from ~/.config/reaver/<filename.yml> and threat them
Instance Attribute Summary collapse
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
Instance Method Summary collapse
-
#initialize(file) ⇒ Collection
constructor
A new instance of Collection.
- #launch(metadata) ⇒ Object
- #load_yaml ⇒ Object
- #save_yaml ⇒ Object
Constructor Details
#initialize(file) ⇒ Collection
Returns a new instance of Collection.
12 13 14 15 |
# File 'lib/reaver/collection.rb', line 12 def initialize(file) @file = file @changed = false end |
Instance Attribute Details
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
10 11 12 |
# File 'lib/reaver/collection.rb', line 10 def tasks @tasks end |
Instance Method Details
#launch(metadata) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/reaver/collection.rb', line 33 def launch() return if !@tasks['things'] || @tasks['things'].nil? get_each_files(@tasks) @tasks['things'].each { |task| move_thing(task) unless task['git'] } .info['changed'] = @changed end |
#load_yaml ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reaver/collection.rb', line 17 def load_yaml puts ">> Loading #{@file}..." @tasks = if RUBY_VERSION >= '3.0' YAML.load_file(@file, permitted_classes: [Time, Symbol]) else @tasks = YAML.load_file(@file) end rescue StandardError => e raise e, "loading YAML fail for #{@file}: #{e.}" end |
#save_yaml ⇒ Object
28 29 30 31 |
# File 'lib/reaver/collection.rb', line 28 def save_yaml in_yaml = YAML.dump(@tasks) File.write(@file, in_yaml) end |