Module: Travis::Yaml::Parser
- Extended by:
- Enumerable, Parser
- Included in:
- Parser
- Defined in:
- lib/travis/yaml/parser.rb,
lib/travis/yaml/parser/ruby.rb,
lib/travis/yaml/parser/dummy.rb,
lib/travis/yaml/parser/psych.rb
Defined Under Namespace
Modules: Dummy
Classes: Psych, Ruby
Instance Method Summary
collapse
Instance Method Details
#each(&block) ⇒ Object
22
23
24
|
# File 'lib/travis/yaml/parser.rb', line 22
def each(&block)
parsers.each(&block)
end
|
#parse(value) ⇒ Object
13
14
15
16
|
# File 'lib/travis/yaml/parser.rb', line 13
def parse(value)
raise ArgumentError, "cannot parse %p" % value unless parser = parser_for(value)
parser.parse(value)
end
|
#parser_for(value) ⇒ Object
18
19
20
|
# File 'lib/travis/yaml/parser.rb', line 18
def parser_for(value)
detect { |p| p.parses? value if p.respond_to? :parses? }
end
|
#parsers ⇒ Object
26
27
28
29
|
# File 'lib/travis/yaml/parser.rb', line 26
def parsers
constants.map { |name| const_get(name) }.
select { |c| c.respond_to? :parse }
end
|
#parses?(value) ⇒ Boolean
9
10
11
|
# File 'lib/travis/yaml/parser.rb', line 9
def parses?(value)
!!parser_for(value)
end
|