Class: SiSU_Param::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/dp.rb

Defined Under Namespace

Classes: Instructions, Md, MdDefault, MdMake

Constant Summary collapse

@@publisher =
'SiSU scribe'
@@md =
@@fns=@@pth=nil

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ Parameters

Returns a new instance of Parameters.



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/sisu/dp.rb', line 81

def initialize(opt)
  @opt=opt
  @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set])
  @fns=if @opt.act[:psql][:set] == [:on] #revisit CHECK
    opt.fns
  else opt.fns.gsub(/\.ssm$/,'.ssm.sst')
  end
  SiSU_Param::Instantiate.new.param_instantiate
  @env=SiSU_Env::InfoEnv.new(@fns)
  @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore"
end

Instance Method Details

#getObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/sisu/dp.rb', line 92

def get
  if @opt.f_pth \
  and @opt.f_pth[:pth] != Dir.pwd #BUG check
    # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter
    # has a path value that is different, however, f_pth is not always set!
    Dir.chdir(@opt.f_pth[:pth])
  end
  if @@fns !=@fns \
  or @@pth !=Dir.pwd               #@opt.f_pth[:pth]
    @@fns,@@pth=@fns,Dir.pwd       #@opt.f_pth[:pth]
    @@md=nil
  end
  if @@md.nil? \
  or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file
    if File.exist?(@pstorefile)
      param_msg='Parameters from pstore'
      store=PStore.new(@pstorefile)
      store.transaction do
        @md=store['md']
      end
      @md
    else
      param_msg='Parameters extracted'
      fns_array=@env.read_source_file(@opt.fns)
      @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract
      @md
    end
    if defined? @md.title.main # on removal check problems with -U
      if (@opt.act[:verbose][:set]==:on \
      || @opt.act[:verbose_plus][:set]==:on \
      || @opt.act[:maintenance][:set]==:on)
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          param_msg,
          @md.title.main
        ).txt_grey
      end
    end
    @@md=@md
  else @@md
  end
  begin
    @@md.opt=@opt
    @@md
  rescue
    SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
      mark('has an existing option been selected?')
    exit
  end
end