tty-font 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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e2386849887ca6ba94f9d32e7e89b7304fd181a
4
+ data.tar.gz: f1fdde346a01e43653f6156180ad670366432586
5
+ SHA512:
6
+ metadata.gz: 9c940a8acbf2c27502ce10ddbefd731ffcc5b818b705ca42df62818e49f8385ce7f300e37499559ed57c394638123e9815ad0efa6e308e318f03cf168ee68d8a
7
+ data.tar.gz: 600a17cc22208aae3cc5dc17cb77943e61e7753f926c454d10c945e63101e91ed08af1fc6be33e7a3ce7fc4a3fd673350b687cd2c9ab3fe5a6b697839e166acf
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /Gemfile.lock
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,24 @@
1
+ ---
2
+ language: ruby
3
+ sudo: false
4
+ cache: bundler
5
+ before_install: "gem update bundler"
6
+ script: "bundle exec rake ci"
7
+ rvm:
8
+ - 2.0.0
9
+ - 2.1.10
10
+ - 2.2.8
11
+ - 2.3.5
12
+ - 2.4.2
13
+ - ruby-head
14
+ - jruby-9000
15
+ - jruby-head
16
+ matrix:
17
+ allow_failures:
18
+ - rvm: ruby-head
19
+ - rvm: jruby-head
20
+ fast_finish: true
21
+ branches:
22
+ only: master
23
+ notifications:
24
+ email: false
@@ -0,0 +1,7 @@
1
+ # Change log
2
+
3
+ ## [v0.1.0] - 2017-12-18
4
+
5
+ * Initial implementation and release
6
+
7
+ [v0.1.0]: https://github.com/piotrmurach/tty-font/compare/v0.1.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at [email]. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
6
+
7
+ gem 'pastel'
8
+ gem 'tty-cursor'
9
+ gem 'tty-screen'
10
+
11
+ group :test do
12
+ gem 'benchmark-ips', '~> 2.0.0'
13
+ gem 'simplecov', '~> 0.10.0'
14
+ gem 'coveralls', '~> 0.8.2'
15
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Piotr Murach
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.
@@ -0,0 +1,112 @@
1
+ # TTY::Font [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/tty-font.svg)][gem]
4
+ [![Build Status](https://secure.travis-ci.org/piotrmurach/tty-font.svg?branch=master)][travis]
5
+ [![Build status](https://ci.appveyor.com/api/projects/status/cj4owy2vlty2q1ko?svg=true)][appveyor]
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/b0d6263bd34e1c0cae74/maintainability)][codeclimate]
7
+ [![Coverage Status](https://coveralls.io/repos/github/piotrmurach/tty-font/badge.svg)][coverage]
8
+ [![Inline docs](http://inch-ci.org/github/piotrmurach/tty-font.svg?branch=master)][inchpages]
9
+
10
+ [gitter]: https://gitter.im/piotrmurach/tty
11
+ [gem]: http://badge.fury.io/rb/tty-font
12
+ [travis]: http://travis-ci.org/piotrmurach/tty-font
13
+ [appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-font
14
+ [codeclimate]: https://codeclimate.com/github/piotrmurach/tty-font/maintainability
15
+ [coverage]: https://coveralls.io/github/piotrmurach/tty-font
16
+ [inchpages]: http://inch-ci.org/github/piotrmurach/tty-font
17
+
18
+ > Write text in large stylized characters using a variety of terminal friendly fonts.
19
+
20
+ ![screenshot](https://github.com/piotrmurach/tty-font/raw/master/assets/starwars_logo.png)
21
+
22
+ **TTY::Font** provides independent terminal font rendering component for [TTY](https://github.com/piotrmurach/tty) toolkit.
23
+
24
+ ## Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+
28
+ ```ruby
29
+ gem 'tty-font'
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ $ bundle
35
+
36
+ Or install it yourself as:
37
+
38
+ $ gem install tty-font
39
+
40
+ ## Usage
41
+
42
+ Initialize font out of [available](#fonts) fonts:
43
+
44
+ ```ruby
45
+ font = TTY::Font.new(:doom)
46
+ ```
47
+
48
+ and then print text out to console:
49
+
50
+ ```ruby
51
+ puts font.write("DOOM")
52
+ # =>
53
+ # ______ _____ _____ ___ ___
54
+ # | _ \| _ || _ || \/ |
55
+ # | | | || | | || | | || . . |
56
+ # | | | || | | || | | || |\/| |
57
+ # | |/ / \ \_/ /\ \_/ /| | | |
58
+ # |___/ \___/ \___/ \_| |_/
59
+ #
60
+ ```
61
+
62
+ To adjust the spacing between all the letters in a piece of text use `:letter_spacing` option:
63
+
64
+ ```ruby
65
+ puts font.write("DOOM", letter_spacing: 4)
66
+ # =>
67
+ # ______ _____ _____ ___ ___
68
+ # | _ \ | _ | | _ | | \/ |
69
+ # | | | | | | | | | | | | | . . |
70
+ # | | | | | | | | | | | | | |\/| |
71
+ # | |/ / \ \_/ / \ \_/ / | | | |
72
+ # |___/ \___/ \___/ \_| |_/
73
+ ```
74
+
75
+ If you wish to print text in color use [pastel](https://github.com/piotrmurach/pastel):
76
+
77
+ ```ruby
78
+ pastel = Pastel.new
79
+ puts pastel.yellow(font.write("DOOM"))
80
+ ```
81
+
82
+ ## Fonts
83
+
84
+ The list of the available fonts: (select link to see font face)
85
+
86
+ * [3d](fonts/3d.md)
87
+ * [doom](fonts/doom.md)
88
+ * [standard](fonts/standard.md)
89
+ * [starwars](fonts/starwars.md)
90
+ * [straight](fonts/straight.md)
91
+
92
+ ## Development
93
+
94
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
95
+
96
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
97
+
98
+ ## Contributing
99
+
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrmurach/tty-font. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
101
+
102
+ ## License
103
+
104
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
105
+
106
+ ## Code of Conduct
107
+
108
+ Everyone interacting in the TTY::Font project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tty-font/blob/master/CODE_OF_CONDUCT.md).
109
+
110
+ ## Copyright
111
+
112
+ Copyright (c) 2017 Piotr Murach. See LICENSE for further details.
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ FileList['tasks/**/*.rake'].each(&method(:import))
4
+
5
+ desc 'Run all specs'
6
+ task ci: %w[ spec ]
7
+
8
+ task default: :spec
@@ -0,0 +1,21 @@
1
+ ---
2
+ install:
3
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
4
+ - ruby --version
5
+ - gem --version
6
+ - bundle install
7
+ build: off
8
+ test_script:
9
+ - bundle exec rake ci
10
+ environment:
11
+ matrix:
12
+ - ruby_version: "200"
13
+ - ruby_version: "200-x64"
14
+ - ruby_version: "21"
15
+ - ruby_version: "21-x64"
16
+ - ruby_version: "22"
17
+ - ruby_version: "22-x64"
18
+ - ruby_version: "23"
19
+ - ruby_version: "23-x64"
20
+ - ruby_version: "24"
21
+ - ruby_version: "24-x64"
Binary file
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tty/font"
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(__FILE__)
@@ -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,19 @@
1
+ require 'tty-font'
2
+ require 'pastel'
3
+
4
+ pastel = Pastel.new
5
+ font = TTY::Font.new("3d")
6
+
7
+ puts pastel.green(font.write('3d'))
8
+
9
+ puts font.write("ABCDEFGHIJKLMN")
10
+ puts font.write("OPQRSTUVWXYZ")
11
+
12
+ puts font.write("abcdefghijklmn")
13
+ puts font.write("opqrstuvwxyz")
14
+
15
+ puts font.write("0123456789")
16
+
17
+ puts font.write("!#\$%^&*()-_+=")
18
+
19
+ puts font.write("\"',.:;><?@][\\/}{|")
@@ -0,0 +1,19 @@
1
+ require 'tty-font'
2
+ require 'pastel'
3
+
4
+ pastel = Pastel.new
5
+ font = TTY::Font.new(:doom)
6
+
7
+ puts pastel.yellow(font.write("DOOM"))
8
+
9
+ puts font.write("ABCDEFGHIJKLMN")
10
+ puts font.write("OPQRSTUVWXYZ")
11
+
12
+ puts font.write("abcdefghijklmn")
13
+ puts font.write("opqrstuvwxyz")
14
+
15
+ puts font.write("0123456789")
16
+
17
+ puts font.write("!#\$%^&*()-_+=")
18
+
19
+ puts font.write("\"',.:;><?@][\\/")
@@ -0,0 +1,18 @@
1
+ require 'tty-font'
2
+ require 'pastel'
3
+
4
+ pastel = Pastel.new
5
+ font = TTY::Font.new(:standard)
6
+
7
+ puts pastel.green(font.write('standard'))
8
+
9
+ puts font.write("ABCDEFGHIJKLMN")
10
+ puts font.write("OPQRSTUVWXYZ")
11
+
12
+ puts font.write("abcdefghijklmnopqrstuvwxyz")
13
+
14
+ puts font.write("0123456789")
15
+
16
+ puts font.write("!#\$%^&*()-_+=")
17
+
18
+ puts font.write("\"',.:;><?@][\\/}{|")
@@ -0,0 +1,51 @@
1
+ require 'pastel'
2
+ require 'tty-font'
3
+ require 'tty-cursor'
4
+ require 'tty-screen'
5
+
6
+ @pastel = Pastel.new
7
+ @cursor = TTY::Cursor
8
+ @font = TTY::Font.new(:starwars)
9
+ @reg_font = TTY::Font.new(:straight)
10
+
11
+ def lines_at(lines, x, y)
12
+ lines.each_with_index.reduce([]) do |acc, (line, i)|
13
+ acc << @cursor.move_to(x - line.size/2, y - lines.size/2 + i) + line
14
+ acc
15
+ end
16
+ end
17
+
18
+ def paint_logo
19
+ @size = TTY::Screen.size
20
+
21
+ print @cursor.save
22
+ print @cursor.clear_screen
23
+ print @cursor.hide
24
+
25
+ # ["2606".to_i(16)].pack("U*")
26
+ stars = ['.', '*']
27
+
28
+ (@size[1] + @size[0]).times do |i|
29
+ print @cursor.move_to(rand(@size[1]), rand(@size[0])) + stars[rand(2)]
30
+ end
31
+
32
+ center_x = @size[1]/2
33
+ center_y = @size[0]/2
34
+
35
+ lines = @font.write('STAR').split("\n")
36
+ print @pastel.red(lines_at(lines, center_x, center_y - 5).join)
37
+ lines = @reg_font.write("THE LAST JEDI", letter_spacing: 1).split("\n")
38
+ print lines_at(lines, center_x, center_y).join
39
+ lines = @font.write('WARS').split("\n")
40
+ print @pastel.red(lines_at(lines, center_x, center_y + 4).join)
41
+ end
42
+
43
+ begin
44
+ Signal.trap('SIGWINCH') { paint_logo }
45
+ paint_logo
46
+ $stdin.getc
47
+ ensure
48
+ print @cursor.show
49
+ print @cursor.clear_screen
50
+ print @cursor.restore
51
+ end