Class: Capricorn::CLI::ApplicationsDomains
- Inherits:
-
Capricorn::CLI
- Object
- Thor
- Capricorn::CLI
- Capricorn::CLI::ApplicationsDomains
- Includes:
- Helpers
- Defined in:
- lib/capricorn-client/cli/applications/domains.rb
Constant Summary
Constants included from Helpers
Instance Method Summary collapse
Methods included from Helpers
#application, #application_ids, #application_info, #applications, #client, #cluster, #config, #environment, #halt, #info, #local_config, #machine, #machines, #node, #nodes
Methods inherited from Capricorn::CLI
banner, #help, #method_missing, start
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Capricorn::CLI
Instance Method Details
#add(domain) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/capricorn-client/cli/applications/domains.rb', line 18 def add(domain) domain = domain.strip.sub(/^www\./, '') begin domain = PublicSuffixService.parse(domain).to_s rescue Exception halt "invalid domain: #{domain}" end machine, id = *application app = application_info app[4] ||= [] if app[4].include?(domain) halt "Domain is already configured" end app[4].push(domain) p client.call.applications.update(machine.to_sym, id, app[4], app[10]) end |
#list ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/capricorn-client/cli/applications/domains.rb', line 8 def list (application_info[4] || []).sort! do |a, b| a <=> b end (application_info[4] || []).each do |domain| puts "- #{domain}" end end |
#remove(domain) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/capricorn-client/cli/applications/domains.rb', line 42 def remove(domain) domain = domain.strip.sub(/^www\./, '') begin domain = PublicSuffixService.parse(domain).to_s rescue Exception halt "invalid domain: #{domain}" end machine, id = *application app = application_info app[4] ||= [] unless app[4].include?(domain) halt "Domain is not configured" end app[4].delete(domain) p client.call.applications.update(machine.to_sym, id, app[4], app[10]) end |