jekyll-theme-open-project-helpers 2.1.0 → 2.1.5

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: 9b045cd70c2375d6cc096ac8d3323e15727c907bcc78ecb627641e0f87832ec9
4
- data.tar.gz: 283ad8eb59754e1d664d442aba2ead3b4fcb6a882a2fba05bc0658ddd5d09d30
3
+ metadata.gz: 9f94594d15f1b9e8b4c7a02d99a6ebfed8164ad00e65fedffb9fd5f3deed0bde
4
+ data.tar.gz: e45b408956ce95fd59e813b1f1af8ec284d0c52938abe12fde4d90ee5d8be24b
5
5
  SHA512:
6
- metadata.gz: cd120bba4d87dbe8b3a20c88b9c468d8c1a561d857597ff1d3111dd177ead51920a15d27b2ac8fc52f83894eba82623b3aeb8f3dd8fbe0bef49e70df215b478e
7
- data.tar.gz: 34c9f84aee668df5e6194b2a5256fe02a870286d5b3883dc9227447f110ba195e354debbe6e7788e5eb14b4d161508915930a0632da7b2c29b8e9a9946dbef73
6
+ metadata.gz: 5b0b8be8ff9299477f8d3ceb29c02832a4e3b61af1f98db082245862c18da9c3ea7441e41a8e4a0097fab6edc6c48524abe1d823a3a799001d809d6e1a1c4afa
7
+ data.tar.gz: adc2f75f13ed2548901e9b8c008b7385f43a07a42a57c94e639d6e54a78e2032cd25a2f780463711593dd72a93e854237514b17f31906cc30e237ec2ef7373ac
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Ribose
3
+ Copyright (c) 2020 Ribose
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -12,7 +12,7 @@ fetching open project/software/specification data from their repos.
12
12
  ## Releasing
13
13
 
14
14
  **Release this helpers gem and theme gem in tandem with matching versions.**
15
- See [https://github.com/riboseinc/jekyll-theme-open-project-helpers](theme gem docs) for more.
15
+ See [Theme gem docs](https://github.com/riboseinc/jekyll-theme-open-project) for more.
16
16
 
17
17
 
18
18
  1. Inside .gemspec within this repo’s root, update main gem version to the one being released.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'jekyll-theme-open-project-helpers'
5
- s.version = '2.1.0'
5
+ s.version = '2.1.5'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -55,7 +55,7 @@ module Jekyll
55
55
  # Creates a data structure like { tag1: [item1, item2], tag2: [item2, item3] }
56
56
  tags = {}
57
57
  items.each do |item|
58
- item.data['tags'].each do |tag|
58
+ (item.data['tags'] or []).each do |tag|
59
59
  unless tags.key? tag
60
60
  tags[tag] = []
61
61
  end
@@ -30,6 +30,8 @@ module Jekyll
30
30
  entries.each do |entry|
31
31
  path = File.join(dir, entry)
32
32
 
33
+ Jekyll.logger.debug("OPF:", "Reading entry #{path}")
34
+
33
35
  if File.directory?(path)
34
36
  read_project_subdir(path, collection, nested=true)
35
37
 
@@ -40,11 +42,17 @@ module Jekyll
40
42
  doc.read
41
43
 
42
44
  # Add document to Jekyll document database if it refers to software or spec
43
- # (as opposed to be some nested document like README)
44
- if doc.url.split('/').size == 4
45
+ # (as opposed to be some random nested document within repository source, like a README)
46
+ doc_url_parts = doc.url.split('/')
47
+ Jekyll.logger.debug("OPF:", "Reading document in collection #{collection.label} with URL #{doc.url} (#{doc_url_parts.size} parts)")
48
+ if collection.label != 'projects' or doc_url_parts.size == 5
49
+ Jekyll.logger.debug("OPF:", "Adding document with URL: #{doc.url}")
45
50
  collection.docs << doc
51
+ else
52
+ Jekyll.logger.debug("OPF:", "Did NOT add document with URL (possibly nesting level doesn’t match): #{doc.url}")
46
53
  end
47
54
  else
55
+ Jekyll.logger.debug("OPF:", "Adding static file: #{path}")
48
56
  collection.files << Jekyll::StaticFile.new(
49
57
  @site,
50
58
  @site.source,
@@ -104,6 +112,9 @@ module Jekyll
104
112
  project['site']['git_repo_url'],
105
113
  ['assets', '_posts', '_software', '_specs'])
106
114
 
115
+
116
+ Jekyll.logger.debug("OPF:", "Reading files in project #{project_path}")
117
+
107
118
  CollectionDocReader.new(site).read(
108
119
  project_path,
109
120
  @site.collections['projects'])
@@ -131,13 +142,9 @@ module Jekyll
131
142
  spec_checkout_path
132
143
  end
133
144
 
134
- begin
135
- repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree])
136
- rescue
137
- repo_checkout = nil
138
- end
145
+ repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree])
139
146
 
140
- if repo_checkout
147
+ if repo_checkout[:success]
141
148
  if build_pages
142
149
  builder = Jekyll::OpenProjectHelpers::SpecBuilder::new(
143
150
  @site,
@@ -164,14 +171,23 @@ module Jekyll
164
171
  def fetch_and_read_specs(collection_name, build_pages=false)
165
172
  # collection_name would be either specs or (for hub site) projects
166
173
 
174
+ Jekyll.logger.debug("OPF:", "Fetching specs for items in collection #{collection_name} (if it exists)")
175
+
167
176
  return unless @site.collections.key?(collection_name)
168
177
 
178
+ Jekyll.logger.debug("OPF:", "Fetching specs for items in collection #{collection_name}")
179
+
169
180
  # Get spec entry points
170
181
  entry_points = @site.collections[collection_name].docs.select do |doc|
171
182
  doc.data['spec_source']
172
183
  end
173
184
 
185
+ if entry_points.size < 1
186
+ Jekyll.logger.info("OPF:", "Fetching specs for items in collection #{collection_name}: No entry points")
187
+ end
188
+
174
189
  entry_points.each do |index_doc|
190
+ Jekyll.logger.debug("OPF:", "Fetching specs: entry point #{index_doc.id} in collection #{collection_name}")
175
191
  build_and_read_spec_pages(collection_name, index_doc, build_pages)
176
192
  end
177
193
  end
@@ -179,14 +195,23 @@ module Jekyll
179
195
  def fetch_and_read_software(collection_name)
180
196
  # collection_name would be either software or (for hub site) projects
181
197
 
198
+ Jekyll.logger.debug("OPF:", "Fetching software for items in collection #{collection_name} (if it exists)")
199
+
182
200
  return unless @site.collections.key?(collection_name)
183
201
 
202
+ Jekyll.logger.debug("OPF:", "Fetching software for items in collection #{collection_name}")
203
+
184
204
  entry_points = @site.collections[collection_name].docs.select do |doc|
185
205
  doc.data['repo_url']
186
206
  end
187
207
 
208
+ if entry_points.size < 1
209
+ Jekyll.logger.info("OPF:", "Fetching software for items in collection #{collection_name}: No entry points")
210
+ end
211
+
188
212
  entry_points.each do |index_doc|
189
213
  item_name = index_doc.id.split('/')[-1]
214
+ Jekyll.logger.debug("OPF:", "Fetching software: entry point #{index_doc.id} in collection #{collection_name}")
190
215
 
191
216
  docs = index_doc.data['docs']
192
217
  main_repo = index_doc.data['repo_url']
@@ -196,13 +221,9 @@ module Jekyll
196
221
 
197
222
  docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
198
223
 
199
- begin
200
- sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
201
- rescue
202
- sw_docs_checkout = nil
203
- end
224
+ sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
204
225
 
205
- if sw_docs_checkout
226
+ if sw_docs_checkout[:success]
206
227
  CollectionDocReader.new(site).read(
207
228
  docs_path,
208
229
  @site.collections[collection_name])
@@ -211,7 +232,7 @@ module Jekyll
211
232
  # Get last repository modification timestamp.
212
233
  # Fetch the repository for that purpose,
213
234
  # unless it’s the same as the repo where docs are.
214
- if sw_docs_checkout == nil or sw_docs_repo != main_repo
235
+ if !sw_docs_checkout[:success] or sw_docs_repo != main_repo
215
236
  repo_path = "#{index_doc.path.split('/')[0..-2].join('/')}/_#{item_name}_repo"
216
237
  repo_checkout = git_shallow_checkout(repo_path, main_repo)
217
238
  index_doc.merge_data!({ 'last_update' => repo_checkout[:modified_at] })
@@ -269,19 +290,39 @@ module Jekyll
269
290
  repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
270
291
 
271
292
  elsif refresh_condition == 'last-resort'
293
+ # This is the default case.
294
+
272
295
  begin
296
+ # Let’s try in case this repo has been fetched before (this would never be the case on CI though)
273
297
  repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
274
298
  rescue Exception => e
275
- if e.message.include? "Sparse checkout leaves no entry on working directory"
276
- # Supposedly, software docs are missing! No big deal.
299
+ if is_sparse_checkout_error(e, sparse_subtrees)
300
+ # Silence errors caused by nonexistent sparse checkout directories
277
301
  return {
278
302
  :success => false,
279
303
  :newly_initialized => nil,
280
304
  :modified_at => nil,
281
305
  }
282
306
  else
307
+ # In case of any other error, presume repo has not been fetched and do that now.
308
+ Jekyll.logger.debug("OPF:", "Fetching & checking out #{remote_url} for #{repo_path}")
283
309
  repo.fetch(DEFAULT_REPO_REMOTE_NAME, { :depth => 1 })
284
- repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
310
+ begin
311
+ # Try checkout again
312
+ repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
313
+ rescue Exception => e
314
+ if is_sparse_checkout_error(e, sparse_subtrees)
315
+ # Again, silence an error caused by nonexistent sparse checkout directories…
316
+ return {
317
+ :success => false,
318
+ :newly_initialized => nil,
319
+ :modified_at => nil,
320
+ }
321
+ else
322
+ # but this time throw any other error.
323
+ raise e
324
+ end
325
+ end
285
326
  end
286
327
  end
287
328
  end
@@ -299,6 +340,15 @@ module Jekyll
299
340
  end
300
341
  end
301
342
 
343
+ def is_sparse_checkout_error(err, subtrees)
344
+ if err.message.include? "Sparse checkout leaves no entry on working directory"
345
+ Jekyll.logger.debug("OPF: It looks like sparse checkout of these directories failed:", subtrees.to_s)
346
+ true
347
+ else
348
+ false
349
+ end
350
+ end
351
+
302
352
  Jekyll::Hooks.register :site, :after_init do |site|
303
353
  if site.theme # TODO: Check theme name
304
354
  site.reader = Jekyll::OpenProjectHelpers::OpenProjectReader::new(site)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-open-project-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.0.6
122
+ rubygems_version: 3.0.8
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Helpers for the Open Project Jekyll theme