Module: Bparity::SpecBundle::Writer

Defined in:
lib/bparity/spec_bundle.rb

Class Method Summary collapse

Class Method Details

.stringify(value) ⇒ Object



186
187
188
189
190
191
192
# File 'lib/bparity/spec_bundle.rb', line 186

def stringify(value)
  case value
  when Hash then value.to_h { |key, item| [key.to_s, stringify(item)] }
  when Array then value.map { |item| stringify(item) }
  else value
  end
end

.write(path, bundle) ⇒ Object



177
178
179
180
181
182
183
184
# File 'lib/bparity/spec_bundle.rb', line 177

def write(path, bundle)
  data = stringify(bundle)
  Validator.validate!(data, verify_checksum: false)
  data["checksum"] = Checksum.calculate(data)
  FileUtils.mkdir_p(File.dirname(path))
  File.write(path, YAML.dump(data))
  data
end