class Ridoku::Domain

Attributes

domains[RW]

Public Instance Methods

run() click to toggle source
# File lib/ridoku/domain.rb, line 14
def run
  clist = Base.config[:command]
  command = clist.shift
  sub_command = clist.shift

  environment = load_environment

  case sub_command
  when 'list', nil
    list
  when 'set', 'add'
    add
  when 'delete', 'remove', 'rm'
    delete
  when 'push'
    push_update
  else
    print_domain_help
  end
end

Protected Instance Methods

add() click to toggle source
# File lib/ridoku/domain.rb, line 73
def add
  ARGV.each do |domain|
    if domains.index(domain) == nil
      domains << domain 
      $stdout.puts "Adding #{domain}."
    end
  end

  Base.save_app(:domains)
end
delete() click to toggle source
# File lib/ridoku/domain.rb, line 84
def delete
  ARGV.each do |domain|
    if domain.match(/^[0-9]+$/)
      value = domains.delete_at(domain.to_i)
    else
      value = domains.delete(domain)
    end
    $stdout.puts "Deleting domain: #{value}"
  end
  
  Base.save_app(:domains)
end
list() click to toggle source
# File lib/ridoku/domain.rb, line 62
def list
  if domains.length == 0
    $stdout.puts 'No domains specified!'
  else
    $stdout.puts 'Domains:'
    domains.each_index do |idx|
      $stdout.puts "  #{$stdout.colorize(idx.to_s, :bold)}: #{domains[idx]}"
    end
  end
end
load_environment() click to toggle source
# File lib/ridoku/domain.rb, line 37
def load_environment
  Base.fetch_app
  self.domains = (Base.app[:domains] ||= [])
end
print_domain_help() click to toggle source
push_update() click to toggle source
# File lib/ridoku/domain.rb, line 97
def push_update
  if domains.length == 0
    $stdout.puts 'No domains specified!'
    $stderr.puts 'Please specify at least 1 domain and try again.'
    return
  end

  unless Base.config[:quiet]
    $stdout.puts "Pushing domains:"

    domains.each_index do |idx|
      $stdout.puts "  #{$stdout.colorize(idx.to_s, :bold)}: #{domains[idx]}"
    end
  end

  Base.standard_deploy('rails-app', 
    {
      opsworks_custom_cookbooks: {
        recipes: [
          "deploy::domains"
        ]
      }
    }
  )
  
end