Class: IssueDB

Inherits:
Object
  • Object
show all
Includes:
Authentication, Init, Version
Defined in:
lib/issue_db.rb

Constant Summary

Constants included from Version

Version::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Init

#init!

Methods included from Authentication

login

Constructor Details

#initialize(repo, log: nil, octokit_client: nil, label: nil, cache_expiry: nil, init: true) ⇒ IssueDB

Create a new IssueDB object :param repo: The GitHub repository to use as the datastore (org/repo format) [required] :param log: An optional logger - created for you by default :param octokit_client: An optional pre-hydrated Octokit::Client object :param label: The label to use for issues managed in the datastore by this library :param cache_expiry: The number of seconds to cache issues in memory (default: 60) :param init: Whether or not to initialize the database on object creation (default: true) - idempotent :return: A new IssueDB object



28
29
30
31
32
33
34
35
36
37
# File 'lib/issue_db.rb', line 28

def initialize(repo, log: nil, octokit_client: nil, label: nil, cache_expiry: nil, init: true)
  @log = log || RedactingLogger.new($stdout, level: ENV.fetch("LOG_LEVEL", "INFO").upcase)
  Retry.setup!(log: @log)
  @version = VERSION
  @client = Authentication.(octokit_client, @log)
  @repo = Repository.new(repo)
  @label = label || ENV.fetch("ISSUE_DB_LABEL", "issue-db")
  @cache_expiry = cache_expiry || ENV.fetch("ISSUE_DB_CACHE_EXPIRY", 60).to_i
  init! if init
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



17
18
19
# File 'lib/issue_db.rb', line 17

def log
  @log
end

#versionObject (readonly)

Returns the value of attribute version.



18
19
20
# File 'lib/issue_db.rb', line 18

def version
  @version
end

Instance Method Details

#create(key, data, options = {}) ⇒ Object



39
40
41
# File 'lib/issue_db.rb', line 39

def create(key, data, options = {})
  db.create(key, data, options)
end

#delete(key, options = {}) ⇒ Object



51
52
53
# File 'lib/issue_db.rb', line 51

def delete(key, options = {})
  db.delete(key, options)
end

#list(options = {}) ⇒ Object



55
56
57
# File 'lib/issue_db.rb', line 55

def list(options = {})
  db.list(options)
end

#list_keys(options = {}) ⇒ Object



59
60
61
# File 'lib/issue_db.rb', line 59

def list_keys(options = {})
  db.list_keys(options)
end

#read(key, options = {}) ⇒ Object



43
44
45
# File 'lib/issue_db.rb', line 43

def read(key, options = {})
  db.read(key, options)
end

#refresh!Object



63
64
65
# File 'lib/issue_db.rb', line 63

def refresh!
  db.refresh!
end

#update(key, data, options = {}) ⇒ Object



47
48
49
# File 'lib/issue_db.rb', line 47

def update(key, data, options = {})
  db.update(key, data, options)
end