Class: Spandx::Terraform::Parsers::LockFile
Constant Summary
Constants inherited
from Core::Parser
Core::Parser::UNKNOWN
Instance Method Summary
collapse
for, parse
#all, #each, #inherited, #registry
Constructor Details
7
8
9
10
|
# File 'lib/spandx/terraform/parsers/lock_file.rb', line 7
def initialize
@parser = Hcl2::Parser.new
super()
end
|
Instance Method Details
#match?(pathname) ⇒ Boolean
12
13
14
15
|
# File 'lib/spandx/terraform/parsers/lock_file.rb', line 12
def match?(pathname)
basename = pathname.basename
basename.fnmatch?('.terraform.lock.hcl')
end
|
#parse(path) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/spandx/terraform/parsers/lock_file.rb', line 17
def parse(path)
tree = @parser.parse(path.read)
tree[:blocks].map do |block|
version_arg = version_arg_from(block)
::Spandx::Core::Dependency.new(
name: block[:name].to_s,
version: version_arg[:value]&.to_s,
path: path
)
end
end
|