Sha256: 62e76fe19325ff86a1bcebdd6d42af7c70e861ef281e954469c554adf5998bb7

Contents?: true

Size: 943 Bytes

Versions: 3

Compression:

Stored size: 943 Bytes

Contents

require 'swiftfake/version'
require 'swiftfake/source_reader'
require 'swiftfake/source_kit_parser'
require 'swiftfake/presenter'
require 'swiftfake/renderer'

module Swiftfake

  Config = Struct.new(:source_reader, :parser_klass, :presenter_klass, :renderer) do
    def self.create(source_reader: SourceReader.new, parser_klass: SourceKitParser, presenter_klass: Presenter, renderer: Renderer.new)
       self.new(source_reader, parser_klass, presenter_klass, renderer)
    end
  end

  class Runner
    attr_reader :args, :config

    def initialize(args:, config: Config.create)
      @args = args
      @config = config
    end

    def run
      source_file, structure_json = config.source_reader.read_file(args[:input])
      parser = config.parser_klass.new
      swift_class = parser.parse(source_file, structure_json)
      presenter = config.presenter_klass.new(swift_class)
      config.renderer.output(presenter)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
swiftfake-0.3.0 lib/swiftfake.rb
swiftfake-0.2.1 lib/swiftfake.rb
swiftfake-0.2.0 lib/swiftfake.rb