inspec-core 3.3.14 → 3.4.1

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: 1d04bc72fe20e2d8fc67e39c6b2764735e0b175b152296913daa56a0d908da94
4
- data.tar.gz: dc4c2c50a48330e7721138214a8b1499af493508620b26ebb19a270ca4f3d580
3
+ metadata.gz: fd93e17059f4e6da1bd640c908688b009b7d851b33ac2c12227045d71a5a25a2
4
+ data.tar.gz: c4edad3d720f7db313a01f7eded6763de0d0b033d34770322496b4a282894e11
5
5
  SHA512:
6
- metadata.gz: cc16274a2aac2b4db029d53e52898ed728f16c1a3a7d14e87014e638b23e73f2226a3902887980c651da9759607c28d60bcf0e47b647a149c257a31f17ac9f42
7
- data.tar.gz: 27108017d22fad18cba4396286099642f20622320d6d0b27809263da49ddd5f4b72b948e09f1a447de958fed30ca5da955766bf2e5f648cff5d0d7242194a6ca
6
+ metadata.gz: 40cc89ad2cd53ecb0662985ff9901c953b00bae85e6313ba7bdf28b68b22acc4725cb871256c22107a552f6ea074e7d02e093b0a566cdded0addd0548f4a7314
7
+ data.tar.gz: 7bb582628c261148e8633bd1e3de49b0c8d7b009873e34458b2669b27af6e93a747b993a67a7acf513f7886e1c5c0d3d97b9e6b023a496d889c3a833a6e9fb90
data/README.md CHANGED
@@ -46,7 +46,7 @@ inspec exec test.rb -t docker://container_id
46
46
 
47
47
  ## Installation
48
48
 
49
- InSpec requires Ruby ( >2.2 ).
49
+ InSpec requires Ruby ( >2.3 ).
50
50
 
51
51
  ### Install as package
52
52
 
@@ -2,5 +2,9 @@
2
2
  "file_version": "1.0.0",
3
3
  "unknown_group_action": "ignore",
4
4
  "groups": {
5
+ "attrs_value_replaces_default": {
6
+ "action": "ignore",
7
+ "prefix": "The 'default' option for attributes is being replaced by 'value' - please use it instead."
8
+ }
5
9
  }
6
10
  }
@@ -1,5 +1,7 @@
1
1
  # encoding:utf-8
2
2
 
3
+ require 'utils/deprecation'
4
+
3
5
  module Inspec
4
6
  class Attribute
5
7
  attr_accessor :name
@@ -21,8 +23,8 @@ module Inspec
21
23
  # output warn message if we are in a exec call
22
24
  Inspec::Log.warn(
23
25
  "Attribute '#{@name}' does not have a value. "\
24
- "Use --attrs to provide a value for '#{@name}' or specify a default "\
25
- "value with `attribute('#{@name}', default: 'somedefault', ...)`.",
26
+ "Use --attrs to provide a value for '#{@name}' or specify a "\
27
+ "value with `attribute('#{@name}', value: 'somevalue', ...)`.",
26
28
  ) if Inspec::BaseCLI.inspec_cli_command == :exec
27
29
  end
28
30
 
@@ -42,8 +44,17 @@ module Inspec
42
44
  def initialize(name, options = {})
43
45
  @name = name
44
46
  @opts = options
45
- validate_value_type(default) if @opts.key?(:type) && @opts.key?(:default)
46
- @value = nil
47
+ if @opts.key?(:default)
48
+ Inspec.deprecate(:attrs_value_replaces_default, "attribute name: '#{name}'")
49
+ if @opts.key?(:value)
50
+ Inspec::Log.warn "Attribute #{@name} created using both :default and :value options - ignoring :default"
51
+ @opts.delete(:default)
52
+ else
53
+ @opts[:value] = @opts.delete(:default)
54
+ end
55
+ end
56
+ @value = @opts[:value]
57
+ validate_value_type(@value) if @opts.key?(:type) && @opts.key?(:value)
47
58
  end
48
59
 
49
60
  def value=(new_value)
@@ -54,7 +65,7 @@ module Inspec
54
65
  def value
55
66
  if @value.nil?
56
67
  validate_required(@value) if @opts[:required] == true
57
- @value = default
68
+ @value = value_or_dummy
58
69
  else
59
70
  @value
60
71
  end
@@ -162,8 +173,8 @@ module Inspec
162
173
  end
163
174
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
164
175
 
165
- def default
166
- @opts.key?(:default) ? @opts[:default] : DEFAULT_ATTRIBUTE.new(@name)
176
+ def value_or_dummy
177
+ @opts.key?(:value) ? @opts[:value] : DEFAULT_ATTRIBUTE.new(@name)
167
178
  end
168
179
  end
169
180
  end
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '3.3.14'
7
+ VERSION = '3.4.1'
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.14
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-25 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train-core