web_font 0.1.4 → 0.1.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: 2fd9d7e518f79d7f0ad465daa7db661ad5768675
4
- data.tar.gz: 0277c9838c048ebd6f8bd7eba40c1c3740fddbaf
3
+ metadata.gz: 2d108bd77059dc95c5ff4646c0773126e053142e
4
+ data.tar.gz: e7c9b177fbd6d2f0d00afd6e1a118692ee1adb82
5
5
  SHA512:
6
- metadata.gz: 0bce25cf2e2b1d24e35d85a7872b87a10b5aaa9a8cc258a5197c427983573313cac5a3827c56f3fb3c25f39782459177c144b4380c30054ff29924f0b0dcc182
7
- data.tar.gz: 999010249f27efe2095358ee07c361ee233ed0bc78105c08b23092f6d07b81c5f320a4989af8cdb834d4a8a2e7fba394ab6b32ff10b031810fc17461b4dab73a
6
+ metadata.gz: 64a49c44d1084d7b9335847cf9e0532f8384a6977562792fbbd46e485cced4547311fa0ef3d71748ed21ee25ba3908db8d6937b71febc5afab6d28353f0fd74f
7
+ data.tar.gz: 03b5ac9c474fdda0cdec1944cc9ac240438d536ebdb923ca8153b85432b01124ef2108f068b1f7ea1af9038634a6269794d14ff3610128dc2a059dd312d94320
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ spec/reports
19
19
  test/tmp
20
20
  test/version_tmp
21
21
  tmp
22
+ cache
data/Rakefile CHANGED
@@ -1,7 +1,16 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
+ require 'web_font/cache_task'
3
4
 
4
5
  Rake::TestTask.new do |t|
5
6
  t.pattern = './test/lib/**/*_test.rb'
6
7
  end
7
8
  task default: :test
9
+
10
+ # ENV['GOOGLE_API_KEY'] ||= ''
11
+ WebFont::Index.path = File.expand_path('../cache/index', __FILE__)
12
+
13
+ WebFont::LocalCache.cache = true
14
+ WebFont::LocalCache.cache_path = File.expand_path('../cache/fonts', __FILE__)
15
+
16
+ WebFont::CacheTask.define_tasks!
@@ -0,0 +1,50 @@
1
+ require 'rake/tasklib'
2
+
3
+ require 'web_font'
4
+
5
+ module WebFont
6
+ class CacheTask < Rake::TaskLib
7
+ attr_accessor :name, :verbose
8
+
9
+ def self.define_tasks!
10
+ new
11
+ end
12
+
13
+ def initialize
14
+ define_tasks
15
+ end
16
+
17
+ private
18
+
19
+ def define_tasks
20
+ namespace :web_font do
21
+ desc 'Download google fonts'
22
+ task :cache_fonts do
23
+ WebFont::Index.download
24
+
25
+ unless Dir.exist?(WebFont::LocalCache.cache_path)
26
+ FileUtils.mkdir_p(WebFont::LocalCache.cache_path)
27
+ end
28
+
29
+ downloader = WebFont::Downloader.new
30
+
31
+ file_path = "#{WebFont::Index.path}/fonts.json"
32
+ hash = JSON.parse(File.open(file_path).read)
33
+
34
+ hash['items'].each_with_index do |item, index|
35
+ family = item['family']
36
+
37
+ puts family
38
+
39
+ downloader.download(family, WebFont::LocalCache.cache_path, false)
40
+ end
41
+
42
+ puts "\n"
43
+ puts '=' * 50
44
+ puts 'ALL FONTS ARE DOWNLOADED...'
45
+ puts '=' * 50
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -13,7 +13,7 @@ module WebFont
13
13
 
14
14
  filename = File.basename(font)
15
15
  path = File.join(cache_path, filename)
16
- FileUtils.copy(font, path)
16
+ FileUtils.copy(font, path) unless font == path
17
17
 
18
18
  path
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module WebFont
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_font
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sophy Eung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-13 00:00:00.000000000 Z
11
+ date: 2014-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - README.md
80
80
  - Rakefile
81
81
  - lib/web_font.rb
82
+ - lib/web_font/cache_task.rb
82
83
  - lib/web_font/command.rb
83
84
  - lib/web_font/downloader.rb
84
85
  - lib/web_font/finder.rb