ttl2html 2.0.11 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9724547c455f091392715e13f386a3e0287c688cfffaf90f9609cb01ff887d4
4
- data.tar.gz: 31e1fe0848b38b0015eaa405d51bb8040ba7f3bf0852c2968fc63ca2a4cfd708
3
+ metadata.gz: 7bea49c3e41eef2b8b8951a536044c77b654d36f929f01bff0f7ab4c183376c2
4
+ data.tar.gz: 02ce27d24d451c56c6096fc4190a3b47976cb46832ba5c40689074bec5934513
5
5
  SHA512:
6
- metadata.gz: b06c2ffd5d06abeffddc1ee87910cc6b0035949742cd36433f52e1e3b6efeced85f09c0dc7601a4ad9650deec3fb788ad8ad71e4924d5189c1f9766ca10dcec7
7
- data.tar.gz: 0f3e934743a63fbcdabbe93aabbd78408891285ece08eb32f0a7fe752c0a296648204ae508ba2931e93a5312391e497e310427d5e05aa34c6dba65ff979177c7
6
+ metadata.gz: a5e50ad48925e650ffcc6d020977478a26e3bf19d11ea82ab94c9549cbb670ef59d620801837bea591d8daba4381af0a38dc0fc773aa8717cc02c75d5e816912
7
+ data.tar.gz: 6c41975ecb5674e5595acd7a51556d76a0c90515dbb8128f89f3fc58a9ddb8939a185df091c5a07b2bd8276a88ae631380eb4df72850b04b67812cb03058b2f8
@@ -1 +1 @@
1
- TTL2HTML::VERSION = "2.0.11"
1
+ TTL2HTML::VERSION = "2.1.0"
data/lib/ttl2html.rb CHANGED
@@ -6,6 +6,7 @@ require "yaml"
6
6
  require "nokogiri"
7
7
  require "rdf/turtle"
8
8
  require "ruby-progressbar"
9
+ require "parallel"
9
10
 
10
11
  require "ttl2html/util"
11
12
  require "ttl2html/template"
@@ -40,19 +41,21 @@ module TTL2HTML
40
41
  end
41
42
 
42
43
  def load_turtle(file)
43
- STDERR.puts "loading #{file}..."
44
+ $stderr.puts "loading #{file}..."
44
45
  count = 0
46
+ subjects = Set.new
45
47
  if file.end_with?(".gz")
46
48
  io = Zlib::GzipReader.open(file)
47
49
  else
48
50
  io = File.open(file)
49
51
  end
50
52
  RDF::Format.for(:turtle).reader.new(io) do |reader|
51
- reader.statements.each do |statement|
53
+ reader.each_statement do |statement|
52
54
  s = statement.subject
53
55
  v = statement.predicate
54
56
  o = statement.object
55
57
  count += 1
58
+ subjects << s
56
59
  @data[s.to_s] ||= {}
57
60
  @data[s.to_s][v.to_s] ||= []
58
61
  if o.is_a? RDF::URI or o.is_a? RDF::Node
@@ -66,7 +69,7 @@ module TTL2HTML
66
69
  end
67
70
  @prefix.merge! reader.prefixes
68
71
  end
69
- STDERR.puts "#{count} triples. #{@data.size} subjects."
72
+ $stderr.puts "#{count} triples. #{subjects.size} subjects."
70
73
  @data
71
74
  end
72
75
  def format_turtle(subject, depth = 1)
@@ -122,17 +125,17 @@ module TTL2HTML
122
125
  end
123
126
 
124
127
  def each_data(label = :each_data)
125
- progressbar = ProgressBar.create(title: label,
126
- total: @data.size,
127
- format: "(%t) %a %e %P% Processed: %c from %C")
128
- @data.keys.sort_by do|uri|
128
+ progressbar_options = {
129
+ title: label.to_s,
130
+ format: "(%t) %a %e %P% Processed: %c from %C"
131
+ }
132
+ data = @data.keys.sort_by do|uri|
129
133
  [ uri.count("/"), uri.size, uri ]
130
- end.reverse_each do |uri|
131
- progressbar.increment
134
+ end.reverse
135
+ Parallel.each(data, progress: progressbar_options) do |uri|
132
136
  next if not uri.start_with? @config[:base_uri]
133
137
  yield uri, @data[uri]
134
138
  end
135
- progressbar.finish
136
139
  end
137
140
  def output_html_files
138
141
  template = Template.new("", @config)
@@ -157,6 +160,7 @@ module TTL2HTML
157
160
  end
158
161
  end
159
162
  @config[:orders_with_class] = shapes2orders(shapes)
163
+ Dir.mkdir @config[:output_dir] if @config[:output_dir] and not File.exist? @config[:output_dir]
160
164
  each_data(:output_html_files) do |uri, v|
161
165
  template = Template.new("default.html.erb", @config)
162
166
  param = @config.dup
@@ -172,7 +176,6 @@ module TTL2HTML
172
176
  end
173
177
  file = uri_mapping_to_path(uri, @config, ".html")
174
178
  if @config[:output_dir]
175
- Dir.mkdir @config[:output_dir] if not File.exist? @config[:output_dir]
176
179
  file = File.join(@config[:output_dir], file)
177
180
  end
178
181
  if template.find_template_path("_default.html.erb")
@@ -190,7 +193,7 @@ module TTL2HTML
190
193
  end
191
194
  end
192
195
  if subjects.empty?
193
- STDERR.puts "WARN: top_class parameter specified as [#{@config[:top_class]}], but there is no instance data."
196
+ $stderr.puts "WARN: top_class parameter specified as [#{@config[:top_class]}], but there is no instance data."
194
197
  else
195
198
  template = Template.new("index.html.erb", @config)
196
199
  param = @config.dup
@@ -469,6 +472,7 @@ module TTL2HTML
469
472
  end
470
473
 
471
474
  def output_turtle_files
475
+ Dir.mkdir @config[:output_dir] if @config[:output_dir] and not File.exist? @config[:output_dir]
472
476
  each_data(:output_turtle_files) do |uri, v|
473
477
  file = uri_mapping_to_path(uri, @config, ".ttl")
474
478
  if @config[:output_dir]
@@ -66,7 +66,7 @@
66
66
  <dd class="col-sm-10"><%=h url %></dd>
67
67
  <%- end -%>
68
68
  </dl>
69
- <%- end -%>
70
- </td></tr>
69
+ </td></tr>
71
70
  </tfoot>
71
+ <%- end -%>
72
72
  </table>
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ttl2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masao Takaku
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-19 00:00:00.000000000 Z
10
+ date: 2025-01-20 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: nokogiri
@@ -52,6 +51,20 @@ dependencies:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
53
  version: 2.9.0
54
+ - !ruby/object:Gem::Dependency
55
+ name: csv
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
55
68
  - !ruby/object:Gem::Dependency
56
69
  name: i18n
57
70
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +121,20 @@ dependencies:
108
121
  - - ">="
109
122
  - !ruby/object:Gem::Version
110
123
  version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: parallel
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
111
138
  - !ruby/object:Gem::Dependency
112
139
  name: rspec
113
140
  requirement: !ruby/object:Gem::Requirement
@@ -184,7 +211,6 @@ homepage: https://github.com/masao/ttl2html
184
211
  licenses:
185
212
  - MIT
186
213
  metadata: {}
187
- post_install_message:
188
214
  rdoc_options: []
189
215
  require_paths:
190
216
  - lib
@@ -199,8 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
225
  - !ruby/object:Gem::Version
200
226
  version: '0'
201
227
  requirements: []
202
- rubygems_version: 3.5.16
203
- signing_key:
228
+ rubygems_version: 3.6.2
204
229
  specification_version: 4
205
230
  summary: ttl2html
206
231
  test_files: []