Class: Lazylead::Opts
- Inherits:
-
Object
- Object
- Lazylead::Opts
- Extended by:
- Forwardable
- Defined in:
- lib/lazylead/opts.rb
Overview
Default options for all lazylead tasks.
- Author
-
Yurii Dubinka ([email protected])
- Copyright
-
Copyright © 2019-2020 Yurii Dubinka
- License
-
MIT
Instance Method Summary collapse
- #blank?(key) ⇒ Boolean
-
#decrypt(key, sid) ⇒ Object
Decrypt particular option using cryptography salt.
-
#initialize(origin = {}) ⇒ Opts
constructor
A new instance of Opts.
-
#jira_defaults ⇒ Object
Default Jira options to use during search for all Jira-based tasks.
-
#jira_fields ⇒ Object
Default fields which to fetch within the Jira issue.
-
#slice(key, delim) ⇒ Object
Split text value by delimiter, trim all spaces and reject blank items.
- #to_h ⇒ Object
Constructor Details
#initialize(origin = {}) ⇒ Opts
Returns a new instance of Opts.
39 40 41 |
# File 'lib/lazylead/opts.rb', line 39 def initialize(origin = {}) @origin = origin end |
Instance Method Details
#blank?(key) ⇒ Boolean
49 50 51 |
# File 'lib/lazylead/opts.rb', line 49 def blank?(key) to_h[key].nil? || @origin[key].blank? end |
#decrypt(key, sid) ⇒ Object
Decrypt particular option using cryptography salt
74 75 76 77 78 79 |
# File 'lib/lazylead/opts.rb', line 74 def decrypt(key, sid) text = to_h[key] return text if text.blank? || text.nil? return Salt.new(sid).decrypt(text) if ENV.key? sid text end |
#jira_defaults ⇒ Object
Default Jira options to use during search for all Jira-based tasks.
58 59 60 61 62 63 |
# File 'lib/lazylead/opts.rb', line 58 def jira_defaults { max_results: fetch("max_results", 50), fields: jira_fields } end |
#jira_fields ⇒ Object
Default fields which to fetch within the Jira issue
66 67 68 |
# File 'lib/lazylead/opts.rb', line 66 def jira_fields to_h.fetch("fields", "").split(",").map(&:to_sym) end |
#slice(key, delim) ⇒ Object
Split text value by delimiter, trim all spaces and reject blank items
44 45 46 47 |
# File 'lib/lazylead/opts.rb', line 44 def slice(key, delim) return [] unless to_h.key? key to_h[key].split(delim).map(&:chomp).map(&:strip).reject(&:blank?) end |
#to_h ⇒ Object
53 54 55 |
# File 'lib/lazylead/opts.rb', line 53 def to_h @origin end |