Class: Vnu

Inherits:
Object
  • Object
show all
Defined in:
lib/vnu.rb

Overview

Ruby wrapper for [vnu](validator.github.io/validator/)

Constant Summary collapse

JAR_PATH =
File.expand_path('../../vnu.jar', __FILE__)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*options) ⇒ Vnu

Returns a new instance of Vnu.



9
10
11
12
13
14
15
16
17
# File 'lib/vnu.rb', line 9

def initialize(*options)
  @target = options.shift
  options = options.last
  if target
    @command = vnu_cli_with_options(options)
  else
    fail RuntimeError
  end
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/vnu.rb', line 7

def command
  @command
end

#targetObject (readonly)

Returns the value of attribute target.



7
8
9
# File 'lib/vnu.rb', line 7

def target
  @target
end

Class Method Details

.cliObject



28
29
30
# File 'lib/vnu.rb', line 28

def cli
  @cli ||= "java -jar #{JAR_PATH}"
end

.cli_versionObject



32
33
34
# File 'lib/vnu.rb', line 32

def cli_version
  @cli_version ||= `#{cli} --version`.chomp
end

.validate(*options) ⇒ Object



36
37
38
# File 'lib/vnu.rb', line 36

def validate(*options)
  new(*options).validate
end

Instance Method Details

#validateObject



23
24
25
# File 'lib/vnu.rb', line 23

def validate
  execute(command)
end

#vnu_cli_with_options(options) ⇒ Object



19
20
21
# File 'lib/vnu.rb', line 19

def vnu_cli_with_options(options)
  "#{self.class.cli}#{vnu_options(options)} -"
end