deep-cover-core 0.7.7 → 0.7.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20f623535ee291144feeb29666497801965317be56a583500bbd2c9cd5c8b576
4
- data.tar.gz: cccf8236fd9e2ac023199cb0f62a1907f0cd847da503ae00d396612751f0209d
3
+ metadata.gz: 800f64be0c9af77333d7e68f729d8c3cb4bd8b35cb965fac10422da993d6553e
4
+ data.tar.gz: 8333ccb194250280995ae1078b48097f2516324f9a85beabddcbca1563735a48
5
5
  SHA512:
6
- metadata.gz: 4285e13e7368c6910d7e9c9b9610423856714fdc457bec0b6cf156b160821a51174c1720d1f4d47f4e601a2901e205d196817985ba2fbae30e3aa0eda5e12e71
7
- data.tar.gz: 91d4cef0eb7743f8882999a954ce46acb677b11f46b516dc4e98cb553b17078f3ce3f72c983b4843755fe3fb1a469070d5b6c977829fc456476987a3c6b4efcd
6
+ metadata.gz: 2bde03af4ab23daf437f6e37d834c0ca1565043f9395955ab9a110b9e54c7f251827d3a05c2145393cfb5cf8d2b519b2ee8fe2a8a349cf3f7ed844c1b450c5b3
7
+ data.tar.gz: 03e57609062505285c7828d28cad3859d62e4c77a0e5a98f8336743c9d8c21e507f43afbf4c8ee126dad7903a4e71891c6311154fe71cb65f1b53009f78c3627
@@ -8,10 +8,11 @@ module DeepCover
8
8
  'Nodes'
9
9
  end
10
10
 
11
- def initialize(source, ignore_uncovered: [], **options)
11
+ def initialize(source, **options)
12
12
  @cache = {}.compare_by_identity
13
13
  super
14
- @allow_filters = Array(ignore_uncovered).map { |kind| Node.filter_to_method_name(kind) }
14
+ @allow_filters = Config.options_to_ignored(**options)
15
+ .map { |kind| Node.filter_to_method_name(kind) }
15
16
  @nocov_ranges = FlagCommentAssociator.new(covered_code)
16
17
  end
17
18
 
@@ -21,3 +21,5 @@ require 'backports/2.5.0/hash/slice'
21
21
  require 'backports/2.5.0/hash/transform_keys'
22
22
  require 'backports/2.5.0/kernel/yield_self'
23
23
  require 'backports/2.6.0/hash/to_h'
24
+ require 'backports/2.6.0/enumerable/to_h'
25
+ require 'backports/2.6.0/array/to_h'
@@ -2,14 +2,20 @@
2
2
 
3
3
  # Basic constants without any dependencies are here
4
4
  module DeepCover
5
+ OPTIONALLY_COVERED = %i[case_implicit_else default_argument raise trivial_if warn]
6
+
7
+ FILTER_NAME = Hash.new { |h, k| h[k] = :"ignore_#{k}" }
8
+
9
+ ignore_defaults = OPTIONALLY_COVERED.to_h { |opt| [FILTER_NAME[opt], false] }
10
+
5
11
  DEFAULTS = {
6
- ignore_uncovered: [].freeze,
7
12
  paths: [:auto_detect].freeze,
8
13
  allow_partial: false,
9
14
  tracker_global: '$_cov',
10
15
  reporter: :html,
11
16
  output: './coverage',
12
17
  cache_directory: './deep_cover',
18
+ **ignore_defaults,
13
19
  }.freeze
14
20
 
15
21
  CLI_DEFAULTS = {
@@ -18,8 +24,6 @@ module DeepCover
18
24
  open: false,
19
25
  }.freeze
20
26
 
21
- OPTIONALLY_COVERED = %i[case_implicit_else default_argument raise trivial_if warn]
22
-
23
27
  REQUIRABLE_EXTENSIONS = {
24
28
  '.rb' => :ruby,
25
29
  ".#{RbConfig::CONFIG['DLEXT']}" => :native_extension,
@@ -2,9 +2,11 @@
2
2
 
3
3
  module DeepCover
4
4
  class Config
5
+ NOT_SPECIFIED = Object.new
6
+
5
7
  def initialize(notify = nil)
6
8
  @notify = nil
7
- @options = {ignore_uncovered: []}
9
+ @options = {}
8
10
  set(**DEFAULTS)
9
11
  @notify = notify
10
12
  end
@@ -36,71 +38,48 @@ module DeepCover
36
38
  raise ArgumentError, "wrong number of arguments (given #{keywords.size}, expected 0..1)" if keywords.size > 1
37
39
  keywords << Node.unique_filter if keywords.empty?
38
40
  Node.create_filter(keywords.first, &block)
41
+ AttributeAccessors.define_accessor(FILTER_NAME[keywords.first])
39
42
  end
40
- if keywords.empty?
41
- @options[:ignore_uncovered]
42
- else
43
+ unless keywords.empty?
43
44
  keywords = check_uncovered(keywords)
44
- change(:ignore_uncovered, @options[:ignore_uncovered] | keywords)
45
+ set(keywords.to_h { |kind| [FILTER_NAME[kind], true] })
45
46
  end
47
+ Config.options_to_ignored(**@options)
46
48
  end
47
49
 
48
50
  def detect_uncovered(*keywords)
49
51
  raise ArgumentError, 'No block is accepted' if block_given?
50
- if keywords.empty?
51
- OPTIONALLY_COVERED - @options[:ignore_uncovered]
52
- else
52
+ unless keywords.empty?
53
53
  keywords = check_uncovered(keywords)
54
- change(:ignore_uncovered, @options[:ignore_uncovered] - keywords)
54
+ set(keywords.to_h { |kind| [FILTER_NAME[kind], false] })
55
55
  end
56
+ OPTIONALLY_COVERED - Config.options_to_ignored(**@options)
56
57
  end
57
58
 
58
- def paths(paths = nil)
59
- if paths
60
- change(:paths, Array(paths).dup)
61
- else
62
- @options[:paths]
63
- end
64
- end
59
+ module AttributeAccessors
60
+ def self.define_accessor(attr)
61
+ define_method(attr) do |arg = NOT_SPECIFIED|
62
+ return @options[attr] if arg == NOT_SPECIFIED
65
63
 
66
- def tracker_global(tracker_global = nil)
67
- if tracker_global
68
- change(:tracker_global, tracker_global)
69
- else
70
- @options[:tracker_global]
64
+ change(attr, arg)
65
+ end
71
66
  end
72
- end
73
67
 
74
- def reporter(reporter = nil)
75
- if reporter
76
- change(:reporter, reporter)
77
- else
78
- @options[:reporter]
79
- end
68
+ %i[paths tracker_global reporter output cache_directory allow_partial]
69
+ .concat(OPTIONALLY_COVERED.map { |filter| FILTER_NAME[filter] })
70
+ .each { |attr| define_accessor(attr) }
80
71
  end
81
72
 
82
- def output(path_or_false = nil)
83
- if path_or_false != nil
84
- change(:output, path_or_false)
85
- else
86
- @options[:output]
87
- end
88
- end
73
+ include AttributeAccessors
89
74
 
90
- def cache_directory(cache_directory = nil)
91
- if cache_directory
92
- change(:cache_directory, cache_directory)
93
- else
94
- File.expand_path(@options[:cache_directory])
95
- end
75
+ def paths(paths = NOT_SPECIFIED)
76
+ paths = Array(paths).dup unless paths == NOT_SPECIFIED
77
+ super
96
78
  end
97
79
 
98
- def allow_partial(allow_partial = nil)
99
- if allow_partial != nil
100
- change(:allow_partial, allow_partial)
101
- else
102
- @options[:allow_partial]
103
- end
80
+ def cache_directory(cache_directory = NOT_SPECIFIED)
81
+ return File.expand_path(super) if cache_directory == NOT_SPECIFIED
82
+ super
104
83
  end
105
84
 
106
85
  def reset
@@ -110,14 +89,26 @@ module DeepCover
110
89
  self
111
90
  end
112
91
 
92
+ def [](opt)
93
+ public_send(opt)
94
+ end
95
+
96
+ def []=(opt, value)
97
+ public_send(opt, value)
98
+ end
99
+
113
100
  def set(**options)
114
- @options[:ignore_uncovered] = [] if options.has_key?(:ignore_uncovered)
115
101
  options.each do |key, value|
116
- public_send key, value
102
+ self[key] = value
117
103
  end
118
104
  self
119
105
  end
120
106
 
107
+ def self.options_to_ignored(**options)
108
+ OPTIONALLY_COVERED
109
+ .select { |filter| options[FILTER_NAME[filter]] }
110
+ end
111
+
121
112
  private
122
113
 
123
114
  def check_uncovered(keywords)
@@ -9,6 +9,7 @@ module DeepCover
9
9
  ]
10
10
 
11
11
  def load_absolute_basics
12
+ require_relative 'backports'
12
13
  require_relative 'base'
13
14
  require_relative 'basics'
14
15
  require_relative 'config_setter'
@@ -44,7 +45,6 @@ module DeepCover
44
45
  def bootstrap
45
46
  @bootstrapped ||= false # Avoid warning
46
47
  return if @bootstrapped
47
- require_relative 'backports'
48
48
  require_relative 'tools'
49
49
  @bootstrapped = true
50
50
  end
@@ -3,5 +3,5 @@
3
3
  top_level_module = Thread.current['_deep_cover_top_level_module'] || Object
4
4
 
5
5
  module top_level_module::DeepCover # rubocop:disable Naming/ClassAndModuleCamelCase
6
- VERSION = '0.7.7'
6
+ VERSION = '0.7.8'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep-cover-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-André Lafortune
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-01-15 00:00:00.000000000 Z
12
+ date: 2020-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parser