jekyll-theme-open-project-helpers 2.1.7 → 2.1.8

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: e4a49b1b98f4b6a8903466391a01dd42cccc0a80d477614b24bafea89d7af97c
4
- data.tar.gz: ff35d3b2783bfa70cd8f72fb2336357a2f1e9a8d15ac48f958d5a1a15f4ac2eb
3
+ metadata.gz: 5340ebd6b73a77f544854b7425860b5a2fa78ae1508182b0fa53f2aaa6002906
4
+ data.tar.gz: 2f9025c1a872c6176924c2f936c9bc1fdb7f14c5ce272da54a96ded564528122
5
5
  SHA512:
6
- metadata.gz: 845c40b2a93ab03c99fff74050da48d099329a430625929e1630625be95c55b1321882ba120dbf5670b53b9769be41ad4d9a9c70ce19b24337af756d785fb9b8
7
- data.tar.gz: 715deb4ae224a58c8084f9eb8f538bc0217b7be91601c0a77b7f934dbf52fc8d5c58455c073bd281a1fc1c736783f469bbbe10df23b013af8b6ae99610388e54
6
+ metadata.gz: 992ce56cd7eafea9d7167384a227eaff95d3dc20bd368e277f386238b13725db49662185aef4f0f415f28784fe392036bf01196af7d715fb3b1790f4ec66848e
7
+ data.tar.gz: 9e6d476f0a89b3aee43f1c3e5d0becc5ca2b3ee3d297eb371143587ae19d7182248fd3c6c1c14fe69bfda241e1522a062fcd363dedab3273ee05a5fc323fbb1e
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /Gemfile.lock
2
+ /.rubocop-https*
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
4
+ source "https://rubygems.org"
5
+
6
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -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.7'
5
+ s.version = '2.1.8'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -1,92 +1,119 @@
1
- require 'fastimage'
1
+ require "fastimage"
2
2
 
3
3
  # Recursively go through given list of nav_items, including any nested items,
4
4
  # and return a flat array containing navigation items with path specified.
5
5
  def get_nav_items_with_path(nav_items)
6
6
  items_with_path = []
7
7
 
8
- for item in nav_items do
9
- if item['path']
8
+ nav_items.each do |item|
9
+ if item["path"]
10
10
  items_with_path.push(item)
11
11
  end
12
12
 
13
- if item['items']
14
- items_with_path.concat(get_nav_items_with_path(item['items']))
13
+ if item["items"]
14
+ items_with_path.concat(get_nav_items_with_path(item["items"]))
15
15
  end
16
16
  end
17
17
 
18
- return items_with_path
18
+ items_with_path
19
19
  end
20
20
 
21
21
  module Builder
22
-
23
22
  class PngDiagramPage < Jekyll::Page
24
- def initialize(site, base, dir, data)
23
+ EXTRA_STYLESHEETS = [{
24
+ "href" => "https://unpkg.com/leaflet@1.3.4/dist/leaflet.css",
25
+ "integrity" => "sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==", # rubocop:disable Layout/LineLength
26
+ "crossorigin" => "",
27
+ }].freeze
28
+
29
+ EXTRA_SCRIPTS = [{
30
+ "src" => "https://unpkg.com/leaflet@1.3.4/dist/leaflet.js",
31
+ "integrity" => "sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==", # rubocop:disable Layout/LineLength
32
+ "crossorigin" => "",
33
+ }].freeze
34
+
35
+ def initialize(site, base, dir, data) # rubocop:disable Lint/MissingSuper
25
36
  @site = site
26
37
  @base = base
27
38
  @dir = dir
28
- @name = 'index.html'
39
+ @name = "index.html"
29
40
 
30
- self.process(@name)
41
+ process(@name)
31
42
  self.data ||= data
32
43
 
33
- self.data['extra_stylesheets'] = [{
34
- "href" => "https://unpkg.com/leaflet@1.3.4/dist/leaflet.css",
35
- "integrity" => "sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==",
36
- "crossorigin" => "",
37
- }]
38
-
39
- self.data['extra_scripts'] = [{
40
- "src" => "https://unpkg.com/leaflet@1.3.4/dist/leaflet.js",
41
- "integrity" => "sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==",
42
- "crossorigin" => "",
43
- }]
44
-
45
- self.data['layout'] = 'spec'
44
+ self.data["extra_stylesheets"] = EXTRA_STYLESHEETS
45
+ self.data["extra_scripts"] = EXTRA_SCRIPTS
46
+ self.data["layout"] = "spec"
46
47
  end
47
48
  end
48
49
 
49
50
  def build_spec_pages(site, spec_info, source, destination, opts)
50
51
  images_path = source
51
52
  spec_root = destination
52
- stub_path = "#{File.dirname(__FILE__)}/png_diagram.html"
53
53
  pages = []
54
54
 
55
- diagram_nav_items = get_nav_items_with_path(spec_info.data['navigation']['items'])
55
+ diagram_nav_items = get_nav_items_with_path(
56
+ spec_info.data["navigation"]["items"],
57
+ )
58
+ not_found_items = diagram_nav_items.dup
56
59
 
57
60
  Dir.glob("#{images_path}/*.png") do |pngfile|
58
61
  png_name = File.basename(pngfile)
59
62
  png_name_noext = File.basename(png_name, File.extname(png_name))
60
63
 
61
- nav_item = diagram_nav_items.select { |item|
62
- item['path'].start_with?(png_name_noext)
63
- } [0].clone
64
-
65
- png_dimensions = FastImage.size(pngfile)
66
- data = spec_info.data.clone
67
- data['image_path'] = "/#{spec_root}/images/#{png_name}"
68
- data['image_width'] = png_dimensions[0]
69
- data['image_height'] = png_dimensions[1]
64
+ nav_item = diagram_nav_items.select do |item|
65
+ item["path"].start_with?(png_name_noext)
66
+ end [0].clone
70
67
 
71
68
  if nav_item == nil
72
- raise "Navigation item matching #{png_name} (#{spec_root}) was not found"
69
+ warn "UNUSED PNG: #{png_name} detected at source without " \
70
+ "a corresponding navigation item at (#{spec_root})."
71
+ next
73
72
  end
74
73
 
75
- data = data.merge(nav_item)
74
+ not_found_items.delete_if { |item| item["title"] == nav_item["title"] }
75
+
76
+ data = build_spec_page_data(pngfile, spec_root, png_name, nav_item,
77
+ spec_info)
76
78
 
77
- data['title'] = "#{spec_info['title']}: #{nav_item['title']}"
78
- data['article_header_title'] = "#{nav_item['title']}"
79
+ pages << build_spec_page(site, spec_root, png_name_noext, data)
80
+ end
79
81
 
80
- page = PngDiagramPage.new(
81
- site,
82
- site.source,
83
- File.join(spec_root, png_name_noext),
84
- data)
85
- page.content = File.read(stub_path)
86
- pages << page
82
+ not_found_items.each do |item|
83
+ title = item["title"]
84
+ warn "SPECIFIED PNG NOT FOUND: #{title}.png not found at source " \
85
+ "as specified at (#{spec_root})."
87
86
  end
88
87
 
89
- return pages
88
+ pages
89
+ end
90
+
91
+ def build_spec_page(site, spec_root, png_name_noext, data)
92
+ page = PngDiagramPage.new(
93
+ site,
94
+ site.source,
95
+ File.join(spec_root, png_name_noext),
96
+ data,
97
+ )
98
+
99
+ stub_path = "#{File.dirname(__FILE__)}/png_diagram.html"
100
+ page.content = File.read(stub_path)
101
+
102
+ page
90
103
  end
91
104
 
105
+ def build_spec_page_data(pngfile, spec_root, png_name, nav_item, spec_info)
106
+ png_dimensions = FastImage.size(pngfile)
107
+ data = spec_info.data.clone
108
+ data["image_path"] = "/#{spec_root}/images/#{png_name}"
109
+ data["image_width"] = png_dimensions[0]
110
+ data["image_height"] = png_dimensions[1]
111
+
112
+ data = data.merge(nav_item)
113
+
114
+ data["title"] = "#{spec_info['title']}: #{nav_item['title']}"
115
+ data["article_header_title"] = nav_item["title"].to_s
116
+
117
+ data
118
+ end
92
119
  end
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.7
4
+ version: 2.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -87,8 +87,12 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - Gemfile
90
93
  - LICENSE.txt
91
94
  - README.md
95
+ - Rakefile
92
96
  - develop/release
93
97
  - jekyll-theme-open-project-helpers.gemspec
94
98
  - lib/jekyll-theme-open-project-helpers.rb
@@ -119,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
123
  - !ruby/object:Gem::Version
120
124
  version: '0'
121
125
  requirements: []
122
- rubygems_version: 3.0.6
126
+ rubygems_version: 3.0.3
123
127
  signing_key:
124
128
  specification_version: 4
125
129
  summary: Helpers for the Open Project Jekyll theme