Class: IssueDB
- Inherits:
-
Object
- Object
- IssueDB
- Includes:
- Authentication, Init, Version
- Defined in:
- lib/issue_db.rb
Constant Summary
Constants included from Version
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #create(key, data, options = {}) ⇒ Object
- #delete(key, options = {}) ⇒ Object
-
#initialize(repo, log: nil, octokit_client: nil, label: nil, cache_expiry: nil, init: true) ⇒ IssueDB
constructor
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.
- #list(options = {}) ⇒ Object
- #list_keys(options = {}) ⇒ Object
- #read(key, options = {}) ⇒ Object
- #refresh! ⇒ Object
- #update(key, data, options = {}) ⇒ Object
Methods included from Init
Methods included from Authentication
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.login(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
#log ⇒ Object (readonly)
Returns the value of attribute log.
17 18 19 |
# File 'lib/issue_db.rb', line 17 def log @log end |
#version ⇒ Object (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, = {}) db.create(key, data, ) end |
#delete(key, options = {}) ⇒ Object
51 52 53 |
# File 'lib/issue_db.rb', line 51 def delete(key, = {}) db.delete(key, ) end |
#list(options = {}) ⇒ Object
55 56 57 |
# File 'lib/issue_db.rb', line 55 def list( = {}) db.list() end |
#list_keys(options = {}) ⇒ Object
59 60 61 |
# File 'lib/issue_db.rb', line 59 def list_keys( = {}) db.list_keys() end |
#read(key, options = {}) ⇒ Object
43 44 45 |
# File 'lib/issue_db.rb', line 43 def read(key, = {}) db.read(key, ) 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, = {}) db.update(key, data, ) end |