Class: Nfcollector::Attributes
- Inherits:
-
Object
- Object
- Nfcollector::Attributes
- Defined in:
- lib/nfcollector/attributes.rb
Constant Summary collapse
- ATTR_CREATED_AT =
't'
- ATTR_CLIENT_IP =
'>a'
- ATTR_CACHED =
'Cs'
- ATTR_HTTP_RESP =
'Hs'
- ATTR_BYTES =
'<s'
- ATTR_HOST =
'Rh'
- ATTR_PATH =
'Rp'
- ATTR_USERNAME =
'Un'
- ATTR_MIME_TYPE =
'mt'
- ATTR_REQUEST_RESPONSE =
'Rr'
- ATTR_USER_GROUP =
'Ug'
- ATTR_CLIENT_FQDN =
'>A'
- ATTR_COMPUTER_GROUP =
'>G'
- ATTR_CATEGORY =
'Rc'
- MAPPINGS =
Input Attributes mapped to their column or map reduce names
{ ATTR_CREATED_AT => :created_at, ATTR_CLIENT_IP => :client_ip, ATTR_CACHED => :cached, ATTR_HTTP_RESP => :http_resp_code, ATTR_BYTES => :bytes, ATTR_HOST => :host, ATTR_PATH => :path, ATTR_USERNAME => :username, ATTR_MIME_TYPE => :mime_type, ATTR_REQUEST_RESPONSE => :request_response, ATTR_USER_GROUP => :user_group, ATTR_CLIENT_FQDN => :client_fqdn, ATTR_COMPUTER_GROUP => :computer_group, ATTR_CATEGORY => :category }
- COPY_FILE_COLUMNS =
[ :created_at, :client_ip, :cached, :http_resp_code, :bytes, :host, :path, :username, :mime_type, :request_response, :user_group, :client_fqdn, :computer_group, :domain ]
- MAP_REDUCE_COLUMNS =
[ :created_at, :bytes, :host, :username, :domain, :category ]
- REQUIRED =
[ ATTR_CREATED_AT, ATTR_CLIENT_IP, ATTR_CACHED, ATTR_HTTP_RESP, ATTR_BYTES, ATTR_HOST, ATTR_PATH, ATTR_USERNAME, ATTR_MIME_TYPE ]
Class Method Summary collapse
-
.for_copy_file(arr) ⇒ Object
Selects from an array of column names only the ones that can be used for copy files.
-
.map(attr_code) ⇒ Object
Returns the column name associated with the given attr code.
-
.parse(attributes_string) ⇒ Object
Parses a comma separated list of attrs into an array of column names as symbols.
Class Method Details
.for_copy_file(arr) ⇒ Object
Selects from an array of column names only the ones that can be used for copy files
77 78 79 80 81 82 |
# File 'lib/nfcollector/attributes.rb', line 77 def self.for_copy_file(arr) # TODO: No longer needed? arr.select { |item| COPY_FILE_COLUMNS.include?(item.to_sym) }.map(&:to_sym) end |
.map(attr_code) ⇒ Object
Returns the column name associated with the given attr code
95 96 97 |
# File 'lib/nfcollector/attributes.rb', line 95 def self.map(attr_code) MAPPINGS[attr_code.to_s] end |
.parse(attributes_string) ⇒ Object
Parses a comma separated list of attrs into an array of column names as symbols
86 87 88 89 90 91 92 |
# File 'lib/nfcollector/attributes.rb', line 86 def self.parse(attributes_string) InputDefinition.new.tap do |definition| attributes_string.split(',').each_with_index do |attr, index| definition.set(index, MAPPINGS[attr]) end end end |