Class: MinaRevisioneer::MessageExtractor
- Inherits:
-
Object
- Object
- MinaRevisioneer::MessageExtractor
show all
- Defined in:
- lib/mina_revisioneer/message_extractor.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(host, token, binding) ⇒ MessageExtractor
Returns a new instance of MessageExtractor.
7
8
9
10
11
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 7
def initialize host, token, binding
@host = host
@api_token = token
@binding = binding
end
|
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
6
7
8
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 6
def api_token
@api_token
end
|
#binding ⇒ Object
Returns the value of attribute binding.
6
7
8
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 6
def binding
@binding
end
|
#host ⇒ Object
Returns the value of attribute host.
6
7
8
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 6
def host
@host
end
|
Instance Method Details
#last_deploy ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 13
def last_deploy
@last_deploy ||= begin
curl = %Q{curl "#{host}/deployments?limit=1" -H "API-TOKEN: #{api_token}" -s}
response = %x[#{curl}].strip
JSON.parse(response).first || {}
end
rescue => err
{} end
|
#last_deploy_date ⇒ Object
30
31
32
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 30
def last_deploy_date
Time.parse(last_deploy.fetch("deployed_at"))
end
|
#last_deploy_sha ⇒ Object
34
35
36
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 34
def last_deploy_sha
last_deploy.fetch("sha", nil)
end
|
#messages ⇒ Object
42
43
44
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 42
def messages
[] end
|
#number_of_new_commits ⇒ Object
23
24
25
26
27
28
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 23
def number_of_new_commits
walker = Rugged::Walker.new(repo)
walker.push sha
walker.hide last_deploy_sha if last_deploy_sha
walker.each.to_a.count
end
|
#repo ⇒ Object
38
39
40
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 38
def repo
@repo ||= Rugged::Repository.new(".")
end
|
#sha ⇒ Object
46
47
48
49
|
# File 'lib/mina_revisioneer/message_extractor.rb', line 46
def sha
ref = repo.head
ref.target
end
|