Class: Giblish::EntryPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/giblish/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, logger = nil) ⇒ EntryPoint

Returns a new instance of EntryPoint.



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/giblish/application.rb', line 191

def initialize(args, logger = nil)
  # force immediate output
  # $stdout.sync = true

  # setup logging
  Giblog.setup(logger)
  Giblog.logger.level = Logger::INFO

  # Parse cmd line
  @user_opts = CmdLine.new.parse(args)
  Giblog.logger.level = @user_opts.log_level
  Giblog.logger.debug { "cmd line args: #{@user_opts.inspect}" }

  # Select the coversion instance to use
  @converter = select_conversion(@user_opts)
end

Class Method Details

.run(args, logger = nil) ⇒ Object



218
219
220
# File 'lib/giblish/application.rb', line 218

def self.run(args, logger = nil)
  EntryPoint.new(args, logger).run
end

.run_from_cmd_lineObject

does not return, exits with status code



223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/giblish/application.rb', line 223

def self.run_from_cmd_line
  begin
    EntryPoint.run(ARGV)
    Giblog.logger.info { "Giblish is done!" }
    exit_code = 0
  rescue => exc
    Giblog.logger.error { exc.message }
    Giblog.logger.error { exc.backtrace }
    exit_code = 1
  end
  exit(exit_code)
end

Instance Method Details

#runObject



208
209
210
211
212
213
214
215
216
# File 'lib/giblish/application.rb', line 208

def run
  begin
    require "asciidoctor-diagram"
  rescue LoadError
    Giblog.logger.warn { "Did not find asciidoctor-diagram installed, diagrams will not be rendered." }
  end
  # do the conversion
  @converter.run
end