Class: BundleSafeUpdate::Config
- Inherits:
-
Object
- Object
- BundleSafeUpdate::Config
- Defined in:
- lib/bundle_safe_update/config.rb
Constant Summary collapse
- DEFAULT_COOLDOWN_DAYS =
14- CONFIG_FILENAME =
'.bundle-safe-update.yml'- DEFAULT_MAX_THREADS =
32- DEFAULT_RISK_SIGNALS =
{ 'low_downloads' => { 'mode' => 'warn', 'threshold' => 1000 }, 'stale_gem' => { 'mode' => 'warn', 'threshold_years' => 3 }, 'new_owner' => { 'mode' => 'warn', 'threshold_days' => 90 }, 'version_jump' => { 'mode' => 'warn' } }.freeze
- DEFAULTS =
{ 'cooldown_days' => DEFAULT_COOLDOWN_DAYS, 'ignore_prefixes' => [], 'ignore_gems' => [], 'trusted_sources' => [], 'trusted_owners' => [], 'max_threads' => DEFAULT_MAX_THREADS, 'audit' => true, 'verbose' => false, 'update' => false, 'lock_only' => false, 'warn_only' => false, 'risk_signals' => DEFAULT_RISK_SIGNALS }.freeze
Instance Attribute Summary collapse
-
#audit ⇒ Object
readonly
Returns the value of attribute audit.
-
#cooldown_days ⇒ Object
readonly
Returns the value of attribute cooldown_days.
-
#ignore_gems ⇒ Object
readonly
Returns the value of attribute ignore_gems.
-
#ignore_prefixes ⇒ Object
readonly
Returns the value of attribute ignore_prefixes.
-
#lock_only ⇒ Object
readonly
Returns the value of attribute lock_only.
-
#max_threads ⇒ Object
readonly
Returns the value of attribute max_threads.
-
#risk_signals ⇒ Object
readonly
Returns the value of attribute risk_signals.
-
#trusted_owners ⇒ Object
readonly
Returns the value of attribute trusted_owners.
-
#trusted_sources ⇒ Object
readonly
Returns the value of attribute trusted_sources.
-
#update ⇒ Object
readonly
Returns the value of attribute update.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
-
#warn_only ⇒ Object
readonly
Returns the value of attribute warn_only.
Instance Method Summary collapse
- #ignored?(gem_name) ⇒ Boolean
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #risk_signal_enabled?(signal_name) ⇒ Boolean
- #risk_signal_mode(signal_name) ⇒ Object
- #risk_signal_threshold(signal_name, key) ⇒ Object
- #trusted_source?(source_url) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
37 38 39 40 41 |
# File 'lib/bundle_safe_update/config.rb', line 37 def initialize( = {}) config = merge_configs() (config) (config) end |
Instance Attribute Details
#audit ⇒ Object (readonly)
Returns the value of attribute audit.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def audit @audit end |
#cooldown_days ⇒ Object (readonly)
Returns the value of attribute cooldown_days.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def cooldown_days @cooldown_days end |
#ignore_gems ⇒ Object (readonly)
Returns the value of attribute ignore_gems.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def ignore_gems @ignore_gems end |
#ignore_prefixes ⇒ Object (readonly)
Returns the value of attribute ignore_prefixes.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def ignore_prefixes @ignore_prefixes end |
#lock_only ⇒ Object (readonly)
Returns the value of attribute lock_only.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def lock_only @lock_only end |
#max_threads ⇒ Object (readonly)
Returns the value of attribute max_threads.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def max_threads @max_threads end |
#risk_signals ⇒ Object (readonly)
Returns the value of attribute risk_signals.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def risk_signals @risk_signals end |
#trusted_owners ⇒ Object (readonly)
Returns the value of attribute trusted_owners.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def trusted_owners @trusted_owners end |
#trusted_sources ⇒ Object (readonly)
Returns the value of attribute trusted_sources.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def trusted_sources @trusted_sources end |
#update ⇒ Object (readonly)
Returns the value of attribute update.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def update @update end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def verbose @verbose end |
#warn_only ⇒ Object (readonly)
Returns the value of attribute warn_only.
34 35 36 |
# File 'lib/bundle_safe_update/config.rb', line 34 def warn_only @warn_only end |
Instance Method Details
#ignored?(gem_name) ⇒ Boolean
55 56 57 58 59 |
# File 'lib/bundle_safe_update/config.rb', line 55 def ignored?(gem_name) return true if @ignore_gems.include?(gem_name) @ignore_prefixes.any? { |prefix| gem_name.start_with?(prefix) } end |
#risk_signal_enabled?(signal_name) ⇒ Boolean
47 48 49 |
# File 'lib/bundle_safe_update/config.rb', line 47 def risk_signal_enabled?(signal_name) risk_signal_mode(signal_name) != 'off' end |
#risk_signal_mode(signal_name) ⇒ Object
43 44 45 |
# File 'lib/bundle_safe_update/config.rb', line 43 def risk_signal_mode(signal_name) @risk_signals.dig(signal_name.to_s, 'mode') || 'off' end |
#risk_signal_threshold(signal_name, key) ⇒ Object
51 52 53 |
# File 'lib/bundle_safe_update/config.rb', line 51 def risk_signal_threshold(signal_name, key) @risk_signals.dig(signal_name.to_s, key.to_s) end |
#trusted_source?(source_url) ⇒ Boolean
61 62 63 64 65 |
# File 'lib/bundle_safe_update/config.rb', line 61 def trusted_source?(source_url) return false if source_url.nil? || @trusted_sources.empty? @trusted_sources.any? { |pattern| source_url.include?(pattern) } end |