Class: Slither
- Inherits:
-
Object
show all
- Defined in:
- lib/slither/column.rb,
lib/slither/parser.rb,
lib/slither/section.rb,
lib/slither/slither.rb,
lib/slither/generator.rb,
lib/slither/definition.rb
Defined Under Namespace
Classes: Column, ColumnMismatchError, Definition, DuplicateColumnNameError, FormattedStringExceedsLengthError, Generator, Parser, ParserError, RequiredSectionEmptyError, RequiredSectionNotFoundError, Section
Constant Summary
collapse
- VERSION =
'0.99.0'
Class Method Summary
collapse
Class Method Details
.define(name, options = {}) {|definition| ... } ⇒ Object
12
13
14
15
16
17
|
# File 'lib/slither/slither.rb', line 12
def self.define(name, options = {}, &block)
definition = Definition.new(options)
yield(definition)
definitions[name] = definition
definition
end
|
.generate(definition_name, data) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/slither/slither.rb', line 19
def self.generate(definition_name, data)
definition = definition(definition_name)
raise ArgumentError, "Definition name '#{name}' was not found." unless definition
generator = Generator.new(definition)
generator.generate(data)
end
|
.parse(filename, definition_name) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/slither/slither.rb', line 32
def self.parse(filename, definition_name)
raise ArgumentError, "File #{filename} does not exist." unless File.exists?(filename)
definition = definition(definition_name)
raise ArgumentError, "Definition name '#{definition_name}' was not found." unless definition
parser = Parser.new(definition, filename)
parser.parse
end
|
.write(filename, definition_name, data) ⇒ Object
26
27
28
29
30
|
# File 'lib/slither/slither.rb', line 26
def self.write(filename, definition_name, data)
File.open(filename, 'w') do |f|
f.write generate(definition_name, data)
end
end
|