Class: Hubeye::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/server/hubeye_server.rb

Overview

simple interface to Github’s api v3 for commits

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Commit

Returns a new instance of Commit.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/server/hubeye_server.rb', line 9

def initialize(input)
  @raw_input = input
  @repo = input.keys.first
  if Hash === input
    if input[@repo].keys == ["sha"]
      @only_sha = true
    else
      @latest = true
    end
  else
    raise ArgumentError.new "input must be a kind of hash"
  end
end

Instance Attribute Details

#latestObject (readonly)

Returns the value of attribute latest.



8
9
10
# File 'lib/server/hubeye_server.rb', line 8

def latest
  @latest
end

#only_shaObject (readonly)

Returns the value of attribute only_sha.



8
9
10
# File 'lib/server/hubeye_server.rb', line 8

def only_sha
  @only_sha
end

#raw_inputObject (readonly)

Returns the value of attribute raw_input.



8
9
10
# File 'lib/server/hubeye_server.rb', line 8

def raw_input
  @raw_input
end

#repoObject (readonly)

Returns the value of attribute repo.



8
9
10
# File 'lib/server/hubeye_server.rb', line 8

def repo
  @repo
end

Instance Method Details

#commit_messageObject



27
28
29
30
31
32
33
34
35
# File 'lib/server/hubeye_server.rb', line 27

def commit_message
  if @only_sha
    return
  elsif @latest
    @commit_message ||= @raw_input[@repo]['commit']['message']
  else
    raise
  end
end

#committer_nameObject



37
38
39
40
41
42
43
44
45
# File 'lib/server/hubeye_server.rb', line 37

def committer_name
  if @only_sha
    return
  elsif @latest
    @committer_name ||= @raw_input[@repo]['commit']['committer']['name']
  else
    raise
  end
end

#shaObject



23
24
25
# File 'lib/server/hubeye_server.rb', line 23

def sha
  @sha ||= @raw_input[@repo]['sha']
end