Class: Skynet::Builder::Base
- Inherits:
-
Object
- Object
- Skynet::Builder::Base
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/skynet/builder/base.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#branches ⇒ Object
Returns the value of attribute branches.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #build(branch = nil) ⇒ Object
-
#initialize(app, config) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(app, config) ⇒ Base
Returns a new instance of Base.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/skynet/builder/base.rb', line 23 def initialize(app, config) self.app = app @config = config @source = File.join Dir.pwd, app, '.' @key = config[:key] self.branches = config[:branches] if branches.present? && branches.first.present? self.branch = branches.first[0] self.destination = branches.first[1] end self.url = config[:url] self.type = config[:type] self.repository = config[:repository] end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
13 14 15 |
# File 'lib/skynet/builder/base.rb', line 13 def app @app end |
#branch ⇒ Object
Returns the value of attribute branch.
13 14 15 |
# File 'lib/skynet/builder/base.rb', line 13 def branch @branch end |
#branches ⇒ Object
Returns the value of attribute branches.
13 14 15 |
# File 'lib/skynet/builder/base.rb', line 13 def branches @branches end |
#destination ⇒ Object
Returns the value of attribute destination.
13 14 15 |
# File 'lib/skynet/builder/base.rb', line 13 def destination @destination end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
14 15 16 |
# File 'lib/skynet/builder/base.rb', line 14 def key @key end |
#repository ⇒ Object
Returns the value of attribute repository.
13 14 15 |
# File 'lib/skynet/builder/base.rb', line 13 def repository @repository end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
14 15 16 |
# File 'lib/skynet/builder/base.rb', line 14 def source @source end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/skynet/builder/base.rb', line 13 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
13 14 15 |
# File 'lib/skynet/builder/base.rb', line 13 def url @url end |
Instance Method Details
#build(branch = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/skynet/builder/base.rb', line 39 def build(branch=nil) if branch.present? return if branches[branch].blank? self.branches = { branch => branches[branch] } end unless valid? Skynet.logger.error "Configuration error for #{app} (branch: #{branch})" Skynet.logger.error errors..join '. ' raise ArgumentError end branches.each_pair do |branch, destination| self.branch = branch.to_s self.destination = destination if valid? Skynet.logger.info "#{type} running for #{app} (branch: #{branch})" else Skynet.logger.error "Configuration error for #{app} (branch: #{branch})" Skynet.logger.error errors..join '. ' raise ArgumentError end build_repository execute end end |