cute_print 1.0.1 → 1.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.
- checksums.yaml +13 -5
- data/CHANGELOG.md +11 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +45 -36
- data/README.md +12 -6
- data/VERSION +1 -1
- data/cute_print.gemspec +10 -4
- data/features/support/step_definitions.rb +32 -0
- data/lib/cute_print/configure.rb +6 -0
- data/lib/cute_print/formatter.rb +1 -3
- data/lib/cute_print/printer.rb +31 -22
- data/lib/cute_print/term_width/detected.rb +42 -0
- data/lib/cute_print/term_width/static.rb +21 -0
- data/lib/cute_print/term_width.rb +29 -0
- metadata +34 -15
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODg0NWRlYWY0NTcwOTA2NzQyYTNkYjlkMzE1OGRmNjcwYTE0NDU1NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Y2M4YTVlZjgyMThhZDhmM2M1OGM3MTkwODM2MmEyY2RjZDE4ZmIzNQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGJiMzU1NGM4YmMxYWM5NTBiMzU0MTNmNWUzNDEzMmYzZGNhMWFmYTA1MDI5
|
10
|
+
MTE2OTlkZmFlNTMwNWM0NGIyNzIyZjExNTRmODc5N2FiNWMzZDViMTQ4ODMy
|
11
|
+
ZTc5M2Y2ZmVlN2E3NjlhYTNhNjgyNmViZmQ5ZGQ5YjNjZDJlOTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2E2NWMwNjViM2MyMjliNjEwM2JmZjdiZDk3ZWJiODMwZDdiODRlZjY4ODJj
|
14
|
+
NjNmNzczMDcwMDg2MGI0NDM2OWY1MWUwM2Y2Y2Y2YmY1M2VmNzlhNTRkMWU0
|
15
|
+
NmNhN2VmNDMwN2FiNjJkYTMzODkzZDY3MTlmNDJlY2I5ODE3NjQ=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
* 1.1.0 - 2015-06-13
|
2
|
+
|
3
|
+
Enhancements:
|
4
|
+
|
5
|
+
* Determine the terminal width and use it instead of just hard-coding
|
6
|
+
"79"
|
7
|
+
|
8
|
+
API changes
|
9
|
+
|
10
|
+
* Added Configure#term_width to set the term width
|
11
|
+
|
1
12
|
# 1.0.1 - 2014-12-21
|
2
13
|
|
3
14
|
* Eliminate warnings in "-w" mode
|
data/Gemfile
CHANGED
@@ -2,10 +2,11 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
gem "ruby_parser", "~> 3.6"
|
4
4
|
gem "ruby2ruby", "~> 2.1"
|
5
|
+
gem "hirb", "~> 0.7"
|
5
6
|
|
6
7
|
group :test do
|
7
8
|
gem "bundler", "~> 1.7"
|
8
|
-
gem "cucumber", "~>
|
9
|
+
gem "cucumber", "~> 2.0"
|
9
10
|
gem "rake", "~> 10.4"
|
10
11
|
gem "rspec", "~> 3.1"
|
11
12
|
gem "rspec-given", "~> 3.5"
|
data/Gemfile.lock
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.3.
|
4
|
+
addressable (2.3.8)
|
5
5
|
builder (3.2.2)
|
6
|
-
cucumber (
|
6
|
+
cucumber (2.0.0)
|
7
7
|
builder (>= 2.1.2)
|
8
|
+
cucumber-core (~> 1.1.3)
|
8
9
|
diff-lcs (>= 1.1.3)
|
9
10
|
gherkin (~> 2.12)
|
10
11
|
multi_json (>= 1.7.5, < 2.0)
|
11
|
-
multi_test (>= 0.1.
|
12
|
+
multi_test (>= 0.1.2)
|
13
|
+
cucumber-core (1.1.3)
|
14
|
+
gherkin (~> 2.12.0)
|
12
15
|
descendants_tracker (0.0.4)
|
13
16
|
thread_safe (~> 0.3, >= 0.3.1)
|
14
17
|
diff-lcs (1.2.5)
|
15
|
-
faraday (0.9.
|
18
|
+
faraday (0.9.1)
|
16
19
|
multipart-post (>= 1.2, < 3)
|
17
20
|
gherkin (2.12.2)
|
18
21
|
multi_json (~> 1.3)
|
19
|
-
git (1.2.
|
20
|
-
github_api (0.12.
|
22
|
+
git (1.2.9.1)
|
23
|
+
github_api (0.12.3)
|
21
24
|
addressable (~> 2.3)
|
22
25
|
descendants_tracker (~> 0.0.4)
|
23
26
|
faraday (~> 0.8, < 0.10)
|
@@ -25,10 +28,11 @@ GEM
|
|
25
28
|
multi_json (>= 1.7.5, < 2.0)
|
26
29
|
nokogiri (~> 1.6.3)
|
27
30
|
oauth2
|
28
|
-
given_core (3.
|
31
|
+
given_core (3.7.0)
|
29
32
|
sorcerer (>= 0.3.7)
|
30
|
-
hashie (3.
|
31
|
-
highline (1.
|
33
|
+
hashie (3.4.2)
|
34
|
+
highline (1.7.2)
|
35
|
+
hirb (0.7.3)
|
32
36
|
jeweler (2.0.1)
|
33
37
|
builder
|
34
38
|
bundler (>= 1.0)
|
@@ -38,14 +42,14 @@ GEM
|
|
38
42
|
nokogiri (>= 1.5.10)
|
39
43
|
rake
|
40
44
|
rdoc
|
41
|
-
json (1.8.
|
42
|
-
jwt (1.
|
43
|
-
mini_portile (0.6.
|
44
|
-
multi_json (1.
|
45
|
-
multi_test (0.1.
|
45
|
+
json (1.8.3)
|
46
|
+
jwt (1.5.0)
|
47
|
+
mini_portile (0.6.2)
|
48
|
+
multi_json (1.11.1)
|
49
|
+
multi_test (0.1.2)
|
46
50
|
multi_xml (0.5.5)
|
47
51
|
multipart-post (2.0.0)
|
48
|
-
nokogiri (1.6.
|
52
|
+
nokogiri (1.6.6.2)
|
49
53
|
mini_portile (~> 0.6.0)
|
50
54
|
oauth2 (1.0.0)
|
51
55
|
faraday (>= 0.8, < 0.10)
|
@@ -53,34 +57,35 @@ GEM
|
|
53
57
|
multi_json (~> 1.3)
|
54
58
|
multi_xml (~> 0.5)
|
55
59
|
rack (~> 1.2)
|
56
|
-
rack (1.
|
60
|
+
rack (1.6.1)
|
57
61
|
rake (10.4.2)
|
58
62
|
rdoc (4.2.0)
|
59
63
|
json (~> 1.4)
|
60
|
-
redcarpet (3.
|
61
|
-
rspec (3.
|
62
|
-
rspec-core (~> 3.
|
63
|
-
rspec-expectations (~> 3.
|
64
|
-
rspec-mocks (~> 3.
|
65
|
-
rspec-core (3.
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-expectations (3.
|
64
|
+
redcarpet (3.3.1)
|
65
|
+
rspec (3.3.0)
|
66
|
+
rspec-core (~> 3.3.0)
|
67
|
+
rspec-expectations (~> 3.3.0)
|
68
|
+
rspec-mocks (~> 3.3.0)
|
69
|
+
rspec-core (3.3.0)
|
70
|
+
rspec-support (~> 3.3.0)
|
71
|
+
rspec-expectations (3.3.0)
|
68
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-given (3.
|
71
|
-
given_core (= 3.
|
72
|
-
rspec (>= 2.
|
73
|
-
rspec-mocks (3.
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
rspec-support (~> 3.3.0)
|
74
|
+
rspec-given (3.7.0)
|
75
|
+
given_core (= 3.7.0)
|
76
|
+
rspec (>= 2.14.0)
|
77
|
+
rspec-mocks (3.3.0)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.3.0)
|
80
|
+
rspec-support (3.3.0)
|
81
|
+
ruby2ruby (2.2.0)
|
77
82
|
ruby_parser (~> 3.1)
|
78
83
|
sexp_processor (~> 4.0)
|
79
|
-
ruby_parser (3.
|
84
|
+
ruby_parser (3.7.0)
|
80
85
|
sexp_processor (~> 4.1)
|
81
|
-
sexp_processor (4.
|
86
|
+
sexp_processor (4.6.0)
|
82
87
|
sorcerer (1.0.2)
|
83
|
-
thread_safe (0.3.
|
88
|
+
thread_safe (0.3.5)
|
84
89
|
yard (0.8.7.6)
|
85
90
|
|
86
91
|
PLATFORMS
|
@@ -88,7 +93,8 @@ PLATFORMS
|
|
88
93
|
|
89
94
|
DEPENDENCIES
|
90
95
|
bundler (~> 1.7)
|
91
|
-
cucumber (~>
|
96
|
+
cucumber (~> 2.0)
|
97
|
+
hirb (~> 0.7)
|
92
98
|
jeweler (~> 2.0)
|
93
99
|
rake (~> 10.4)
|
94
100
|
redcarpet (~> 3.2)
|
@@ -97,3 +103,6 @@ DEPENDENCIES
|
|
97
103
|
ruby2ruby (~> 2.1)
|
98
104
|
ruby_parser (~> 3.6)
|
99
105
|
yard (~> 0.8.7)
|
106
|
+
|
107
|
+
BUNDLED WITH
|
108
|
+
1.10.3
|
data/README.md
CHANGED
@@ -154,6 +154,18 @@ the filename:
|
|
154
154
|
c.location_format = :path
|
155
155
|
end
|
156
156
|
|
157
|
+
The terminal width is detected, if possible, but you can override it:
|
158
|
+
|
159
|
+
CutePrint.configure do |c|
|
160
|
+
c.term_width = 132
|
161
|
+
end
|
162
|
+
|
163
|
+
To set the terminal width back to being detected:
|
164
|
+
|
165
|
+
CutePrint.configure do |c|
|
166
|
+
c.term_width = :detect
|
167
|
+
end
|
168
|
+
|
157
169
|
To reset the configuration to its defaults:
|
158
170
|
|
159
171
|
CutePrint.configure do |c|
|
@@ -196,12 +208,6 @@ statement's source is derived from the _wrong_ gem.
|
|
196
208
|
|
197
209
|
This gem uses [semantic versioning 2.0][3].
|
198
210
|
|
199
|
-
While the version is < 1.0.0, the API can change with any version
|
200
|
-
increment. If you need stability, lock the gem down to a minor
|
201
|
-
version, e.g.:
|
202
|
-
|
203
|
-
gem "cute_print", "~> 0.1.0"
|
204
|
-
|
205
211
|
## Contributing
|
206
212
|
|
207
213
|
1. Fork it ( http://github.com/wconrad/cute_print/fork )
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/cute_print.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: cute_print 1.0
|
5
|
+
# stub: cute_print 1.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "cute_print"
|
9
|
-
s.version = "1.0
|
9
|
+
s.version = "1.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Wayne Conrad"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2015-06-13"
|
15
15
|
s.description = "Write debug output to stderr. Optionally print the source filename and line number, or the source of the debug statement. Easily inspect the middle of a call chain."
|
16
16
|
s.email = "wconrad@yagni.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -83,6 +83,9 @@ Gem::Specification.new do |s|
|
|
83
83
|
"lib/cute_print/ruby_parser/wraps_sexp.rb",
|
84
84
|
"lib/cute_print/source_label.rb",
|
85
85
|
"lib/cute_print/stderr_out.rb",
|
86
|
+
"lib/cute_print/term_width.rb",
|
87
|
+
"lib/cute_print/term_width/detected.rb",
|
88
|
+
"lib/cute_print/term_width/static.rb",
|
86
89
|
"lib/cute_print/values.rb",
|
87
90
|
"spec/cute_print_spec.rb",
|
88
91
|
"spec/format/inspect_spec.rb",
|
@@ -107,7 +110,7 @@ Gem::Specification.new do |s|
|
|
107
110
|
]
|
108
111
|
s.homepage = "http://github.com/wconrad/cute_print"
|
109
112
|
s.licenses = ["MIT"]
|
110
|
-
s.rubygems_version = "2.4.
|
113
|
+
s.rubygems_version = "2.4.8"
|
111
114
|
s.summary = "print debug to stderr, with flair"
|
112
115
|
|
113
116
|
if s.respond_to? :specification_version then
|
@@ -116,13 +119,16 @@ Gem::Specification.new do |s|
|
|
116
119
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
117
120
|
s.add_runtime_dependency(%q<ruby_parser>, ["~> 3.6"])
|
118
121
|
s.add_runtime_dependency(%q<ruby2ruby>, ["~> 2.1"])
|
122
|
+
s.add_runtime_dependency(%q<hirb>, ["~> 0.7"])
|
119
123
|
else
|
120
124
|
s.add_dependency(%q<ruby_parser>, ["~> 3.6"])
|
121
125
|
s.add_dependency(%q<ruby2ruby>, ["~> 2.1"])
|
126
|
+
s.add_dependency(%q<hirb>, ["~> 0.7"])
|
122
127
|
end
|
123
128
|
else
|
124
129
|
s.add_dependency(%q<ruby_parser>, ["~> 3.6"])
|
125
130
|
s.add_dependency(%q<ruby2ruby>, ["~> 2.1"])
|
131
|
+
s.add_dependency(%q<hirb>, ["~> 0.7"])
|
126
132
|
end
|
127
133
|
end
|
128
134
|
|
@@ -1,3 +1,35 @@
|
|
1
|
+
module EnvUtil
|
2
|
+
|
3
|
+
extend self
|
4
|
+
|
5
|
+
# Set environment variables for the duration of the block, then
|
6
|
+
# restore them to their original value.
|
7
|
+
# @param h [Hash]
|
8
|
+
def set(h)
|
9
|
+
orig = {}
|
10
|
+
h.keys.each do |key|
|
11
|
+
orig[key] = ENV[key]
|
12
|
+
end
|
13
|
+
begin
|
14
|
+
h.each do |key, value|
|
15
|
+
ENV[key] = value.to_s
|
16
|
+
end
|
17
|
+
yield
|
18
|
+
ensure
|
19
|
+
orig.each do |key, value|
|
20
|
+
ENV[key] = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
Around do |scenario, block|
|
28
|
+
EnvUtil.set("CUTE_PRINT_TERM_WIDTH" => 79) do
|
29
|
+
block.call
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
1
33
|
Given(/^a file with:$/) do |contents|
|
2
34
|
@example = Example.new(contents)
|
3
35
|
@example.run
|
data/lib/cute_print/configure.rb
CHANGED
@@ -32,6 +32,12 @@ module CutePrint
|
|
32
32
|
# @see Printer#out
|
33
33
|
delegate_accessor :out
|
34
34
|
|
35
|
+
# @!attribute [rw] term_width
|
36
|
+
# @return [Integer, Symbol] The terminal width, or :detect if it
|
37
|
+
# is being detected automatically.
|
38
|
+
# @see Printer#term_width
|
39
|
+
delegate_accessor :term_width
|
40
|
+
|
35
41
|
end
|
36
42
|
|
37
43
|
end
|
data/lib/cute_print/formatter.rb
CHANGED
@@ -12,15 +12,13 @@ module CutePrint
|
|
12
12
|
# @api private
|
13
13
|
class Formatter
|
14
14
|
|
15
|
-
DEFAULT_WIDTH = 79
|
16
|
-
|
17
15
|
def initialize(opts = {})
|
18
16
|
@method = opts.fetch(:method)
|
19
17
|
@out = opts.fetch(:out)
|
20
18
|
@block = opts.fetch(:block, nil)
|
21
19
|
@args = opts.fetch(:values, [])
|
22
20
|
@values = Values.new(@args, @block)
|
23
|
-
@width = opts.fetch(:width
|
21
|
+
@width = opts.fetch(:width)
|
24
22
|
@location_label = nil
|
25
23
|
end
|
26
24
|
|
data/lib/cute_print/printer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "formatter"
|
2
2
|
require_relative "stderr_out"
|
3
|
+
require_relative "term_width"
|
3
4
|
|
4
5
|
module CutePrint
|
5
6
|
class Printer
|
@@ -10,7 +11,7 @@ module CutePrint
|
|
10
11
|
# @return [#print]
|
11
12
|
attr_accessor :out
|
12
13
|
|
13
|
-
# The location format.
|
14
|
+
# The location format. Defaults to :filename
|
14
15
|
#
|
15
16
|
# One of:
|
16
17
|
# * :filename
|
@@ -19,6 +20,21 @@ module CutePrint
|
|
19
20
|
# @return [String]
|
20
21
|
attr_accessor :location_format
|
21
22
|
|
23
|
+
# The terminal width. May be an integer, or :detect to cause the
|
24
|
+
# terminal width to be determined automatically. Defaults to
|
25
|
+
# :detect
|
26
|
+
#
|
27
|
+
# @!attribute [rw] term_width
|
28
|
+
# @return [Integer, Symbol]
|
29
|
+
|
30
|
+
def term_width
|
31
|
+
@term_width.visible
|
32
|
+
end
|
33
|
+
|
34
|
+
def term_width=(value)
|
35
|
+
@term_width = TermWidth.make(value)
|
36
|
+
end
|
37
|
+
|
22
38
|
# Create an instance. If attributes are supplied, they override
|
23
39
|
# the defaults. For example:
|
24
40
|
#
|
@@ -34,16 +50,12 @@ module CutePrint
|
|
34
50
|
def set_defaults
|
35
51
|
@out = StderrOut.new
|
36
52
|
@location_format = :filename
|
53
|
+
self.term_width = :detect
|
37
54
|
end
|
38
55
|
|
39
56
|
# @see CutePrint.q
|
40
57
|
def q(*values, &block)
|
41
|
-
formatter =
|
42
|
-
method: __method__,
|
43
|
-
out: @out,
|
44
|
-
block: block,
|
45
|
-
values: values
|
46
|
-
)
|
58
|
+
formatter = make_formatter(__method__, values, block)
|
47
59
|
formatter.inspect
|
48
60
|
formatter.write
|
49
61
|
nil
|
@@ -51,11 +63,7 @@ module CutePrint
|
|
51
63
|
|
52
64
|
# @see CutePrint.ql
|
53
65
|
def ql(*values, &block)
|
54
|
-
formatter =
|
55
|
-
method: __method__,
|
56
|
-
out: @out,
|
57
|
-
block: block,
|
58
|
-
values: values)
|
66
|
+
formatter = make_formatter(__method__, values, block)
|
59
67
|
formatter.inspect
|
60
68
|
formatter.with_location @location_format
|
61
69
|
formatter.write
|
@@ -64,11 +72,7 @@ module CutePrint
|
|
64
72
|
|
65
73
|
# @see CutePrint.qq
|
66
74
|
def qq(*values, &block)
|
67
|
-
formatter =
|
68
|
-
method: __method__,
|
69
|
-
out: @out,
|
70
|
-
block: block,
|
71
|
-
values: values)
|
75
|
+
formatter = make_formatter(__method__, values, block)
|
72
76
|
formatter.pretty_print
|
73
77
|
formatter.write
|
74
78
|
nil
|
@@ -76,11 +80,7 @@ module CutePrint
|
|
76
80
|
|
77
81
|
# @see CutePrint.qql
|
78
82
|
def qql(*values, &block)
|
79
|
-
formatter =
|
80
|
-
method: __method__,
|
81
|
-
out: @out,
|
82
|
-
block: block,
|
83
|
-
values: values)
|
83
|
+
formatter = make_formatter(__method__, values, block)
|
84
84
|
formatter.pretty_print
|
85
85
|
formatter.with_location @location_format
|
86
86
|
formatter.write
|
@@ -89,5 +89,14 @@ module CutePrint
|
|
89
89
|
|
90
90
|
private
|
91
91
|
|
92
|
+
def make_formatter(method, values, block)
|
93
|
+
Formatter.new(
|
94
|
+
method: method,
|
95
|
+
block: block,
|
96
|
+
values: values,
|
97
|
+
out: @out,
|
98
|
+
width: @term_width.width)
|
99
|
+
end
|
100
|
+
|
92
101
|
end
|
93
102
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "hirb"
|
2
|
+
|
3
|
+
module CutePrint
|
4
|
+
class TermWidth
|
5
|
+
|
6
|
+
# A terminal width that tries to determine the terminal width
|
7
|
+
# automatically.
|
8
|
+
# @api private
|
9
|
+
class Detected
|
10
|
+
|
11
|
+
attr_reader :width
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@width = detect_width
|
15
|
+
end
|
16
|
+
|
17
|
+
def visible
|
18
|
+
:detect
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
FALLBACK_WIDTH = 79
|
24
|
+
|
25
|
+
def detect_width
|
26
|
+
return width_override_for_tests if width_override_for_tests
|
27
|
+
width, _height = Hirb::Util.detect_terminal_size
|
28
|
+
# Hirb returns nil if it can't determine the terminal width.
|
29
|
+
# Program run in Emacs have an apparent terminal width of "0".
|
30
|
+
width = FALLBACK_WIDTH if width.nil? || width == 0
|
31
|
+
width
|
32
|
+
end
|
33
|
+
|
34
|
+
def width_override_for_tests
|
35
|
+
n = ENV['CUTE_PRINT_TERM_WIDTH']
|
36
|
+
n && Integer(n)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CutePrint
|
2
|
+
class TermWidth
|
3
|
+
|
4
|
+
# A terminal width with a fixed value
|
5
|
+
# @api private
|
6
|
+
class Static
|
7
|
+
|
8
|
+
attr_reader :width
|
9
|
+
|
10
|
+
def initialize(width)
|
11
|
+
@width = width
|
12
|
+
end
|
13
|
+
|
14
|
+
def visible
|
15
|
+
@width
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "term_width/detected"
|
2
|
+
require_relative "term_width/static"
|
3
|
+
|
4
|
+
module CutePrint
|
5
|
+
|
6
|
+
# @api private
|
7
|
+
class TermWidth
|
8
|
+
|
9
|
+
# Given a width, make an appropriate TermWidth object. The object
|
10
|
+
# returned has these readers:
|
11
|
+
# * #width [Integer] Return the actual terminal width
|
12
|
+
# * #visible [Object] Return the terminal width that
|
13
|
+
# #Configuration#term_width should return.
|
14
|
+
# @param width [Object] Either the static terminal width,
|
15
|
+
# or :detect to automatically detect the terminal width.
|
16
|
+
# @return [#width, #visible]
|
17
|
+
def self.make(width)
|
18
|
+
case width
|
19
|
+
when Integer
|
20
|
+
Static.new(width)
|
21
|
+
when :detect
|
22
|
+
Detected.new
|
23
|
+
else
|
24
|
+
raise ArgumentError, "Invalid terminal width: #{width.inspect}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cute_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wayne Conrad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby_parser
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: !binary |-
|
20
|
+
My42
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- -
|
25
|
+
- - ~>
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
+
version: !binary |-
|
28
|
+
My42
|
27
29
|
- !ruby/object:Gem::Dependency
|
28
30
|
name: ruby2ruby
|
29
31
|
requirement: !ruby/object:Gem::Requirement
|
30
32
|
requirements:
|
31
|
-
- -
|
33
|
+
- - ~>
|
32
34
|
- !ruby/object:Gem::Version
|
33
35
|
version: '2.1'
|
34
36
|
type: :runtime
|
35
37
|
prerelease: false
|
36
38
|
version_requirements: !ruby/object:Gem::Requirement
|
37
39
|
requirements:
|
38
|
-
- -
|
40
|
+
- - ~>
|
39
41
|
- !ruby/object:Gem::Version
|
40
42
|
version: '2.1'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: hirb
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.7'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.7'
|
41
57
|
description: Write debug output to stderr. Optionally print the source filename and
|
42
58
|
line number, or the source of the debug statement. Easily inspect the middle of
|
43
59
|
a call chain.
|
@@ -48,10 +64,10 @@ extra_rdoc_files:
|
|
48
64
|
- LICENSE
|
49
65
|
- README.md
|
50
66
|
files:
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
67
|
+
- .config/cucumber.yml
|
68
|
+
- .rspec
|
69
|
+
- .travis.yml
|
70
|
+
- .yardopts
|
55
71
|
- CHANGELOG.md
|
56
72
|
- Gemfile
|
57
73
|
- Gemfile.lock
|
@@ -112,6 +128,9 @@ files:
|
|
112
128
|
- lib/cute_print/ruby_parser/wraps_sexp.rb
|
113
129
|
- lib/cute_print/source_label.rb
|
114
130
|
- lib/cute_print/stderr_out.rb
|
131
|
+
- lib/cute_print/term_width.rb
|
132
|
+
- lib/cute_print/term_width/detected.rb
|
133
|
+
- lib/cute_print/term_width/static.rb
|
115
134
|
- lib/cute_print/values.rb
|
116
135
|
- spec/cute_print_spec.rb
|
117
136
|
- spec/format/inspect_spec.rb
|
@@ -143,17 +162,17 @@ require_paths:
|
|
143
162
|
- lib
|
144
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
164
|
requirements:
|
146
|
-
- -
|
165
|
+
- - ! '>='
|
147
166
|
- !ruby/object:Gem::Version
|
148
167
|
version: '0'
|
149
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
169
|
requirements:
|
151
|
-
- -
|
170
|
+
- - ! '>='
|
152
171
|
- !ruby/object:Gem::Version
|
153
172
|
version: '0'
|
154
173
|
requirements: []
|
155
174
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.4.
|
175
|
+
rubygems_version: 2.4.8
|
157
176
|
signing_key:
|
158
177
|
specification_version: 4
|
159
178
|
summary: print debug to stderr, with flair
|