fontist 1.11.2 → 1.11.3

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: 13b78039fab8bac4324cc22dc75a21beac4dd1303853ed782cabf1e89b78617c
4
- data.tar.gz: d9ddc52af7fce3a9650b227170940c78e757266d27215add37cac136b8710548
3
+ metadata.gz: 0461da7c09c672b443f4a0bad5443f3bf48294cb3e0aee5ea7082838825519ca
4
+ data.tar.gz: 0e5931e6617e4484074b7d740fbe9f593dc3a31d9b524859167d90cdfc060498
5
5
  SHA512:
6
- metadata.gz: 8e88289ff2d6acac6c10599332227163d41ac6fcc7ea2f7acb6d2a4c5e62dec6ab814aecc2e807e08f5de4a3491abf69a88e9648d2ef8829dbd4885dfcd8954c
7
- data.tar.gz: 2b67bf621a77b9d9882af25329930e3900c8e852077822dd2582ece1b6528e1fc63ec8c9f7404b89505b8a3d17377e841e476c264e2a7b837dbdab35dfe2c243
6
+ metadata.gz: c0b30b8bfc0f01507d436dea54d5b122751c852a63d2309a5236a5a5f698c140892e54c2f665dbbce4bf0c6f6276c9a7cd1910f212aa7a27937ceca1b8ba510d
7
+ data.tar.gz: de92e684e1368ee2a5c10d1789962181316590b87ea5b806d8fd0a959329c54dd0d95723d99334038f75e2865d277b12dbc2c17aeed39b5b57436506273e7be4
data/fontist.gemspec CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "nokogiri", "~> 1.0"
41
41
  spec.add_development_dependency "rake", "~> 13"
42
42
  spec.add_development_dependency "rspec", "~> 3.0"
43
+ spec.add_development_dependency "rspec-benchmark", "~> 0.6"
43
44
  spec.add_development_dependency "rubocop", "1.5.2"
44
45
  spec.add_development_dependency "rubocop-rails"
45
46
  spec.add_development_dependency "rubocop-performance"
@@ -4,7 +4,7 @@ module Fontist
4
4
  module Import
5
5
  class RecursiveExtraction
6
6
  LICENSE_PATTERN =
7
- /(ofl\.txt|ufl\.txt|licenses?\.txt|license|copying)$/i.freeze
7
+ /(ofl\.txt|ufl\.txt|licenses?\.txt|license(\.md)?|copying)$/i.freeze
8
8
 
9
9
  def initialize(archive, subarchive: nil, subdir: nil)
10
10
  @archive = archive
@@ -70,6 +70,8 @@ module Fontist
70
70
 
71
71
  def extract_data(archive)
72
72
  Excavate::Archive.new(path(archive)).files(recursive_packages: true) do |path|
73
+ next unless File.file?(path)
74
+
73
75
  match_license(path)
74
76
  match_font(path) if font_directory?(path)
75
77
  end
@@ -12,6 +12,10 @@ module Fontist
12
12
  end
13
13
 
14
14
  def self.system_font_paths
15
+ @system_font_paths ||= load_system_font_paths
16
+ end
17
+
18
+ def self.load_system_font_paths
15
19
  config_path = Fontist.system_file_path
16
20
  os = Fontist::Utils::System.user_os.to_s
17
21
  templates = YAML.load_file(config_path)["system"][os]["paths"]
@@ -20,6 +24,10 @@ module Fontist
20
24
  Dir.glob(patterns)
21
25
  end
22
26
 
27
+ def self.reset_system_font_paths_cache
28
+ @system_font_paths = nil
29
+ end
30
+
23
31
  def self.expand_paths(paths)
24
32
  paths.map do |path|
25
33
  require "etc"
@@ -37,35 +37,39 @@ module Fontist
37
37
  LANGUAGE_MAC_ENGLISH = 0
38
38
  LANGUAGE_MS_ENGLISH_AMERICAN = 0x409
39
39
 
40
- attr_reader :font_paths
41
-
42
40
  def self.system_index
43
- if Fontist.preferred_family?
44
- new(Fontist.system_preferred_family_index_path,
45
- SystemFont.font_paths,
46
- PreferredFamily.new)
47
- else
48
- new(Fontist.system_index_path,
49
- SystemFont.font_paths,
50
- DefaultFamily.new)
51
- end
41
+ path = if Fontist.preferred_family?
42
+ Fontist.system_preferred_family_index_path
43
+ else
44
+ Fontist.system_index_path
45
+ end
46
+
47
+ @system_index ||= {}
48
+ @system_index[Fontist.preferred_family?] ||= {}
49
+ @system_index[Fontist.preferred_family?][path] ||=
50
+ new(path, -> { SystemFont.font_paths }, family)
52
51
  end
53
52
 
54
53
  def self.fontist_index
55
- if Fontist.preferred_family?
56
- new(Fontist.fontist_preferred_family_index_path,
57
- SystemFont.fontist_font_paths,
58
- PreferredFamily.new)
59
- else
60
- new(Fontist.fontist_index_path,
61
- SystemFont.fontist_font_paths,
62
- DefaultFamily.new)
63
- end
54
+ path = if Fontist.preferred_family?
55
+ Fontist.fontist_preferred_family_index_path
56
+ else
57
+ Fontist.fontist_index_path
58
+ end
59
+
60
+ @fontist_index ||= {}
61
+ @fontist_index[Fontist.preferred_family?] ||= {}
62
+ @fontist_index[Fontist.preferred_family?][path] ||=
63
+ new(path, -> { SystemFont.fontist_font_paths }, family)
64
64
  end
65
65
 
66
- def initialize(index_path, font_paths, family)
66
+ def self.family
67
+ Fontist.preferred_family? ? PreferredFamily.new : DefaultFamily.new
68
+ end
69
+
70
+ def initialize(index_path, font_paths_fetcher, family)
67
71
  @index_path = index_path
68
- @font_paths = font_paths
72
+ @font_paths_fetcher = font_paths_fetcher
69
73
  @family = family
70
74
  end
71
75
 
@@ -85,7 +89,18 @@ module Fontist
85
89
  private
86
90
 
87
91
  def index
88
- @index ||= build_index
92
+ return @index unless index_changed?
93
+
94
+ @index = build_index
95
+ end
96
+
97
+ def index_changed?
98
+ @index.nil? ||
99
+ @index.map { |x| x[:path] }.uniq.sort != font_paths.sort
100
+ end
101
+
102
+ def font_paths
103
+ @font_paths_fetcher.call
89
104
  end
90
105
 
91
106
  def build_index
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "1.11.2".freeze
2
+ VERSION = "1.11.3".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.11.2
4
+ version: 1.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-11 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '3.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rspec-benchmark
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.6'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.6'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: rubocop
183
197
  requirement: !ruby/object:Gem::Requirement