Sha256: 4b7245a8ebe2965ffc985d8d06e993a1f8f44858c53877071a6ba7c918ad90ab

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

require 'parslet'
require 'junoser/display'
require 'junoser/input'
require 'junoser/parser'


module Junoser
  module Cli
    class << self
      def commit_check(io_or_string)
        config = Junoser::Input.new(io_or_string).read

        if Junoser::Display.display_set?(config)
          commit_check_display_set config
        else
          commit_check_structured config
        end
      end

      def display_set(io_or_string)
        Junoser::Display::Set.new(io_or_string).transform
      end

      def struct(io_or_string)
        Junoser::Display::Structure.new(io_or_string).transform
      end


      private

      def commit_check_structured(config)
        Junoser::Display::Set.new(config).commit_check
      end

      def commit_check_display_set(config)
        parser = Junoser::Parser.new
        passed = true

        config.split("\n").each do |line|
          begin
            parser.parse line
          rescue Parslet::ParseFailed
            $stderr.puts "Invalid syntax:  #{line}"
            passed = false
          end
        end

        passed
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
junoser-0.2.4 lib/junoser/cli.rb
junoser-0.2.3 lib/junoser/cli.rb
junoser-0.2.2 lib/junoser/cli.rb
junoser-0.2.1 lib/junoser/cli.rb
junoser-0.2.0 lib/junoser/cli.rb
junoser-0.1.6 lib/junoser/cli.rb
junoser-0.1.5 lib/junoser/cli.rb
junoser-0.1.4 lib/junoser/cli.rb
junoser-0.1.3 lib/junoser/cli.rb