class Wordmove::EnvironmentsList

Attributes

local_vhost[R]
logger[R]
movefile[R]
remote_vhosts[R]

Public Class Methods

new(options) click to toggle source
# File lib/wordmove/environments_list.rb, line 11
def initialize(options)
  @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
  @movefile = Wordmove::Movefile.new(options[:config])
  @remote_vhosts = []
  @local_vhost = []
end
print(cli_options) click to toggle source

Public Instance Methods

print() click to toggle source

Private Instance Methods

generate_vhost_list(contents:) click to toggle source

return env, vhost map Exp. {:env=>:local, :vhost=>“vhost.local”},

{:env=>:production, :vhost=>"http://example.com"}
# File lib/wordmove/environments_list.rb, line 56
def generate_vhost_list(contents:)
  # select object which has 'vhost' only
  vhosts = select_vhost(contents: contents)
  vhosts.each do |list|
    if list[:env] == :local
      @local_vhost << list
    else
      @remote_vhosts << list
    end
  end
end
output() click to toggle source
# File lib/wordmove/environments_list.rb, line 35
def output
  logger.task('Listing Local')
  logger.plain(output_string(vhost_list: local_vhost))

  logger.task('Listing Remotes')
  logger.plain(output_string(vhost_list: remote_vhosts))
end
output_string(vhost_list:) click to toggle source
# File lib/wordmove/environments_list.rb, line 43
def output_string(vhost_list:)
  return 'vhost list is empty' if vhost_list.empty?

  vhost_list.each_with_object("") do |entry, retval|
    retval << "#{entry[:env]}: #{entry[:vhost]}\n"
  end
end
parse_movefile(movefile:) click to toggle source
# File lib/wordmove/environments_list.rb, line 31
def parse_movefile(movefile:)
  movefile.fetch
end
select_vhost(contents:) click to toggle source
# File lib/wordmove/environments_list.rb, line 26
def select_vhost(contents:)
  target = contents.select { |_key, env| env[:vhost].present? }
  target.map { |key, env| { env: key, vhost: env[:vhost] } }
end