Module: YES

Defined in:
lib/yes.rb,
lib/yes/cli.rb,
lib/yes/lint.rb,
lib/yes/logical_and.rb,
lib/yes/constraints/key.rb,
lib/yes/constraints/tag.rb,
lib/yes/constraints/kind.rb,
lib/yes/constraints/type.rb,
lib/yes/constraints/count.rb,
lib/yes/constraints/range.rb,
lib/yes/constraints/value.rb,
lib/yes/constraints/choice.rb,
lib/yes/constraints/length.rb,
lib/yes/constraints/regexp.rb,
lib/yes/constraints/fnmatch.rb,
lib/yes/constraints/required.rb,
lib/yes/constraints/requires.rb,
lib/yes/constraints/exclusive.rb,
lib/yes/constraints/inclusive.rb,
lib/yes/constraints/node_constraint.rb,
lib/yes/constraints/tree_constraint.rb,
lib/yes/constraints/abstract_constraint.rb

Defined Under Namespace

Modules: Constraints Classes: And, Lint

Class Method Summary collapse

Class Method Details

.cli(*argv) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/yes/cli.rb', line 5

def self.cli(*argv)
  schema_file = argv[0]
  target_file = argv[1]

  lint = Lint.new(File.new(schema_file))
  edit = lint.validate(File.new(target_file))

  if edit.size == 0
    #$stderr.puts "valid: #{target_file}"
  else
    $stderr.puts edit.to_yaml
    exit -1
  end
end

.constraintsObject



4
5
6
# File 'lib/yes/constraints/abstract_constraint.rb', line 4

def self.constraints
  @constraints ||= []
end

.valid?(schema, yaml) ⇒ Boolean

Simple validatily check.

Returns:

  • (Boolean)


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

def self.valid?(schema, yaml)
  yes = YES::Lint.new(@schema)
  yes.validate(@yaml).empty? 
end