Class: Jetmeter::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/jetmeter/config.rb,
lib/jetmeter/config/flow.rb,
lib/jetmeter/config/file_cache_store.rb,
lib/jetmeter/config/client_middleware.rb

Defined Under Namespace

Classes: ClientMiddleware, FileCacheStore, Flow

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api: Octokit::Client, middleware: Jetmeter::Config::ClientMiddleware) {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
# File 'lib/jetmeter/config.rb', line 8

def initialize(api: Octokit::Client, middleware: Jetmeter::Config::ClientMiddleware)
  raise ArgumentError unless block_given?

  @api = api
  @middleware = middleware
  @flows = {}
  @cache_path = nil

  yield self
end

Instance Attribute Details

#cache_path=(value) ⇒ Object (writeonly)

Sets the attribute cache_path

Parameters:

  • value

    the value to set the attribute cache_path to.



6
7
8
# File 'lib/jetmeter/config.rb', line 6

def cache_path=(value)
  @cache_path = value
end

#flowsObject (readonly)

Returns the value of attribute flows.



5
6
7
# File 'lib/jetmeter/config.rb', line 5

def flows
  @flows
end

#output_pathObject

Returns the value of attribute output_path.



4
5
6
# File 'lib/jetmeter/config.rb', line 4

def output_path
  @output_path
end

#repository_nameObject

Returns the value of attribute repository_name.



3
4
5
# File 'lib/jetmeter/config.rb', line 3

def repository_name
  @repository_name
end

Instance Method Details

#clientObject



24
25
26
27
28
29
30
31
# File 'lib/jetmeter/config.rb', line 24

def client
  @_client ||= begin
    client = @api.new(@github_credentials)
    client.auto_paginate = true
    client.middleware = @middleware.build(@cache_path) if @cache_path
    client
  end
end

#github_credentials=(credentials) ⇒ Object



19
20
21
22
# File 'lib/jetmeter/config.rb', line 19

def github_credentials=(credentials)
  @github_credentials = credentials
  @_client = nil
end

#register_flow(flow_name, &block) ⇒ Object



33
34
35
# File 'lib/jetmeter/config.rb', line 33

def register_flow(flow_name, &block)
  @flows[flow_name] = Jetmeter::Config::Flow.new.tap(&block)
end