Class: Squidward::Command::Info

Inherits:
Base
  • Object
show all
Defined in:
lib/squidward/commands/info.rb

Overview

Handles the echoing of the current configuration (pretty basic tough)

Instance Method Summary collapse

Methods inherited from Base

#configuration, #display, #logger, #store_configuration

Instance Method Details

#index(args = nil) ⇒ Object

Goes thru the settings and echos their values.



6
7
8
9
# File 'lib/squidward/commands/info.rb', line 6

def index(args = nil)
  return show_info if (read_credentials)
  puts("Not yet configured. Run 'squidward credentials:set' for configuring credentials.")
end

#read_credentialsObject

Reads credentials from the configuration file



31
32
33
34
35
# File 'lib/squidward/commands/info.rb', line 31

def read_credentials
  conf = self.configuration
  return nil unless conf[:credentials]
  return [conf[:credentials][:access_key], conf[:credentials][:secret_key]]
end

#show_infoObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/squidward/commands/info.rb', line 11

def show_info
  display("=== Current Settings")
  display("Amazon Web Services Account:  #{configuration[:credentials][:access_key]}")
  display("Amazon S3 Bucket:             #{configuration[:default_bucket]}")
  display("")
  if (configuration[:domains] and configuration[:domains].size > 0)
    display("Configured Domains:           ", false)  
    first = true
    configuration[:domains].each do |domain|
      spaces = (not first) ? " " * 30 : ""
      display(spaces + "#{domain[:domain]} is being uploaded to #{domain[:vpath] or "<bucket_root>"}")
      first = false
    end
  else
    display("Configured Domains:           You currently have no domains configuration for backup")
  end
  display("")
end