Module: WebFont::Index
- Defined in:
- lib/web_font/index.rb
Constant Summary collapse
- INDEX_URL =
'https://www.googleapis.com/webfonts/v1/webfonts'
Class Attribute Summary collapse
-
.path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
-
.download ⇒ Object
Download font index from Google, save it locally and index it.
Class Attribute Details
.path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/web_font/index.rb', line 7 def path @path end |
Class Method Details
.download ⇒ Object
Download font index from Google, save it locally and index it.
fonts.json schema: {
"kind": "webfonts#webfontList",
"items": [
{
"kind": "webfonts#webfont",
"family": "ABeeZee",
"variants": [
"regular",
"italic"
],
"subsets": [
"latin"
],
"version": "v1",
"lastModified": "2013-12-16",
"files": {
"regular": "http://themes.googleusercontent.com/static/fonts/abeezee/v1/mE5BOuZKGln_Ex0uYKpIaw.ttf",
"italic": "http://themes.googleusercontent.com/static/fonts/abeezee/v1/kpplLynmYgP0YtlJA3atRw.ttf"
}
},
{ ... },
{ ... }
]
}
Returns nothing
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/web_font/index.rb', line 39 def self.download raise 'WebFont::Index.path is empty' unless path raise "ENV['GOOGLE_API_KEY'] is empty" unless ENV['GOOGLE_API_KEY'] FileUtils.mkdir_p(path) unless Dir.exist?(path) uri = "#{INDEX_URL}?key=#{ENV['GOOGLE_API_KEY']}" output_path = "#{path}/fonts.json" HTTP.get(uri, output_path) index end |