Class: TOOL_INFO

Inherits:
Object show all
Defined in:
lib/tecsgen/core/tool_info.rb

Overview

TOOL_INFO class

The syntax of the contents of tool_info is same as JSON. Home made schema is used to validate the contents of tool_info. the schema is not defiened well. see saveload.rb for example of the schema.

Defined Under Namespace

Classes: VALIDATOR

Constant Summary collapse

@@tool_info =

tool_info

{ }
@@TECSGEN_schema =

tool_info schema for tecsgen

{
  :tecsgen => { # require
    :base_dir       => [:string],             # dir where the cde created initially
    :direct_import  => [:string],             # .cdl (sometimes .cde) specified in argments
    :import_path    => [:string],             # -I of tecsgen
    :define_macro   => [:string],             # -D of tecsgen
    :tecscde_version => :string,                 # TECSCDE version
    :cde_format_version => :string,              # CDE format version
    :save_date      => :string,                 # last save date & time
  },
  :__tecsgen => { # optioanl
    :cpp            => :string # -c or TECS_CPP environment variable
  }
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, val) ⇒ TOOL_INFO

Returns a new instance of TOOL_INFO.



64
65
66
67
68
69
70
71
72
# File 'lib/tecsgen/core/tool_info.rb', line 64

def initialize(name, val)
  @@tool_info[name] = val

  # __tool_info__( "tecsgen" ): validate & reflect immediately
  p "tool_info: tecsgen #{name}"
  if name == :tecsgen
    set_tecsgen_tool_info
  end
end

Class Method Details

.get_tool_info(name) ⇒ Object



74
75
76
# File 'lib/tecsgen/core/tool_info.rb', line 74

def self.get_tool_info(name)
  @@tool_info[name]
end

Instance Method Details

#set_tecsgen_tool_infoObject

TOOL_INFO#set_tecsgen_tool_info

tool_info( “tecsgen” )



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/tecsgen/core/tool_info.rb', line 80

def set_tecsgen_tool_info
  validator = TOOL_INFO::VALIDATOR.new(:tecsgen, @@TECSGEN_schema)
  if validator.validate || $b_force_apply_tool_info
    info = TOOL_INFO.get_tool_info(:tecsgen)
    (info[:base_dir]).each{|bd|
      if !$base_dir.include? bd
        $base_dir[bd] = true
      end
    }

    info[:import_path].each{|path|
      if !$import_path.include?(path)
        $import_path << path
      end
    }

    info[:define_macro].each{|define|
      if !$define.include?(define)
        $define << define
      end
    }
    if info[:cpp]
      if !$b_cpp_specified
        $cpp = info[:cpp]
        $b_cpp_specified = true
      end
    end

    info[:direct_import] && info[:direct_import].each{|import|
      Import.new(import, false, false)
    }
  end
end