Class: VagrantPlugins::ServerSpecHtmlReport::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-serverspechtmlreport/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
9
# File 'lib/vagrant-serverspechtmlreport/config.rb', line 6

def initialize
  super
  @spec_files = UNSET_VALUE
end

Instance Attribute Details

#spec_filesObject

Returns the value of attribute spec_files.



4
5
6
# File 'lib/vagrant-serverspechtmlreport/config.rb', line 4

def spec_files
  @spec_files
end

Instance Method Details

#finalize!Object



15
16
17
# File 'lib/vagrant-serverspechtmlreport/config.rb', line 15

def finalize!
  @spec_files = [] if @spec_files == UNSET_VALUE
end

#pattern=(pat) ⇒ Object



11
12
13
# File 'lib/vagrant-serverspechtmlreport/config.rb', line 11

def pattern=(pat)
  @spec_files = Dir.glob(pat)
end

#validate(machine) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vagrant-serverspechtmlreport/config.rb', line 19

def validate(machine)
  errors = _detected_errors

  if @spec_files.nil? || @spec_files.empty?
    errors << I18n.t('vagrant.config.serverspec.no_spec_files')
  end

  missing_files = @spec_files.select { |path| !File.file?(path) }
  unless missing_files.empty?
    errors << I18n.t('vagrant.config.serverspec.missing_spec_files', files: missing_files.join(', '))
  end

  { 'serverspechtml provisioner' => errors }
end