fontabulous 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0e75ce82c42a59cd957914e760defe3e6fe7cfc
4
- data.tar.gz: c9c7738242ffcced9c365c51b33b153929420f1b
3
+ metadata.gz: 9e8037826c668bff4f29f3e40d69f109fb39c310
4
+ data.tar.gz: a5a61a18c634478ac257e4acfdb7bb24623dde41
5
5
  SHA512:
6
- metadata.gz: 316f660853e56106940e219903d0f6855be386a67f7ad85736cb657d46096b7a6f06a852296142fa616291eeccef6705b8d82f16ca3291e37e261bb1281ca579
7
- data.tar.gz: d06b08c93da12ee0500a13b88c18d69d11cde8d19c141c6bc8f5f64e528b411892b912aacd0cbc87ef67102f41b78694bb0b043a3ef887a3d18bf167609ae6ff
6
+ metadata.gz: 69b79637f97bbd1424367b27dc2ad96f54c13105ca8a6995938816abb914d8c0cff2e8917706843bf06fa85d194d0678b5deedaf677e656c3192bf425de15624
7
+ data.tar.gz: c9dcdd496d7615ff84559518eb9a415981b2d0e3ea9fa4af823f5e2a94ade5d7ebcb238bfa848dac9c7ff4857431cb87d9a9311c52415de9004a601114601c75
@@ -0,0 +1,193 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ # Created by https://www.gitignore.io/api/ruby,macos,rubymine,sublimetext
15
+
16
+ ### macOS ###
17
+ *.DS_Store
18
+ .AppleDouble
19
+ .LSOverride
20
+
21
+ # Icon must end with two \r
22
+ Icon
23
+
24
+ # Thumbnails
25
+ ._*
26
+
27
+ # Files that might appear in the root of a volume
28
+ .DocumentRevisions-V100
29
+ .fseventsd
30
+ .Spotlight-V100
31
+ .TemporaryItems
32
+ .Trashes
33
+ .VolumeIcon.icns
34
+ .com.apple.timemachine.donotpresent
35
+
36
+ # Directories potentially created on remote AFP share
37
+ .AppleDB
38
+ .AppleDesktop
39
+ Network Trash Folder
40
+ Temporary Items
41
+ .apdisk
42
+
43
+ ### Ruby ###
44
+ *.gem
45
+ *.rbc
46
+ /.config
47
+ /coverage/
48
+ /InstalledFiles
49
+ /pkg/
50
+ /spec/reports/
51
+ /spec/examples.txt
52
+ /test/tmp/
53
+ /test/version_tmp/
54
+ /tmp/
55
+
56
+ # Used by dotenv library to load environment variables.
57
+ # .env
58
+
59
+ ## Specific to RubyMotion:
60
+ .dat*
61
+ .repl_history
62
+ build/
63
+ *.bridgesupport
64
+ build-iPhoneOS/
65
+ build-iPhoneSimulator/
66
+
67
+ ## Specific to RubyMotion (use of CocoaPods):
68
+ #
69
+ # We recommend against adding the Pods directory to your .gitignore. However
70
+ # you should judge for yourself, the pros and cons are mentioned at:
71
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
72
+ #
73
+ # vendor/Pods/
74
+
75
+ ## Documentation cache and generated files:
76
+ /.yardoc/
77
+ /_yardoc/
78
+ /doc/
79
+ /rdoc/
80
+
81
+ ## Environment normalization:
82
+ /.bundle/
83
+ /vendor/bundle
84
+ /lib/bundler/man/
85
+
86
+ # for a library or gem, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # Gemfile.lock
89
+ # .ruby-version
90
+ # .ruby-gemset
91
+
92
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
93
+ .rvmrc
94
+
95
+ ### RubyMine ###
96
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
97
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
98
+
99
+ # User-specific stuff:
100
+ .idea/**/workspace.xml
101
+ .idea/**/tasks.xml
102
+ .idea/dictionaries
103
+
104
+ # Sensitive or high-churn files:
105
+ .idea/**/dataSources/
106
+ .idea/**/dataSources.ids
107
+ .idea/**/dataSources.xml
108
+ .idea/**/dataSources.local.xml
109
+ .idea/**/sqlDataSources.xml
110
+ .idea/**/dynamic.xml
111
+ .idea/**/uiDesigner.xml
112
+
113
+ # Gradle:
114
+ .idea/**/gradle.xml
115
+ .idea/**/libraries
116
+
117
+ # CMake
118
+ cmake-build-debug/
119
+
120
+ # Mongo Explorer plugin:
121
+ .idea/**/mongoSettings.xml
122
+
123
+ ## File-based project format:
124
+ *.iws
125
+
126
+ ## Plugin-specific files:
127
+
128
+ # IntelliJ
129
+ /out/
130
+
131
+ # mpeltonen/sbt-idea plugin
132
+ .idea_modules/
133
+
134
+ # JIRA plugin
135
+ atlassian-ide-plugin.xml
136
+
137
+ # Cursive Clojure plugin
138
+ .idea/replstate.xml
139
+
140
+ # Ruby plugin and RubyMine
141
+ /.rakeTasks
142
+
143
+ # Crashlytics plugin (for Android Studio and IntelliJ)
144
+ com_crashlytics_export_strings.xml
145
+ crashlytics.properties
146
+ crashlytics-build.properties
147
+ fabric.properties
148
+
149
+ ### RubyMine Patch ###
150
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
151
+
152
+ # *.iml
153
+ # modules.xml
154
+ # .idea/misc.xml
155
+ # *.ipr
156
+
157
+ # Sonarlint plugin
158
+ .idea/sonarlint
159
+
160
+ ### SublimeText ###
161
+ # cache files for sublime text
162
+ *.tmlanguage.cache
163
+ *.tmPreferences.cache
164
+ *.stTheme.cache
165
+
166
+ # workspace files are user-specific
167
+ *.sublime-workspace
168
+
169
+ # project files should be checked into the repository, unless a significant
170
+ # proportion of contributors will probably not be using SublimeText
171
+ # *.sublime-project
172
+
173
+ # sftp configuration file
174
+ sftp-config.json
175
+
176
+ # Package control specific files
177
+ Package Control.last-run
178
+ Package Control.ca-list
179
+ Package Control.ca-bundle
180
+ Package Control.system-ca-bundle
181
+ Package Control.cache/
182
+ Package Control.ca-certs/
183
+ Package Control.merged-ca-bundle
184
+ Package Control.user-ca-bundle
185
+ oscrypto-ca-bundle.crt
186
+ bh_unicode_properties.cache
187
+
188
+ # Sublime-github package stores a github token in this file
189
+ # https://packagecontrol.io/packages/sublime-github
190
+ GitHub.sublime-settings
191
+
192
+
193
+ # End of https://www.gitignore.io/api/ruby,macos,rubymine,sublimetext
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,8 @@
1
+ Metrics/LineLength:
2
+ Max: 120
3
+
4
+ Layout/SpaceAroundOperators:
5
+ Enabled: false
6
+
7
+ Metrics/BlockLength:
8
+ Max: 50
@@ -0,0 +1 @@
1
+ 2.4.2
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.0
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in fontabulous.gemspec
8
+ gemspec
@@ -0,0 +1,48 @@
1
+ # Fontabulous
2
+
3
+ [![Build Status](https://travis-ci.org/v1nayv/fontabulous.svg?branch=master)](https://travis-ci.org/v1nayv/fontabulous)
4
+
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/4b3ad8039c9df03695de/maintainability)](https://codeclimate.com/github/v1nayv/fontabulous/maintainability)
6
+
7
+
8
+ Command line Ruby application to access information about Typekit kits using [Adobe Typekit's public API](https://typekit.com/docs/api).
9
+
10
+ ## Installation
11
+
12
+ $ gem install fontabulous
13
+
14
+ ## Setup
15
+
16
+ Create a `.fontabulous` config file which contains configuration items to your typekit account. Note that this config file should be created in the home directory.
17
+
18
+ If this config file is not created you will be asked for the token every time you run a command.
19
+
20
+ Here is a sample file
21
+
22
+ typekit_auth_token: df0c9e6b07bf7695adc44cd302b474a9fa424b49
23
+ base_uri: https://typekit.com
24
+
25
+ **typekit_auth_token** - Is the token generated from your account. <br>
26
+ **base_uri (optional)** - is the base_uri to access Adobes typekit public API. If this is not defined the base uri will default to https://typekit.com
27
+ ## Usage
28
+
29
+ ### Available commands
30
+
31
+ * `foab kits` - Lists kits owned by the authenticating user.
32
+ * `foab kit draft <id>` - Shows draft version of the kit based on the id.
33
+ * `foab kit published <id>` - Shows published version of the kit based on the id.
34
+ * `foab help` - Shows available commands.
35
+
36
+ ## Development
37
+
38
+ * git clone the repo
39
+ * `bundle` to install dependencies
40
+ * Use `bundle exec bin/foab <command>` to run the commands during development.
41
+
42
+ ### Tests
43
+
44
+ * Run `rspec` to run tests.
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/v1nayv/fontabulous.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'fontabulous'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'fontabulous'
5
+
6
+ Fontabulous::FoabCli.start(ARGV)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('../lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require 'fontabulous/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'fontabulous'
10
+ spec.version = Fontabulous::VERSION
11
+ spec.authors = ['Vinay Vasudevamurthy']
12
+ spec.email = ['vinay.vasudevamurthy@cerner.com']
13
+
14
+ spec.summary = 'Ruby gem to retrieve retrieve Adobe Typekit information.'
15
+ spec.description = 'Ruby gem to retrieve retrieve Adobe Typekit information.'
16
+ spec.homepage = 'https://github.com/v1nayv/fontabulous'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'bin'
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.required_ruby_version = '~> 2.4'
26
+
27
+ spec.add_dependency 'activesupport', '~> 5.1'
28
+ spec.add_dependency 'highline', '~> 1.7'
29
+ spec.add_dependency 'httparty', '~> 0.15'
30
+ spec.add_dependency 'thor', '~> 0.20'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.16'
33
+ spec.add_development_dependency 'pry-byebug', '~> 3.5'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.0'
36
+ spec.add_development_dependency 'rubocop', '~> 0.52.1'
37
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fontabulous/version'
4
+ require 'fontabulous/cli'
5
+ require 'active_support'
6
+ require 'active_support/core_ext'
7
+
8
+ ##
9
+ # Contains code to access Adobe typekit information.
10
+ module Fontabulous
11
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'fontabulous/retrievers/kit'
5
+ require 'fontabulous/templates/console_output_template'
6
+ require 'fontabulous/typekit_config'
7
+
8
+ module Fontabulous
9
+ ##
10
+ # This is a class that lets you retreive information about a kit from command line.
11
+ class Kit < Thor
12
+ desc 'draft <id>', 'Shows the current draft version of the kit'
13
+ def draft(id)
14
+ config = Fontabulous::TypekitConfig.instance
15
+ kit = Fontabulous::Retrievers::Kit.new(base_uri: config.base_uri, auth_token: config.auth_token)
16
+
17
+ header = "The current draft version of Kit: #{id}"
18
+ output_template = Fontabulous::Templates::ConsoleOutputTemplate.new(header, kit.draft(id: id).data)
19
+ output_template.print
20
+ end
21
+
22
+ desc 'published <id>', 'Shows the current published version of the kit'
23
+ def published(id)
24
+ config = Fontabulous::TypekitConfig.instance
25
+ kit = Fontabulous::Retrievers::Kit.new(base_uri: config.base_uri, auth_token: config.auth_token)
26
+
27
+ header = "The current published version of Kit: #{id}"
28
+ output_template = Fontabulous::Templates::ConsoleOutputTemplate.new(header, kit.published(id: id).data)
29
+ output_template.print
30
+ end
31
+ end
32
+
33
+ ##
34
+ # This is a class that lets you retreive information about Adobe Typekits from command line.
35
+ class FoabCli < Thor
36
+ desc 'kits', 'Lists all the kits under your account.'
37
+ def kits
38
+ config = Fontabulous::TypekitConfig.instance
39
+ kit = Fontabulous::Retrievers::Kit.new(base_uri: config.base_uri, auth_token: config.auth_token)
40
+
41
+ header = 'Information about your kits are as follows'
42
+ output_template = Fontabulous::Templates::ConsoleOutputTemplate.new(header, kit.all.data)
43
+ output_template.print
44
+ end
45
+
46
+ desc 'kit SUBCOMMAND ...ARGS', 'Show details about the kit. `foab kit help` for subcommand help.'
47
+ subcommand 'kit', Fontabulous::Kit
48
+ end
49
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+ require 'fontabulous/retrievers/typekit_base'
5
+
6
+ module Fontabulous
7
+ module Retrievers
8
+ ##
9
+ # This is a retriever class which retrieves Adobe Typekit information from the
10
+ # typekit public api https://typekit.com/docs/api/v1/:format/kits
11
+ class Kit < TypekitBase
12
+ def all
13
+ response = self.class.get('/api/v1/json/kits', options)
14
+ Response.new(response.code, response.parsed_response)
15
+ end
16
+
17
+ def draft(id:)
18
+ response = self.class.get("/api/v1/json/kits/#{id}", options)
19
+ Response.new(response.code, response.parsed_response)
20
+ end
21
+
22
+ def published(id:)
23
+ response = self.class.get("/api/v1/json/kits/#{id}/published", options)
24
+ Response.new(response.code, response.parsed_response)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+
5
+ module Fontabulous
6
+ module Retrievers
7
+ ##
8
+ # This is a base class which is responsible for setting up config to access Adobe Typekit public api.
9
+ class TypekitBase
10
+ include HTTParty
11
+
12
+ attr_reader :options
13
+
14
+ def initialize(base_uri:, auth_token:)
15
+ self.class.base_uri base_uri
16
+ @options = { headers: { 'X-Typekit-Token' => auth_token } }
17
+ end
18
+ end
19
+
20
+ Response = Struct.new(:code, :data)
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fontabulous/templates/output_template'
4
+ require 'yaml'
5
+
6
+ module Fontabulous
7
+ module Templates
8
+ ##
9
+ # This is class responsible for writing information out on the console.
10
+ class ConsoleOutputTemplate < OutputTemplate
11
+ def initialize(header, hash_data)
12
+ @header = header
13
+ @hash_data = hash_data
14
+ end
15
+
16
+ def header
17
+ puts @header
18
+ end
19
+
20
+ def separator
21
+ puts '-' * 50
22
+ end
23
+
24
+ def body
25
+ puts @hash_data.to_yaml(indentation: 4)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fontabulous
4
+ module Templates
5
+ ##
6
+ # This is a template for writing out information. This class should to be inherited to get a
7
+ # custom output.
8
+ class OutputTemplate
9
+ def print
10
+ separator
11
+ header
12
+ separator
13
+ body
14
+ separator
15
+ end
16
+
17
+ def separator
18
+ raise 'Not implemented'
19
+ end
20
+
21
+ def header
22
+ raise 'Not implemented'
23
+ end
24
+
25
+ def body
26
+ raise 'Not implemented'
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'singleton'
4
+ require 'highline/import'
5
+
6
+ module Fontabulous
7
+ ##
8
+ # Singleton class to acess users configuration.
9
+ class TypekitConfig
10
+ include Singleton
11
+
12
+ def initialize
13
+ user_config_path = File.expand_path('~/.fontabulous')
14
+
15
+ @config = begin
16
+ default_hash = { base_uri: 'https://typekit.com' }
17
+ if File.exist?(user_config_path)
18
+ default_hash.merge!(YAML.load_file(user_config_path).symbolize_keys)
19
+ else
20
+ puts 'Consider creating .fontabulous config file in your home directory'
21
+ end
22
+
23
+ default_hash.freeze
24
+ end
25
+ end
26
+
27
+ def auth_token
28
+ return @config[:typekit_auth_token] if @config[:typekit_auth_token].present?
29
+ ask('Enter Typekit Auth token:')
30
+ end
31
+
32
+ def base_uri
33
+ @config[:base_uri]
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fontabulous
4
+ VERSION = '0.2.0'
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontabulous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinay Vasudevamurthy
@@ -139,10 +139,33 @@ dependencies:
139
139
  description: Ruby gem to retrieve retrieve Adobe Typekit information.
140
140
  email:
141
141
  - vinay.vasudevamurthy@cerner.com
142
- executables: []
142
+ executables:
143
+ - console
144
+ - foab
145
+ - setup
143
146
  extensions: []
144
147
  extra_rdoc_files: []
145
- files: []
148
+ files:
149
+ - ".gitignore"
150
+ - ".rspec"
151
+ - ".rubocop.yml"
152
+ - ".ruby-version"
153
+ - ".travis.yml"
154
+ - Gemfile
155
+ - README.md
156
+ - Rakefile
157
+ - bin/console
158
+ - bin/foab
159
+ - bin/setup
160
+ - fontabulous.gemspec
161
+ - lib/fontabulous.rb
162
+ - lib/fontabulous/cli.rb
163
+ - lib/fontabulous/retrievers/kit.rb
164
+ - lib/fontabulous/retrievers/typekit_base.rb
165
+ - lib/fontabulous/templates/console_output_template.rb
166
+ - lib/fontabulous/templates/output_template.rb
167
+ - lib/fontabulous/typekit_config.rb
168
+ - lib/fontabulous/version.rb
146
169
  homepage: https://github.com/v1nayv/fontabulous
147
170
  licenses: []
148
171
  metadata: {}
@@ -152,9 +175,9 @@ require_paths:
152
175
  - lib
153
176
  required_ruby_version: !ruby/object:Gem::Requirement
154
177
  requirements:
155
- - - ">="
178
+ - - "~>"
156
179
  - !ruby/object:Gem::Version
157
- version: '0'
180
+ version: '2.4'
158
181
  required_rubygems_version: !ruby/object:Gem::Requirement
159
182
  requirements:
160
183
  - - ">="