Class: Magnum::Payload::Base

Inherits:
Object
  • Object
show all
Includes:
MessageParser
Defined in:
lib/magnum/payload/base.rb

Direct Known Subclasses

Beanstalk, Bitbucket, Custom, Github, Gitlab

Constant Summary collapse

GIT_ZERO_SHA =
/\A[0]{40}\z/

Constants included from MessageParser

MessageParser::REGEX_SKIP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MessageParser

#skip_message?

Constructor Details

#initialize(payload) ⇒ Base

Returns a new instance of Base.


26
27
28
29
30
31
32
33
34
35
# File 'lib/magnum/payload/base.rb', line 26

def initialize(payload)
  set_defaults
  
  @raw_data = payload
  @data     = parse_payload(payload)

  parse!

  @skip = skip_message? unless @skip
end

Instance Attribute Details

#authorObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def author
  @author
end

#author_emailObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def author_email
  @author_email
end

#branchObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def branch
  @branch
end

#commitObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def commit
  @commit
end

#commit_urlObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def commit_url
  @commit_url
end

#committerObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def committer
  @committer
end

#committer_emailObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def committer_email
  @committer_email
end

#compare_urlObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def compare_url
  @compare_url
end

#dataObject (readonly)

Returns the value of attribute data


11
12
13
# File 'lib/magnum/payload/base.rb', line 11

def data
  @data
end

#messageObject (readonly)

Commit SHA or ID


16
17
18
# File 'lib/magnum/payload/base.rb', line 16

def message
  @message
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data


11
12
13
# File 'lib/magnum/payload/base.rb', line 11

def raw_data
  @raw_data
end

#skipObject (readonly)

Flag to indicate payload skip


13
14
15
# File 'lib/magnum/payload/base.rb', line 13

def skip
  @skip
end

#testObject (readonly)

Flag to indicate payload skip


13
14
15
# File 'lib/magnum/payload/base.rb', line 13

def test
  @test
end

Instance Method Details

#attributes_hashObject


37
38
39
40
41
42
43
44
45
46
47
# File 'lib/magnum/payload/base.rb', line 37

def attributes_hash
  {
    "commit"      => commit,
    "branch"      => branch,
    "author"      => author,
    "committer"   => committer,
    "message"     => message,
    "commit_url"  => commit_url,
    "compare_url" => compare_url
  }
end

#parse!Object


49
50
51
# File 'lib/magnum/payload/base.rb', line 49

def parse!
  raise "Not implemented in base class"
end

#skip?Boolean

Returns:

  • (Boolean)

53
54
55
# File 'lib/magnum/payload/base.rb', line 53

def skip?
  skip == true
end