typedeploy 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.md +64 -0
- data/Rakefile +145 -0
- data/lib/typedeploy.rb +9 -0
- data/lib/typedeploy/api.rb +65 -0
- data/lib/typedeploy/api_url.rb +25 -0
- data/lib/typedeploy/config.rb +28 -0
- data/lib/typedeploy/kit.rb +57 -0
- data/lib/typedeploy/kit_loader.rb +21 -0
- data/lib/typedeploy/rake/typedeploytask.rb +71 -0
- data/spec/api_spec.rb +26 -0
- data/spec/api_url_spec.rb +19 -0
- data/spec/config_spec.rb +33 -0
- data/spec/example/kits.yml +2 -0
- data/spec/example/kits/example.yml +15 -0
- data/spec/kit_loader_spec.rb +35 -0
- data/spec/kit_spec.rb +51 -0
- data/spec/spec_helper.rb +6 -0
- data/typedeploy.gemspec +88 -0
- metadata +83 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright 2010 (c) Matt Colyer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
Typedeploy
|
2
|
+
=======
|
3
|
+
|
4
|
+
Manage and deploy your Typekit kits from the comfort of your own project.
|
5
|
+
|
6
|
+
cd ~/Project
|
7
|
+
|
8
|
+
vi Gemfile
|
9
|
+
# Add gem "typedeploy"
|
10
|
+
|
11
|
+
bundle install
|
12
|
+
|
13
|
+
vi Rakefile
|
14
|
+
# Add
|
15
|
+
# require 'typedeploy'
|
16
|
+
# require 'typedeploy/rake/typedeploytask'
|
17
|
+
#
|
18
|
+
# Typedeploy::Config.api_token = 'secrettoken'
|
19
|
+
# Typedeploy::Config.directory = File.dirname(__FILE__)
|
20
|
+
# Typedeploy::TypedeployTask.new
|
21
|
+
|
22
|
+
|
23
|
+
rake typekit:init
|
24
|
+
|
25
|
+
vi kits/example.yml
|
26
|
+
# edit as desired, be sure to change the default domain list
|
27
|
+
|
28
|
+
rake typekit:create
|
29
|
+
rake typekit:update
|
30
|
+
|
31
|
+
Then to use your example kit, do something like this
|
32
|
+
|
33
|
+
require 'rubygems'
|
34
|
+
require 'sinatra'
|
35
|
+
require 'typedeploy'
|
36
|
+
|
37
|
+
Typedeploy::Config.directory = File.dirname(__FILE__)
|
38
|
+
|
39
|
+
get "/" do
|
40
|
+
erb <<-eos
|
41
|
+
<script type="text/javascript" src="http://use.typekit.com/<%= Typedeploy::Config.kits['example'] %>.js"></script>
|
42
|
+
<script type="text/javascript">try{Typekit.load({});}catch(e){}</script>
|
43
|
+
<h1 class="tk-droid-serif">Test</h1>
|
44
|
+
<h1>Control</h1>
|
45
|
+
eos
|
46
|
+
end
|
47
|
+
|
48
|
+
Handling new versions
|
49
|
+
---------------------
|
50
|
+
|
51
|
+
Say you decide that you want to redesign your site but you don't want to break
|
52
|
+
your existing site. Easy. Just make your changes to kits/*.yml and
|
53
|
+
|
54
|
+
rake typekit:create
|
55
|
+
rake typekit:update
|
56
|
+
|
57
|
+
Brand new kits have been created for you to develop with and ultimately
|
58
|
+
publish, that way when you deploy you know that your kits are exactly as you
|
59
|
+
expect.
|
60
|
+
|
61
|
+
Notes
|
62
|
+
-----
|
63
|
+
Be sure to check in your kits.yml and kits/*.yml files as they are now vital to
|
64
|
+
the proper functioning of your project.
|
data/Rakefile
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
require 'rspec/core/rake_task'
|
49
|
+
desc "Run all specs"
|
50
|
+
RSpec::Core::RakeTask.new('test') do |t|
|
51
|
+
t.pattern = './spec/*_spec.rb'
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Generate RCov test coverage and open in your browser"
|
55
|
+
task :coverage do
|
56
|
+
require 'rcov'
|
57
|
+
sh "rm -fr coverage"
|
58
|
+
sh "rcov test/test_*.rb"
|
59
|
+
sh "open coverage/index.html"
|
60
|
+
end
|
61
|
+
|
62
|
+
require 'rake/rdoctask'
|
63
|
+
Rake::RDocTask.new do |rdoc|
|
64
|
+
rdoc.rdoc_dir = 'rdoc'
|
65
|
+
rdoc.title = "#{name} #{version}"
|
66
|
+
rdoc.rdoc_files.include('README*')
|
67
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Open an irb session preloaded with this library"
|
71
|
+
task :console do
|
72
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
73
|
+
end
|
74
|
+
|
75
|
+
#############################################################################
|
76
|
+
#
|
77
|
+
# Custom tasks (add your own tasks here)
|
78
|
+
#
|
79
|
+
#############################################################################
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
#############################################################################
|
84
|
+
#
|
85
|
+
# Packaging tasks
|
86
|
+
#
|
87
|
+
#############################################################################
|
88
|
+
|
89
|
+
task :release => :build do
|
90
|
+
unless `git branch` =~ /^\* master$/
|
91
|
+
puts "You must be on the master branch to release!"
|
92
|
+
exit!
|
93
|
+
end
|
94
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
95
|
+
sh "git tag v#{version}"
|
96
|
+
sh "git push origin master"
|
97
|
+
sh "git push v#{version}"
|
98
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
99
|
+
end
|
100
|
+
|
101
|
+
task :build => :gemspec do
|
102
|
+
sh "mkdir -p pkg"
|
103
|
+
sh "gem build #{gemspec_file}"
|
104
|
+
sh "mv #{gem_file} pkg"
|
105
|
+
end
|
106
|
+
|
107
|
+
task :gemspec => :validate do
|
108
|
+
# read spec file and split out manifest section
|
109
|
+
spec = File.read(gemspec_file)
|
110
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
111
|
+
|
112
|
+
# replace name version and date
|
113
|
+
replace_header(head, :name)
|
114
|
+
replace_header(head, :version)
|
115
|
+
replace_header(head, :date)
|
116
|
+
#comment this out if your rubyforge_project has a different name
|
117
|
+
#replace_header(head, :rubyforge_project)
|
118
|
+
|
119
|
+
# determine file list from git ls-files
|
120
|
+
files = `git ls-files`.
|
121
|
+
split("\n").
|
122
|
+
sort.
|
123
|
+
reject { |file| file =~ /^\./ }.
|
124
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
125
|
+
map { |file| " #{file}" }.
|
126
|
+
join("\n")
|
127
|
+
|
128
|
+
# piece file back together and write
|
129
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
130
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
131
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
132
|
+
puts "Updated #{gemspec_file}"
|
133
|
+
end
|
134
|
+
|
135
|
+
task :validate do
|
136
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
137
|
+
unless libfiles.empty?
|
138
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
139
|
+
exit!
|
140
|
+
end
|
141
|
+
unless Dir['VERSION*'].empty?
|
142
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
143
|
+
exit!
|
144
|
+
end
|
145
|
+
end
|
data/lib/typedeploy.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
|
4
|
+
module Typedeploy
|
5
|
+
class Api
|
6
|
+
def initialize
|
7
|
+
@api_url = ApiUrl.new(Config.url, :yaml)
|
8
|
+
end
|
9
|
+
|
10
|
+
def publish(kid)
|
11
|
+
successful, body = self.class.request(:post, @api_url.publish(kid), {})
|
12
|
+
successful
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(kit)
|
16
|
+
successful, body = self.class.request(:post, @api_url.create, kit.to_params)
|
17
|
+
|
18
|
+
if successful
|
19
|
+
data = YAML.load(body)
|
20
|
+
kit.kid = data['kit']['id']
|
21
|
+
puts "Created #{kit} as #{kit.kid}"
|
22
|
+
|
23
|
+
kit.families.each do |family|
|
24
|
+
successful, body = self.class.request(:post, @api_url.link_family(kit.kid, family.fid), family.to_params)
|
25
|
+
|
26
|
+
if successful
|
27
|
+
puts "#{family} added to #{kit.kid}"
|
28
|
+
else
|
29
|
+
puts "Error adding #{family} to #{kit.kid}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
kit.kid
|
33
|
+
else
|
34
|
+
puts "Error creating #{kit}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def self.request(method, url, data=nil)
|
41
|
+
url = URI.parse("#{url}?token=#{Config.api_token}")
|
42
|
+
|
43
|
+
parsed_url = url.path+"?"+url.query
|
44
|
+
|
45
|
+
req = case method
|
46
|
+
when :get: Net::HTTP::Get.new(parsed_url)
|
47
|
+
when :post: Net::HTTP::Post.new(parsed_url)
|
48
|
+
end
|
49
|
+
|
50
|
+
req.set_form_data(data) if data
|
51
|
+
|
52
|
+
http = Net::HTTP.new(url.host, url.port)
|
53
|
+
http.use_ssl = true
|
54
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
55
|
+
res = http.start { |http| http.request(req) }
|
56
|
+
|
57
|
+
case res
|
58
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
59
|
+
[true, res.body]
|
60
|
+
else
|
61
|
+
[false, res.body]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Typedeploy
|
2
|
+
class ApiUrl
|
3
|
+
def initialize(endpoint, format)
|
4
|
+
@endpoint = endpoint
|
5
|
+
@format = format
|
6
|
+
end
|
7
|
+
|
8
|
+
def publish(kit_id)
|
9
|
+
"#{base}kits/#{kit_id}/publish"
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
"#{base}kits/"
|
14
|
+
end
|
15
|
+
|
16
|
+
def link_family(kit_id, family_id)
|
17
|
+
"#{base}kits/#{kit_id}/families/#{family_id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
def base
|
22
|
+
"#{@endpoint}#{@format}/"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Typedeploy
|
4
|
+
class Config
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
@url = "https://typekit.com/api/v1/"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :directory, :api_token, :url
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.kits_directory
|
14
|
+
File.join(directory, "kits")
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.kits
|
18
|
+
kits = {}
|
19
|
+
kits.default = ""
|
20
|
+
kits.merge!(YAML.load(File.read(kits_file))) if File.exist? kits_file
|
21
|
+
kits
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.kits_file
|
25
|
+
File.join(directory, "kits.yml")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Typedeploy
|
2
|
+
class Kit
|
3
|
+
attr_reader :data
|
4
|
+
attr_accessor :kid
|
5
|
+
|
6
|
+
def initialize(id, data)
|
7
|
+
@kid = id
|
8
|
+
@data = data
|
9
|
+
@api = Api.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def publish
|
13
|
+
@api.publish(@kid)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@api.create(self)
|
18
|
+
end
|
19
|
+
|
20
|
+
class Family
|
21
|
+
def initialize(data)
|
22
|
+
@data = data
|
23
|
+
end
|
24
|
+
|
25
|
+
def fid
|
26
|
+
@data['id']
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_params
|
30
|
+
params = {'variations' => @data['variations'].join(',')}
|
31
|
+
params['subset'] = @data['subset']
|
32
|
+
params
|
33
|
+
end
|
34
|
+
def to_s
|
35
|
+
"<Family #{@data['id']}:#{to_params.inspect}>"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def families
|
40
|
+
@data['families'].map { |f| Family.new(f) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_params
|
44
|
+
params = {'domains' => @data['domains'].join(",")}
|
45
|
+
|
46
|
+
['name', 'badge', 'analytics'].each do |attr|
|
47
|
+
params[attr] = @data[attr]
|
48
|
+
end
|
49
|
+
|
50
|
+
params
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_s
|
54
|
+
"<Kit #{@data['name']}:#{to_params.inspect}>"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Typedeploy
|
4
|
+
class KitLoader
|
5
|
+
def self.each(&block)
|
6
|
+
kits = []
|
7
|
+
Dir.glob(File.join(Config.kits_directory, "*.yml")) do |file|
|
8
|
+
name = File.basename(file, ".yml")
|
9
|
+
kits << [self.parse(Config.kits[name], file), name]
|
10
|
+
end
|
11
|
+
kits.each(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
def self.parse(id, file)
|
16
|
+
data = File.read(file)
|
17
|
+
yaml = YAML.load(data)
|
18
|
+
Kit.new(id, yaml['kit'])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/tasklib'
|
4
|
+
|
5
|
+
module Typedeploy
|
6
|
+
class TypedeployTask
|
7
|
+
def initialize
|
8
|
+
define
|
9
|
+
end
|
10
|
+
|
11
|
+
def define
|
12
|
+
namespace :typedeploy do
|
13
|
+
desc "Create the necessary files to integrate typekit with your project"
|
14
|
+
task :init do
|
15
|
+
FileUtils.mkdir_p(Config.kits_directory)
|
16
|
+
|
17
|
+
example_file = File.join(Config.kits_directory, "example.yml")
|
18
|
+
File.open(example_file, "w") do |f|
|
19
|
+
f.write(<<-eos
|
20
|
+
---
|
21
|
+
kit:
|
22
|
+
name: "example"
|
23
|
+
badge: true
|
24
|
+
analytics: true
|
25
|
+
domains:
|
26
|
+
- localhost
|
27
|
+
families:
|
28
|
+
- id: droid-serif
|
29
|
+
subset: all
|
30
|
+
variations:
|
31
|
+
- n4
|
32
|
+
- i4
|
33
|
+
- n7
|
34
|
+
- i7
|
35
|
+
eos
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Create kits based on definitions in kits/*.yml"
|
41
|
+
task :create do
|
42
|
+
kits = {}
|
43
|
+
Typedeploy::KitLoader.each do |kit, name|
|
44
|
+
kits[name] = kit.create
|
45
|
+
end
|
46
|
+
|
47
|
+
File.open(Config.kits_file, "w") do |f|
|
48
|
+
f.write(kits.to_yaml)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
desc "Update kits with the latest settings in kits/*.yml"
|
54
|
+
task :update do
|
55
|
+
kits = {}
|
56
|
+
Typedeploy::KitLoader.each do |kit, name|
|
57
|
+
kits[name] = kit
|
58
|
+
end
|
59
|
+
|
60
|
+
Typedeploy::Config.kits.each_pair do |name, kit_id|
|
61
|
+
if kits[name].publish
|
62
|
+
puts "#{kit_id} successfully published"
|
63
|
+
else
|
64
|
+
puts "#{kit_id} not published"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/api_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Typedeploy::Api do
|
4
|
+
subject do
|
5
|
+
base_directory = File.join(File.dirname(__FILE__), "example")
|
6
|
+
Typedeploy::Config.directory = base_directory
|
7
|
+
Typedeploy::Api.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can publish a kit" do
|
11
|
+
Typedeploy::Api.should_receive(:request).with(:post, "https://typekit.com/api/v1/yaml/kits/1/publish", {}).and_return(true)
|
12
|
+
subject.publish("1").should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can create a kit" do
|
16
|
+
kit = nil
|
17
|
+
Typedeploy::KitLoader.each { |k, n| kit = k if n == "example"}
|
18
|
+
kit_params = kit.to_params
|
19
|
+
family_params = kit.families.first.to_params
|
20
|
+
|
21
|
+
Typedeploy::Api.should_receive(:request).with(:post, "https://typekit.com/api/v1/yaml/kits/", kit_params).and_return([true, {"kit" => {"id" => "123"}}.to_yaml])
|
22
|
+
Typedeploy::Api.should_receive(:request).with(:post, "https://typekit.com/api/v1/yaml/kits/123/families/droid-serif", family_params).and_return([true, ""])
|
23
|
+
subject.create(kit).should == "123"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Typedeploy::ApiUrl do
|
4
|
+
subject do
|
5
|
+
Typedeploy::ApiUrl.new("/", :yaml)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "can create a kit create url" do
|
9
|
+
subject.create.should == "/yaml/kits/"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can create a family link create url" do
|
13
|
+
subject.link_family(1,2).should == "/yaml/kits/1/families/2"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can create a kit publish url" do
|
17
|
+
subject.publish(1).should == "/yaml/kits/1/publish"
|
18
|
+
end
|
19
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Typedeploy::Config do
|
4
|
+
before(:all) do
|
5
|
+
@base_directory = File.join(File.dirname(__FILE__), "example")
|
6
|
+
Typedeploy::Config.api_token = "token"
|
7
|
+
Typedeploy::Config.directory = @base_directory
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has an api token" do
|
11
|
+
Typedeploy::Config.api_token.should == "token"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has a directory" do
|
15
|
+
Typedeploy::Config.directory.should == @base_directory
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has a kits directory" do
|
19
|
+
Typedeploy::Config.kits_directory.should == File.join(@base_directory, "kits")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has a kits file" do
|
23
|
+
Typedeploy::Config.kits_file.should == File.join(@base_directory, "kits.yml")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can read an existing kit" do
|
27
|
+
Typedeploy::Config.kits.should have_key "example"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can return '' for a missing kit" do
|
31
|
+
Typedeploy::Config.kits['missing'].should == ""
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Typedeploy::KitLoader do
|
4
|
+
subject do
|
5
|
+
@base_directory = File.join(File.dirname(__FILE__), "example")
|
6
|
+
Typedeploy::Config.directory = @base_directory
|
7
|
+
Typedeploy::KitLoader
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can iterate over all existing kit configurations" do
|
11
|
+
kits = {}
|
12
|
+
subject.each { |k, n| kits[n] = k }
|
13
|
+
kits["example"].to_params.should == {
|
14
|
+
"name"=>"example",
|
15
|
+
"domains"=>"localhost",
|
16
|
+
"badge"=>true,
|
17
|
+
"analytics"=>true
|
18
|
+
}
|
19
|
+
|
20
|
+
kits["example"].families.size.should == 1
|
21
|
+
kits["example"].families.first.to_params.should =={
|
22
|
+
"variations"=> "n4,i4,n7,i7",
|
23
|
+
"subset"=>"all"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
context "no created kits" do
|
28
|
+
before(:all) do
|
29
|
+
Typedeploy::Config.directory = "/"
|
30
|
+
end
|
31
|
+
it "can still return .kits" do
|
32
|
+
Typedeploy::Config.kits.should == {}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/kit_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe Typedeploy::Kit do
|
5
|
+
context "hasn't been uploaded" do
|
6
|
+
subject do
|
7
|
+
data = {"name" => "test", "badge" => true, "analytics" => true, "domains" => ["1", "2"],
|
8
|
+
"families" => [{"name" => "test-1", "variations" => ["i7", "n7"], "subset" => "all"}]}
|
9
|
+
Typedeploy::Kit.new(nil, data)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can be published" do
|
13
|
+
subject.should respond_to(:publish)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can be created" do
|
17
|
+
subject.should respond_to(:create)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has one family" do
|
21
|
+
subject.families.length.should == 1
|
22
|
+
params = subject.families.first.to_params
|
23
|
+
params.should have_key "variations"
|
24
|
+
params.should have_key "subset"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "doesn't have a kid" do
|
28
|
+
subject.kid.should be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "can describe itself to the api" do
|
32
|
+
params = subject.to_params
|
33
|
+
params.should have_key "badge"
|
34
|
+
params.should have_key "analytics"
|
35
|
+
params.should have_key "name"
|
36
|
+
params.should have_key "domains"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "has been uploaded" do
|
41
|
+
subject do
|
42
|
+
data = {"name" => "test", "badge" => true, "analytics" => true, "domains" => ["1", "2"],
|
43
|
+
"families" => [{"name" => "test-1", "variations" => ["i7", "n7"], "subset" => "all"}]}
|
44
|
+
Typedeploy::Kit.new("1", data)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has a kid" do
|
48
|
+
subject.kid.should_not be_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/typedeploy.gemspec
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
## This is the rakegem gemspec template. Make sure you read and understand
|
2
|
+
## all of the comments. Some sections require modification, and others can
|
3
|
+
## be deleted if you don't need them. Once you understand the contents of
|
4
|
+
## this file, feel free to delete any comments that begin with two hash marks.
|
5
|
+
## You can find comprehensive Gem::Specification documentation, at
|
6
|
+
## http://docs.rubygems.org/read/chapter/20
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
|
+
s.rubygems_version = '1.3.5'
|
11
|
+
|
12
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
13
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
14
|
+
## the sub! line in the Rakefile
|
15
|
+
s.name = 'typedeploy'
|
16
|
+
s.version = '0.1.0'
|
17
|
+
s.date = '2010-08-06'
|
18
|
+
s.rubyforge_project = 'typedeploy'
|
19
|
+
|
20
|
+
## Make sure your summary is short. The description may be as long
|
21
|
+
## as you like.
|
22
|
+
s.summary = "Manage and deploy your Typekit kits from the comfort of your own project."
|
23
|
+
s.description = "A rubygem which provides several rake tasks to allow you to
|
24
|
+
interact with the Typekit API directly from your project directory."
|
25
|
+
|
26
|
+
## List the primary authors. If there are a bunch of authors, it's probably
|
27
|
+
## better to set the email to an email list or something. If you don't have
|
28
|
+
## a custom homepage, consider using your GitHub URL or the like.
|
29
|
+
s.authors = ["John Doe"]
|
30
|
+
s.email = 'jdoe@example.com'
|
31
|
+
s.homepage = 'http://example.com/typedeploy'
|
32
|
+
|
33
|
+
## This gets added to the $LOAD_PATH so that 'lib/typedeploy.rb' can be required as
|
34
|
+
## require 'typedeploy.rb' or'/lib/typedeploy/file.rb' can be as require 'typedeploy/file.rb'
|
35
|
+
s.require_paths = %w[lib]
|
36
|
+
|
37
|
+
## This sections is only necessary if you have C extensions.
|
38
|
+
#s.require_paths << 'ext'
|
39
|
+
#s.extensions = %w[ext/extconf.rb]
|
40
|
+
|
41
|
+
## If your gem includes any executables, list them here.
|
42
|
+
#s.executables = ["name"]
|
43
|
+
#s.default_executable = 'name'
|
44
|
+
|
45
|
+
## Specify any RDoc options here. You'll want to add your README and
|
46
|
+
## LICENSE files to the extra_rdoc_files list.
|
47
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
48
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
49
|
+
|
50
|
+
## List your runtime dependencies here. Runtime dependencies are those
|
51
|
+
## that are needed for an end user to actually USE your code.
|
52
|
+
#s.add_dependency('DEPtypedeploy', [">= 1.1.0", "< 2.0.0"])
|
53
|
+
|
54
|
+
## List your development dependencies here. Development dependencies are
|
55
|
+
## those that are only needed during development
|
56
|
+
#s.add_development_dependency('DEVDEPtypedeploy', [">= 1.1.0", "< 2.0.0"])
|
57
|
+
|
58
|
+
## Leave this section as-is. It will be automatically generated from the
|
59
|
+
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
60
|
+
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
61
|
+
# = MANIFEST =
|
62
|
+
s.files = %w[
|
63
|
+
LICENSE
|
64
|
+
README.md
|
65
|
+
Rakefile
|
66
|
+
lib/typedeploy.rb
|
67
|
+
lib/typedeploy/api.rb
|
68
|
+
lib/typedeploy/api_url.rb
|
69
|
+
lib/typedeploy/config.rb
|
70
|
+
lib/typedeploy/kit.rb
|
71
|
+
lib/typedeploy/kit_loader.rb
|
72
|
+
lib/typedeploy/rake/typedeploytask.rb
|
73
|
+
spec/api_spec.rb
|
74
|
+
spec/api_url_spec.rb
|
75
|
+
spec/config_spec.rb
|
76
|
+
spec/example/kits.yml
|
77
|
+
spec/example/kits/example.yml
|
78
|
+
spec/kit_loader_spec.rb
|
79
|
+
spec/kit_spec.rb
|
80
|
+
spec/spec_helper.rb
|
81
|
+
typedeploy.gemspec
|
82
|
+
]
|
83
|
+
# = MANIFEST =
|
84
|
+
|
85
|
+
## Test files will be grabbed from the file list. Make sure the path glob
|
86
|
+
## matches what you actually use.
|
87
|
+
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: typedeploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- John Doe
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-06 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: |-
|
22
|
+
A rubygem which provides several rake tasks to allow you to
|
23
|
+
interact with the Typekit API directly from your project directory.
|
24
|
+
email: jdoe@example.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files:
|
30
|
+
- README.md
|
31
|
+
- LICENSE
|
32
|
+
files:
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- lib/typedeploy.rb
|
37
|
+
- lib/typedeploy/api.rb
|
38
|
+
- lib/typedeploy/api_url.rb
|
39
|
+
- lib/typedeploy/config.rb
|
40
|
+
- lib/typedeploy/kit.rb
|
41
|
+
- lib/typedeploy/kit_loader.rb
|
42
|
+
- lib/typedeploy/rake/typedeploytask.rb
|
43
|
+
- spec/api_spec.rb
|
44
|
+
- spec/api_url_spec.rb
|
45
|
+
- spec/config_spec.rb
|
46
|
+
- spec/example/kits.yml
|
47
|
+
- spec/example/kits/example.yml
|
48
|
+
- spec/kit_loader_spec.rb
|
49
|
+
- spec/kit_spec.rb
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
- typedeploy.gemspec
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://example.com/typedeploy
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --charset=UTF-8
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: typedeploy
|
78
|
+
rubygems_version: 1.3.6
|
79
|
+
signing_key:
|
80
|
+
specification_version: 2
|
81
|
+
summary: Manage and deploy your Typekit kits from the comfort of your own project.
|
82
|
+
test_files: []
|
83
|
+
|