web_font 0.1.14 → 0.2.0

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: 2fec2cb86562a54ec598f8f6a8547cca984ec5c9
4
- data.tar.gz: 5cba31ab3971229eb4a0ef322bf93bd57949f756
3
+ metadata.gz: 5aed946344dcdee1067007706303701cdfc09e48
4
+ data.tar.gz: a6e6e750732d54b41c00a0649464f1d5f5946131
5
5
  SHA512:
6
- metadata.gz: 337975c1ba68019d4d001aa2ee8887d9b7d25ea96783d0914828b71bf4427bb4a77f877a9021ffbca6bda0440fc5392402dfda8dc56e8e01ac406ac785bdc602
7
- data.tar.gz: b54a49889d2ac7c904536d38795c0a87d9220171b45768c9ebe0312830288fc5944a7c066fbc37a874e3b2370a82f9c6cc82743d2ca2156bb789c713a3a4094a
6
+ metadata.gz: eb4143e2072560d356fe76b470394032c5fe1246c4a7064168a8fd1b5b05351e52bb0f0dd2736fa61c6ca028e4c5420ffffa8a01b959c85bdd29db4f9ba01fff
7
+ data.tar.gz: d052082c7400f5b1bc5649d0dc867c4a55140f61219ca9eac7c481b863a32532f78b05b15b8067db26354d07888d42cc54f242c279b659f4858846ec4f39ee38
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # WebFont
2
2
 
3
- WebFont is a Ruby library that will help you download fonts from Google. For now, we support only [Google Font](http://www.google.com/fonts).
3
+ WebFont is a Ruby library that will help you download fonts from the web. For now, we support only [Google Font](http://www.google.com/fonts).
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,19 +16,10 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install web_font
18
18
 
19
- ## Dependencies
20
-
21
- WebFont depends on [wget](http://en.wikipedia.org/wiki/Wget). Make sure you have it installed first.
22
-
23
- For Ubuntu:
24
- ```
25
- sudo apt-get install wget
26
- ```
19
+ ## Usage
27
20
 
28
21
  To download font from Google, you need to have [Google API Key](https://www.google.com/search?q=google+api+key), then set ``GOOGLE_API_KEY`` environment variable.
29
22
 
30
- ## Usage
31
-
32
23
  ```ruby
33
24
  require 'web_font'
34
25
 
data/Rakefile CHANGED
@@ -8,9 +8,9 @@ end
8
8
  task default: :test
9
9
 
10
10
  # ENV['GOOGLE_API_KEY'] ||= ''
11
- WebFont::Index.path = File.expand_path('../cache/index', __FILE__)
11
+ WebFont::Index.path = File.join(__dir__, 'cache', 'index')
12
12
 
13
13
  WebFont::LocalCache.cache = true
14
- WebFont::LocalCache.cache_path = File.expand_path('../cache/fonts', __FILE__)
14
+ WebFont::LocalCache.cache_path = File.join(__dir__, 'cache', 'fonts')
15
15
 
16
16
  WebFont::CacheTask.define_tasks!
data/lib/web_font.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'json'
2
2
  require 'fileutils'
3
+ require 'net/http'
3
4
 
4
5
  require 'web_font/version'
5
- require 'web_font/command'
6
+ require 'web_font/http'
6
7
  require 'web_font/downloader'
7
8
  require 'web_font/index'
8
9
  require 'web_font/finder'
@@ -25,7 +25,7 @@ module WebFont
25
25
  downloaded_fonts << font_path
26
26
  else
27
27
  unless File.exist?(font_path)
28
- Command.wget(url, font_path)
28
+ HTTP.get(url, font_path)
29
29
  LocalCache.save(font_path)
30
30
  downloaded_fonts << font_path
31
31
  end
@@ -0,0 +1,8 @@
1
+ module WebFont
2
+ module HTTP
3
+ def self.get(uri, output_path)
4
+ json_str = Net::HTTP.get(URI(uri))
5
+ File.open(output_path, 'w') { |fp| fp.puts(json_str) }
6
+ end
7
+ end
8
+ end
@@ -1,6 +1,8 @@
1
1
  module WebFont
2
2
  module Index
3
3
 
4
+ INDEX_URL = 'https://www.googleapis.com/webfonts/v1/webfonts'
5
+
4
6
  class << self
5
7
  attr_accessor :path
6
8
  end
@@ -40,9 +42,9 @@ module WebFont
40
42
 
41
43
  FileUtils.mkdir_p(path) unless Dir.exist?(path)
42
44
 
43
- url = "https://www.googleapis.com/webfonts/v1/webfonts?key=#{ENV['GOOGLE_API_KEY']}"
45
+ uri = "#{INDEX_URL}?key=#{ENV['GOOGLE_API_KEY']}"
44
46
  output_path = "#{path}/fonts.json"
45
- Command.wget(url, output_path)
47
+ HTTP.get(uri, output_path)
46
48
 
47
49
  index
48
50
  end
@@ -1,3 +1,3 @@
1
1
  module WebFont
2
- VERSION = '0.1.14'
2
+ VERSION = '0.2.0'
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.14
4
+ version: 0.2.0
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-07-18 00:00:00.000000000 Z
11
+ date: 2014-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,9 +80,9 @@ files:
80
80
  - Rakefile
81
81
  - lib/web_font.rb
82
82
  - lib/web_font/cache_task.rb
83
- - lib/web_font/command.rb
84
83
  - lib/web_font/downloader.rb
85
84
  - lib/web_font/finder.rb
85
+ - lib/web_font/http.rb
86
86
  - lib/web_font/index.rb
87
87
  - lib/web_font/local_cache.rb
88
88
  - lib/web_font/version.rb
@@ -1,7 +0,0 @@
1
- module WebFont
2
- module Command
3
- def self.wget(url, output_path)
4
- system("wget -q -O #{output_path} #{url}")
5
- end
6
- end
7
- end