Module: Cliver::Filter

Defined in:
lib/cliver/filter.rb

Overview

A Namespace to hold filter procs

Constant Summary

IDENTITY =

The identity filter returns its input unchanged.

proc { |version| version }

Instance Method Summary (collapse)

Instance Method Details

- (String) apply(version)

Apply to some input

Parameters:

  • version (String)

Returns:

  • (String)


24
25
26
# File 'lib/cliver/filter.rb', line 24

def apply(version)
  to_proc.call(version)
end

- (Array<String>) requirements(requirements)

Apply to a list of requirements

Parameters:

  • requirements (Array<String>)

Returns:

  • (Array<String>)


12
13
14
15
16
17
18
19
# File 'lib/cliver/filter.rb', line 12

def requirements(requirements)
  requirements.map do |requirement|
    req_parts = requirement.split(/\b(?=\d)/, 2)
    version = req_parts.last
    version.replace apply(version)
    req_parts.join
  end
end