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
Instance Method Details
#concatenate(source_dir, outfile) ⇒ Object
51
52
53
|
# File 'lib/relaton/cli/command.rb', line 51
def concatenate(source_dir, outfile)
Relaton::Cli::RelatonFile.concatenate(source_dir, outfile, options)
end
|
#convert(file) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/relaton/cli/command.rb', line 129
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
|
39
40
41
|
# File 'lib/relaton/cli/command.rb', line 39
def (source_dir, outdir)
Relaton::Cli::RelatonFile.(source_dir, outdir, options)
end
|
#fetch(code) ⇒ Object
29
30
31
32
|
# File 'lib/relaton/cli/command.rb', line 29
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
149
150
151
|
# File 'lib/relaton/cli/command.rb', line 149
def fetch_data(source)
DataFetcher.fetch source, options
end
|
#split(source, outdir) ⇒ Object
60
61
62
|
# File 'lib/relaton/cli/command.rb', line 60
def split(source, outdir)
Relaton::Cli::RelatonFile.split(source, outdir, options)
end
|
#xml2html(file, style = nil, template = nil) ⇒ Object
107
108
109
|
# File 'lib/relaton/cli/command.rb', line 107
def xml2html(file, style = nil, template = nil)
Relaton::Cli::XMLConvertor.to_html(file, style, template)
end
|
#xml2yaml(filename) ⇒ Object
94
95
96
|
# File 'lib/relaton/cli/command.rb', line 94
def xml2yaml(filename)
Relaton::Cli::XMLConvertor.to_yaml(filename, options)
end
|
#yaml2html(file, style = nil, template = nil) ⇒ Object
120
121
122
|
# File 'lib/relaton/cli/command.rb', line 120
def yaml2html(file, style = nil, template = nil)
Relaton::Cli::YAMLConvertor.to_html(file, style, template)
end
|
#yaml2xml(filename) ⇒ Object
77
78
79
|
# File 'lib/relaton/cli/command.rb', line 77
def yaml2xml(filename)
Relaton::Cli::YAMLConvertor.to_xml(filename, options)
end
|