Sha256: fc5b3ba055432e4c20157443a5636e87b929efd123ea04177c1e139621f4a46e

Contents?: true

Size: 548 Bytes

Versions: 216

Compression:

Stored size: 548 Bytes

Contents

module Generator
  module CaseValues
    class Extractor
      def initialize(case_class:)
        @case_class = case_class
      end

      def cases(exercise_data)
        extract_test_cases(data: JSON.parse(exercise_data)['cases'])
          .map { |case_properties| @case_class.new(canonical: OpenStruct.new(case_properties)) }
      end

      private

      def extract_test_cases(data:)
        data.flat_map do |entry|
          entry.key?('cases') ? extract_test_cases(data: entry['cases']) : entry
        end
      end
    end
  end
end

Version data entries

216 entries across 216 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.138 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.137 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.136 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.135 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.134 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.133 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.132 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.131 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.130 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.129 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.128 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.127 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.126 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.125 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.124 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.123 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.122 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.121 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.120 tracks/ruby/lib/generator/case_values.rb