web_font 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 1797db0f5be3a95b6051fa734a0792eb31008d2a
4
- data.tar.gz: 8335727402909e97cd97e99473fdb68a97e3cee4
3
+ metadata.gz: f0d8d2461c2cb78dac3588cd7931d18df3b224fd
4
+ data.tar.gz: 29d992b865a5269e535c67a5d570080911a2f88d
5
5
  SHA512:
6
- metadata.gz: 67a78d99efcd2aee784a49c04394affd67cf59cccd3fa8224398639a7e400be1d26876f42073cc8944b32df85215cfc4744274134adeed314960cf718478cccd
7
- data.tar.gz: 756237552de9293071d2fe19b3b5c0ed03d83b22a0616bee67bb47206e6e160b2d8078f8aa4aa2af8682544c5d0ad41306efd85eaafe93978bc7d354be7f013a
6
+ metadata.gz: 960e90afc819598b1aec864e99ae752dbe19067ffe1c176a083fdda32d57ad78ae3b9a4051ce0a98ff926788b0e1b48a84a3bb54c593d755e6c50f45eac60e03
7
+ data.tar.gz: 99006b36361eaf44927a527009f1f6f677d8cb7440bc5ce2a753bf9cba10e0afc7c6335f6a94a1a33b510c343582824cb7da1ebd250759465f3758ca066bb3b4
@@ -27,6 +27,19 @@ module WebFont
27
27
  item || {}
28
28
  end
29
29
 
30
+ # A convenient method to get all font variants
31
+ #
32
+ # Returns array
33
+ def info(font_family)
34
+ item = find(font_family)
35
+ return [] unless item['family']
36
+
37
+ font_family = item['family'].gsub(/\s/, '-')
38
+ item['files'].map do |variant, url|
39
+ "#{font_family}-#{variant}#{File.extname(url)}"
40
+ end
41
+ end
42
+
30
43
  private
31
44
 
32
45
  def match?(font_family1, font_family2)
@@ -1,3 +1,3 @@
1
1
  module WebFont
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -6,7 +6,7 @@ describe WebFont::Finder do
6
6
  describe '#find' do
7
7
  it 'returns font data when it found one' do
8
8
  font_name = 'Open Sans'
9
- item = finder.find(font_name)
9
+ item = finder.find('Open Sans')
10
10
 
11
11
  item['family'].must_equal font_name
12
12
  end
@@ -18,4 +18,24 @@ describe WebFont::Finder do
18
18
  item.must_be_empty
19
19
  end
20
20
  end
21
+
22
+ describe '#info' do
23
+ it 'returns font info' do
24
+ info = finder.info('Open Sans')
25
+
26
+ info.must_equal ['Open-Sans-300.ttf', 'Open-Sans-300italic.ttf',
27
+ 'Open-Sans-regular.ttf', 'Open-Sans-italic.ttf',
28
+ 'Open-Sans-600.ttf', 'Open-Sans-600italic.ttf',
29
+ 'Open-Sans-700.ttf', 'Open-Sans-700italic.ttf',
30
+ 'Open-Sans-800.ttf', 'Open-Sans-800italic.ttf']
31
+ end
32
+
33
+ describe 'when font is not available' do
34
+ it 'returns empty array' do
35
+ info = finder.info('Arial')
36
+
37
+ info.must_be_empty
38
+ end
39
+ end
40
+ end
21
41
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  gem 'minitest'
2
2
  require 'minitest/autorun'
3
+ require 'pp'
3
4
 
4
5
  require 'web_font'
5
6
  WebFont::Data.path = File.join(WebFont.test_root, 'data', 'google')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_font
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sophy Eung