class Dustcart::Resource::Input::Postgres
input: postgresql
Attributes
database_name[R]
Public Class Methods
new(to_dir, database_name, &block)
click to toggle source
Calls superclass method
Dustcart::Resource::Input::Base::new
# File lib/dustcart/input/postgres.rb, line 16 def initialize(to_dir, database_name, &block) super(to_dir, &block) @database_name = database_name host '127.0.0.1' unless host port '5432' unless port label 'database.dump' unless label command 'pg_dump' unless command end
Public Instance Methods
precheck()
click to toggle source
Calls superclass method
Dustcart::Resource::Input::Base#precheck
# File lib/dustcart/input/postgres.rb, line 26 def precheck super requirements raise <<-EOS.unindent unless SystemCommand.exists?(command) #{command} command is not installed EOS raise <<-EOS.unindent unless database_name 'database_name' is required EOS end
run()
click to toggle source
Calls superclass method
Dustcart::Resource::Base#run
# File lib/dustcart/input/postgres.rb, line 40 def run super create_dump end
Private Instance Methods
create_dump()
click to toggle source
# File lib/dustcart/input/postgres.rb, line 56 def create_dump pipeline = CommandPipeline.new pipeline.add( "#{password_env} #{Shellwords.escape(command)} #{options} #{Shellwords.escape(database_name)}" ) pipeline.run end
general_options()
click to toggle source
ignore :reek:FeatureEnvy:
# File lib/dustcart/input/postgres.rb, line 78 def general_options options = [] options << '--format=custom' options << '--blobs' options << "--file=#{Shellwords.escape(to_dir)}/#{Shellwords.escape(label)}" options.join(' ') end
options()
click to toggle source
ignore :reek:FeatureEnvy:
# File lib/dustcart/input/postgres.rb, line 69 def options options = [] options << general_options options << user_options options << target_options options.join(' ') end
password_env()
click to toggle source
# File lib/dustcart/input/postgres.rb, line 64 def password_env "PGPASSWORD=#{Shellwords.escape(pass)}" end
requirements()
click to toggle source
# File lib/dustcart/input/postgres.rb, line 48 def requirements %i(host port user pass label).each do |var| raise <<-EOS.unindent unless attributes.key?(var) '#{var}' is required EOS end end
target_options()
click to toggle source
ignore :reek:FeatureEnvy:
# File lib/dustcart/input/postgres.rb, line 96 def target_options options = [] options << "--file=#{Shellwords.escape(to_dir)}/#{Shellwords.escape(label)}" options.join(' ') end
user_options()
click to toggle source
ignore :reek:FeatureEnvy:
# File lib/dustcart/input/postgres.rb, line 87 def user_options options = [] options << "--host=#{Shellwords.escape(host)}" options << "--port=#{Shellwords.escape(port)}" options << "--username=#{Shellwords.escape(user)}" options.join(' ') end