Module: PDC

Defined in:
lib/pdc.rb,
lib/pdc/v1.rb,
lib/pdc/base.rb,
lib/pdc/http.rb,
lib/pdc/config.rb,
lib/pdc/errors.rb,
lib/pdc/logger.rb,
lib/pdc/version.rb,
lib/pdc/v1/release.rb,
lib/pdc/http/errors.rb,
lib/pdc/http/request.rb,
lib/pdc/v1/variant_cpe.rb,
lib/pdc/resource/errors.rb,
lib/pdc/v1/released_file.rb,
lib/pdc/v1/multi_destination.rb,
lib/pdc/v1/content_delivery_repo.rb,
lib/pdc/http/request/append_slash.rb,
lib/pdc/http/response/raise_error.rb

Defined Under Namespace

Modules: Http, Logging, Request, Resource, Response, V1 Classes: Base, Config, ConfigError, Error, InvalidPathError, JsonError, JsonParseError, MultipleResultsError, ResourceNotFound, ResponseError, TokenFetchFailed

Constant Summary collapse

VERSION =
'0.1.13'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject



7
8
9
10
11
# File 'lib/pdc/logger.rb', line 7

def logger
  @logger ||= ::Logger.new($stdout).tap do |log|
    log.progname = name
  end
end

Class Method Details

.api_urlObject



80
81
82
# File 'lib/pdc/config.rb', line 80

def api_url
  URI.join(config.site, config.api_root)
end

.configObject



67
68
69
# File 'lib/pdc/config.rb', line 67

def config
  @config ||= Config.new
end

.config=(new_config) ⇒ Object



71
72
73
74
# File 'lib/pdc/config.rb', line 71

def config=(new_config)
  @config = new_config
  apply_config
end

.configureObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/pdc/config.rb', line 56

def configure
  @config = Config.new
  begin
    yield(@config) if block_given?
  rescue NoMethodError => e
    raise ConfigError, e
  end

  apply_config
end

.tokenObject



84
85
86
87
# File 'lib/pdc/config.rb', line 84

def token
  return unless config.requires_token
  config.token || Request::TokenFetcher.fetch
end

.token_urlObject



76
77
78
# File 'lib/pdc/config.rb', line 76

def token_url
  URI.join(api_url, config.token_obtain_path)
end