kramdown-rfc2629 1.3.35 → 1.3.36

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c7cb1da81c5398c23b2118c7faf5ee1e620d65e4f3c6078fd27758403e9fa79
4
- data.tar.gz: ba71f18945de2bb908e503ef7dd049de8477e57d3ddd5420161d2a9ad37b5589
3
+ metadata.gz: 1a7a8c78c412d9bf4830f3335bba088f220a983e391057bdf90cad5d716d2d2f
4
+ data.tar.gz: 8fbac5333fb0e14e732aac23ba11b9a110fe8ca9948e6aa89ce953e88c95a193
5
5
  SHA512:
6
- metadata.gz: 8238ed916370bf73c5d21d8d03dbc465528d5865039affb4aeff21d9c1b3e79b5984e76d3df070c33abcb57e739c7312686f8a0754123e34ce2df6ce11287e50
7
- data.tar.gz: 9d5ab035fdf87fc4dff43072adb17e24f4933629352787cc3aea7647d0e5fd8a38012ba3bbc52a78926477c6dbd8160a3342dc3a32ad335f25f8769adf362975
6
+ metadata.gz: 889c151d93059ebd22e6adb9b7bc295206056c70ae69adab2c300b736c9b3037d7a7ec1af865ff7aeba29af5a4d3ab82525aebbd1bcddb8fb9f8ad2b9ba5c0af
7
+ data.tar.gz: 9e067408ad82182fb0ae4f0461b0e47db3888d3839b6a1e2915333fd1acffa34c783b8a7185ebe8afdb56a64a89854638de1c1d6a2c781aa95c4c093e58793fb
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+ # prerequisite:
3
+ # gem install net-http-persistent
4
+ #
5
+ # dumps all bibxml for current, "Active" I-Ds in cache
6
+ # reasonably efficient after initial call if the output is retained
7
+ #
8
+ # requires Ruby 2.4 or above because of "liberal_parsing" option
9
+ #
10
+ # uses ENV["KRAMDOWN_REFCACHEDIR"] for where you want to have your bibxml3 data
11
+ #
12
+
13
+ require 'csv'
14
+ require 'fileutils'
15
+
16
+ begin
17
+ require 'net/http/persistent'
18
+ rescue
19
+ warn "*** please install net-http-persistent:"
20
+ warn " gem install net-http-persistent"
21
+ warn "(prefix by sudo only if required)."
22
+ exit 72 # EX_OSFILE
23
+ end
24
+
25
+
26
+ TARGET_DIR = ENV["KRAMDOWN_REFCACHEDIR"] || (
27
+ path = File.expand_path("~/.cache/xml2rfc")
28
+ warn "*** set environment variable KRAMDOWN_REFCACHEDIR to #{path} to actually use the cache"
29
+ path
30
+ )
31
+
32
+ FileUtils.mkdir_p(TARGET_DIR)
33
+ FileUtils.chdir(TARGET_DIR)
34
+
35
+ $http = Net::HTTP::Persistent.new name: 'allid'
36
+
37
+ KRAMDOWN_PERSISTENT_VERBOSE = true
38
+
39
+ def get_and_write_resource_persistently(url, fn, age_verbose=false)
40
+ t1 = Time.now
41
+ response = $http.request(URI(url))
42
+ if response.code != "200"
43
+ raise "*** Status code #{response.code} while fetching #{url}"
44
+ else
45
+ File.write(fn, response.body)
46
+ end
47
+ t2 = Time.now
48
+ warn "#{url} -> #{fn} (#{"%.3f" % (t2 - t1)} s)" if KRAMDOWN_PERSISTENT_VERBOSE
49
+ if age_verbose
50
+ if age = response.get_fields("age")
51
+ warn "(working from a web cache, index is #{age.first} seconds stale)"
52
+ end
53
+ end
54
+ end
55
+
56
+ CLEAR_RET = "\e[K\r" # XXX all the world is ECMA-48 (ISO 6429), no?
57
+
58
+ def noisy(name)
59
+ print "#{name}...#{CLEAR_RET}"
60
+ end
61
+ def clear_noise
62
+ print CLEAR_RET
63
+ end
64
+
65
+ ALL_ID2_SOURCE = "https://www.ietf.org/id/all_id2.txt"
66
+ ALL_ID2_COPY = ".all_id2.txt"
67
+
68
+ get_and_write_resource_persistently(ALL_ID2_SOURCE, ALL_ID2_COPY, true) unless ENV["KRAMDOWN_DONT_REFRESH_ALL_ID2"]
69
+ ix = File.read(ALL_ID2_COPY).lines.grep_v(/^#/).join
70
+
71
+ csv = CSV.new(ix, col_sep: "\t", liberal_parsing: true)
72
+
73
+ drafts = csv.read
74
+ active = drafts.select { |d| d[2] == "Active" }
75
+ active_names = active.map { |a| a[0] }
76
+ puts "#{active_names.size} active drafts"
77
+
78
+ active_names.each do |name|
79
+ if name =~ /\Adraft-(.*)-(\d\d)\z/
80
+ namepart = $1
81
+ version = $2
82
+ name0 = "reference.I-D.#{namepart}.xml"
83
+ noisy(name0) if File.exists?(name0)
84
+ name1 = "reference.I-D.draft-#{namepart}-#{version}.xml"
85
+ if File.exists?(name1)
86
+ noisy(name1)
87
+ FileUtils.touch(name0) # because name1 already exists, we believe name0 is fresh
88
+ else
89
+ begin
90
+ url0 = "https://datatracker.ietf.org/doc/bibxml3/draft-#{namepart}/xml"
91
+ get_and_write_resource_persistently(url0, name0) # get name0 first
92
+ url1 = "https://datatracker.ietf.org/doc/bibxml3/draft-#{namepart}-#{version}/xml"
93
+ get_and_write_resource_persistently(url1, name1) # then name1 to mark this as updated
94
+ rescue => e
95
+ warn "*** #{name0}: #{e}"
96
+ end
97
+ end
98
+ else
99
+ warn "*** Malformed draft name: #{name}"
100
+ end
101
+ end
102
+ clear_noise
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.35'
3
+ s.version = '1.3.36'
4
4
  s.summary = "Kramdown extension for generating RFC 7749 XML."
5
5
  s.description = %{An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
6
6
  "kramdown" markdown parser. Mostly useful for RFC writers.}
@@ -9,7 +9,8 @@ spec = Gem::Specification.new do |s|
9
9
  s.add_dependency('json_pure', '~> 2.0')
10
10
  s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json)
11
11
  s.require_path = 'lib'
12
- s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown', 'kdrfc']
12
+ s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown',
13
+ 'kdrfc', 'kramdown-rfc-cache-i-d-bibxml']
13
14
  s.required_ruby_version = '>= 2.3.0'
14
15
  # s.requirements = 'wget'
15
16
  # s.has_rdoc = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-rfc2629
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.35
4
+ version: 1.3.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -61,6 +61,7 @@ executables:
61
61
  - doilit
62
62
  - kramdown-rfc-extract-markdown
63
63
  - kdrfc
64
+ - kramdown-rfc-cache-i-d-bibxml
64
65
  extensions: []
65
66
  extra_rdoc_files: []
66
67
  files:
@@ -68,6 +69,7 @@ files:
68
69
  - README.md
69
70
  - bin/doilit
70
71
  - bin/kdrfc
72
+ - bin/kramdown-rfc-cache-i-d-bibxml
71
73
  - bin/kramdown-rfc-extract-markdown
72
74
  - bin/kramdown-rfc2629
73
75
  - data/encoding-fallbacks.txt