Sha256: 48cb785301d167d125e7979370fee1da7d78c290281c3db57a04b972a3e622c6

Contents?: true

Size: 1.47 KB

Versions: 24

Compression:

Stored size: 1.47 KB

Contents

require 'delegate'

module Generator
  class Implementation
    include Files::TrackFiles
    include Files::MetadataFiles
    include TemplateValuesFactory

    def initialize(paths:, slug:)
      @paths = paths
      @slug = slug
    end

    attr_reader :paths, :slug

    def version
      tests_version.to_i
    end

    def update_tests_version
      tests_version.increment
    end

    def update_example_solution
      example_solution.update_version(version)
    end

    def create_tests_file
      minitest_tests.generate(
        template: tests_template.to_s,
        values: template_values
      )
    end

    def exercise_name
      @exercise_name ||= slug.tr('-', '_')
    end
  end

  # This exists to give us a clue as to what we are delegating to.
  class ImplementationDelegator < SimpleDelegator
  end

  # A implementation that also logs its progress.
  class LoggingImplementation < ImplementationDelegator
    def initialize(implementation:, logger:)
      __setobj__ @implementation = implementation
      @logger = logger
    end

    def update_tests_version
      @implementation.update_tests_version
      @logger.debug "Incremented tests version to #{version}"
    end

    def update_example_solution
      @implementation.update_example_solution
      @logger.debug "Updated version in example solution to #{version}"
    end

    def create_tests_file
      @implementation.create_tests_file
      @logger.info "Generated #{slug} tests version #{version}"
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trackler-2.1.0.36 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.34 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.33 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.32 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.31 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.30 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.29 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.28 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.27 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.26 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.25 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.24 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.23 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.22 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.21 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.20 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.19 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.18 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.17 tracks/ruby/lib/generator/implementation.rb
trackler-2.1.0.16 tracks/ruby/lib/generator/implementation.rb