Method: Mkgraph#initialize
- Defined in:
- lib/mkgraph.rb
#initialize(pattern) ⇒ Mkgraph
Initialise
Params: The name of the file to be processed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/mkgraph.rb', line 34 def initialize pattern begin $yml = YAML.load_file 'mgopts.yml' rescue Exception => e print e. + "\n" print "You could use the default \'mgopts.yml\' file in the installation\n" print "directory as a template.\n" print "Example:\n" tip = <<-EOS Log Options: format: brief # brief or full output: stderr # stderr, stdout or file name level: WARN # INFO, WARN or FATAL Labels: root: Entry Point root comment: The Root Comment Output: image name: view.png EOS puts "#{tip}" exit 1 end # puts $yml['sectionA']['user'] + "**************\n" # puts $yml['sectionB']['file'] + "**************\n" log_fmt = $yml['Log Options']['format'] log_opt = $yml['Log Options']['output'] case log_opt when 'stderr' log_op = $stderr when 'stdout' log_op = $stdout else log_op = log_opt end loglev = $yml['Log Options']['level'] case loglev when 'INFO' ll = Logger::INFO when 'WARN' ll = Logger::WARN else ll = Logger::FATAL end @file_pattern = pattern $LOG = Logger.new(log_op).tap do |log| log.progname = 'mkgraph' log.level = ll # Logger::INFO # $yml['Log Options']['level'] if log_fmt == 'brief' log.formatter = proc do |severity, datetime, progname, msg| "#{progname}: #{msg}\n" end end end $LOG.info "Pattern: " + @file_pattern # Rough test for OS TODO if RUBY_PLATFORM.include?("linux") == false $windows = true else $windows = false end end |