Class: Wordmove::Movefile
- Inherits:
-
Object
- Object
- Wordmove::Movefile
- Defined in:
- lib/wordmove/movefile.rb
Instance Attribute Summary collapse
-
#cli_options ⇒ Object
readonly
Returns the value of attribute cli_options.
-
#config_file_name ⇒ Object
readonly
Returns the value of attribute config_file_name.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#start_dir ⇒ Object
readonly
Returns the value of attribute start_dir.
Instance Method Summary collapse
- #environment ⇒ Object
-
#initialize(cli_options = {}, start_dir = nil, verbose = true) ⇒ Movefile
constructor
rubocop:disable Style/OptionalBooleanParameter.
- #secrets ⇒ Object
Constructor Details
#initialize(cli_options = {}, start_dir = nil, verbose = true) ⇒ Movefile
rubocop:disable Style/OptionalBooleanParameter
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wordmove/movefile.rb', line 9 def initialize( = {}, start_dir = nil, verbose = true) # rubocop:disable Style/OptionalBooleanParameter @logger = Logger.new($stdout).tap { |l| l.level = Logger::DEBUG } @cli_options = .deep_symbolize_keys || {} @config_file_name = @cli_options.fetch(:config, nil) @start_dir = start_dir || current_dir @options = fetch(verbose) .deep_symbolize_keys! .freeze end |
Instance Attribute Details
#cli_options ⇒ Object (readonly)
Returns the value of attribute cli_options.
3 4 5 |
# File 'lib/wordmove/movefile.rb', line 3 def @cli_options end |
#config_file_name ⇒ Object (readonly)
Returns the value of attribute config_file_name.
3 4 5 |
# File 'lib/wordmove/movefile.rb', line 3 def config_file_name @config_file_name end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/wordmove/movefile.rb', line 3 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/wordmove/movefile.rb', line 3 def @options end |
#start_dir ⇒ Object (readonly)
Returns the value of attribute start_dir.
3 4 5 |
# File 'lib/wordmove/movefile.rb', line 3 def start_dir @start_dir end |
Instance Method Details
#environment ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wordmove/movefile.rb', line 20 def environment available_enviroments = extract_available_envs() if available_enviroments.size > 1 && [:environment].nil? raise( UndefinedEnvironment, 'You need to specify an environment with --environment parameter' ) end if [:environment].present? && !available_enviroments.include?([:environment].to_sym) raise UndefinedEnvironment, "No environment found for \"#{[:environment]}\". " \ "Available Environments: #{available_enviroments.join(' ')}" end # NOTE: This is Hash#fetch, not self.fetch. .fetch(:environment, available_enviroments.first).to_sym end |
#secrets ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/wordmove/movefile.rb', line 40 def secrets secrets = [] .each_key do |env| secrets << .dig(env, :database, :password) secrets << .dig(env, :database, :host) secrets << .dig(env, :vhost) secrets << .dig(env, :ssh, :password) secrets << .dig(env, :ssh, :host) secrets << .dig(env, :ftp, :password) secrets << .dig(env, :ftp, :host) secrets << .dig(env, :wordpress_path) end secrets.compact.delete_if(&:empty?) end |