Module: AgentClient

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

Overview

Copyright 2017 Stratumn SAS. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Helper, Request Classes: Agent, Process, Segment

Constant Summary collapse

VERSION =
'0.2.0'.freeze

Class Method Summary collapse

Class Method Details

.configObject



57
58
59
# File 'lib/agent_client.rb', line 57

def self.config
  @config
end

.configure(opts = {}) ⇒ Object

Configure through hash



36
37
38
39
40
# File 'lib/agent_client.rb', line 36

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



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/agent_client.rb', line 43

def self.configure_with(path_to_yaml_file)
  begin
    config = YAML.safe_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