Class: Deployme::Deployment
- Inherits:
-
Object
- Object
- Deployme::Deployment
- Defined in:
- lib/deployme/deployment.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #environment ⇒ Object
-
#initialize(options:) ⇒ Deployment
constructor
A new instance of Deployment.
-
#logger ⇒ Object
Attributes.
- #notify(stage, *args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(options:) ⇒ Deployment
Returns a new instance of Deployment.
26 27 28 29 |
# File 'lib/deployme/deployment.rb', line 26 def initialize(options:) @options = @config ||= Config.new(options: ).load end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
24 25 26 |
# File 'lib/deployme/deployment.rb', line 24 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/deployme/deployment.rb', line 24 def @options end |
Class Method Details
.options(parser) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/deployme/deployment.rb', line 9 def self.(parser) parser.separator '' parser.separator 'Deployment Options:' parser.on('--url=URL', String, 'URL for deployment environment') { |, value| .deploy_url = value } parser.on('--domain=domain', String, 'URL for deployment environment') { |, value| .deploy_domain = value } parser.on('-nNAME', '--name=NAME', String, 'Deployment name') { |, value| .name = value } parser.on('-eENVIRONMENT', '--environment=ENVIRONMENT', String, 'Environment to deploy to') { |, value| .environment = value } parser.on('-dDIRECTORY', '--directory=DIRECTORY', String, 'Directory where to find deployment instructions') { |, value| .directory = File.(value) } parser.on('--commit=COMMIT', String, 'Git Commit to deploy') { |, value| .git_commit = value } parser.on('--branch=BRANCH', String, 'Git Branch to deploy') { |, value| .git_branch = value } parser.on('--change-id=CHANGE_ID', String, 'Change ID (Pull Request) to deploy') { |, value| .change_id = value } end |
Instance Method Details
#environment ⇒ Object
57 58 59 |
# File 'lib/deployme/deployment.rb', line 57 def environment .environment end |
#logger ⇒ Object
Attributes
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/deployme/deployment.rb', line 43 def logger @logger ||= Logger.new(STDOUT).tap do |logger| logger.formatter = proc do |severity, _datetime, _progname, msg| status = case severity when 'INFO' then "\e[34m==>\e[0m" when 'WARNING' then "\e[33m==>\e[0m" when 'ERROR' then "\e[31m==>\e[0m" end format("%<status>s %<msg>s\n", status: status, msg: msg) end end end |
#notify(stage, *args) ⇒ Object
36 37 38 39 40 |
# File 'lib/deployme/deployment.rb', line 36 def notify(stage, *args) notifications.each do |notification| notification.public_send("notify_#{stage}", *args) end end |
#run ⇒ Object
31 32 33 34 |
# File 'lib/deployme/deployment.rb', line 31 def run logger.info "Start deployment for #{.deploy_name}" providers.each(&:deploy) end |