Class: DefMastership::Document
- Inherits:
-
Object
- Object
- DefMastership::Document
show all
- Extended by:
- Forwardable
- Defined in:
- lib/defmastership/document.rb
Overview
Reflects document structure from a definition point of view
Defined Under Namespace
Modules: Helper
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Document.
76
77
78
79
80
|
# File 'lib/defmastership/document.rb', line 76
def initialize
@data = DocumentData.new([], Set.new, {}, false, {}, {})
@parsing_state = ParsingState.new
@definition_parser = DefinitionParser.new(self)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
108
109
110
111
112
113
|
# File 'lib/defmastership/document.rb', line 108
def method_missing(method_name, *args)
action = PARSER_ACTIONS[method_name]
return instance_exec(*args, &action) if action
super
end
|
Instance Method Details
#explicit_version? ⇒ Boolean
102
103
104
105
106
|
# File 'lib/defmastership/document.rb', line 102
def explicit_version?
definitions.reduce(false) do |res, definition|
res || !!definition.explicit_version
end
end
|
#iref=(value) ⇒ Object
124
125
126
|
# File 'lib/defmastership/document.rb', line 124
def iref=(value)
@data.iref = value
end
|
#parse(lines) ⇒ Object
82
83
84
85
86
87
88
89
90
|
# File 'lib/defmastership/document.rb', line 82
def parse(lines)
lines.each do |line|
if @parsing_state.enabled?(line)
apply_filters(line)
else
generate_event(:new_line, MatchingLine.new(nil, line))
end
end
end
|
#parse_file_with_preprocessor(adoc_file) ⇒ Object
92
93
94
|
# File 'lib/defmastership/document.rb', line 92
def parse_file_with_preprocessor(adoc_file)
parse(Asciidoctor.load_file(adoc_file, safe: :unsafe, parse: false).reader.read_lines)
end
|
#ref_to_def(reference) ⇒ Object
120
121
122
|
# File 'lib/defmastership/document.rb', line 120
def ref_to_def(reference)
definitions.find { |definition| definition.reference == reference }
end
|
#respond_to_missing?(method_name, *_args) ⇒ Boolean
This method smells of :reek:UtilityFunction
116
117
118
|
# File 'lib/defmastership/document.rb', line 116
def respond_to_missing?(method_name, *_args)
PARSER_ACTIONS.key?(method_name)
end
|
#wrong_explicit_checksum? ⇒ Boolean
96
97
98
99
100
|
# File 'lib/defmastership/document.rb', line 96
def wrong_explicit_checksum?
definitions.reduce(false) do |res, definition|
res || !!definition.wrong_explicit_checksum
end
end
|