tty-screen 0.5.0 → 0.5.1
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 +4 -4
- data/.travis.yml +8 -12
- data/CHANGELOG.md +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +2 -3
- data/README.md +18 -12
- data/appveyor.yml +21 -0
- data/lib/tty-screen.rb +0 -2
- data/lib/tty/screen.rb +2 -4
- data/lib/tty/screen/size.rb +25 -15
- data/lib/tty/screen/version.rb +1 -3
- data/spec/spec_helper.rb +0 -2
- data/spec/unit/new_spec.rb +0 -2
- data/spec/unit/size_spec.rb +3 -5
- data/tasks/console.rake +1 -1
- data/tty-screen.gemspec +1 -1
- metadata +17 -17
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a63a2019e73caf56b233666335b21ec5f0f5200
|
4
|
+
data.tar.gz: c01de14e847e44852e352a7a916379f82c657560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c7da830b7bfcc5c08f061d27e5ced6593fe39c26e503adee00364937531b7cee77a1eda6134eec8d344dd8e2fe412b28fd6de12edd56e37aa586ac401a453df
|
7
|
+
data.tar.gz: 474a96f5cfe40c0d4cae44be6bbc928d2f350adc4aa96bfe32f399409f851b3dae50c266b135463410e7cc263f2146cad5bb726e0fd874a7c63dded3d5663b16
|
data/.travis.yml
CHANGED
@@ -2,25 +2,21 @@
|
|
2
2
|
language: ruby
|
3
3
|
sudo: false
|
4
4
|
cache: bundler
|
5
|
+
before_install: "gem update bundler"
|
5
6
|
script: "bundle exec rake ci"
|
6
7
|
rvm:
|
7
|
-
-
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.
|
8
|
+
- 2.0.0
|
9
|
+
- 2.1.10
|
10
|
+
- 2.2.5
|
11
|
+
- 2.3.1
|
12
|
+
- 2.4.1
|
11
13
|
- ruby-head
|
14
|
+
- jruby-9000
|
15
|
+
- jruby-head
|
12
16
|
matrix:
|
13
|
-
include:
|
14
|
-
- rvm: jruby-19mode
|
15
|
-
- rvm: jruby-20mode
|
16
|
-
- rvm: jruby-21mode
|
17
|
-
- rvm: jruby-head
|
18
|
-
- rvm: rbx-2
|
19
17
|
allow_failures:
|
20
18
|
- rvm: ruby-head
|
21
19
|
- rvm: jruby-head
|
22
|
-
- rvm: jruby-20mode
|
23
|
-
- rvm: jruby-21mode
|
24
20
|
fast_finish: true
|
25
21
|
branches:
|
26
22
|
only: master
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.5.1] - 2017-10-26
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
* Change #from_io_console to return nil when no size present
|
7
|
+
* Change #run_command to silently ignore any errors
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
* Fix #from_readline check to prevent from failing on missing api call
|
11
|
+
* Fix #from_stty to only extract size when stty command returns output
|
12
|
+
* Fix #run_command to correctly capture command output and fix #from_tput check
|
13
|
+
|
3
14
|
## [v0.5.0] - 2016-01-03
|
4
15
|
|
5
16
|
### Changed
|
@@ -45,6 +56,7 @@
|
|
45
56
|
### Fixed
|
46
57
|
* Fix bug with screen detection from_io_console by @luxflux
|
47
58
|
|
59
|
+
[v0.5.1]: https://github.com/peter-murach/tty-screen/compare/v0.5.0...v0.5.1
|
48
60
|
[v0.5.0]: https://github.com/peter-murach/tty-screen/compare/v0.4.3...v0.5.0
|
49
61
|
[v0.4.3]: https://github.com/peter-murach/tty-screen/compare/v0.4.2...v0.4.3
|
50
62
|
[v0.4.2]: https://github.com/peter-murach/tty-screen/compare/v0.4.1...v0.4.2
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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
CHANGED
data/README.md
CHANGED
@@ -1,19 +1,23 @@
|
|
1
|
-
# TTY::Screen
|
1
|
+
# TTY::Screen [][gitter]
|
2
|
+
|
2
3
|
[][gem]
|
3
|
-
[][travis]
|
5
|
+
[][appveyor]
|
6
|
+
[][codeclimate]
|
7
|
+
[][coverage]
|
8
|
+
[][inchpages]
|
7
9
|
|
10
|
+
[gitter]: https://gitter.im/piotrmurach/tty
|
8
11
|
[gem]: http://badge.fury.io/rb/tty-screen
|
9
|
-
[travis]: http://travis-ci.org/
|
10
|
-
[
|
11
|
-
[
|
12
|
-
[
|
12
|
+
[travis]: http://travis-ci.org/piotrmurach/tty-screen
|
13
|
+
[appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-screen
|
14
|
+
[codeclimate]: https://codeclimate.com/github/piotrmurach/tty-screen
|
15
|
+
[coverage]: https://coveralls.io/r/piotrmurach/tty-screen
|
16
|
+
[inchpages]: http://inch-ci.org/github/piotrmurach/tty-screen
|
13
17
|
|
14
18
|
> Terminal screen size detection which works on Linux, OS X and Windows/Cygwin platforms and supports MRI, JRuby and Rubinius interpreters.
|
15
19
|
|
16
|
-
**TTY::Screen** provides independent screen size detection component for [TTY](https://github.com/
|
20
|
+
**TTY::Screen** provides independent screen size detection component for [TTY](https://github.com/piotrmurach/tty) toolkit.
|
17
21
|
|
18
22
|
## Installation
|
19
23
|
|
@@ -53,12 +57,14 @@ TTY::Screen.height # => 51
|
|
53
57
|
|
54
58
|
## Contributing
|
55
59
|
|
56
|
-
1. Fork it ( https://github.com/
|
60
|
+
1. Fork it ( https://github.com/piotrmurach/tty-screen/fork )
|
57
61
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
62
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
63
|
4. Push to the branch (`git push origin my-new-feature`)
|
60
64
|
5. Create a new Pull Request
|
61
65
|
|
66
|
+
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.
|
67
|
+
|
62
68
|
## Copyright
|
63
69
|
|
64
|
-
Copyright (c) 2014-
|
70
|
+
Copyright (c) 2014-2017 Piotr Murach. See LICENSE for further details.
|
data/appveyor.yml
ADDED
@@ -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"
|
data/lib/tty-screen.rb
CHANGED
data/lib/tty/screen.rb
CHANGED
data/lib/tty/screen/size.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
module TTY
|
4
2
|
class Screen
|
5
3
|
class Size
|
@@ -34,7 +32,7 @@ module TTY
|
|
34
32
|
#
|
35
33
|
# @api private
|
36
34
|
def from_io_console
|
37
|
-
return
|
35
|
+
return if jruby?
|
38
36
|
try_io_console { |size| size if nonzero_column?(size[1]) }
|
39
37
|
end
|
40
38
|
|
@@ -49,24 +47,22 @@ module TTY
|
|
49
47
|
begin
|
50
48
|
if output.tty? && IO.method_defined?(:winsize)
|
51
49
|
yield output.winsize
|
52
|
-
else
|
53
|
-
false
|
54
50
|
end
|
55
51
|
rescue Errno::EOPNOTSUPP
|
56
|
-
|
52
|
+
# no support for winsize on output
|
57
53
|
end
|
58
54
|
rescue LoadError
|
59
|
-
warn 'no native io/console support' if @verbose
|
60
|
-
false
|
55
|
+
warn 'no native io/console support or io-console gem' if @verbose
|
61
56
|
end
|
62
57
|
|
63
58
|
# Detect screen size using Readline
|
64
59
|
#
|
65
60
|
# @api private
|
66
61
|
def from_readline
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
if defined?(Readline) && Readline.respond_to?(:get_screen_size)
|
63
|
+
size = Readline.get_screen_size
|
64
|
+
size if nonzero_column?(size[1])
|
65
|
+
end
|
70
66
|
rescue NotImplementedError
|
71
67
|
end
|
72
68
|
|
@@ -86,7 +82,9 @@ module TTY
|
|
86
82
|
# @api private
|
87
83
|
def from_stty
|
88
84
|
return unless output.tty?
|
89
|
-
|
85
|
+
out = run_command('stty', 'size')
|
86
|
+
return unless out
|
87
|
+
size = out.split.map(&:to_i)
|
90
88
|
size if nonzero_column?(size[1])
|
91
89
|
rescue Errno::ENOENT
|
92
90
|
end
|
@@ -126,13 +124,25 @@ module TTY
|
|
126
124
|
|
127
125
|
private
|
128
126
|
|
129
|
-
# Runs command
|
127
|
+
# Runs command silently capturing the output
|
130
128
|
#
|
131
129
|
# @api private
|
132
|
-
def run_command(
|
133
|
-
|
130
|
+
def run_command(*args)
|
131
|
+
require 'tempfile'
|
132
|
+
out = Tempfile.new('tty-screen')
|
133
|
+
result = system(*args, out: out.path)
|
134
|
+
return if result.nil?
|
135
|
+
out.rewind
|
136
|
+
out.read
|
137
|
+
ensure
|
138
|
+
out.close if out
|
134
139
|
end
|
135
140
|
|
141
|
+
# Check if number is non zero
|
142
|
+
#
|
143
|
+
# return [Boolean]
|
144
|
+
#
|
145
|
+
# @api private
|
136
146
|
def nonzero_column?(column)
|
137
147
|
column.to_i > 0
|
138
148
|
end
|
data/lib/tty/screen/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/unit/new_spec.rb
CHANGED
data/spec/unit/size_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
require 'delegate'
|
4
2
|
|
5
3
|
RSpec.describe TTY::Screen::Size, '#size' do
|
@@ -26,7 +24,7 @@ RSpec.describe TTY::Screen::Size, '#size' do
|
|
26
24
|
it "doesn't calculate size if jruby " do
|
27
25
|
screen = described_class.new({})
|
28
26
|
allow(screen).to receive(:jruby?).and_return(true)
|
29
|
-
expect(screen.from_io_console).to eq(
|
27
|
+
expect(screen.from_io_console).to eq(nil)
|
30
28
|
end
|
31
29
|
|
32
30
|
it "calcualtes the size" do
|
@@ -47,7 +45,7 @@ RSpec.describe TTY::Screen::Size, '#size' do
|
|
47
45
|
allow(screen).to receive(:jruby?).and_return(false)
|
48
46
|
allow(screen).to receive(:require).with('io/console').
|
49
47
|
and_raise(LoadError)
|
50
|
-
expect(screen.from_io_console).to eq(
|
48
|
+
expect(screen.from_io_console).to eq(nil)
|
51
49
|
end
|
52
50
|
|
53
51
|
it "doesn't calculate size if it is run without a console" do
|
@@ -57,7 +55,7 @@ RSpec.describe TTY::Screen::Size, '#size' do
|
|
57
55
|
and_return(true)
|
58
56
|
allow(output).to receive(:tty?).and_return(true)
|
59
57
|
allow(IO).to receive(:method_defined?).with(:winsize).and_return(false)
|
60
|
-
expect(screen.from_io_console).to eq(
|
58
|
+
expect(screen.from_io_console).to eq(nil)
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
data/tasks/console.rake
CHANGED
data/tty-screen.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = [""]
|
11
11
|
spec.summary = %q{Terminal screen size detection which works on Linux, OS X and Windows/Cygwin platforms and supports MRI, JRuby and Rubinius interpreters.}
|
12
12
|
spec.description = %q{Terminal screen size detection which works on Linux, OS X and Windows/Cygwin platforms and supports MRI, JRuby and Rubinius interpreters.}
|
13
|
-
spec.homepage = "
|
13
|
+
spec.homepage = "https://piotrmurach.github.io/tty/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-screen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.5.0
|
20
|
-
- - <
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2.0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.5.0
|
30
|
-
- - <
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ~>
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '10.0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - ~>
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '10.0'
|
47
47
|
description: Terminal screen size detection which works on Linux, OS X and Windows/Cygwin
|
@@ -52,15 +52,16 @@ executables: []
|
|
52
52
|
extensions: []
|
53
53
|
extra_rdoc_files: []
|
54
54
|
files:
|
55
|
-
- .gitignore
|
56
|
-
- .rspec
|
57
|
-
- .
|
58
|
-
- .travis.yml
|
55
|
+
- ".gitignore"
|
56
|
+
- ".rspec"
|
57
|
+
- ".travis.yml"
|
59
58
|
- CHANGELOG.md
|
59
|
+
- CODE_OF_CONDUCT.md
|
60
60
|
- Gemfile
|
61
61
|
- LICENSE.txt
|
62
62
|
- README.md
|
63
63
|
- Rakefile
|
64
|
+
- appveyor.yml
|
64
65
|
- lib/tty-screen.rb
|
65
66
|
- lib/tty/screen.rb
|
66
67
|
- lib/tty/screen/size.rb
|
@@ -72,7 +73,7 @@ files:
|
|
72
73
|
- tasks/coverage.rake
|
73
74
|
- tasks/spec.rake
|
74
75
|
- tty-screen.gemspec
|
75
|
-
homepage:
|
76
|
+
homepage: https://piotrmurach.github.io/tty/
|
76
77
|
licenses:
|
77
78
|
- MIT
|
78
79
|
metadata: {}
|
@@ -82,17 +83,17 @@ require_paths:
|
|
82
83
|
- lib
|
83
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
85
|
requirements:
|
85
|
-
- -
|
86
|
+
- - ">="
|
86
87
|
- !ruby/object:Gem::Version
|
87
88
|
version: '0'
|
88
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
90
|
requirements:
|
90
|
-
- -
|
91
|
+
- - ">="
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
95
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.5.1
|
96
97
|
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: Terminal screen size detection which works on Linux, OS X and Windows/Cygwin
|
@@ -101,4 +102,3 @@ test_files:
|
|
101
102
|
- spec/spec_helper.rb
|
102
103
|
- spec/unit/new_spec.rb
|
103
104
|
- spec/unit/size_spec.rb
|
104
|
-
has_rdoc:
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.0.0
|