Class: Xembly::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/xembly/base.rb

Overview

Code base abstraction

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Base

Ctor.

opts

Options



53
54
55
56
57
58
# File 'lib/xembly/base.rb', line 53

def initialize(opts)
  @opts = opts
  Xembly.log.level = Logger::INFO if @opts.verbose?
  Xembly.log.info "my version is #{Xembly::VERSION}"
  Xembly.log.info "Ruby version is #{RUBY_VERSION} at #{RUBY_PLATFORM}"
end

Instance Method Details

#xmlObject

Generate XML.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/xembly/base.rb', line 61

def xml
  if @opts.xml?
    xml = File.read(@opts[:xml])
    Xembly.log.info "reading #{@opts[:xml]}"
  else
    xml = $stdin.read
    Xembly.log.info 'reading STDIN'
  end
  if @opts.dirs?
    Xembly.log.info "reading directives from #{@opts[:dirs]}"
    dirs = File.read(@opts[:dirs])
  else
    Xembly.log.info "#{@opts.arguments.length} directives in command line"
    dirs = @opts.arguments.join
  end
  Xembler.new(Directives.new(dirs)).apply(xml).to_xml
end