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.180 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.179 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.178 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.177 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.176 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.175 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.174 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.173 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.172 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.171 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.170 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.169 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.167 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.166 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.165 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.164 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.163 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.162 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.161 tracks/ruby/lib/generator/case_values.rb
trackler-2.2.1.160 tracks/ruby/lib/generator/case_values.rb