Class: Xembly::Base
- Inherits:
-
Object
- Object
- Xembly::Base
- Defined in:
- lib/xembly.rb
Overview
Code base abstraction
Instance Method Summary collapse
-
#initialize(opts) ⇒ Base
constructor
Ctor.
-
#xml ⇒ Object
Generate XML.
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
#xml ⇒ Object
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 |