typie 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1 @@
1
+ --private
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem 'typekit', '~> 0.2.3'
6
+
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem "shoulda", ">= 0"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.5.2"
13
+ gem "rcov", ">= 0"
14
+ end
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ crack (0.1.8)
5
+ git (1.2.5)
6
+ httparty (0.7.4)
7
+ crack (= 0.1.8)
8
+ jeweler (1.5.2)
9
+ bundler (~> 1.0.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ rake (0.8.7)
13
+ rcov (0.9.9)
14
+ shoulda (2.11.3)
15
+ typekit (0.2.3)
16
+ httparty (~> 0.7.3)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ bundler (~> 1.0.0)
23
+ jeweler (~> 1.5.2)
24
+ rcov
25
+ shoulda
26
+ typekit (~> 0.2.3)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Corey Ward
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ Typie – Typekit Kits Made Easy
2
+ ==============================
3
+
4
+ Typie helps you create [Typekit](http://typekit.com/) kits with custom domains for each of your users' custom domains. This allows hosting user websites with badass typography, easily.
5
+
6
+ Usage
7
+ -----
8
+
9
+ So hotshot John Smith wants you to be his [Flavors.me](http://flavors.me/) using on his own 'thejohnsmith.com' domain name. You don't want to give up the really awesome Calluna font you've been using through Typekit. So what do you do? Drop in a Typie and tell your boss you deserve a raise.
10
+
11
+ Typie.new_kit :token => 'your_api_token' do
12
+ call_it 'JohnSmith'
13
+ add_domains 'localhost', 'thejohnsmith.com'
14
+ add_font 'Calluna', :include_variations => ['n3', 'n4', 'i4', 'n6']
15
+ add_font 'Calluna Sans' # includes all available variations (watch out for large kit sizes)
16
+ end
17
+ #=> 'abcdef' (Typekit Kit ID)
18
+
19
+ Typie returns the Typekit Kit ID. You can store it along with the domain or user information, then you can easily use the Typekit API to add or remove domains, fonts, and variations, or delete it when you're done with it. Typie uses the [Typekit API Ruby Client](http://github.com/coreyward/typekit) gem. If you find yourself needing to do more than what Typie offers, check it out.
20
+
21
+ #### Font Variation Descriptions
22
+
23
+ If you're not familiar with "Font Variation Descriptions" like 'n4' and 'i6', you should check out [this page](http://typekit.github.com/fvd/) where they are explained in detail. In the future Typie will probably allow you to use Font Names like 'Calluna Regular' and 'Calluna Black Italic', but for now it uses the same FVDs that the Typekit API uses.
24
+
25
+
26
+ Install
27
+ -------
28
+
29
+ Typie is available as a RubyGem. You can install it like so:
30
+
31
+ gem install typie
32
+
33
+ Or if you'll be using Typie in a Rails project (or anywhere else with a Gemfile):
34
+
35
+ gem 'typie'
36
+
37
+ Note that Typie currently requires Ruby 1.9+, or that you have added a Symbol#to_proc method.
38
+
39
+ Documentation
40
+ -------------
41
+
42
+ Full documentation is available at [http://rubydoc.info/github/coreyward/typie](http://rubydoc.info/github/coreyward/typie).
43
+
44
+ Contributing to Typie
45
+ ---------------------
46
+
47
+ * Fork the project
48
+ * Start a feature/bugfix branch
49
+ * Add [yard](http://yardoc.org/)-compatible documentation for your changes, where relevant. Follow the existing styles.
50
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
51
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
52
+
53
+ Copyright
54
+ ---------
55
+
56
+ Copyright (c) 2011 Corey Ward. Licensed under the "MIT" license. See LICENSE.txt for further details.
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "typie"
16
+ gem.homepage = "http://github.com/coreyward/typie"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Create Typekit kits for each of your users easily with Typie.}
19
+ gem.description = %Q{Typie helps you create kits with custom domains for each of your users' custom domains. This allows hosting user websites with badass typography, easily.}
20
+ gem.email = "corey.atx@gmail.com"
21
+ gem.authors = ["Corey Ward"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "typie #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,64 @@
1
+ require 'typekit'
2
+
3
+ class Typie
4
+ class << self
5
+
6
+ # Add a Kit to Typekit
7
+ # @param options [Hash]
8
+ # @option options [String] :token Required: Your Typekit API Token
9
+ # @return [String] Typekit Kit ID of the resulting Kit
10
+ def new_kit(options = {}, &block)
11
+ raise 'Token required' unless options[:token]
12
+
13
+ # Setup Typie
14
+ @typekit = Typekit::Client.new(options[:token])
15
+ @settings = { :name => 'Unnamed', :domains => [] }
16
+ @fonts = []
17
+
18
+ # Wreak havoc
19
+ instance_eval &block
20
+
21
+ # Handle it all
22
+ kit = @typekit.create_kit @settings
23
+ @fonts.each do |font|
24
+ kit.add_family(font[:id], :variations => font[:variations])
25
+ end
26
+
27
+ kit.id
28
+ end
29
+
30
+ private
31
+
32
+ # Set the name of the Kit
33
+ # @param name [String] The desired name
34
+ def call_it(name)
35
+ @settings[:name] = name
36
+ end
37
+
38
+ # Add domains for Typekit to serve this Kit to
39
+ # @param domains [Array] An array of the domains to allow
40
+ def add_domains(*domains)
41
+ @settings[:domains] << domains
42
+ @settings[:domains].flatten!
43
+ end
44
+ alias :add_domain :add_domains
45
+
46
+ # Add a Family to the Kit
47
+ # @param name [String] The Family name (must match Typekit exactly)
48
+ # @param options [Hash]
49
+ # @option options [Array] :include_variations An array of Font Variation Descriptions to be included
50
+ def add_font(name, options = {})
51
+ font = @typekit.family_by_name(name)
52
+
53
+ if options[:include_variations]
54
+ # We're silently ignoring invalid variations
55
+ variations = options[:include_variations] & font.variations.map(&:to_fvd)
56
+ else
57
+ # Add all variations available by default
58
+ variations = font.variations.map(&:to_fvd)
59
+ end
60
+
61
+ @fonts << { :id => font.id, :variations => variations }
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'typie'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestTypie < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typie
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Corey Ward
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-02-17 00:00:00 -06:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: typekit
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.2.3
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: shoulda
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: bundler
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: jeweler
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.5.2
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rcov
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ description: Typie helps you create kits with custom domains for each of your users' custom domains. This allows hosting user websites with badass typography, easily.
72
+ email: corey.atx@gmail.com
73
+ executables: []
74
+
75
+ extensions: []
76
+
77
+ extra_rdoc_files:
78
+ - LICENSE.txt
79
+ - README.md
80
+ files:
81
+ - .document
82
+ - .yardopts
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - VERSION
89
+ - lib/typie.rb
90
+ - test/helper.rb
91
+ - test/test_typie.rb
92
+ has_rdoc: true
93
+ homepage: http://github.com/coreyward/typie
94
+ licenses:
95
+ - MIT
96
+ post_install_message:
97
+ rdoc_options: []
98
+
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: -4584652167556624863
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ requirements: []
117
+
118
+ rubyforge_project:
119
+ rubygems_version: 1.5.2
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Create Typekit kits for each of your users easily with Typie.
123
+ test_files:
124
+ - test/helper.rb
125
+ - test/test_typie.rb