typekit-cli 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f360b3425744b01e3a81f58144f0ff4762c5210
4
+ data.tar.gz: 6e0df96f43979fae0af8cbf5ff850d00748cf034
5
+ SHA512:
6
+ metadata.gz: 00488a6e6c2bee043b7a2120756ac021639f32b20c7557b2c66d4ee97a0c4345c32637c14045ee2e874e1740e43389f135077c62fce094167b87544fffedd615
7
+ data.tar.gz: fdf197213a2eff802287f8df43883fbea231fd671ee0d2a9f94d125e5e9f311503306a3f3df7f46bb7a61d158e2a03efc730523a9b34dc0910604c0d8dba4fe7
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ before_install: gem install bundler --pre
3
+
4
+ rvm:
5
+ - 2.2.0
6
+
7
+ script: 'bundle exec rake'
8
+
9
+ notifications:
10
+ email:
11
+ recipients:
12
+ - danil.zvyagintsev@gmail.com
13
+ on_failure: change
14
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in typekit_cli.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Danil Zvyagintsev
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ # TypekitCli
2
+
3
+ [![Build Status](https://travis-ci.org/blackbumer/typekit_cli.svg?branch=master)](https://travis-ci.org/blackbumer/typekit_cli)
4
+ [![Coverage Status](https://coveralls.io/repos/blackbumer/typekit_cli/badge.svg?branch=master)](https://coveralls.io/r/blackbumer/typekit_cli?branch=master)
5
+
6
+ A command line interface in Ruby to fetch information about your kits using the public Typekit APIs.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'typekit-cli'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install typekit-cli
23
+
24
+ ## Authentication
25
+
26
+ Some API endpoints require authentication - for example, editing a kit or viewing private information such as a list of kits owned by a user. Other endpoints will give extra information when authenticated. To authenticate as a user you need to pass a token to the API.
27
+
28
+ You can support your TypeKit token through an environment variable:
29
+
30
+ exports TYPEKIT_TOKEN = your_typekit_api_token
31
+ typekit kits
32
+
33
+ Otherwise you need to pass a token inline:
34
+
35
+ typekit kits token your_typekit_api_token
36
+
37
+ Or with a shortcut:
38
+
39
+ typekit kits -t your_typekit_api_token
40
+
41
+ ## Usage and supported commands
42
+
43
+
44
+ typekit help
45
+ typekit kits
46
+ typekit kit KIT_ID
47
+
48
+
49
+
50
+ ## Development
51
+
52
+ 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.
53
+
54
+ 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).
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it ( https://github.com/blackbumer/typekit_cli/fork )
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create a new Pull Request
63
+
64
+ License
65
+ -------
66
+ Released under the MIT License. See the [LICENSE][] file for further details.
67
+
68
+ [license]: LICENSE.md
@@ -0,0 +1,13 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look within is `/specs`
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ task :spec => :set_env
10
+
11
+ task :set_env do
12
+ ENV['TYPEKIT_TOKEN']='mocked token'
13
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "typekit_cli"
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
@@ -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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'rubygems' unless defined? Gem
6
+ require 'typekit_cli/cli'
7
+
8
+ TypekitCli::CLI.start
@@ -0,0 +1,5 @@
1
+ require 'typekit_cli/version'
2
+ require 'typekit_cli/cli'
3
+
4
+ module TypekitCli
5
+ end
@@ -0,0 +1,52 @@
1
+ require 'thor'
2
+ require 'typekit_cli'
3
+ require 'rest-client'
4
+ require 'table_print'
5
+ require 'json'
6
+
7
+ module TypekitCli
8
+ class CLI < Thor
9
+ def self.exit_on_failure?
10
+ true
11
+ end
12
+
13
+ class_option :token, :type => :string, :required => false,
14
+ :aliases => '-t', :desc => 'A token to the API, can be specified through the environment variable TYPEKIT_TOKEN'
15
+
16
+ desc 'kits', 'Returns a list of kits owned by the authenticating user'
17
+ def kits
18
+ kits_array = getJSON(:kits) || []
19
+ kits_array.length > 0 ? tp(kits_array) : puts('You don\'t have any kits')
20
+ end
21
+
22
+ desc 'kit ID', 'Returns an information about a kit by ID'
23
+ def kit(id)
24
+ puts JSON.pretty_generate(getJSON(:kit,id))
25
+ end
26
+
27
+ private
28
+
29
+ def getJSON(resourse, id = nil)
30
+ response = RestClient.get url_for(resourse, id), auth_headers
31
+ JSON.parse(response)[resourse.to_s]
32
+ end
33
+
34
+ def url_for(resourse, id = nil)
35
+ base_url = 'https://typekit.com/api/v1/json/'
36
+ case resourse
37
+ when :kits
38
+ base_url + 'kits'
39
+ when :kit
40
+ "#{base_url}kits/#{id}"
41
+ else
42
+ raise('unimplemented resource!')
43
+ end
44
+ end
45
+
46
+ def auth_headers
47
+ token = options[:token] || ENV['TYPEKIT_TOKEN']
48
+ raise('Token is required') unless token
49
+ {'X-Typekit-Token' => token}
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module TypekitCli
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,30 @@
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 = ['Danil Zvyagintsev']
10
+ spec.email = ['danil.zvyagintsev@gmail.com']
11
+
12
+ spec.summary = 'A command line interface in Ruby to fetch information about your kits using the public Typekit APIs.'
13
+ spec.homepage = 'https://github.com/blackbumer/typekit_cli'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'thor'
21
+ spec.add_dependency 'rest-client'
22
+ spec.add_dependency 'table_print'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.9'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'webmock'
29
+ spec.add_development_dependency 'coveralls'
30
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typekit-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Danil Zvyagintsev
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-23 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: rest-client
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: table_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: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
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: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email:
127
+ - danil.zvyagintsev@gmail.com
128
+ executables:
129
+ - typekit
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .coveralls.yml
134
+ - .gitignore
135
+ - .rspec
136
+ - .travis.yml
137
+ - Gemfile
138
+ - LICENSE.md
139
+ - README.md
140
+ - Rakefile
141
+ - bin/console
142
+ - bin/setup
143
+ - exe/typekit
144
+ - lib/typekit_cli.rb
145
+ - lib/typekit_cli/cli.rb
146
+ - lib/typekit_cli/version.rb
147
+ - typekit_cli.gemspec
148
+ homepage: https://github.com/blackbumer/typekit_cli
149
+ licenses: []
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.0.14
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: A command line interface in Ruby to fetch information about your kits using
171
+ the public Typekit APIs.
172
+ test_files: []