Module: OrigenTesters::Decompiler::Pattern::SpecHelpers

Included in:
OrigenTesters::Decompiler::Pattern
Defined in:
lib/origen_testers/decompiler/pattern/spec_helpers.rb

Instance Method Summary collapse

Instance Method Details

#spec_yaml_approvedObject


26
27
28
# File 'lib/origen_testers/decompiler/pattern/spec_helpers.rb', line 26

def spec_yaml_approved
  "#{Origen.app!.root}/approved/#{platform}/decompiler/models/#{source.basename}.yaml"
end

#spec_yaml_outputObject


22
23
24
# File 'lib/origen_testers/decompiler/pattern/spec_helpers.rb', line 22

def spec_yaml_output
  "#{Origen.app!.root}/output/#{platform}/decompiler/models/#{source.basename}.yaml"
end

#to_spec_yaml(options = {}) ⇒ Object


18
19
20
# File 'lib/origen_testers/decompiler/pattern/spec_helpers.rb', line 18

def to_spec_yaml(options = {})
  to_yaml_hash.to_yaml
end

#to_yaml_hash(options = {}) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/origen_testers/decompiler/pattern/spec_helpers.rb', line 5

def to_yaml_hash(options = {})
  {
    pattern:     @path,
    timestamp:   Time.now.to_s,
    class:       self.class.to_s,
    # ... Add in the variables here

    frontmatter: frontmatter.to_yaml_hash,
    pinlist:     pinlist.to_yaml_hash,
    vectors:     collect_vectors { |v, i| v.to_yaml_hash }
  }
end

#write_spec_yaml(options = {}) ⇒ Object


30
31
32
33
34
35
36
37
# File 'lib/origen_testers/decompiler/pattern/spec_helpers.rb', line 30

def write_spec_yaml(options = {})
  path = options[:approved] ? spec_yaml_approved : spec_yaml_output
  unless Dir.exist?(File.dirname(path))
    FileUtils.mkdir_p(File.dirname(path))
  end
  File.open(path, 'w').puts(to_spec_yaml(options))
  path
end