Class: Appifier::Components::Appifile
- Inherits:
-
Object
- Object
- Appifier::Components::Appifile
- Defined in:
- lib/appifier/components/Appifile.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
- #actions ⇒ Object
- #dataset_rules ⇒ Object
-
#initialize(path:) ⇒ Appifile
constructor
A new instance of Appifile.
Constructor Details
#initialize(path:) ⇒ Appifile
Returns a new instance of Appifile.
9 10 11 12 13 14 15 16 |
# File 'lib/appifier/components/Appifile.rb', line 9 def initialize(path:) @path = path begin @content = open_yaml filename: @path rescue RuntimeError raise "Appifile missing" end end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/appifier/components/Appifile.rb', line 7 def content @content end |
Class Method Details
.validate!(path:) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/appifier/components/Appifile.rb', line 26 def self.validate!(path:) appifile = {} res = {status: :ok, warn: [], error: [], cleaned: []} begin appifile = open_yaml filename: path validator = Schash::Validator.new do { template: { authors: optional(array_of(string)), version: numeric, contact: optional(string), description: optional(string), dataset: { } }, actions: { deploy: {}, run: {}, build: {}, publish: {}, test: {}, }, } end dataset_rules_validator = Schash::Validator.new do { format: string, description: string, default: optional(string) } end result = validator.validate(appifile) result.each {|item| res[:error].push "Appifiler : //#{item.position.join('/')} #{item.}"} appifile[:template][:dataset].each do |rule, definition| result = dataset_rules_validator.validate definition result.each {|item| res[:error].push "Appifiler : //template/dataset/#{rule}/#{item.position.join('/')} #{item.}"} end rescue RuntimeError res[:error].push "Appifile missing" end return res end |
Instance Method Details
#actions ⇒ Object
22 23 24 |
# File 'lib/appifier/components/Appifile.rb', line 22 def actions @content[:actions] end |
#dataset_rules ⇒ Object
18 19 20 |
# File 'lib/appifier/components/Appifile.rb', line 18 def dataset_rules @content[:template][:dataset] end |