Module: Dapp::Helper::YAML
- Included in:
- Kube::Dapp::Dapp, Kube::Helm::Release, Kube::Kubernetes::Client
- Defined in:
- lib/dapp/helper/yaml.rb
Instance Method Summary collapse
Instance Method Details
#yaml_load(string, hash: true) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dapp/helper/yaml.rb', line 10 def yaml_load(string, hash: true) ::YAML::load(string).tap do |res| if hash && !res.is_a?(Hash) raise ::Dapp::Error::Dapp, code: :yaml_incorrect, data: { message: "unexpected yaml data \n>>> START YAML\n#{string.strip}\n>>> END YAML\n" } end end rescue Psych::SyntaxError => e raise ::Dapp::Error::Dapp, code: :yaml_incorrect, data: { message: e. } end |
#yaml_load_file(file_path, hash: true) ⇒ Object
4 5 6 7 8 |
# File 'lib/dapp/helper/yaml.rb', line 4 def yaml_load_file(file_path, hash: true) yaml_load(File.read(file_path), hash: hash) rescue ::Dapp::Error::Dapp => e raise ::Dapp::Error::Dapp, code: :yaml_file_incorrect, data: { file: file_path, message: e.net_status[:data][:message] } end |