Class: Xembly::Base

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

Overview

Code base abstraction

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Base

Ctor.

opts

Options



55
56
57
58
59
60
# File 'lib/xembly.rb', line 55

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.



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

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