Module: Hyla

Defined in:
lib/hyla.rb,
lib/hyla/logger.rb,
lib/hyla/command.rb,
lib/hyla/logger2.rb,
lib/hyla/project.rb,
lib/hyla/websocket.rb,
lib/hyla/commands/add.rb,
lib/hyla/commands/new.rb,
lib/hyla/configuration.rb,
lib/hyla/commands/build.rb,
lib/hyla/commands/serve.rb,
lib/hyla/commands/watch.rb,
lib/hyla/commands/reload.rb,
lib/hyla/commands/publish.rb,
lib/hyla/commands/generate.rb,
lib/hyla/commands/sendmail.rb

Defined Under Namespace

Modules: Commands Classes: Command, Configuration, Logger, Logger2, WebSocket

Constant Summary collapse

VERSION =
'1.0.8'
DESCRIPTION =
'Asciidoctor Hyla - Command Line tool to create new project, watch modifications, generate content, publish or consult it live !'
SUMMARY =
'Asciidoctor Hyla - builder/generator of HTML5, slideshow. Watch modifications, generate content, publish or consult it live !'

Class Method Summary collapse

Class Method Details

.loggerObject



54
55
56
# File 'lib/hyla.rb', line 54

def self.logger
  @logger ||= Logger.new
end

.logger2Object



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
# File 'lib/hyla.rb', line 58

def self.logger2
  configs = $options[:config].split(",").map(&:strip) if $options[:config]
  if !configs.nil? && !configs.empty?
    @yaml_cfg = nil
    configs.each do |config|
      cfg = safe_load_file(config)
      @yaml_cfg = cfg if @yaml_cfg.nil?
      @yaml_cfg = @yaml_cfg.deep_merge(cfg)
    end
  else
    # We will try to read the _config.yaml file if it exists within the project
    cfg = safe_load_file(Configuration::YAML_CONFIG_FILE_NAME)
    @yaml_cfg = cfg if !cfg.nil? && !cfg.empty?
  end
  hyla_cfg ||= @yaml_cfg if @yaml_cfg

  log_cfg ||= $options[:log]
  mode ||= hyla_cfg['mode'] if hyla_cfg
  dirname ||= hyla_cfg['dirname'] if hyla_cfg
  logname ||= hyla_cfg['logname'] if hyla_cfg
  level ||= hyla_cfg['level'] if hyla_cfg
  tracer ||= hyla_cfg['tracer'] if hyla_cfg

  $logger2 ||= Logger2.new(mode, log_cfg, dirname, logname, level, tracer)
end

.safe_load_file(filename) ⇒ Object



84
85
86
87
88
89
# File 'lib/hyla.rb', line 84

def self.safe_load_file(filename)
  f = File.expand_path(filename, $cmd_directory)
  YAML.safe_load_file(f)
rescue SystemCallError
  puts "No configuration file retrieved for the name : #{filename}"
end