Module: Tigre

Defined in:
lib/tigre-client.rb,
lib/tigre-client/url.rb,
lib/tigre-client/scan.rb,
lib/tigre-client/sample.rb,
lib/tigre-client/version.rb,
lib/tigre-client/analysis.rb,
lib/tigre-client/occurrence.rb,
lib/tigre-client/common/common_params.rb,
lib/tigre-client/common/common_getters.rb,
lib/tigre-client/common/tag_components.rb,
lib/tigre-client/common/analysis_components.rb

Defined Under Namespace

Modules: AnalysisComponents, Client, CommonGetters, CommonParams, TagComponents Classes: Analysis, Occurrence, Sample, Scan, Url

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connObject

Returns the value of attribute conn.



21
22
23
# File 'lib/tigre-client.rb', line 21

def conn
  @conn
end

.endpointObject

Returns the value of attribute endpoint.



21
22
23
# File 'lib/tigre-client.rb', line 21

def endpoint
  @endpoint
end

.loggerObject

Returns the value of attribute logger.



21
22
23
# File 'lib/tigre-client.rb', line 21

def logger
  @logger
end

.s3_analysis_bucketObject

Returns the value of attribute s3_analysis_bucket.



22
23
24
# File 'lib/tigre-client.rb', line 22

def s3_analysis_bucket
  @s3_analysis_bucket
end

.s3_bucketObject

Returns the value of attribute s3_bucket.



22
23
24
# File 'lib/tigre-client.rb', line 22

def s3_bucket
  @s3_bucket
end

.s3_keyObject

Returns the value of attribute s3_key.



22
23
24
# File 'lib/tigre-client.rb', line 22

def s3_key
  @s3_key
end

.s3_secretObject

Returns the value of attribute s3_secret.



22
23
24
# File 'lib/tigre-client.rb', line 22

def s3_secret
  @s3_secret
end

.serverObject

Returns the value of attribute server.



21
22
23
# File 'lib/tigre-client.rb', line 21

def server
  @server
end

.tokenObject

Returns the value of attribute token.



21
22
23
# File 'lib/tigre-client.rb', line 21

def token
  @token
end

Class Method Details

.build_get_connectionObject



37
38
39
40
41
# File 'lib/tigre-client.rb', line 37

def build_get_connection
  @conn = Faraday.new(:url => "#{Tigre.server}") do |builder|
    builder.adapter :net_http
  end
end

.build_post_connectionObject



43
44
45
46
47
48
49
50
# File 'lib/tigre-client.rb', line 43

def build_post_connection
  @conn = Faraday.new(:url => "#{Tigre.server}") do |builder|
    builder.use Faraday::Request::MultipartWithFile
    builder.use Faraday::Request::Multipart
    builder.use Faraday::Request::UrlEncoded
    builder.adapter :net_http
  end
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Tigre)

    the object that the method was called on



24
25
26
27
# File 'lib/tigre-client.rb', line 24

def configure
  yield self
  true
end

.get_connection(uri_string) ⇒ Object



52
53
54
55
56
# File 'lib/tigre-client.rb', line 52

def get_connection(uri_string)
  build_get_connection
  response = Tigre.conn.get(Tigre.endpoint + uri_string, 'API-TOKEN' => Tigre.token)
  [response.status, response.body]
end

.post_connection(uri_string, data) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/tigre-client.rb', line 58

def post_connection(uri_string, data)
  build_post_connection
  response = Tigre.conn.post do |req|
    req.url Tigre.endpoint + uri_string
    req.headers['API-TOKEN'] = Tigre.token
    req.body                 = data
  end
  [response.status, response.body]
end

.put_connection(uri_string, data) ⇒ Object

TODO do we need a post_connection and a post_file_connection? def post_file_connection(uri_string, data)

build_post_connection

response = Tigre.conn.post do |req|
  req.url Tigre.endpoint + uri_string
  req.headers['API-TOKEN'] = Tigre.token
  req.body                 = data
end
[response.status, response.body]

end



80
81
82
83
84
85
86
87
88
# File 'lib/tigre-client.rb', line 80

def put_connection(uri_string, data)
  build_post_connection
  response = Tigre.conn.put do |req|
    req.url Tigre.endpoint + uri_string
    req.headers['API-TOKEN'] = Tigre.token
    req.body                 = data
  end
  [response.status, response.body]
end

.s3_analysis_enabled?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/tigre-client.rb', line 33

def s3_analysis_enabled?
  !Tigre.s3_key.nil? && !Tigre.s3_secret.nil? && !Tigre.s3_analysis_bucket.nil?
end

.s3_enabled?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/tigre-client.rb', line 29

def s3_enabled?
  !Tigre.s3_key.nil? && !Tigre.s3_secret.nil? && !Tigre.s3_bucket.nil?
end