fontpair 0.1.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5ee3429eea88097822aea991f8852602d115f38f
4
+ data.tar.gz: 22fe426df7b0790de9c40477819f532a559c6c45
5
+ SHA512:
6
+ metadata.gz: 71b7e6b81f7ee80ac84530471bd00386df933f9ba45a232577626bb0c0bdcbe82f33773bdcc677bc9f648e2c408256a85c366d801f92a52d88911591f15cc721
7
+ data.tar.gz: b4a222ed3d8fa25d00fd706f7f158c2e2363f48b47c0f9fd275787010da30d9edf92114a14743866b83eda424981d533bc158b985b5a7cc9ac24894e679114fe
data/bin/fontpair ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require_relative '../lib/fontpair'
5
+ require 'optparse'
6
+
7
+ OptionParser.new do |opts|
8
+ opts.banner = 'Usage: fontpair <fontname>'
9
+
10
+ opts.on('-v', '--version', 'Show program version') do
11
+ $stderr.puts "fontpair ver#{FontPair::VERSION} | Based on http://fontpair.co"
12
+ end
13
+
14
+ opts.on('-f [FONT]', '--font [FONT]', 'Specify font to pair') do |font|
15
+ if font.nil?
16
+ $stderr.puts 'You must specify a font to pair.'
17
+ exit 1
18
+ end
19
+
20
+ results = FontPair::Search.new(font)
21
+ results.pretty_print
22
+ end
23
+ end.parse!
data/lib/fontpair.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'net/http'
2
+ require 'nokogiri'
3
+
4
+ require_relative 'fontpair/search'
5
+ require_relative 'fontpair/version'
6
+
7
+ ##
8
+ # Implements a way to access to FontPair.co data directly from command-line.
9
+ module FontPair
10
+ end
@@ -0,0 +1,35 @@
1
+ module FontPair
2
+ ##
3
+ # Search pairs for a specific typeface.
4
+ class Search
5
+ attr_reader :pairs
6
+
7
+ SOURCE_URL = 'http://fontpair.co'.freeze
8
+
9
+ def initialize(typeface)
10
+ @typeface = typeface.downcase
11
+ @pairs = find_pairs
12
+ end
13
+
14
+ def pretty_print
15
+ if pairs.length.zero?
16
+ $stderr.puts 'No pairs found'
17
+ return
18
+ end
19
+
20
+ $stderr.puts 'You should consider the following pairs:'
21
+ pairs.each { |pair| $stderr.puts " + #{pair}" }
22
+ end
23
+
24
+ private
25
+
26
+ def find_pairs
27
+ data = Net::HTTP.get(URI(SOURCE_URL))
28
+ font_pairs = Nokogiri::HTML(data).css('.fontName').map { |pair| pair.content }
29
+
30
+ # Delete the sections' headings and filter the pairs.
31
+ font_pairs.select { |pair| pair.downcase.match(%r{\band\b}) }
32
+ .select { |pair| pair.downcase.match(%r{\b#{@typeface}\b}) }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module FontPair
2
+ VERSION = '0.1.0.1'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fontpair
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dom Corvasce
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ description: A command-line utility to pair fonts based on http://fontpair.co
28
+ email: dom.corvasce@yandex.com
29
+ executables:
30
+ - fontpair
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/fontpair
35
+ - lib/fontpair.rb
36
+ - lib/fontpair/search.rb
37
+ - lib/fontpair/version.rb
38
+ homepage: https://github.com/domcorvasce/fontpair
39
+ licenses:
40
+ - GPL-3.0
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 2.6.11
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Pair fonts directly from command-line
62
+ test_files: []