typekitable 0.1.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.
@@ -0,0 +1,23 @@
1
+ module Typekitable
2
+ module Tokenizer
3
+ TOKEN_STORE = File.absolute_path('.typekitable', Dir.home)
4
+
5
+ def self.store(token)
6
+ File.open(TOKEN_STORE, 'w') do |file|
7
+ file.write(token)
8
+ end
9
+ end
10
+
11
+ def self.has_token?
12
+ File.exist?(TOKEN_STORE)
13
+ end
14
+
15
+ def self.get_token
16
+ return unless has_token?
17
+
18
+ File.open(TOKEN_STORE, 'r') do |file|
19
+ file.gets
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Typekitable
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ body:
7
+ encoding: US-ASCII
8
+ string: name=A+new+kit&domains=http%3A%2F%2Fpersazula.com
9
+ headers:
10
+ X-Typekit-Token:
11
+ - 5e4ce50b7c5b996b2fb5e65ee4a6b870b9bd3297
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Sun, 26 Apr 2015 19:48:53 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Content-Length:
32
+ - '103'
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 200 OK
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ X-Request-Id:
40
+ - 7f5aa58e70d6f4d874b087594c2ce08d
41
+ Remote-User:
42
+ - '25026'
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Ua-Compatible:
46
+ - IE=Edge,chrome=1
47
+ Etag:
48
+ - '"58b5c03ed0999955324ac392713f4784"'
49
+ Cache-Control:
50
+ - max-age=0, private, must-revalidate
51
+ Set-Cookie:
52
+ - tk_session_production=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTQxYzY4ZWE1YzA3NzY1OTE0MGJiYmI5OTc2OWJiOWNhBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMTFuWi9PaWFXbjM5ODdwVUZKc1NGOFc5VW5TYlVWS3dvdlBZT3J5cnhRUDQ9BjsARg%3D%3D--e4b8f838f81631461265d7793598cce7ee687bb5;
53
+ domain=typekit.com; path=/; expires=Sun, 10-May-2015 19:48:53 GMT; HttpOnly
54
+ X-Runtime:
55
+ - '0.071526'
56
+ X-Rack-Cache:
57
+ - invalidate, pass
58
+ body:
59
+ encoding: UTF-8
60
+ string: '{"kit":{"id":"fla3cfh","name":"A new kit","analytics":false,"domains":["persazula.com"],"families":[]}}'
61
+ http_version:
62
+ recorded_at: Sun, 26 Apr 2015 19:48:58 GMT
63
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ body:
7
+ encoding: US-ASCII
8
+ string: name=A+new+kit&domain=http%3A%2F%2Fpersazula.com
9
+ headers:
10
+ X-Typekit-Token:
11
+ - 5e4ce50b7c5b996b2fb5e65ee4a6b870b9bd3297
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ response:
21
+ status:
22
+ code: 400
23
+ message: Bad Request
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ X-Rack-Cache:
28
+ - invalidate, pass
29
+ Cache-Control:
30
+ - no-cache
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Date:
34
+ - Sun, 26 Apr 2015 19:46:07 GMT
35
+ Status:
36
+ - 400 Bad Request
37
+ X-Request-Id:
38
+ - a9b7654e60fda8cdc2c88332b56d733b
39
+ X-Runtime:
40
+ - '0.018256'
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ Connection:
44
+ - close
45
+ Remote-User:
46
+ - '25026'
47
+ Set-Cookie:
48
+ - tk_session_production=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTFlYTU4MDViODM0Yjc2NGFhYTY1NTQ2NmJjMDg5NzUwBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMXVxZ05Rc2pJWEFuR0pGd0VOeUFjQ2JMd2hqTFhIbWpuajNVczhpN3VGU0k9BjsARg%3D%3D--011eea16061003f7745ecf13ef381ab95d24d09d;
49
+ domain=typekit.com; path=/; expires=Sun, 10-May-2015 19:46:07 GMT; HttpOnly
50
+ X-Frame-Options:
51
+ - SAMEORIGIN
52
+ X-Ua-Compatible:
53
+ - IE=Edge,chrome=1
54
+ Content-Length:
55
+ - '58'
56
+ body:
57
+ encoding: UTF-8
58
+ string: '{"errors":["You have reached the maximum number of kits"]}'
59
+ http_version:
60
+ recorded_at: Sun, 26 Apr 2015 19:46:12 GMT
61
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ body:
7
+ encoding: US-ASCII
8
+ string: name=A+new+kit&domain=http%3A%2F%2Fpersazula.com
9
+ headers:
10
+ X-Typekit-Token:
11
+ - 143250b7c5b996b2fb5e65ee4a6b870b9bd3297
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Sun, 26 Apr 2015 19:46:06 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Content-Length:
32
+ - '29'
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 401 Unauthorized
37
+ Www-Authenticate:
38
+ - Token realm="http://typekit.com/api/v1", coverage="none"
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ X-Request-Id:
42
+ - 66668552da9a2fe81030b31880ac777c
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Ua-Compatible:
46
+ - IE=Edge,chrome=1
47
+ Cache-Control:
48
+ - no-cache
49
+ Set-Cookie:
50
+ - tk_session_production=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTM5ZGUyMDliMjFlM2Y0NWI0OWIxNDE3ZDY2OGNlMWNlBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMTJrbjUxQjRQNWpONkxwZWlXV2N5eTZmMWw4SnVXMUp2dDh0K1RuNE9ROTA9BjsARg%3D%3D--3f551ebcb5fa4d78fefa8165cadef5de28d2bb04;
51
+ domain=typekit.com; path=/; expires=Sun, 10-May-2015 19:46:06 GMT; HttpOnly
52
+ X-Runtime:
53
+ - '0.007466'
54
+ X-Rack-Cache:
55
+ - invalidate, pass
56
+ body:
57
+ encoding: UTF-8
58
+ string: '{"errors":["Not authorized"]}'
59
+ http_version:
60
+ recorded_at: Sun, 26 Apr 2015 19:46:12 GMT
61
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Typekit-Token:
11
+ - 5e4ce50b7c5b996b2fb5e65ee4a6b870b9bd3297
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Sun, 26 Apr 2015 03:32:55 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '62'
31
+ Connection:
32
+ - keep-alive
33
+ Status:
34
+ - 200 OK
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ X-Request-Id:
38
+ - 91ef73951039be5257ba39f1ea6cb2be
39
+ Remote-User:
40
+ - '25026'
41
+ X-Frame-Options:
42
+ - SAMEORIGIN
43
+ X-Ua-Compatible:
44
+ - IE=Edge,chrome=1
45
+ Etag:
46
+ - '"0070f6a6c33fddff5ec1d2ee68d3f426"'
47
+ Cache-Control:
48
+ - max-age=0, private, must-revalidate
49
+ Set-Cookie:
50
+ - tk_session_production=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTNiMzUxNTU1ODRmN2FiODczNzgyYWE3NmQ4ZGFiMWEwBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMU5RZEYxcm1Cb0dnODBaSzlsOVcrTXdlMlVwSDNkWDJPQ3BseEsveDFBY3M9BjsARg%3D%3D--1045504f3264a48862ceae4f7fd41a0295788a39;
51
+ domain=typekit.com; path=/; expires=Sun, 10-May-2015 03:32:55 GMT; HttpOnly
52
+ X-Runtime:
53
+ - '0.011173'
54
+ X-Rack-Cache:
55
+ - miss
56
+ body:
57
+ encoding: UTF-8
58
+ string: '{"kits":[{"id":"yuw0tqs","link":"/api/v1/json/kits/yuw0tqs"}]}'
59
+ http_version:
60
+ recorded_at: Sun, 26 Apr 2015 03:32:55 GMT
61
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Typekit-Token:
11
+ - 143250b7c5b996b2fb5e65ee4a6b870b9bd3297
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 401
21
+ message: Unauthorized
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Sun, 26 Apr 2015 13:16:49 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '29'
31
+ Connection:
32
+ - keep-alive
33
+ Status:
34
+ - 401 Unauthorized
35
+ Www-Authenticate:
36
+ - Token realm="http://typekit.com/api/v1", coverage="none"
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ X-Request-Id:
40
+ - 8f7bfa67e6e630a4c329751985ecb6a3
41
+ X-Frame-Options:
42
+ - SAMEORIGIN
43
+ X-Ua-Compatible:
44
+ - IE=Edge,chrome=1
45
+ Cache-Control:
46
+ - no-cache
47
+ Set-Cookie:
48
+ - tk_session_production=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTI1ZDJhYzllNDQ5ZTk3YzRhNmU1MzNlNTlhOTAwOGY4BjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMWZUWjhPTS9VSkJ0OG9MNFZiaTRUeUp3Sm5EWlkvcmZUSVJTV1RpWHpKbWc9BjsARg%3D%3D--8976393bd9e03e723a908cfe2002ae9694146327;
49
+ domain=typekit.com; path=/; expires=Sun, 10-May-2015 13:16:49 GMT; HttpOnly
50
+ X-Runtime:
51
+ - '0.007759'
52
+ X-Rack-Cache:
53
+ - miss
54
+ body:
55
+ encoding: UTF-8
56
+ string: '{"errors":["Not authorized"]}'
57
+ http_version:
58
+ recorded_at: Sun, 26 Apr 2015 13:16:49 GMT
59
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/libraries
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Typekit-Token:
11
+ - 5e4ce50b7c5b996b2fb5e65ee4a6b870b9bd3297
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Sun, 26 Apr 2015 13:46:36 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '249'
31
+ Connection:
32
+ - keep-alive
33
+ Status:
34
+ - 200 OK
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ X-Request-Id:
38
+ - 3a9c6ab859e018835781ae79d2508c62
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ X-Ua-Compatible:
42
+ - IE=Edge,chrome=1
43
+ Etag:
44
+ - '"54f8212ec7e5d658d55ad0c9b337d0fb"'
45
+ Cache-Control:
46
+ - max-age=0, private, must-revalidate
47
+ Set-Cookie:
48
+ - tk_session_production=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTRhMmZjNGQyMDE1NGY0YThjZjBhYzI3NzM0NTdhNDIxBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMVl2N2NKMDV3T2w0Umt3ckdHQjR0WFhBK1RrNFBkNGlONUx1Y3A2aFRKdms9BjsARg%3D%3D--8124d7eb51941a00e3f9ad6c1a1566ab9a36e6c9;
49
+ domain=typekit.com; path=/; expires=Sun, 10-May-2015 13:46:36 GMT; HttpOnly
50
+ X-Runtime:
51
+ - '0.007882'
52
+ X-Rack-Cache:
53
+ - miss
54
+ body:
55
+ encoding: UTF-8
56
+ string: '{"libraries":[{"id":"trial","link":"/api/v1/json/libraries/trial","name":"Trial
57
+ Library"},{"id":"personal","link":"/api/v1/json/libraries/personal","name":"Personal
58
+ Library"},{"id":"full","link":"/api/v1/json/libraries/full","name":"Full Library"}]}'
59
+ http_version:
60
+ recorded_at: Sun, 26 Apr 2015 13:46:37 GMT
61
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module Typekitable
4
+ describe Commander do
5
+ subject { described_class }
6
+ let(:authenticator) { double(:authenticator) }
7
+
8
+ context ".re_authenticate" do
9
+ it "gets the result of re-authenticating" do
10
+ expect(Authenticator).to receive(:new).and_return(authenticator)
11
+ expect(authenticator).to receive(:get_authentication).and_return(true)
12
+
13
+ subject.start(%w(re-authenticate))
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ module Typekitable
4
+ describe RequestFetcher do
5
+ subject { described_class.new(:kit_list) }
6
+ let(:type) { :kit_list }
7
+ let(:path) { "kits" }
8
+ let(:verb) { "GET" }
9
+ let(:response) { double(:response) }
10
+ let(:request) { double(:request, :response => response) }
11
+
12
+ context ".new" do
13
+ it "stores a type if the type is valid" do
14
+ expect(type).to eq(type)
15
+ end
16
+
17
+ it "raises an error if the type is invalid" do
18
+ invalid_type = :invalid
19
+
20
+ expect{described_class.new(invalid_type)}.to raise_error(InvalidTypeError)
21
+ end
22
+
23
+ it "raises an error if the options are invalid for the type" do
24
+ type = :kit_add
25
+ options = {:library => "Museo"}
26
+
27
+ expect{described_class.new(type, options)}.to raise_error(InvalidOptionsError)
28
+ end
29
+
30
+ it "does not raise an error if there are no options given" do
31
+ type = :kit_list
32
+
33
+ expect{described_class.new(type)}.to_not raise_error
34
+ expect(described_class.new(type).options).to eq({})
35
+ end
36
+
37
+ it "stores the options if the options are valid" do
38
+ type = :kit_add
39
+ options = {:name => "Web 2.0", :domains => "http://example.com"}
40
+
41
+ expect{described_class.new(type, options)}.to_not raise_error
42
+ expect(described_class.new(type, options).options).to eq(options)
43
+ end
44
+ end
45
+
46
+ context ".request_path" do
47
+ it "returns the request path for type" do
48
+ expect(subject.request_path).to eq(path)
49
+ end
50
+ end
51
+
52
+ context ".verb" do
53
+ it "returns the verb for type" do
54
+ expect(subject.verb).to eq(verb)
55
+ end
56
+ end
57
+
58
+ context ".response" do
59
+ it "sends for the response" do
60
+ expect(Request).to receive(:new).with(path, verb, {}).and_return(request)
61
+ expect(request).to receive(:response).and_return(response)
62
+
63
+ subject.response
64
+ end
65
+ end
66
+ end
67
+ end