Sha256: e528fd6517e5e7c80cac403c3a8acdc2b6a1c8faa507d8c348bb3260156ab125

Contents?: true

Size: 915 Bytes

Versions: 16

Compression:

Stored size: 915 Bytes

Contents

require 'junoser/input'
require 'junoser/display/config_store'
require 'junoser/parser'
require 'junoser/transformer'

module Junoser
  module Display
    class Structure
      def initialize(io_or_string)
        @input = io_or_string
        @config = Junoser::Display::ConfigStore.new
      end

      def transform
        parser = Junoser::Parser.new
        transform = Junoser::Transformer.new

        config = Junoser::Input.new(@input).read.split("\n")
        deactivated_lines = config.grep(/^deactivate /).map {|l| l.sub(/^deactivate /, '') }

        config.each do |line|
          next if line =~ /^deactivate /

          transformed = transform.apply(parser.parse(line))
          raise "ERROR: parse failed" unless transformed.is_a?(String)
          @config << transformed
        end

        deactivated_lines.each {|l| @config.deactivate l }

        @config.to_s
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
junoser-0.3.6 lib/junoser/display/structure.rb
junoser-0.3.5 lib/junoser/display/structure.rb
junoser-0.3.4 lib/junoser/display/structure.rb
junoser-0.3.3 lib/junoser/display/structure.rb
junoser-0.3.2 lib/junoser/display/structure.rb
junoser-0.3.1 lib/junoser/display/structure.rb
junoser-0.3.0 lib/junoser/display/structure.rb
junoser-0.2.13 lib/junoser/display/structure.rb
junoser-0.2.12 lib/junoser/display/structure.rb
junoser-0.2.11 lib/junoser/display/structure.rb
junoser-0.2.10 lib/junoser/display/structure.rb
junoser-0.2.9 lib/junoser/display/structure.rb
junoser-0.2.8 lib/junoser/display/structure.rb
junoser-0.2.7 lib/junoser/display/structure.rb
junoser-0.2.6 lib/junoser/display/structure.rb
junoser-0.2.5 lib/junoser/display/structure.rb