Class: DeepCover::Config
- Inherits:
-
Object
- Object
- DeepCover::Config
- Defined in:
- lib/deep_cover/config.rb
Instance Method Summary collapse
- #allow_partial(allow_partial = nil) ⇒ Object
- #cache_directory(cache_directory = nil) ⇒ Object
- #detect_uncovered(*keywords) ⇒ Object
- #ignore_uncovered(*keywords, &block) ⇒ Object
-
#initialize(notify = nil) ⇒ Config
constructor
A new instance of Config.
- #load_hash_for_serialize(hash) ⇒ Object
- #output(path_or_false = nil) ⇒ Object
- #paths(paths = nil) ⇒ Object
- #reporter(reporter = nil) ⇒ Object
- #reset ⇒ Object
- #set(**options) ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
- #to_hash_for_serialize ⇒ Object
- #tracker_global(tracker_global = nil) ⇒ Object
Constructor Details
Instance Method Details
#allow_partial(allow_partial = nil) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/deep_cover/config.rb', line 98 def allow_partial(allow_partial = nil) if allow_partial != nil change(:allow_partial, allow_partial) else @options[:allow_partial] end end |
#cache_directory(cache_directory = nil) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/deep_cover/config.rb', line 90 def cache_directory(cache_directory = nil) if cache_directory change(:cache_directory, cache_directory) else File.(@options[:cache_directory]) end end |
#detect_uncovered(*keywords) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/deep_cover/config.rb', line 48 def detect_uncovered(*keywords) raise ArgumentError, 'No block is accepted' if block_given? if keywords.empty? OPTIONALLY_COVERED - @options[:ignore_uncovered] else keywords = check_uncovered(keywords) change(:ignore_uncovered, @options[:ignore_uncovered] - keywords) end end |
#ignore_uncovered(*keywords, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/deep_cover/config.rb', line 34 def ignore_uncovered(*keywords, &block) if block raise ArgumentError, "wrong number of arguments (given #{keywords.size}, expected 0..1)" if keywords.size > 1 keywords << Node.unique_filter if keywords.empty? Node.create_filter(keywords.first, &block) end if keywords.empty? @options[:ignore_uncovered] else keywords = check_uncovered(keywords) change(:ignore_uncovered, @options[:ignore_uncovered] | keywords) end end |
#load_hash_for_serialize(hash) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/deep_cover/config.rb', line 26 def load_hash_for_serialize(hash) @options.merge!(hash) hash.each_key { |option| @notify.config_changed(option) } if @notify # This was already transformed, it should all be absolute paths / globs, avoid doing it for nothing by setting it right away # TODO: (Max) I don't like mixup of configs being partly on DeepCover and Config like that... DeepCover.instance_variable_set(:@lookup_globs, hash[:paths]) end |
#output(path_or_false = nil) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/deep_cover/config.rb', line 82 def output(path_or_false = nil) if path_or_false != nil change(:output, path_or_false) else @options[:output] end end |
#paths(paths = nil) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/deep_cover/config.rb', line 58 def paths(paths = nil) if paths change(:paths, Array(paths).dup) else @options[:paths] end end |
#reporter(reporter = nil) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/deep_cover/config.rb', line 74 def reporter(reporter = nil) if reporter change(:reporter, reporter) else @options[:reporter] end end |
#reset ⇒ Object
106 107 108 109 110 111 |
# File 'lib/deep_cover/config.rb', line 106 def reset DEFAULTS.each do |key, value| change(key, value) end self end |
#set(**options) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/deep_cover/config.rb', line 113 def set(**) @options[:ignore_uncovered] = [] if .has_key?(:ignore_uncovered) .each do |key, value| public_send key, value end self end |
#to_hash ⇒ Object Also known as: to_h
12 13 14 |
# File 'lib/deep_cover/config.rb', line 12 def to_hash @options.dup end |
#to_hash_for_serialize ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/deep_cover/config.rb', line 17 def to_hash_for_serialize hash = to_hash # TODO: (Max) I don't like mixup of configs being partly on DeepCover and Config like that... hash[:paths] = DeepCover.lookup_globs hash[:output] = hash[:output] ? File.(hash[:output]) : hash[:output] hash[:cache_directory] = File.(hash[:cache_directory]) hash end |
#tracker_global(tracker_global = nil) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/deep_cover/config.rb', line 66 def tracker_global(tracker_global = nil) if tracker_global change(:tracker_global, tracker_global) else @options[:tracker_global] end end |