Sha256: 95accb9ffbdb6401b81b71f59a2f4127629e519a52d1e49bd6e8daa108492184

Contents?: true

Size: 920 Bytes

Versions: 13

Compression:

Stored size: 920 Bytes

Contents

module Departure
  # Encapsulates the pt-online-schema-change options defined by the user
  class UserOptions
    delegate :each, :merge, to: :to_set

    # Constructor
    #
    # @param arguments [String]
    def initialize(arguments = ENV['PERCONA_ARGS'])
      @arguments = arguments
    end

    private

    attr_reader :arguments

    # Returns the arguments the user defined but without duplicates
    #
    # @return [Set]
    def to_set
      Set.new(user_options)
    end

    # Returns Option instances from the arguments the user specified, if any
    #
    # @return [Array]
    def user_options
      if arguments
        build_options
      else
        []
      end
    end

    # Builds Option instances from the user arguments
    #
    # @return [Array<Option>]
    def build_options
      arguments.split(/\s(?=-)/).map do |argument|
        Option.from_string(argument)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
departure-next-6.7.1.pre.1 lib/departure/user_options.rb
departure-next-6.7.1.pre.pre lib/departure/user_options.rb
departure-6.7.0 lib/departure/user_options.rb
departure-6.6.0 lib/departure/user_options.rb
departure-6.5.0 lib/departure/user_options.rb
departure-6.4.0 lib/departure/user_options.rb
departure-6.3.0 lib/departure/user_options.rb
departure-76c9880-6.2.0 lib/departure/user_options.rb
departure-6.2.0 lib/departure/user_options.rb
departure-6.1.0 lib/departure/user_options.rb
departure-6.0.0 lib/departure/user_options.rb
departure-5.0.0 lib/departure/user_options.rb
departure-4.0.1 lib/departure/user_options.rb