relaton-cli 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- unless ARGV.size == 1
4
- warn "./relaton-concatenate DIRECTORY (containing Relaton-XML or YAML)"
5
- end
6
- dir = ARGV.pop
7
-
8
- ret = ""
9
-
10
- Dir.foreach dir do |f|
11
- if /\.yaml$/.match f
12
- puts "#{__dir__}/relaton-yaml-xml -R #{dir} #{dir}/#{f}"
13
- system "#{__dir__}/relaton-yaml-xml -R #{dir} #{dir}/#{f}"
14
- end
15
- end
16
-
17
- Dir.foreach dir do |f|
18
- if /\.xml$/.match f
19
- ret += File.read("#{dir}/#{f}", encoding: "utf-8")
20
- end
21
- end
22
-
23
- ret = "<relaton-collection>\n#{ret}\n</relaton-collection>"
24
- puts ret
data/exe/relaton-fetch DELETED
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "relaton"
4
- require "optparse"
5
-
6
- cache = "#{Dir.home}/.relaton-bib.pstore"
7
- relaton = Relaton::Db.new(cache, nil)
8
- types = Relaton::Db::SUPPORTED_GEMS.join(', ')
9
-
10
- options = {}
11
-
12
- opt_parser = OptionParser.new do |opts|
13
- opts.banner += " <file>"
14
- opts.on(
15
- '-t',
16
- '--type TYPE',
17
- "Type of standard to get bibliographic entry for: #{types}"
18
- ) { |v| options[:type] = v.to_sym }
19
-
20
- opts.on(
21
- '-y',
22
- '--year YEAR',
23
- "Year the standard was published"
24
- ) { |v| options[:year] = v }
25
-
26
- opts.on_tail("-h", "--help", "Show this message") do
27
- puts opts
28
- exit
29
- end
30
- end
31
-
32
- opt_parser.parse!(ARGV)
33
- options[:code] = ARGV.pop
34
-
35
- ret = relaton.fetch_std(options[:code], options[:year], options[:type], {})
36
-
37
- if ret.nil?
38
- warn "No matching bibliographic entry found"
39
- else
40
- puts ret.to_xml
41
- end
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "nokogiri"
4
-
5
- unless ARGV.size == 2
6
- warn "./relaton-metanorma-extract Metanorma-XML-Directory Relaton-XML-Directory"
7
- end
8
- indir = ARGV[0]
9
- outdir = ARGV[1]
10
-
11
- Dir.foreach indir do |f|
12
- if /\.xml$/.match f
13
- file = File.read("#{indir}/#{f}", encoding: "utf-8")
14
- xml = Nokogiri::XML(file)
15
- bibdata = xml.at("//xmlns:bibdata") || next
16
- docid = bibdata&.at("./xmlns:docidentifier")&.text || f.sub(/\.xml$/, "")
17
- outname = docid.sub(/^\s+/, "").sub(/\s+$/, "").gsub(/\s+/, "-") + ".xml"
18
- File.open("#{outdir}/#{outname}", "w:UTF-8") { |f| f.write bibdata.to_xml }
19
- end
20
- end
data/exe/relaton-xml-html DELETED
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Invoke as: ./relaton-doc FILENAME STYLESHEET RELATON-ROOT
4
- require "yaml"
5
- require "optparse"
6
- require "fileutils"
7
- require "relaton/cli"
8
-
9
-
10
- if ARGV.size < 2 || ARGV.size > 3
11
- warn "Invoke as: ./relaton-xml-html <relaton-index-xml> <stylesheet> <liquid-template-dir>"
12
- exit
13
- end
14
-
15
- filename = ARGV[0]
16
- file = File.read(filename, encoding: "utf-8")
17
-
18
- puts ARGV.inspect
19
-
20
- xml_to_html = Relaton::Cli::XmlToHtmlRenderer.new({
21
- stylesheet: ARGV[1],
22
- liquid_dir: ARGV[2]
23
- })
24
-
25
- File.open(filename.sub(/\.xml$/, ".html"), "w:UTF-8") do |f|
26
- f.write(xml_to_html.render(file))
27
- end
28
-
data/exe/relaton-yaml-xml DELETED
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "yaml"
4
- require "optparse"
5
- require "fileutils"
6
- require "relaton/cli"
7
-
8
- options = {}
9
-
10
- opt_parser = OptionParser.new do |opts|
11
- opts.banner += " <file>"
12
-
13
- opts.on(
14
- '-r',
15
- '--require LIBRARY',
16
- 'Require LIBRARY prior to execution'
17
- ) { |v|
18
- options[:require] ||= []
19
- options[:require] << v
20
- }
21
-
22
- opts.on(
23
- '-R OUTDIR',
24
- '--relaton-outdir OUTDIR',
25
- "Create Relaton XML per item, within this output directory (e.g. {outdir}/{docid}.xml)"
26
- ) { |v| options[:outdir] = v }
27
-
28
- opts.on_tail("-h", "--help", "Show this message") do
29
- puts opts
30
- exit
31
- end
32
- end
33
-
34
- opt_parser.parse!(ARGV)
35
- options[:filename] = ARGV.pop
36
-
37
- if options[:require]
38
- options[:require].each do |r|
39
- require r
40
- end
41
- end
42
-
43
- index_input = YAML.load_file(options[:filename])
44
- index_collection = ::Relaton::Bibcollection.new(index_input["root"])
45
-
46
- # TODO real lookup of namespaces and root elements
47
-
48
- # Write out index.html
49
- outfilename = options[:filename].sub(/\.[^.]+$/, ".xml")
50
- File.open(outfilename, "w") do |f|
51
- f.write index_collection.to_xml
52
- end
53
-
54
- outdir = options[:outdir]
55
-
56
- if outdir
57
- FileUtils.mkdir_p(outdir)
58
- # Write out relaton/#{id}.xml
59
- index_collection.items_flattened.each do |item|
60
- filename = File.join(outdir, "#{item.docid_code}.xml")
61
-
62
- File.open(filename, "w:UTF-8") do |f|
63
- f.write(item.to_xml)
64
- end
65
-
66
- end
67
- end
68
-