Class: TravisCustomDeploy::Deployment
- Inherits:
-
Object
- Object
- TravisCustomDeploy::Deployment
- Defined in:
- lib/travis-custom-deploy/deployment.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#check_services(first_file) ⇒ Object
Check if the first file matches service:<service-name> and try to determine the files based on the service.
-
#deploy ⇒ Object
Starts the deployment.
-
#get_transfer(type) ⇒ Object
Creates an instance for the transfer type and return it .
-
#initialize(transfer_type, options, files) ⇒ Deployment
constructor
Initializes a new deployment.
Constructor Details
#initialize(transfer_type, options, files) ⇒ Deployment
Initializes a new deployment
remteopts - the options to connect to the remote server files - the files to transfer
12 13 14 15 16 17 18 |
# File 'lib/travis-custom-deploy/deployment.rb', line 12 def initialize(transfer_type, , files) raise ArgumentError, 'transfer type must not be nil' if transfer_type.nil? @files = files check_services(@files[0]) @options = @transfer = get_transfer(transfer_type) end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/travis-custom-deploy/deployment.rb', line 6 def files @files end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/travis-custom-deploy/deployment.rb', line 5 def @options end |
Instance Method Details
#check_services(first_file) ⇒ Object
Check if the first file matches service:<service-name> and try to determine the files based on the service.
first_file the first file given
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/travis-custom-deploy/deployment.rb', line 47 def check_services(first_file) if first_file.start_with?('service:') service = first_file.sub(/service:/, '') SERVICES.each do |k,v| if k == service @files = v end end end end |
#deploy ⇒ Object
Starts the deployment
21 22 23 |
# File 'lib/travis-custom-deploy/deployment.rb', line 21 def deploy @transfer.transfer end |
#get_transfer(type) ⇒ Object
Creates an instance for the transfer type and return it
type - the transfer type like sftp, ftp, etc.
28 29 30 31 32 |
# File 'lib/travis-custom-deploy/deployment.rb', line 28 def get_transfer(type) type = type[0].upcase + type[1..-1] try_require(type) Transfer.const_get(type).new(@options, @files) end |