Sha256: c2acb4481238d6e552e9b2e9423cfb97fcfcb6762ff316cf96fb59b1038be7e4

Contents?: true

Size: 875 Bytes

Versions: 11

Compression:

Stored size: 875 Bytes

Contents

module Posgra::CLI::Helper
  REGEXP_OPTIONS = [
    :include_schema,
    :exclude_schema,
    :include_role,
    :exclude_role,
    :include_object,
    :exclude_object,
  ]

  def check_fileanem(file)
    if file =~ /\A-.+/
      raise "Invalid failname: #{file}"
    end
  end

  def client
    client_options = {}
    String.colorize = options[:color]
    Posgra::Logger.instance.set_debug(options[:debug])

    options.each do |key, value|
      if key.to_s =~ /-/
        key = key.to_s.gsub('-', '_')
      end

      client_options[key.to_sym] = value if value
    end

    REGEXP_OPTIONS.each do |key|
      if client_options[key]
        client_options[key] = Regexp.new(client_options[key])
      end
    end

    client_options[:identifier] = Posgra::Identifier::Auto.new(options['account-output'], client_options)
    Posgra::Client.new(client_options)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
posgra-0.2.3.beta lib/posgra/cli/helper.rb
posgra-0.2.2 lib/posgra/cli/helper.rb
posgra-0.2.1 lib/posgra/cli/helper.rb
posgra-0.2.0 lib/posgra/cli/helper.rb
posgra-0.1.9 lib/posgra/cli/helper.rb
posgra-0.1.8 lib/posgra/cli/helper.rb
posgra-0.1.7 lib/posgra/cli/helper.rb
posgra-0.1.6 lib/posgra/cli/helper.rb
posgra-0.1.5 lib/posgra/cli/helper.rb
posgra-0.1.4 lib/posgra/cli/helper.rb
posgra-0.1.3 lib/posgra/cli/helper.rb