Module: Dyndoc::DynConfig

Included in:
Document, TemplateDocument
Defined in:
lib/dyndoc/document.rb

Overview

# used for Docker mode

module Docker

  ## TO TEST: @@task_file = "/Users/remy/DOCKER_TASK_FILE"
  @@task_file = "/dyndoc-proj/.cache/task_latex_file"
  @@tasks=nil

  def Docker.init_task_file
    FileUtils.rm_f(@@task_file)
    @@tasks=[]
  end

  def Docker.add_task(task)
    @@tasks << task
  end

  def Docker.save_task_file
    File.open(@@task_file,"w") do |f|
      f << @@tasks.join(",")
    end
  end

end

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



61
62
63
# File 'lib/dyndoc/document.rb', line 61

def [](key)
  @cfg[key]
end

#[]=(key, value) ⇒ Object



65
66
67
68
# File 'lib/dyndoc/document.rb', line 65

def []=(key,value)
 @cfg[key]=value
 return self
end

#append_cfg(cfg) ⇒ Object

append with partial match



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/dyndoc/document.rb', line 49

def append_cfg(cfg)
  return unless cfg.respond_to? "[]"
  keys=@cfg.keys.map{|e| e.to_s}.sort
  cfg.each_key do |k|
    #like R, partial match of the parameter names
    if k2=keys.find{|e| e=~/^#{k}/}
      @cfg[k2.to_sym]=cfg[k]
    end
  end
  ## puts "append_cfg";p @cfg
end

#init_cfg(cfg = nil) ⇒ Object



37
38
39
40
# File 'lib/dyndoc/document.rb', line 37

def init_cfg(cfg=nil)
  @cfg=@@cfg.dup
  read_cfg(cfg) if cfg
end

#read_cfg(cfg) ⇒ Object



42
43
44
45
46
# File 'lib/dyndoc/document.rb', line 42

def read_cfg(cfg)
  cfg.each_key do |k|
    @cfg[k]=cfg[k]
  end
end