fontist 1.15.0 → 1.15.2

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: 8ef3c1df1ab7760fa50abdca9dc9c760d7f953dfc209f3841a8c01b9297760e9
4
- data.tar.gz: b6e32f79b2cdeb3af88ec2ae3bdbf9ad767f41d3721dcfa2991f670e74ceaade
3
+ metadata.gz: d98d4d83f8bbfe87d19e6c11dd8d365810ac47ddeef59a8855f3fba7f9d5418d
4
+ data.tar.gz: 4f349a35dfe3d164e599dee2e077625b8273dd91c6d4b698042bf25a54ba45a0
5
5
  SHA512:
6
- metadata.gz: bb6f7c6325ba122a79e6713b642dd6ca4967f6622f013dc1c56b41a03e0228da6e5a7e3707211dd293d78d9a3e4a07eec7edc545710f9b322c45f0f7b4c0e7e1
7
- data.tar.gz: 2e42062f05fa332dcea0b93fde315db285c8d5894f029e85fdcfcda9f3f57eeed60dc55ed816cb33405c80581a7b313e15cb44e2c13eedafab1d011043b20336
6
+ metadata.gz: 007af294bcd909651345c08df9f948dae6d62eb7c3e6f26048dc91df3542a53f417a9446c69790f9bfb017e3fd7d9389784938d37274223ff4e16bd1bae47703
7
+ data.tar.gz: 4068f33a62c9e8afe20b3bd6c135fc642c9dcfc9738faa37b49f1e582a6e5b4d879e7d8df65c34554818b2dd1258bd76ee57b90f85b1a119bd3748263f5d374d
@@ -82,7 +82,7 @@ jobs:
82
82
  needs: prepare
83
83
  if: needs.prepare.outputs.push-for-tag != 'true'
84
84
 
85
- continue-on-error: ${{ matrix.ruby.experimental }}
85
+ continue-on-error: ${{ matrix.ruby.experimental || matrix.os == 'windows-latest' }} # workaround https://github.com/metanorma/metanorma/issues/288
86
86
  strategy:
87
87
  fail-fast: false
88
88
  max-parallel: 5
data/fontist.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency "nokogiri", "~> 1.0"
35
35
  spec.add_runtime_dependency "mime-types", "~> 3.0"
36
36
  spec.add_runtime_dependency "sys-uname", "~> 1.2"
37
- spec.add_runtime_dependency "thor", "~> 1.0.1"
37
+ spec.add_runtime_dependency "thor", "~> 1.2.1"
38
38
  spec.add_runtime_dependency "git", "~> 1.0"
39
39
  spec.add_runtime_dependency "ttfunk", "~> 1.6"
40
40
  spec.add_runtime_dependency "plist", "~> 3.0"
@@ -2,13 +2,27 @@ module Fontist
2
2
  class CacheCLI < Thor
3
3
  include CLI::ClassOptions
4
4
 
5
- desc "clear", "Clear fontist download cache"
5
+ desc "clear", "Clear fontist cache"
6
6
  def clear
7
7
  handle_class_options(options)
8
8
  dir = Fontist.downloads_path
9
- dir.each_child(&:delete) if dir.exist?
10
- Fontist.ui.success("Download cache has been successfully removed.")
9
+ dir.each_child(&:rmtree) if dir.exist?
10
+ clear_indexes
11
+ Fontist.ui.success("Cache has been successfully removed.")
11
12
  CLI::STATUS_SUCCESS
12
13
  end
14
+
15
+ private
16
+
17
+ def clear_indexes
18
+ delete_file_with_lock(Fontist.system_index_path)
19
+ delete_file_with_lock(Fontist.system_preferred_family_index_path)
20
+ end
21
+
22
+ def delete_file_with_lock(path)
23
+ path.delete if path.exist?
24
+ lock_path = Pathname.new Fontist::Utils::Cache.lock_path(path)
25
+ lock_path.delete if lock_path.exist?
26
+ end
13
27
  end
14
28
  end
data/lib/fontist/repo.rb CHANGED
@@ -1,6 +1,62 @@
1
1
  require "git"
2
2
 
3
3
  module Fontist
4
+ class Info
5
+ attr_reader :name, :metadata, :formulas
6
+
7
+ def initialize(name, path)
8
+ @name = name
9
+ @metadata = build_metadata(path)
10
+ @formulas = build_formulas(path)
11
+ end
12
+
13
+ def to_s
14
+ <<~MSG.chomp
15
+ Repository info for '#{@name}':
16
+ #{@metadata.map { |k, v| " #{k}: #{v}" }.join("\n")}
17
+ Found #{formulas.count} formulas:
18
+ #{@formulas.map { |info| "- #{info.description} (#{info.name})" }.join("\n")}
19
+ MSG
20
+ end
21
+
22
+ private
23
+
24
+ def build_metadata(path)
25
+ repo = Git.open(path)
26
+
27
+ {
28
+ url: repo.config["remote.origin.url"],
29
+ revision: revision(repo),
30
+ created: created(repo),
31
+ updated: updated(repo),
32
+ dirty: dirty?(repo),
33
+ }
34
+ end
35
+
36
+ def build_formulas(path)
37
+ path.glob("*.yml").map do |formula_path|
38
+ formula = Formula.new_from_file(formula_path)
39
+ Struct.new(:name, :description).new(formula.key, formula.description)
40
+ end
41
+ end
42
+
43
+ def revision(repo)
44
+ repo.log.first.sha[0..6]
45
+ end
46
+
47
+ def created(repo)
48
+ repo.gcommit(repo.log.last.sha).date
49
+ end
50
+
51
+ def updated(repo)
52
+ repo.gcommit(repo.log.first.sha).date
53
+ end
54
+
55
+ def dirty?(repo)
56
+ !repo.status.changed.empty?
57
+ end
58
+ end
59
+
4
60
  class Repo
5
61
  class << self
6
62
  def setup(name, url)
@@ -47,11 +103,20 @@ module Fontist
47
103
  .map { |path| File.basename(path) }
48
104
  end
49
105
 
106
+ def info(name)
107
+ path = Pathname.new repo_path(name)
108
+ unless path.exist?
109
+ raise(Errors::RepoNotFoundError, "No such repo '#{name}'.")
110
+ end
111
+
112
+ Info.new(name, path)
113
+ end
114
+
50
115
  private
51
116
 
52
117
  def ensure_private_formulas_path_exists
53
118
  Fontist.private_formulas_path.tap do |path|
54
- FileUtils.mkdir_p(path) unless Dir.exist?(path)
119
+ FileUtils.mkdir_p(path)
55
120
  end
56
121
  end
57
122
 
@@ -47,6 +47,16 @@ module Fontist
47
47
  CLI::STATUS_SUCCESS
48
48
  end
49
49
 
50
+ desc "info NAME", "Information about repos"
51
+ def info(name)
52
+ handle_class_options(options)
53
+ info = Repo.info(name)
54
+ Fontist.ui.say(info.to_s)
55
+ CLI::STATUS_SUCCESS
56
+ rescue Errors::RepoNotFoundError
57
+ handle_repo_not_found(name)
58
+ end
59
+
50
60
  private
51
61
 
52
62
  def handle_repo_not_found(name)
@@ -121,7 +121,7 @@ module Fontist
121
121
  end
122
122
 
123
123
  def lock_path
124
- "#{@index_path}.lock"
124
+ Utils::Cache.lock_path(@index_path)
125
125
  end
126
126
 
127
127
  def do_build_index
@@ -3,6 +3,10 @@ module Fontist
3
3
  class Cache
4
4
  include Locking
5
5
 
6
+ def self.lock_path(path)
7
+ "#{path}.lock"
8
+ end
9
+
6
10
  def fetch(key)
7
11
  map = load_cache
8
12
  if cache_exist?(map[key])
@@ -79,7 +83,7 @@ module Fontist
79
83
  end
80
84
 
81
85
  def lock_path
82
- cache_map_path.to_s + ".lock"
86
+ Cache.lock_path(cache_map_path)
83
87
  end
84
88
 
85
89
  def move_to_downloads(source)
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.15.0".freeze
2
+ VERSION = "1.15.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-03 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.1
89
+ version: 1.2.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.1
96
+ version: 1.2.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: git
99
99
  requirement: !ruby/object:Gem::Requirement