Module: VectorAmp::SourceNames
- Defined in:
- lib/vector_amp/source.rb
Overview
Default source-name helpers used when a name is omitted.
Class Method Summary collapse
-
.confluence(spaces: nil, cloud_id: nil, base_url: nil) ⇒ String
confluence-<space>,confluence-<host>, orconfluence-source. -
.file_upload(now: Time.now.utc) ⇒ String
Timestamped
ruby-sdk-file-upload-YYYYmmddHHMMSSname. - .gcs(bucket, prefix = nil) ⇒ Object
-
.google_drive(folder_ids: nil, file_ids: nil) ⇒ String
google-drive-<first id>orgoogle-drive-source. - .host_from_url(url) ⇒ Object
- .jira(project_keys: nil, cloud_id: nil) ⇒ Object
-
.s3(bucket, prefix = nil) ⇒ String
s3-<bucket>ors3-<bucket>-<prefix>. -
.web(start_urls) ⇒ String
web-<host>from the first URL, orweb-source.
Class Method Details
.confluence(spaces: nil, cloud_id: nil, base_url: nil) ⇒ String
Returns confluence-<space>, confluence-<host>, or confluence-source.
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/vector_amp/source.rb', line 147 def confluence(spaces: nil, cloud_id: nil, base_url: nil) space = Array(spaces).first return "confluence-#{space}" if space host = host_from_url(base_url) return "confluence-#{host}" if host return "confluence-#{cloud_id}" if cloud_id "confluence-source" end |
.file_upload(now: Time.now.utc) ⇒ String
Returns timestamped ruby-sdk-file-upload-YYYYmmddHHMMSS name.
111 112 113 |
# File 'lib/vector_amp/source.rb', line 111 def file_upload(now: Time.now.utc) "ruby-sdk-file-upload-#{now.strftime("%Y%m%d%H%M%S")}" end |
.gcs(bucket, prefix = nil) ⇒ Object
133 134 135 136 |
# File 'lib/vector_amp/source.rb', line 133 def gcs(bucket, prefix = nil) parts = ["gcs", bucket.to_s, prefix.to_s.delete_suffix("/")].reject(&:empty?) parts.join("-") end |
.google_drive(folder_ids: nil, file_ids: nil) ⇒ String
Returns google-drive-<first id> or google-drive-source.
170 171 172 173 174 175 |
# File 'lib/vector_amp/source.rb', line 170 def google_drive(folder_ids: nil, file_ids: nil) first_folder = Array(folder_ids).first first_file = Array(file_ids).first suffix = first_folder || first_file suffix ? "google-drive-#{suffix}" : "google-drive-source" end |
.host_from_url(url) ⇒ Object
158 159 160 161 162 163 164 165 |
# File 'lib/vector_amp/source.rb', line 158 def host_from_url(url) return nil if url.nil? || url.to_s.empty? host = URI.parse(url.to_s).host host && !host.empty? ? host : nil rescue URI::InvalidURIError nil end |
.jira(project_keys: nil, cloud_id: nil) ⇒ Object
138 139 140 141 |
# File 'lib/vector_amp/source.rb', line 138 def jira(project_keys: nil, cloud_id: nil) key = Array(project_keys).first || cloud_id key ? "jira-#{key}" : "jira-source" end |
.s3(bucket, prefix = nil) ⇒ String
Returns s3-<bucket> or s3-<bucket>-<prefix>.
128 129 130 131 |
# File 'lib/vector_amp/source.rb', line 128 def s3(bucket, prefix = nil) parts = ["s3", bucket.to_s, prefix.to_s.delete_suffix("/")].reject(&:empty?) parts.join("-") end |
.web(start_urls) ⇒ String
Returns web-<host> from the first URL, or web-source.
117 118 119 120 121 122 123 |
# File 'lib/vector_amp/source.rb', line 117 def web(start_urls) first_url = Array(start_urls).first.to_s host = URI.parse(first_url).host host && !host.empty? ? "web-#{host}" : "web-source" rescue URI::InvalidURIError "web-source" end |