Module: Yarnlock
- Defined in:
- lib/yarnlock.rb,
lib/yarnlock/version.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
Class Method Details
.load(file) ⇒ Object
23 24 25 |
# File 'lib/yarnlock.rb', line 23 def self.load(file) parse File.read(file) end |
.parse(yarnlock) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/yarnlock.rb', line 7 def self.parse(yarnlock) json_string = execute_script 'parse', yarnlock parsed = JSON.parse json_string raise "An error was occurred when parsing yarn.lock: #{parsed}" unless parsed.is_a? Hash raise "Could not parse yarn.lock: #{parsed['reason']}" unless parsed['type'] == 'success' parsed['object'] end |
.stringify(object) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/yarnlock.rb', line 15 def self.stringify(object) json_string = execute_script 'stringify', JSON.generate(object) parsed = JSON.parse json_string raise "An error was occurred when stringing object: #{parsed}" unless parsed.is_a? Hash raise "Could not stringing object: #{parsed['reason']}" unless parsed['type'] == 'success' parsed['yarnlock'] end |