Class: Vx::ServiceConnector::Model::Payload
- Inherits:
-
Struct
- Object
- Struct
- Vx::ServiceConnector::Model::Payload
- Defined in:
- lib/vx/service_connector/model.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#author_email ⇒ Object
Returns the value of attribute author_email.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#branch_label ⇒ Object
Returns the value of attribute branch_label.
-
#foreign_pull_request? ⇒ Object
Returns the value of attribute foreign_pull_request?.
-
#internal_pull_request? ⇒ Object
Returns the value of attribute internal_pull_request?.
-
#message ⇒ Object
Returns the value of attribute message.
-
#pull_request_number ⇒ Object
Returns the value of attribute pull_request_number.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#skip ⇒ Object
Returns the value of attribute skip.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#web_url ⇒ Object
Returns the value of attribute web_url.
Class Method Summary collapse
Instance Method Summary collapse
- #ignore? ⇒ Boolean
- #perform?(restriction = nil) ⇒ Boolean
- #pull_request? ⇒ Boolean
- #tag? ⇒ Boolean
- #to_hash ⇒ Object
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def @author end |
#author_email ⇒ Object
Returns the value of attribute author_email
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def @author_email end |
#branch ⇒ Object
Returns the value of attribute branch
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def branch @branch end |
#branch_label ⇒ Object
Returns the value of attribute branch_label
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def branch_label @branch_label end |
#foreign_pull_request? ⇒ Object
Returns the value of attribute foreign_pull_request?
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17
def foreign_pull_request?
@foreign_pull_request?
end
|
#internal_pull_request? ⇒ Object
Returns the value of attribute internal_pull_request?
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17
def internal_pull_request?
@internal_pull_request?
end
|
#message ⇒ Object
Returns the value of attribute message
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def @message end |
#pull_request_number ⇒ Object
Returns the value of attribute pull_request_number
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def pull_request_number @pull_request_number end |
#sha ⇒ Object
Returns the value of attribute sha
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def sha @sha end |
#skip ⇒ Object
Returns the value of attribute skip
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def skip @skip end |
#tag ⇒ Object
Returns the value of attribute tag
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def tag @tag end |
#web_url ⇒ Object
Returns the value of attribute web_url
17 18 19 |
# File 'lib/vx/service_connector/model.rb', line 17 def web_url @web_url end |
Class Method Details
.from_hash(params) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/vx/service_connector/model.rb', line 98 def from_hash(params) payload = Payload.new payload.members.each do |m| payload[m] = params.key?(m) ? params[m] : params[m.to_s] end payload end |
Instance Method Details
#ignore? ⇒ Boolean
85 86 87 |
# File 'lib/vx/service_connector/model.rb', line 85 def ignore? !!(skip || .to_s =~ PAYLOAD_IGNORE_RE) end |
#perform?(restriction = nil) ⇒ Boolean
35 36 37 38 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/vx/service_connector/model.rb', line 35 def perform?(restriction = nil) if ignore? # skip build return false end if restriction.nil? # skip internal pr or tag # allow all pushes and foreign pr return !(internal_pull_request? or tag?) end if restriction.is_a?(Hash) branch_re = restriction[:branch] pr_branch_re = restriction[:pull_requests_filter] pr = restriction[:pull_request] if pr && branch_re.nil? && pr_branch_re.nil? # skip internal pr or tag # allow all pushes and foreign pr return !(internal_pull_request? or tag?) end if !branch_re && internal_pull_request? return false end if branch_re && Regexp.new(branch_re).match(branch) # if branch name matches # we're already building it, # so we should ignore prs. return !internal_pull_request? end if pr && pull_request? if !pr_branch_re.nil? return !Regexp.new(pr_branch_re).match(branch).nil? else return true end end return false end # unknown restriction # denied return false end |
#pull_request? ⇒ Boolean
93 94 95 |
# File 'lib/vx/service_connector/model.rb', line 93 def pull_request? internal_pull_request? or foreign_pull_request? end |
#tag? ⇒ Boolean
89 90 91 |
# File 'lib/vx/service_connector/model.rb', line 89 def tag? !!tag end |
#to_hash ⇒ Object
31 32 33 |
# File 'lib/vx/service_connector/model.rb', line 31 def to_hash to_h end |