Class: Relaton::Cli::Command
- Inherits:
-
Thor
- Object
- Thor
- Relaton::Cli::Command
show all
- Includes:
- Relaton::Cli
- Defined in:
- lib/relaton/cli/command.rb
Constant Summary
VERSION
Instance Method Summary
collapse
parse_xml, processor, relaton, start, version
Instance Method Details
#concatenate(source_dir, outfile) ⇒ Object
56
57
58
|
# File 'lib/relaton/cli/command.rb', line 56
def concatenate(source_dir, outfile)
Relaton::Cli::RelatonFile.concatenate(source_dir, outfile, options)
end
|
#convert(file) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/relaton/cli/command.rb', line 132
def convert(file) xml = Nokogiri::XML(File.read(file, encoding: "UTF-8"))
item = Relaton::Cli.parse_xml xml
result = if /yaml|yml/.match?(options[:format])
item.to_hash.to_yaml
else item.send "to_#{options[:format]}"
end
ext = case options[:format]
when "bibtex" then "bib"
when "asciibib" then "adoc"
else options[:format]
end
output = options[:output] || file.sub(/(?<=\.)[^.]+$/, ext)
File.write output, result, encoding: "UTF-8"
end
|
45
46
47
|
# File 'lib/relaton/cli/command.rb', line 45
def (source_dir, outdir)
Relaton::Cli::RelatonFile.(source_dir, outdir, options)
end
|
#fetch(code) ⇒ Object
35
36
37
38
|
# File 'lib/relaton/cli/command.rb', line 35
def fetch(code)
io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
io.puts(fetch_document(code, options) || supported_type_message)
end
|
#fetch_data(source) ⇒ Object
152
153
154
|
# File 'lib/relaton/cli/command.rb', line 152
def fetch_data(source)
DataFetcher.fetch source, options
end
|
#split(source, outdir) ⇒ Object
65
66
67
|
# File 'lib/relaton/cli/command.rb', line 65
def split(source, outdir)
Relaton::Cli::RelatonFile.split(source, outdir, options)
end
|
#version ⇒ Object
18
19
20
|
# File 'lib/relaton/cli/command.rb', line 18
def version
Relaton::Cli.version
end
|
#xml2html(file, style = nil, template = nil) ⇒ Object
111
112
113
|
# File 'lib/relaton/cli/command.rb', line 111
def xml2html(file, style = nil, template = nil)
Relaton::Cli::XMLConvertor.to_html(file, style, template)
end
|
#xml2yaml(filename) ⇒ Object
#yaml2html(file, style = nil, template = nil) ⇒ Object
124
125
126
|
# File 'lib/relaton/cli/command.rb', line 124
def yaml2html(file, style = nil, template = nil)
Relaton::Cli::YAMLConvertor.to_html(file, style, template)
end
|
#yaml2xml(filename) ⇒ Object