Class: Drone::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/drone/commit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, status: nil, sha: nil, started_at: nil, finished_at: nil, duration: nil, branch: nil, pull_request: nil, message: nil, author: nil, gravatar: nil, timestamp: nil, created_at: nil, updated_at: nil) ⇒ Commit

Returns a new instance of Commit.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/drone/commit.rb', line 5

def initialize(
    id: nil, status: nil, sha: nil,
    started_at: nil, finished_at: nil, duration: nil,
    branch: nil, pull_request: nil, message: nil,
    author: nil, gravatar: nil,
    timestamp: nil, created_at: nil, updated_at: nil)
  @id           = id
  @status       = status
  @sha          = sha
  @started_at   = started_at
  @finished_at  = finished_at
  @duration     = duration
  @branch       = branch
  @pull_request = pull_request
  @message      = message
  @author       = author
  @gravatar     = gravatar
  @timestamp    = timestamp
  @created_at   = created_at
  @updated_at   = updated_at
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



3
4
5
# File 'lib/drone/commit.rb', line 3

def author
  @author
end

#branchObject (readonly)

Returns the value of attribute branch.



3
4
5
# File 'lib/drone/commit.rb', line 3

def branch
  @branch
end

#created_atObject (readonly)

Returns the value of attribute created_at.



3
4
5
# File 'lib/drone/commit.rb', line 3

def created_at
  @created_at
end

#durationObject (readonly)

Returns the value of attribute duration.



3
4
5
# File 'lib/drone/commit.rb', line 3

def duration
  @duration
end

#finished_atObject (readonly)

Returns the value of attribute finished_at.



3
4
5
# File 'lib/drone/commit.rb', line 3

def finished_at
  @finished_at
end

#gravatarObject (readonly)

Returns the value of attribute gravatar.



3
4
5
# File 'lib/drone/commit.rb', line 3

def gravatar
  @gravatar
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/drone/commit.rb', line 3

def id
  @id
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/drone/commit.rb', line 3

def message
  @message
end

#pull_requestObject (readonly)

Returns the value of attribute pull_request.



3
4
5
# File 'lib/drone/commit.rb', line 3

def pull_request
  @pull_request
end

#shaObject (readonly)

Returns the value of attribute sha.



3
4
5
# File 'lib/drone/commit.rb', line 3

def sha
  @sha
end

#started_atObject (readonly)

Returns the value of attribute started_at.



3
4
5
# File 'lib/drone/commit.rb', line 3

def started_at
  @started_at
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/drone/commit.rb', line 3

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



3
4
5
# File 'lib/drone/commit.rb', line 3

def timestamp
  @timestamp
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



3
4
5
# File 'lib/drone/commit.rb', line 3

def updated_at
  @updated_at
end

Class Method Details

.build_with_hash(hash) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/drone/commit.rb', line 27

def self.build_with_hash(hash)
  Commit.new(
    id:           hash["id"],
    status:       hash["status"],
    sha:          hash["sha"],
    started_at:   hash["started_at"],
    finished_at:  hash["finished_at"],
    duration:     hash["duration"],
    branch:       hash["branch"],
    pull_request: hash["pull_request"],
    message:      hash["message"],
    author:       hash["author"],
    gravatar:     hash["gravatar"],
    timestamp:    Time.parse(hash["timestamp"]),
    created_at:   hash["created_at"],
    updated_at:   hash["updated_at"]
  )
end