Class: ContributorsStats::Reader

Inherits:
Base
  • Object
show all
Includes:
JsonHelper
Defined in:
lib/contributors_stats/reader.rb,
lib/plugins/contributors_stats/reader/gh_org.rb,
lib/plugins/contributors_stats/reader/gh_repo.rb

Overview

Base for reading ContributorsStats data

Direct Known Subclasses

Calculator

Defined Under Namespace

Classes: GhOrg, GhRepo

Instance Attribute Summary collapse

Attributes inherited from Base

#logger, #options

Instance Method Summary collapse

Methods included from JsonHelper

#load_json, #path_prefix, #path_suffix, #url_builder

Constructor Details

#initialize(options = {}) ⇒ Reader

Returns a new instance of Reader.



12
13
14
15
16
17
18
# File 'lib/contributors_stats/reader.rb', line 12

def initialize(options = {})
  configure_path(*options.delete(:configure_path)) if options[:configure_path]
  super(options)
  @raw_data = []
  @data = nil
  parse_readers(filter_options("reader"))
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/contributors_stats/reader.rb', line 10

def data
  @data
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



10
11
12
# File 'lib/contributors_stats/reader.rb', line 10

def raw_data
  @raw_data
end

Instance Method Details

#load(type, name) ⇒ Object

load data using given plugin

Parameters:

  • type (String)

    plugin to use

  • name (String)

    name to pass to the plugin



23
24
25
26
27
28
29
# File 'lib/contributors_stats/reader.rb', line 23

def load(type, name)
  reader_plugin(type).load(name) do |data, name|
    log "repository: #{name}"
    @raw_data += data
  end
  @data = nil
end