Sha256: 79b7e3d85f673d03c3a4b3abf7a0b74bb563e028ebc2886fe004f15cc4db46ba

Contents?: true

Size: 868 Bytes

Versions: 2

Compression:

Stored size: 868 Bytes

Contents

module Fixtures
  DB = {
    artists: [
      { name: 'Blake Mills', genre: 'alternative', release_count: 3 },
      { name: 'Björk', genre: 'electronic', release_count: 3 },
      { name: 'James Blake', genre: 'electronic', release_count: 3 },
      { name: 'Janelle Monae', genre: 'alt-soul', release_count: 3 },
      { name: 'SZA', genre: 'alt-soul', release_count: 3 },
      { name: 'Chris Frank', genre: 'alt-soul', release_count: nil },
    ]
  }

  FILTERS = [
    ->(genre:) {
      select { |item| item[:genre].match(/#{genre}/i) }
    },
    ->(name:) {
      select { |item| item[:name].match(/#{name}/i) }
    },
    ->(sort: 'name') {
      sort_by { |item| item[sort.to_sym] }
    },
    ->(releases:) {
      select { |item| item[:release_count].to_i == releases.to_i }
    },
  ]

  ArtistReducer = Rack::Reducer.create(DB[:artists], *FILTERS)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-reducer-1.1.2 spec/fixtures.rb
rack-reducer-1.1.1 spec/fixtures.rb