typekitter 0.1.0

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: 16fe29eeace8c7d8069f8cd020acaedc042e0ae2
4
+ data.tar.gz: 593891988160afa3a5268ebad54e1485d515b7db
5
+ SHA512:
6
+ metadata.gz: d690110880a81ea395a7be48390f62e23708ae75222c8d6b00d1f7f89da2c0f1531005a546fa98edb7a2359159ce4bd225367cfa262dde19e56f3ec106856cf2
7
+ data.tar.gz: c4771431b8a580931808cb2ef9ab73586362084f22d2b4ff2738fb96f3c89edb19790b93e3936dedf1e00bd66ef40ffdd5e0b1738dc742a5bfe45330a431371c
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
11
+ *.env
12
+ .typekitter_token
data/.hound.yml ADDED
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ enabled: true
3
+ config_file: config/rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'codeclimate-test-reporter'
5
+ end
6
+
7
+ # Specify your gem's dependencies in typekitter.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ricardo Rubio
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,61 @@
1
+ [![Code Climate](https://codeclimate.com/github/rickarubio/typekitter/badges/gpa.svg)](https://codeclimate.com/github/rickarubio/typekitter)
2
+ [![Test Coverage](https://codeclimate.com/github/rickarubio/typekitter/badges/coverage.svg)](https://codeclimate.com/github/rickarubio/typekitter/coverage)
3
+ [![Build Status](https://travis-ci.org/rickarubio/typekitter.svg?branch=master)](https://travis-ci.org/rickarubio/typekitter)
4
+
5
+ # Typekitter
6
+ Allows you to interact with typekit APIs with a ruby client
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'typekitter'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install typekitter
23
+
24
+ ## Usage
25
+ ```
26
+ typekitter commands:
27
+ typekitter display_token # Displays the current token in use
28
+ typekitter help [COMMAND] # Describe available commands or one specific command
29
+ typekitter kits_create --name=NAME # Creates a new draft kit, returns kit info. See help for options
30
+ typekitter kits_index # Display a list of all your typekits
31
+ typekitter save_token [value] # Saves the token to .typekitter-token
32
+ ```
33
+
34
+ Use the help command to get more information about commands:
35
+
36
+ ```
37
+ Usage:
38
+ typekitter kits_create --name=NAME
39
+
40
+ Options:
41
+ --name=NAME
42
+ [--domains=DOMAINS]
43
+ [--families=FAMILIES]
44
+ [--segmented-names=SEGMENTED_NAMES]
45
+
46
+ Creates a new draft kit, returns kit info. See help for options
47
+ ```
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it ( https://github.com/[my-github-username]/typekitter/fork )
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+ require 'byebug'
4
+ require 'cucumber'
5
+ require 'cucumber/rake/task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec) do |task|
8
+ task.rspec_opts = ['--color']
9
+ end
10
+
11
+ Cucumber::Rake::Task.new(:features) do |task|
12
+ task.cucumber_opts = "features --format pretty"
13
+ end
14
+
15
+ task :default => [:spec, :features]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "typekitter"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/bin/typekitter ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'typekitter'
4
+
5
+ Typekitter::CLI.start
@@ -0,0 +1,8 @@
1
+ Style/EndOfLine:
2
+ Enabled: true
3
+
4
+ Style/GuardClause:
5
+ Enabled: false
6
+
7
+ Style/StringLiterals:
8
+ EnforcedStyle: single_quotes
@@ -0,0 +1,45 @@
1
+ module Typekitter
2
+ class ApiClient
3
+ ENDPOINTS = {
4
+ kits_index: 'https://typekit.com/api/v1/json/kits'
5
+ }
6
+
7
+ def kits_index
8
+ kits = Typhoeus.get(
9
+ ENDPOINTS[:kits_index],
10
+ headers: { 'X-Typekit-Token' => Typekitter::Token.load.value }
11
+ )
12
+
13
+ if kits.success?
14
+ JSON.parse(kits.body)
15
+ else
16
+ error_message(kits.body)
17
+ end
18
+ end
19
+
20
+ def kits_create(options={})
21
+ kit = Typhoeus.post(
22
+ ENDPOINTS[:kits_index],
23
+ headers: { 'X-Typekit-Token' => Typekitter::Token.load.value },
24
+ body: {
25
+ name: options[:name],
26
+ domains: options[:domains],
27
+ families: options[:families],
28
+ segmented_names: options[:segmented_names]
29
+ }
30
+ )
31
+
32
+ if kit.success?
33
+ JSON.parse(kit.body)
34
+ else
35
+ error_message(kit.body)
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def error_message(description)
42
+ "An error occured: #{description}"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,43 @@
1
+ class Typekitter::CLI < Thor
2
+ attr_reader :client
3
+
4
+ package_name 'typekitter'
5
+
6
+ def initialize(*args)
7
+ super
8
+ @client = Typekitter::ApiClient.new
9
+ @token = Typekitter::Token.load
10
+ end
11
+
12
+ desc 'save_token [value]', 'Saves the token to .typekitter-token'
13
+ def save_token(value)
14
+ @token = Typekitter::Token.setup(value)
15
+ if @token
16
+ puts "typekit token saved successfully"
17
+ end
18
+ end
19
+
20
+ desc 'display_token', 'Displays the current token in use'
21
+ def display_token
22
+ puts "Your typekit token is: #{@token.value}"
23
+ end
24
+
25
+ desc 'kits_index', 'Display a list of all your typekits'
26
+ def kits_index
27
+ ap @client.kits_index, index: false
28
+ end
29
+
30
+ desc 'kits_create', 'Creates a new draft kit, returns kit info. See help for options'
31
+ option :name, required: true
32
+ option :domains
33
+ option :families
34
+ option :segmented_names
35
+ def kits_create
36
+ ap @client.kits_create(
37
+ name: options[:name],
38
+ domains: options[:domains],
39
+ families: options[:families],
40
+ segmented_names: options[:segmented_names]
41
+ ), index: false
42
+ end
43
+ end
@@ -0,0 +1,37 @@
1
+ module Typekitter
2
+ class Token
3
+ attr_reader :value
4
+
5
+ DEFAULT_TOKEN_NAME = '.typekitter_token'
6
+
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ def self.token_path
12
+ "#{Dir.pwd}/#{DEFAULT_TOKEN_NAME}"
13
+ end
14
+
15
+ def self.setup(value)
16
+ save(value)
17
+ self.load
18
+ end
19
+
20
+ def self.save(value)
21
+ File.open(token_path, 'w') do |file|
22
+ file.write(value)
23
+ end
24
+ end
25
+
26
+ def self.load
27
+ if token_exists?
28
+ value = File.open(token_path).read
29
+ new value
30
+ end
31
+ end
32
+
33
+ def self.token_exists?
34
+ File.exists?(token_path)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Typekitter
2
+ VERSION = "0.1.0"
3
+ end
data/lib/typekitter.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'thor'
2
+ require 'typhoeus'
3
+ require 'json'
4
+ require 'awesome_print'
5
+ require 'typekitter/version'
6
+ require 'typekitter/token'
7
+ require 'typekitter/api_client'
8
+ require 'typekitter/cli'
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'typekitter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "typekitter"
8
+ spec.version = Typekitter::VERSION
9
+ spec.authors = ["Ricardo Rubio"]
10
+ spec.email = ["rickarubio@gmail.com"]
11
+
12
+ spec.summary = %q{Allows you to interact with typekit apis with a ruby client}
13
+ spec.homepage = "https://github.com/rickarubio/typekitter"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "thor"
22
+ spec.add_runtime_dependency "typhoeus"
23
+ spec.add_runtime_dependency "awesome_print"
24
+ spec.add_runtime_dependency "webmock"
25
+ spec.add_runtime_dependency "json"
26
+ spec.add_development_dependency "aruba"
27
+ spec.add_development_dependency "bundler", "~> 1.7"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec"
30
+ spec.add_development_dependency "byebug"
31
+ spec.add_development_dependency "fakefs"
32
+ spec.add_development_dependency "cucumber"
33
+ end
metadata ADDED
@@ -0,0 +1,231 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typekitter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ricardo Rubio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-15 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: typhoeus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: awesome_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: aruba
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.7'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.7'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: fakefs
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: cucumber
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description:
182
+ email:
183
+ - rickarubio@gmail.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".gitignore"
189
+ - ".hound.yml"
190
+ - ".rspec"
191
+ - ".travis.yml"
192
+ - CODE_OF_CONDUCT.md
193
+ - Gemfile
194
+ - LICENSE.txt
195
+ - README.md
196
+ - Rakefile
197
+ - bin/console
198
+ - bin/setup
199
+ - bin/typekitter
200
+ - config/rubocop.yml
201
+ - lib/typekitter.rb
202
+ - lib/typekitter/api_client.rb
203
+ - lib/typekitter/cli.rb
204
+ - lib/typekitter/token.rb
205
+ - lib/typekitter/version.rb
206
+ - typekitter.gemspec
207
+ homepage: https://github.com/rickarubio/typekitter
208
+ licenses:
209
+ - MIT
210
+ metadata: {}
211
+ post_install_message:
212
+ rdoc_options: []
213
+ require_paths:
214
+ - lib
215
+ required_ruby_version: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - ">="
218
+ - !ruby/object:Gem::Version
219
+ version: '0'
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ requirements: []
226
+ rubyforge_project:
227
+ rubygems_version: 2.4.6
228
+ signing_key:
229
+ specification_version: 4
230
+ summary: Allows you to interact with typekit apis with a ruby client
231
+ test_files: []