Module: Yarnlock
- Defined in:
- lib/yarnlock.rb,
lib/yarnlock/entry.rb,
lib/yarnlock/config.rb,
lib/yarnlock/version.rb,
lib/yarnlock/js_executor.rb,
lib/yarnlock/entry/collection.rb
Defined Under Namespace
Modules: JsExecutor
Classes: Config, Entry
Constant Summary
collapse
- VERSION =
'0.2.0'
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
13
14
15
|
# File 'lib/yarnlock.rb', line 13
def self.config
@config ||= Config.new
end
|
17
18
19
|
# File 'lib/yarnlock.rb', line 17
def self.configure
yield config
end
|
.load(file) ⇒ Object
42
43
44
|
# File 'lib/yarnlock.rb', line 42
def self.load(file)
parse File.read(file)
end
|
.parse(yarnlock) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/yarnlock.rb', line 21
def self.parse(yarnlock)
json_string = JsExecutor.execute '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'
return parsed['object'] unless config.return_collection
Entry::Collection.parse parsed['object']
end
|
.stringify(object) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/yarnlock.rb', line 32
def self.stringify(object)
json_string = JsExecutor.execute '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
|