Sha256: 890e04cdb06eae2b58d9e04eaa6008d628d21da11a2452ec8e07fb97aea69fea

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

#
# This class handles the filter of arrays of hashes based on given regex.
#
# This class smells of :reek:InstanceVariableAssumption
class GithubListerCore
    class << self
        #
        # Everything below here is private
        #

        private

        # This method smells of :reek:ControlParameter, :reek:DuplicateMethodCall
        def handle_regex(list, key, regex, nocase)
            if (nocase)
                list.select { |item| item[key].to_s.match(/#{regex}/i) }
            else
                list.select { |item| item[key].to_s.match(/#{regex}/) }
            end
        end

        def handle_repo_regex(list, options)
            nocase = get_flag(options, :repo_regex_nocase) | get_flag(options, :regex_nocase)

            handle_regex(list, :name, get_option(options, :repo_regex), nocase)
        end

        def handle_org_regex(list, options)
            nocase = get_flag(options, :org_regex_nocase) | get_flag(options, :regex_nocase)

            handle_regex(list, :login, get_option(options, :org_regex), nocase)
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github-lister-core-0.1.8 lib/github-lister-core/regex.rb