Class: GithubRunDeck

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/github-rundeck.rb

Overview

> GitHub RunDeck

Constant Summary collapse

VERSION =
'0.1.2'.freeze

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.cache_timeoutObject

Returns the value of attribute cache_timeout.



18
19
20
# File 'lib/github-rundeck.rb', line 18

def cache_timeout
  @cache_timeout
end

.config_fileObject

Returns the value of attribute config_file.



17
18
19
# File 'lib/github-rundeck.rb', line 17

def config_file
  @config_file
end

.github_oauth_tokenObject

Returns the value of attribute github_oauth_token.



19
20
21
# File 'lib/github-rundeck.rb', line 19

def github_oauth_token
  @github_oauth_token
end

Instance Method Details

#ghclientObject

> Definitions <=#



33
34
35
36
# File 'lib/github-rundeck.rb', line 33

def ghclient
  # => Instantiate a new GitHub Client
  Github::Client.new
end

#serialize(response) ⇒ Object



38
39
40
41
# File 'lib/github-rundeck.rb', line 38

def serialize(response)
  # => Serialize Object into JSON Array
  JSON.pretty_generate(response.map(&:name).sort_by(&:downcase))
end

#serialize_revisions(branches, tags) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/github-rundeck.rb', line 43

def serialize_revisions(branches, tags)
  # => Serialize Branches/Tags into JSON Array
  # => Branches = String, Tags = Key/Value
  branches = branches.map(&:name).sort_by(&:downcase)
  tags = tags.map(&:name).sort_by(&:downcase).reverse.map { |tag| { name: "Tag: #{tag}", value: tag } }
  JSON.pretty_generate(branches + tags)
end