Class: Putpaws::ScheduleConfig
- Inherits:
-
Struct
- Object
- Struct
- Putpaws::ScheduleConfig
- Defined in:
- lib/putpaws/schedule_config.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#command ⇒ Object
Returns the value of attribute command.
-
#name ⇒ Object
Returns the value of attribute name.
-
#network ⇒ Object
Returns the value of attribute network.
-
#region ⇒ Object
Returns the value of attribute region.
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
- .all ⇒ Object
- .build_args(name, config_args) ⇒ Object
- .find(name) ⇒ Object
- .load(path_prefix: '.putpaws') ⇒ Object
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
6 7 8 |
# File 'lib/putpaws/schedule_config.rb', line 6 def args @args end |
#command ⇒ Object
Returns the value of attribute command
6 7 8 |
# File 'lib/putpaws/schedule_config.rb', line 6 def command @command end |
#name ⇒ Object
Returns the value of attribute name
6 7 8 |
# File 'lib/putpaws/schedule_config.rb', line 6 def name @name end |
#network ⇒ Object
Returns the value of attribute network
6 7 8 |
# File 'lib/putpaws/schedule_config.rb', line 6 def network @network end |
#region ⇒ Object
Returns the value of attribute region
6 7 8 |
# File 'lib/putpaws/schedule_config.rb', line 6 def region @region end |
#target ⇒ Object
Returns the value of attribute target
6 7 8 |
# File 'lib/putpaws/schedule_config.rb', line 6 def target @target end |
Class Method Details
.all ⇒ Object
32 33 34 35 36 |
# File 'lib/putpaws/schedule_config.rb', line 32 def self.all load.map{|k,v| new(build_args(k, v)) } end |
.build_args(name, config_args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/putpaws/schedule_config.rb', line 18 def self.build_args(name, config_args) region = config_args.delete(:region) network = config_args.delete(:network) target = config_args.delete(:target) command = config_args.delete(:command) { name: name.to_s, region: region, network: network, target: target, command: command, }.merge(args: config_args) end |
.find(name) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/putpaws/schedule_config.rb', line 38 def self.find(name) schedule_data = load data = schedule_data[name.to_sym] return nil unless data new(build_args(name, data)) end |
.load(path_prefix: '.putpaws') ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/putpaws/schedule_config.rb', line 9 def self.load(path_prefix: '.putpaws') @schedule_data ||= begin path = Pathname.new(path_prefix).join("schedule.json").to_s data = File.exist?(path) ? JSON.parse(File.read(path), symbolize_names: true).to_h : {} end end |