Module: AgentClient

Defined in:
lib/agent_client.rb,
lib/agent_client/agent.rb,
lib/agent_client/helper.rb,
lib/agent_client/request.rb,
lib/agent_client/segment.rb,
lib/agent_client/version.rb

Overview

Copyright © 2017 Stratumn SAS

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at mozilla.org/MPL/2.0/.

Defined Under Namespace

Modules: Helper, Request Classes: Agent, Segment

Constant Summary collapse

VERSION =
'1.0.0'.freeze

Class Method Summary collapse

Class Method Details

.configObject



48
49
50
# File 'lib/agent_client.rb', line 48

def self.config
  @config
end

.configure(opts = {}) ⇒ Object

Configure through hash



27
28
29
30
31
# File 'lib/agent_client.rb', line 27

def self.configure(opts = {})
  opts.each do |k, v|
    @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym
  end
end

.configure_with(path_to_yaml_file) ⇒ Object

Configure through yaml file



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/agent_client.rb', line 34

def self.configure_with(path_to_yaml_file)
  begin
    config = YAML.load(IO.read(path_to_yaml_file))
  rescue Errno::ENOENT
    puts 'YAML configuration file couldn\'t be found. Using defaults.'
    return
  rescue Psych::SyntaxError
    puts 'YAML configuration file contains invalid syntax. Using defaults.'
    return
  end

  configure(config)
end