typekitty 0.1.2 → 0.2.0
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 +4 -4
- data/bin/typekitty +1 -4
- data/lib/typekitty.rb +1 -0
- data/lib/typekitty/api.rb +22 -3
- data/lib/typekitty/cli.rb +7 -2
- data/lib/typekitty/kit.rb +22 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12ef796ef4d8ac7424248dd866bd7e17f88b20c9
|
4
|
+
data.tar.gz: 16cafcb320a5ece2d40497b23c2b03c2c536eacf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7897142ca94c94d167ce415cc9cf1431c1cc8d83c09b7329344b30a9608a9b1d8bd8e028af48e1cbc0d53e2cc6019ecdda079c2199d150b0e925605c1500044
|
7
|
+
data.tar.gz: cd747e7611e8e3a46fea3e69389ae2d37592fad9f2cc0d44445005b94259529bb176354ad3430cbe6f3a2a4acbea6eedfc63f06b8f0f389f9bc05a52af9b9d88
|
data/bin/typekitty
CHANGED
data/lib/typekitty.rb
CHANGED
data/lib/typekitty/api.rb
CHANGED
@@ -1,16 +1,35 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'typekitty/kit'
|
2
3
|
|
3
4
|
module Typekitty
|
4
5
|
module API
|
5
|
-
include
|
6
|
+
include HTTParty
|
6
7
|
|
7
8
|
format :json
|
8
9
|
base_uri 'https://typekit.com/api/v1/json'
|
9
10
|
default_params :token => ENV['TYPEKIT_TOKEN']
|
10
11
|
|
11
|
-
# Lists kits by their `id`
|
12
12
|
def self.kits
|
13
|
-
|
13
|
+
response = handle_response get '/kits'
|
14
|
+
|
15
|
+
response['kits'].inject([]) do |kits, kit|
|
16
|
+
kits << self.kit(kit['id'])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.kit id
|
21
|
+
response = handle_response get "/kits/#{id}"
|
22
|
+
|
23
|
+
Typekitty::Kit.new response['kit']
|
14
24
|
end
|
25
|
+
|
26
|
+
def self.handle_response response
|
27
|
+
case response.code
|
28
|
+
when 200 then response
|
29
|
+
when 401 then raise UnauthorizedError
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class UnauthorizedError < StandardError; end
|
15
34
|
end
|
16
35
|
end
|
data/lib/typekitty/cli.rb
CHANGED
@@ -3,13 +3,18 @@ require 'typekitty/api'
|
|
3
3
|
|
4
4
|
module Typekitty
|
5
5
|
class CLI < Thor
|
6
|
+
desc 'kits', 'Lists your kits'
|
6
7
|
option :token, :required => true
|
7
|
-
|
8
|
-
desc 'kits', 'Lists your kits by their `id`'
|
9
8
|
def kits
|
10
9
|
puts api.kits
|
11
10
|
end
|
12
11
|
|
12
|
+
desc 'kit KIT_ID', 'Get information about a kit'
|
13
|
+
option :token, :required => true
|
14
|
+
def kit id
|
15
|
+
puts api.kit id
|
16
|
+
end
|
17
|
+
|
13
18
|
no_commands do
|
14
19
|
def api
|
15
20
|
Typekitty::API.default_params :token => options[:token]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
require 'typekitty/api'
|
3
|
+
|
4
|
+
module Typekitty
|
5
|
+
class Kit < Hashie::Dash
|
6
|
+
property :id, :required => true
|
7
|
+
property :link
|
8
|
+
property :name, :required => true
|
9
|
+
property :analytics, :required => true
|
10
|
+
property :badge, :required => true
|
11
|
+
property :domains, :required => true
|
12
|
+
property :families, :required => true
|
13
|
+
|
14
|
+
def self.all
|
15
|
+
Typekitty::API.kits
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find id
|
19
|
+
Typekitty::API.kit id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typekitty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Adam Kaplan
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.13.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.1.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.1.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,6 +119,7 @@ files:
|
|
105
119
|
- lib/typekitty.rb
|
106
120
|
- lib/typekitty/api.rb
|
107
121
|
- lib/typekitty/cli.rb
|
122
|
+
- lib/typekitty/kit.rb
|
108
123
|
homepage: https://github.com/razic/typekitty
|
109
124
|
licenses:
|
110
125
|
- MIT
|