nuts 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in nuts.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/nuts ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path("../../lib", __FILE__)
3
+ require "nuts/cli"
4
+ Nuts::CLI.start
data/lib/nuts.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "nuts/version"
2
+
3
+ module Nuts
4
+ # Your code goes here...
5
+ end
data/lib/nuts/cli.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'nuts'
2
+ require 'net/http'
3
+ require 'json'
4
+ require 'thor'
5
+
6
+ class Nuts::CLI < Thor
7
+ URL = "http://www.fontsquirrel.com"
8
+
9
+ desc "list [search_term]", "list available fonts"
10
+ def list(term=nil)
11
+ url = URI.parse("#{URL}/api/fontlist/all")
12
+ req = Net::HTTP::Get.new(url.path)
13
+ res = Net::HTTP.start(url.host, url.port) do |http|
14
+ http.request(req)
15
+ end
16
+ result = JSON.parse(res.body)
17
+ if term
18
+ filtered = result.find_all { |item| item["family_urlname"] =~ /#{term}/i }
19
+ else
20
+ filtered = result
21
+ end
22
+ print(filtered)
23
+ end
24
+
25
+ desc "show", "show font"
26
+ def show(font_slug=nil)
27
+ end
28
+
29
+ desc "install", "install font"
30
+ def install(font_slug=nil)
31
+ `mkdir -p ./app/assets/fonts/#{font_slug} &&
32
+ cd ./app/assets/fonts/#{font_slug} &&
33
+ wget #{URL}/fontfacekit/#{font_slug} &&
34
+ unzip #{font_slug} &&
35
+ sed "s#url('#url('/assets/#{font_slug}/#g" ./stylesheet.css > ./../../stylesheets/#{font_slug}.css
36
+ rm demo.html &&
37
+ rm #{font_slug}`
38
+ end
39
+
40
+ private
41
+
42
+ def print(data)
43
+ data.each do |value|
44
+ item = value['family_urlname']
45
+ puts "#{item}"
46
+ end
47
+ end
48
+ end
49
+
50
+
@@ -0,0 +1,3 @@
1
+ module Nuts
2
+ VERSION = "0.0.1"
3
+ end
data/nuts.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "nuts/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "nuts"
7
+ s.version = Nuts::VERSION
8
+ s.authors = ["Phil"]
9
+ s.email = ["phil.mcclure@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Install fonts from fontsquirrel.com with ease}
12
+ s.description = %q{Install fonts from fontsquirrel.com with ease}
13
+
14
+ s.rubyforge_project = "nuts"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nuts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Phil
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-29 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Install fonts from fontsquirrel.com with ease
15
+ email:
16
+ - phil.mcclure@gmail.com
17
+ executables:
18
+ - nuts
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - Rakefile
25
+ - bin/nuts
26
+ - lib/nuts.rb
27
+ - lib/nuts/cli.rb
28
+ - lib/nuts/version.rb
29
+ - nuts.gemspec
30
+ homepage: ''
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project: nuts
50
+ rubygems_version: 1.8.11
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Install fonts from fontsquirrel.com with ease
54
+ test_files: []