Class: Xaases::Serverless::Yaml
- Inherits:
-
Object
- Object
- Xaases::Serverless::Yaml
- Defined in:
- lib/xaases/serverless/yaml.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
writeonly
Sets the attribute data.
Instance Method Summary collapse
- #add_resource(name, rs) ⇒ Object
- #functions=(fns) ⇒ Object
-
#initialize(filename, name = nil) ⇒ Yaml
constructor
A new instance of Yaml.
- #provider=(prov) ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(filename, name = nil) ⇒ Yaml
Returns a new instance of Yaml.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/xaases/serverless/yaml.rb', line 8 def initialize(filename, name = nil) @filename = filename begin @data = YAML.load_file filename rescue Errno::ENOENT @data = { 'service' => name, 'provider' => {}, 'resources' => {'Resources' => {}}, 'functions' => {} } end end |
Instance Attribute Details
#data=(value) ⇒ Object (writeonly)
Sets the attribute data
6 7 8 |
# File 'lib/xaases/serverless/yaml.rb', line 6 def data=(value) @data = value end |
Instance Method Details
#add_resource(name, rs) ⇒ Object
26 27 28 |
# File 'lib/xaases/serverless/yaml.rb', line 26 def add_resource(name, rs) @data['resources']['Resources'][name] = rs end |
#functions=(fns) ⇒ Object
30 31 32 |
# File 'lib/xaases/serverless/yaml.rb', line 30 def functions=(fns) @data['functions'] = fns end |
#provider=(prov) ⇒ Object
22 23 24 |
# File 'lib/xaases/serverless/yaml.rb', line 22 def provider=(prov) @data['provider'] = prov end |
#write ⇒ Object
34 35 36 |
# File 'lib/xaases/serverless/yaml.rb', line 34 def write YAML.dump @data, File.open(@filename, 'w') end |