typekit_cli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 02367b4a3bb0835dec7fcdf29a4290d90cf944ba
4
+ data.tar.gz: 61e2b453ad7cf13e83d9e6a4bb612775c6bccd22
5
+ SHA512:
6
+ metadata.gz: a3f94cb177bc89ea14830b0f69090b6b28377ab4193ec945c4a9aa54790c6246f20f5b7e1c724258e77b1568791f1391bcac4a7e4c861ca769ca307de81f25a8
7
+ data.tar.gz: 9b4bec9e2b4b13baab0b1914a594aa7593f00c08266715f51db195a971cc1e886df3805071523d6bdf23ffe8a782467034439ed80176b31d18e2e71a6535d81c
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ .idea
3
+ home/*
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rspec'
7
+ gem 'cucumber'
8
+ gem 'aruba'
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Marko Iskander
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # TypeKitCli
2
+ Command line interface to interact with your type kit kits and associated font families.
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'typekit_cli'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install typekit_cli
17
+
18
+ ## Usage
19
+
20
+ - Run typekit from a command prompt to see a list of possible commands and descriptions
21
+
22
+ ## Contributing
23
+
24
+ 1. Fork it ( http://github.com/<my-github-username>/typekit_cli/fork )
25
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
26
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
27
+ 4. Push to the branch (`git push origin my-new-feature`)
28
+ 5. Create new Pull Request
29
+ ##### To run the binary after forking use the following command to ensure all the file paths resolve:
30
+
31
+ bundle exec ruby bin/typekit
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/typekit ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ require 'typekit_cli'
3
+
4
+ class TypeKit<Thor
5
+ include TypeKitCli::RequestHelpers
6
+ include TypeKitCli::CliResponseFormaters
7
+
8
+ desc "list_kits", "List all kits for a given account"
9
+
10
+ def list_kits
11
+ response = get_request
12
+ if response.code == "200"
13
+ output_simple_table(JSON.parse(response.body)['kits'])
14
+ else
15
+ output_error_line("An error occurred while trying to fetch your kits, response code #{response.code}")
16
+ end
17
+ end
18
+
19
+ desc "show_draft_kit KIT_ID", "Fetch draft version for specified kit name"
20
+
21
+ def show_draft_kit(kit_id)
22
+ response = get_request(kit_id)
23
+ if response.code == "200"
24
+ output_kit_and_families(JSON.parse(response.body), kit_id)
25
+ else
26
+ output_error_line("An error occurred while trying to fetch draft kit, response code #{response.code}")
27
+ end
28
+ end
29
+
30
+ desc "publish_kit KIT_ID", "Publish a draft kit"
31
+
32
+ def publish_kit(kit_name)
33
+ response = post_request("#{kit_name}/publish")
34
+ if response.code == "200"
35
+ output_simple_table(JSON.parse(response.body))
36
+ else
37
+ output_error_line("An error occurred while trying to fetch published kit, response code #{response.code}")
38
+ end
39
+ end
40
+
41
+ desc "show_published_kit KIT_ID", "Fetch published version for specified kit name"
42
+
43
+ def show_published_kit(kit_id)
44
+ response = get_request("#{kit_id}/published")
45
+ if response.code == "200"
46
+ output_kit_and_families(JSON.parse(response.body), kit_id)
47
+ else
48
+ output_error_line("An error occurred while trying to fetch published kit, response code #{response.code}")
49
+ end
50
+ end
51
+
52
+ desc "show_kit_family KIT_ID FAMILY_ID", "Fetch information about a font family used in a kit"
53
+
54
+ def show_kit_family(kit_name, family_id)
55
+ response = get_request("#{kit_name}/families/#{family_id}")
56
+ if response.code == "200"
57
+ output_simple_table(JSON.parse(response.body)["family"])
58
+ else
59
+ output_error_line("An error occurred while trying to fetch kit family, response code #{response.code}")
60
+ end
61
+ end
62
+ end
63
+
64
+ #Allow file to be required without starting the CLI interface or prompting for auth token.
65
+ if Pathname.new($0).basename == Pathname.new(__FILE__).basename
66
+ #Load cached auth token or prompt user for it.
67
+ AUTH_TOKEN = TypeKitCli::AuthToken.new().get_token
68
+ if AUTH_TOKEN.empty?
69
+ puts("You must provide an api token to continue")
70
+ exit
71
+ end
72
+
73
+ #Start the Thor CLI interface
74
+ TypeKit.start(ARGV)
75
+ end
@@ -0,0 +1,3 @@
1
+ And /^show me (the )?output so far$/ do |_|
2
+ puts unescape(all_output)
3
+ end
@@ -0,0 +1,19 @@
1
+ $:.push File.dirname(__FILE__)
2
+
3
+ require 'cucumber'
4
+ require 'aruba/cucumber'
5
+ require 'fileutils'
6
+
7
+ Before do
8
+ #Set the aruba directories
9
+ @dirs = [File.expand_path(File.join(File.dirname(__FILE__), '../..'))]
10
+
11
+ #Create a fake home directory for the test suit.
12
+ set_env 'HOME', File.expand_path(File.join(current_dir, 'home'))
13
+ FileUtils.mkdir_p ENV['HOME']
14
+ end
15
+
16
+ After do
17
+ #Clean up the fake home directory after the tests are done.
18
+ FileUtils.rm_f ENV['HOME']
19
+ end
@@ -0,0 +1,32 @@
1
+ @mocked_home_directory
2
+ Feature: I do something
3
+
4
+ Background:
5
+ Given I run `bundle exec ruby bin/typekit list_kits` interactively
6
+ And I type "fec094cc45d9d75ac27961d2033eeb38281331b1"
7
+ And I type "y"
8
+
9
+ Scenario: Executing the binary should list possible options
10
+ Given I run `bundle exec ruby bin/typekit` interactively
11
+ And the output should contain "Commands:"
12
+
13
+
14
+ Scenario:
15
+ Given I run `bundle exec ruby bin/typekit list_kits` interactively
16
+ And the output should match /id\s+|\s+link/
17
+
18
+ Scenario:
19
+ Given I run `bundle exec ruby bin/typekit show_draft_kit foo` interactively
20
+ And the output should contain "An error occurred while trying to fetch draft kit, response code 404"
21
+
22
+ Scenario:
23
+ Given I run `bundle exec ruby bin/typekit publish_kit foo` interactively
24
+ And the output should contain "An error occurred while trying to fetch published kit, response code 404"
25
+
26
+ Scenario:
27
+ Given I run `bundle exec ruby bin/typekit show_published_kit foo` interactively
28
+ And the output should contain "An error occurred while trying to fetch published kit, response code 404"
29
+
30
+ Scenario:
31
+ Given I run `bundle exec ruby bin/typekit show_kit_family foo bar` interactively
32
+ And the output should contain "An error occurred while trying to fetch kit family, response code 404"
@@ -0,0 +1,28 @@
1
+ module TypeKitCli
2
+ class AuthToken < Thor
3
+ CACHE_FILE = "#{Dir.home}/.typekit"
4
+ no_commands{
5
+ def get_token
6
+ auth_token = nil
7
+ if File.exist?(CACHE_FILE)
8
+ File.open(CACHE_FILE, 'r') { |file| auth_token = file.gets }
9
+ else
10
+ auth_token = prompt_for_token
11
+ end
12
+ auth_token
13
+ end
14
+
15
+ }
16
+
17
+ private
18
+ def prompt_for_token
19
+ auth_token = ask("Typekit API Token:")
20
+ if yes?("Would you like to cache this token? [y/N]:")
21
+ say("Token will be cached to in #{CACHE_FILE} file")
22
+ File.open(CACHE_FILE, 'w') { |file| file.write(auth_token) }
23
+ end
24
+ auth_token
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,24 @@
1
+ module TypeKitCli
2
+ module CliResponseFormaters
3
+ def output_simple_table(data)
4
+ data = data.kind_of?(Array) ? data : [data]
5
+ Formatador.display_table(data)
6
+ end
7
+
8
+ def output_error_line(str)
9
+ Formatador.display_line("[red]#{str}[/]")
10
+ end
11
+
12
+ def output_kit_and_families(hash, kit_id)
13
+ kit = hash['kit']
14
+ families = kit['families']
15
+ kit.delete('families')
16
+
17
+ Formatador.display_line("Kit #{kit_id}")
18
+ output_simple_table(kit)
19
+
20
+ Formatador.display_line("Kit Families")
21
+ output_simple_table(families)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module TypeKitCli
2
+ module RequestHelpers
3
+ BASE_TYPEKIT_URL='https://typekit.com/api/v1/json/kits/'
4
+
5
+ def post_request(uri_str="")
6
+ uri = URI.parse(BASE_TYPEKIT_URL+uri_str)
7
+ http = Net::HTTP.new(uri.host, uri.port)
8
+ http.use_ssl = true
9
+ headers = {'X-Typekit-Token' => AUTH_TOKEN}
10
+ post_req = Net::HTTP::Post.new(uri.path, headers)
11
+ http.request(post_req)
12
+ end
13
+
14
+ def get_request(uri_str="")
15
+ uri = URI.parse(BASE_TYPEKIT_URL+uri_str)
16
+ http = Net::HTTP.new(uri.host, uri.port)
17
+ http.use_ssl = true
18
+ headers = {'X-Typekit-Token' => AUTH_TOKEN}
19
+ http.get(uri.path, headers)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module TypeKitCli
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'thor'
2
+ require 'net/http'
3
+ require 'pathname'
4
+ require 'formatador'
5
+ require 'json'
6
+ require 'typekit_cli/version'
7
+ require 'typekit_cli/auth_token'
8
+ require 'typekit_cli/request_helpers'
9
+ require 'typekit_cli/cli_response_formaters'
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe TypeKitCli::AuthToken do
4
+ let(:token_obj){TypeKitCli::AuthToken.new}
5
+ context "#get_token" do
6
+ it 'should use use a cached token if it exists' do
7
+ expect(File).to receive(:exist?).with("#{Dir.home}/.typekit").and_return(true)
8
+ file = double('file')
9
+
10
+ expect(File).to receive(:open).with("#{Dir.home}/.typekit", "r").and_yield(file)
11
+ expect(file).to receive(:gets).and_return("foo_bar")
12
+ token = token_obj.get_token
13
+ expect(token).to eql("foo_bar")
14
+ end
15
+ it 'should prompt the user if file doesn\'t exist' do
16
+ expect(File).to receive(:exist?).with("#{Dir.home}/.typekit").and_return(false)
17
+ expect(token_obj).to receive(:prompt_for_token).and_return("foo_bar")
18
+ token = token_obj.get_token
19
+ expect(token).to eql("foo_bar")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,54 @@
1
+ shared_examples TypeKitCli::CliResponseFormaters do
2
+
3
+ let(:kit){{'kit'=> hash_data.merge({'families'=> array_data})}}
4
+ let(:hash_data){{foo: "test string", bar:"test string 2"}}
5
+ let(:array_data){[{foo: "test string"}, {bar: "test string 2"}]}
6
+ let(:kit_id){"someid"}
7
+ let(:text_msg){"test string"}
8
+
9
+ context "#output_simple_table"do
10
+ it 'should transform passed in data to an array if it is not before passing it to Formatador' do
11
+ expect(Formatador).to receive(:display_table).with([hash_data])
12
+ subject.output_simple_table(hash_data)
13
+ end
14
+ it 'should not transform the data if it is already an array before passing it to Formatador' do
15
+ expect(Formatador).to receive(:display_table).with(array_data)
16
+ subject.output_simple_table(array_data)
17
+ end
18
+ end
19
+ context "#output_error_line" do
20
+ it 'should apply red color to the error message passed in before passing it to Formatador' do
21
+ expect(Formatador).to receive(:display_line).with("[red]#{text_msg}[/]")
22
+ subject.output_error_line(text_msg)
23
+ end
24
+ end
25
+ context "#output_kit_and_families" do
26
+ it 'should print a kit table header' do
27
+ expect(Formatador).to receive(:display_line).once.with("Kit #{kit_id}")
28
+ allow(Formatador).to receive(:display_line)
29
+ allow(subject).to receive(:output_simple_table).twice
30
+ subject.output_kit_and_families(kit, kit_id)
31
+ end
32
+ it 'should print the kit table without the families value'do
33
+ allow(Formatador).to receive(:display_line).twice
34
+ expect(subject).to receive(:output_simple_table).with(kit['kit'])
35
+ allow(subject).to receive(:output_simple_table)
36
+ subject.output_kit_and_families(kit, kit_id)
37
+ end
38
+ it 'should print the families table header' do
39
+ allow(Formatador).to receive(:display_line)
40
+ expect(Formatador).to receive(:display_line).with("Kit Families")
41
+ allow(subject).to receive(:output_simple_table).twice
42
+
43
+ subject.output_kit_and_families(kit, kit_id)
44
+ end
45
+ it 'should print the families table' do
46
+ allow(Formatador).to receive(:display_line).twice
47
+ allow(subject).to receive(:output_simple_table)
48
+ expect(subject).to receive(:output_simple_table).with(kit['kit']['families'])
49
+
50
+ subject.output_kit_and_families(kit, kit_id)
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,94 @@
1
+ shared_examples TypeKitCli::RequestHelpers do
2
+ let(:http_obj) { double("http") }
3
+ let(:post_request_obj) { double("post_request") }
4
+ let(:uri) { double("uri") }
5
+ TypeKitCli::RequestHelpers::AUTH_TOKEN = "test auth"
6
+
7
+ context "#post_request" do
8
+ it 'should append uri_str to base url' do
9
+ test_uri = "test_uri"
10
+ expect(URI).to receive(:parse).with(TypeKitCli::RequestHelpers::BASE_TYPEKIT_URL + test_uri).and_return(uri)
11
+
12
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
13
+ allow(Net::HTTP).to receive(:new).and_return(http_obj)
14
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
15
+ allow(Net::HTTP::Post).to receive(:new).and_return(post_request_obj)
16
+ allow(http_obj).to receive(:request)
17
+ subject.post_request(test_uri)
18
+ end
19
+ it 'should use ssl' do
20
+ allow(URI).to receive(:parse).and_return(uri)
21
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
22
+
23
+ expect(Net::HTTP).to receive(:new).and_return(http_obj)
24
+
25
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
26
+ allow(Net::HTTP::Post).to receive(:new).and_return(post_request_obj)
27
+ allow(http_obj).to receive(:request)
28
+ subject.post_request
29
+ end
30
+ it 'should set the header with an auth token' do
31
+ allow(URI).to receive(:parse).and_return(uri)
32
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
33
+ allow(Net::HTTP).to receive(:new).and_return(http_obj)
34
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
35
+
36
+ header = {'X-Typekit-Token' => TypeKitCli::RequestHelpers::AUTH_TOKEN}
37
+ expect(Net::HTTP::Post).to receive(:new).with(anything, header).and_return(post_request_obj)
38
+ expect(http_obj).to receive(:request).with(post_request_obj)
39
+ subject.post_request
40
+ end
41
+ it 'should make a post request and return the response' do
42
+ allow(URI).to receive(:parse).and_return(uri)
43
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
44
+ allow(Net::HTTP).to receive(:new).and_return(http_obj)
45
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
46
+
47
+ expect(Net::HTTP::Post).to receive(:new).and_return(post_request_obj)
48
+ expect(http_obj).to receive(:request).with(post_request_obj)
49
+ subject.post_request
50
+ end
51
+ end
52
+ context "#get_request" do
53
+ it 'should append uri_str to base url' do
54
+ test_uri = "test_uri"
55
+ expect(URI).to receive(:parse).with(TypeKitCli::RequestHelpers::BASE_TYPEKIT_URL + test_uri).and_return(uri)
56
+
57
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
58
+ allow(Net::HTTP).to receive(:new).and_return(http_obj)
59
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
60
+ allow(http_obj).to receive(:get)
61
+
62
+ subject.get_request(test_uri)
63
+ end
64
+ it 'should use ssl' do
65
+ allow(URI).to receive(:parse).and_return(uri)
66
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
67
+
68
+ expect(Net::HTTP).to receive(:new).and_return(http_obj)
69
+
70
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
71
+ allow(http_obj).to receive(:get)
72
+ subject.get_request
73
+ end
74
+ it 'should set the header with an auth token' do
75
+ allow(URI).to receive(:parse).and_return(uri)
76
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
77
+
78
+ expect(Net::HTTP).to receive(:new).and_return(http_obj)
79
+
80
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
81
+ allow(http_obj).to receive(:get)
82
+ subject.get_request
83
+ end
84
+ it 'should make a get request and return the response' do
85
+ allow(URI).to receive(:parse).and_return(uri)
86
+ allow(uri).to receive_messages({host: nil, port: nil, path: nil})
87
+ allow(Net::HTTP).to receive(:new).and_return(http_obj)
88
+ allow(http_obj).to receive_messages({:use_ssl= => nil, request: nil})
89
+
90
+ expect(http_obj).to receive(:get)
91
+ subject.get_request
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,5 @@
1
+ require 'typekit_cli'
2
+ load 'bin/typekit'
3
+
4
+ #require all shared specs in the shared directory
5
+ Dir[File.join(File.dirname(__FILE__), 'shared/**/shared_*.rb')].each { |f| require File.expand_path(f) }
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe TypeKit do
4
+ let(:cli) { TypeKit.new }
5
+ let(:http_response) { double("response") }
6
+ let(:success_status_code) { "200" }
7
+ let(:failed_status_code) { "404" }
8
+ let(:response_body) { {"title"=> "Test Output"}.to_json }
9
+
10
+ before(:each, type: :success_request) do
11
+ expect(http_response).to receive(:code).and_return(success_status_code)
12
+ expect(http_response).to receive(:body).and_return(response_body)
13
+ end
14
+ before(:each, type: :failure_request) do
15
+ expect(http_response).to receive(:code).twice.and_return(failed_status_code)
16
+ end
17
+ def subject
18
+ cli
19
+ end
20
+
21
+ context "#list_kits" do
22
+ it 'should output the response if the API request was successful', :type => :success_request do
23
+ expect(cli).to receive(:get_request).and_return(http_response)
24
+ expect(cli).to receive(:output_simple_table).and_return(nil)
25
+
26
+ cli.list_kits
27
+ end
28
+ it 'should output an error message if the request failed', :type => :failure_request do
29
+ expect(cli).to receive(:get_request).and_return(http_response)
30
+ expect(cli).to receive(:output_error_line).with("An error occurred while trying to fetch your kits, response code #{failed_status_code}")
31
+
32
+ cli.list_kits
33
+ end
34
+ end
35
+ context "#show_draft_kit" do
36
+ it 'should output the response if the API request was successful', :type => :success_request do
37
+ expect(cli).to receive(:get_request).with("foo").and_return(http_response)
38
+ expect(cli).to receive(:output_kit_and_families).and_return(nil)
39
+
40
+ cli.show_draft_kit("foo")
41
+ end
42
+ it 'should output an error message if the request failed', :type => :failure_request do
43
+ expect(cli).to receive(:get_request).with("foo").and_return(http_response)
44
+ expect(cli).to receive(:output_error_line).with("An error occurred while trying to fetch draft kit, response code #{failed_status_code}")
45
+
46
+ cli.show_draft_kit("foo")
47
+ end
48
+ end
49
+ context "#publish_kit" do
50
+ it 'should output the response if the API request was successful', :type => :success_request do
51
+ expect(cli).to receive(:post_request).with("foo/publish").and_return(http_response)
52
+ expect(cli).to receive(:output_simple_table).and_return(nil)
53
+
54
+ cli.publish_kit("foo")
55
+ end
56
+ it 'should output an error message if the request failed', :type => :failure_request do
57
+ expect(cli).to receive(:post_request).with("foo/publish").and_return(http_response)
58
+ expect(cli).to receive(:output_error_line).with("An error occurred while trying to fetch published kit, response code #{failed_status_code}")
59
+
60
+ cli.publish_kit("foo")
61
+ end
62
+ end
63
+ context "#show_published_kit" do
64
+ it 'should output the response if the API request was successful', :type => :success_request do
65
+ expect(cli).to receive(:get_request).with("foo/published").and_return(http_response)
66
+ expect(cli).to receive(:output_kit_and_families).and_return(nil)
67
+
68
+ cli.show_published_kit("foo")
69
+ end
70
+ it 'should output an error message if the request failed', :type => :failure_request do
71
+ expect(cli).to receive(:get_request).with("foo/published").and_return(http_response)
72
+ expect(cli).to receive(:output_error_line).with("An error occurred while trying to fetch published kit, response code #{failed_status_code}")
73
+
74
+ cli.show_published_kit("foo")
75
+ end
76
+ end
77
+ context "#show_kit_family" do
78
+ it 'should output the response if the API request was successful', :type => :success_request do
79
+ expect(cli).to receive(:get_request).with("foo/families/bar").and_return(http_response)
80
+ expect(cli).to receive(:output_simple_table).and_return(nil)
81
+
82
+ cli.show_kit_family("foo", "bar")
83
+ end
84
+ it 'should output an error message if the request failed', :type => :failure_request do
85
+ expect(cli).to receive(:get_request).with("foo/families/bar").and_return(http_response)
86
+ expect(cli).to receive(:output_error_line).with("An error occurred while trying to fetch kit family, response code #{failed_status_code}")
87
+
88
+ cli.show_kit_family("foo", "bar")
89
+ end
90
+ end
91
+ it_behaves_like TypeKitCli::RequestHelpers
92
+ it_behaves_like TypeKitCli::CliResponseFormaters
93
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'typekit_cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "typekit_cli"
8
+ spec.version = TypeKitCli::VERSION
9
+ spec.authors = ["Marko Iskander"]
10
+ spec.email = ["markoiskander@gmail.com"]
11
+ spec.summary = %q{Command line interface to interact with your type kit kits and associated font families.}
12
+ spec.description = %q{Command line interface to interact with your type kit kits and associated font families.}
13
+ spec.homepage = "https://github.com/miskander/typekit_cli"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ['typekit']
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.add_dependency 'thor', '~> 0.19', '>= 0.19.1'
21
+ spec.add_dependency 'formatador', '~> 0.2', '>= 0.2.5'
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
24
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typekit_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marko Iskander
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.19.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.19'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.19.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: formatador
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.2'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.2.5
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.2'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.2.5
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.5'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.5'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '10.3'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 10.3.2
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '10.3'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 10.3.2
87
+ description: Command line interface to interact with your type kit kits and associated
88
+ font families.
89
+ email:
90
+ - markoiskander@gmail.com
91
+ executables:
92
+ - typekit
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/typekit
102
+ - features/step_definitions/aruba_steps.rb.rb
103
+ - features/support/env.rb
104
+ - features/typekit_cmd.feature
105
+ - lib/typekit_cli.rb
106
+ - lib/typekit_cli/auth_token.rb
107
+ - lib/typekit_cli/cli_response_formaters.rb
108
+ - lib/typekit_cli/request_helpers.rb
109
+ - lib/typekit_cli/version.rb
110
+ - spec/auth_token_spec.rb
111
+ - spec/shared/shared_cli_format_helpers.rb
112
+ - spec/shared/shared_request_helpers.rb
113
+ - spec/spec_helper.rb
114
+ - spec/typekit_spec.rb
115
+ - typekit_cli.gemspec
116
+ homepage: https://github.com/miskander/typekit_cli
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.2.2
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Command line interface to interact with your type kit kits and associated
140
+ font families.
141
+ test_files:
142
+ - features/step_definitions/aruba_steps.rb.rb
143
+ - features/support/env.rb
144
+ - features/typekit_cmd.feature
145
+ - spec/auth_token_spec.rb
146
+ - spec/shared/shared_cli_format_helpers.rb
147
+ - spec/shared/shared_request_helpers.rb
148
+ - spec/spec_helper.rb
149
+ - spec/typekit_spec.rb
150
+ has_rdoc: