module Evostream

:reek: NilCheck

:reek: UtilityFunction

:reek: UtilityFunction

:reek: FeatureEnvy :reek: TooManyStatements :reek: DuplicateMethodCall :reek: NilCheck :reek: UtilityFunction

:reek: NilCheck

Primary command to gem

:reek: UncommunicativeMethodName :reek: NestedIterators :reek: DuplicateMethodCall

:reek: TooManyMethods

:reek: UtilityFunction

@author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv> Define constant to gem.

:reek: Attribute :reek: ClassVariable

Constants

AUTHORS

Authors

DESCRIPTION

Define a long description to gem

EMAILS

Emails

GEM_NAME

Name to gem

HOMEPAGE

Define homepage

LICENSE

Licence

POST_INSTALL

Define a post install message

SUMMARY

Define a summary description to gem

VERSION

Define version to gem

Public Class Methods

find_fixture(command) click to toggle source
# File lib/evostream/event.rb, line 59
def find_fixture(command)
  File.join(path_fixture, "#{command.split('?')[0].underscore}.json")
end
logger(message) click to toggle source
# File lib/evostream/event.rb, line 22
def self.logger(message)
  Rails.logger.debug "[#{Evostream::GEM_NAME}] #{message}" \
    if Evostream::Service.environment.eql?('development') && defined?(Rails)
end
path_fixture() click to toggle source
# File lib/evostream/event.rb, line 54
def path_fixture
  File.realpath(File.join(File.dirname(__FILE__), '..', '..', 'spec',
                          'support', 'fixtures'))
end
prepare_request(cmd, uri_in = nil) click to toggle source
# File lib/evostream/event.rb, line 27
def self.prepare_request(cmd, uri_in = nil)
  env = Evostream::Service.environment.to_sym
  Evostream.logger "ENV  ------> #{env}"
  case env
  when :test
    Evostream.request_test(cmd)
  when :development, :production
    prepare_request_real(uri_in.nil? ? Evostream::Service.uri_in : uri_in,
                         cmd)
  end
end
prepare_request_real(url, cmd) click to toggle source
# File lib/evostream/event.rb, line 39
def self.prepare_request_real(url, cmd)
  Evostream.request_real(URI.parse("#{url}/#{cmd}"))
end
request_real(uri) click to toggle source
# File lib/evostream/event.rb, line 49
def request_real(uri)
  http = Net::HTTP.new(uri.host, uri.port)
  http.request(Net::HTTP::Get.new(uri.request_uri))
end
request_test(command) click to toggle source
# File lib/evostream/event.rb, line 44
def request_test(command)
  json = JSON.parse(File.read(find_fixture(command)))
  Net::HTTPSuccess.mock(json)
end
send_command(cmd, uri_in = nil) click to toggle source
# File lib/evostream/event.rb, line 17
def self.send_command(cmd, uri_in = nil)
  Evostream.logger "CMD : #{cmd}"
  Evostream::Responses.new(prepare_request(cmd, uri_in)).message
end