cute_print 1.1.4 → 1.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -17
- data/README.md +3 -3
- data/cute_print.gemspec +63 -77
- data/lib/cute_print/release.rb +13 -0
- metadata +98 -62
- data/.config/cucumber.yml +0 -1
- data/.rspec +0 -1
- data/.travis.yml +0 -6
- data/.yardopts +0 -7
- data/Gemfile.lock +0 -110
- data/VERSION +0 -1
- data/features/.nav +0 -10
- data/features/call_chain.feature +0 -96
- data/features/configuring/configure_output.feature +0 -21
- data/features/configuring/configure_position_format.feature +0 -39
- data/features/configuring/readme.md +0 -1
- data/features/configuring/reset_configuration.feature +0 -24
- data/features/inspect/core.feature +0 -18
- data/features/inspect/inspect.feature +0 -29
- data/features/inspect/inspect_with_location.feature +0 -54
- data/features/inspect/inspect_with_source.feature +0 -16
- data/features/inspect/readme.md +0 -1
- data/features/pretty_print/pretty_print.feature +0 -41
- data/features/pretty_print/pretty_print_with_location.feature +0 -73
- data/features/pretty_print/pretty_print_with_source.feature +0 -27
- data/features/readme.md +0 -1
- data/features/support/env.rb +0 -9
- data/features/support/helpers/example.rb +0 -52
- data/features/support/helpers/example_runner.rb +0 -24
- data/features/support/helpers/fork_example_runner.rb +0 -37
- data/features/support/helpers/lib_path.rb +0 -7
- data/features/support/helpers/shell_example_runner.rb +0 -26
- data/features/support/helpers/temp_dir.rb +0 -15
- data/features/support/step_definitions.rb +0 -49
- data/spec/cute_print_spec.rb +0 -54
- data/spec/format/inspect_spec.rb +0 -20
- data/spec/format/pretty_print_spec.rb +0 -36
- data/spec/inline_labeler_spec.rb +0 -39
- data/spec/irb_spec.rb +0 -25
- data/spec/labeler_spec.rb +0 -97
- data/spec/outline_labeler_spec.rb +0 -37
- data/spec/printer_spec.rb +0 -79
- data/spec/silence_warnings.rb +0 -24
- data/spec/spec_helper.rb +0 -21
- data/spec/support/captures_stderr.rb +0 -3
- data/tasks/cucumber.rake +0 -8
- data/tasks/default.rake +0 -1
- data/tasks/jeweler.rake +0 -39
- data/tasks/spec.rake +0 -5
- data/tasks/test.rake +0 -2
- data/tasks/yard.rake +0 -3
- data/test_support/captures_stderr.rb +0 -16
- data/test_support/captures_stdout.rb +0 -16
- data/test_support/thread_unsafe_string_io.rb +0 -13
@@ -1,16 +0,0 @@
|
|
1
|
-
Feature: Inspect with source
|
2
|
-
|
3
|
-
Kernel#q, if given a block, prints the source for the block and then
|
4
|
-
the inspected result of running the block.
|
5
|
-
|
6
|
-
Scenario: Label and inspect an object
|
7
|
-
Given a file with:
|
8
|
-
"""
|
9
|
-
require "cute_print"
|
10
|
-
q {1 + 2}
|
11
|
-
"""
|
12
|
-
Then stderr should be
|
13
|
-
"""
|
14
|
-
(1 + 2) is 3
|
15
|
-
|
16
|
-
"""
|
data/features/inspect/readme.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
There are several ways to inspect objects:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
Feature: Pretty-print
|
2
|
-
|
3
|
-
Kernel#qq pretty-prints its arguments and prints them, one per line. This
|
4
|
-
is just like Kernel#pp from the pp library, except that it writes to $stderr
|
5
|
-
by default.
|
6
|
-
|
7
|
-
Scenario: One argument
|
8
|
-
Given a file with:
|
9
|
-
"""
|
10
|
-
require "cute_print"
|
11
|
-
a = [
|
12
|
-
"Once upon a time there were four little Rabbits, and their names were",
|
13
|
-
"Flopsy,",
|
14
|
-
"Mopsy,",
|
15
|
-
"Cotton-tail, and",
|
16
|
-
"Peter.",
|
17
|
-
]
|
18
|
-
qq a
|
19
|
-
"""
|
20
|
-
Then stderr should be
|
21
|
-
"""
|
22
|
-
["Once upon a time there were four little Rabbits, and their names were",
|
23
|
-
"Flopsy,",
|
24
|
-
"Mopsy,",
|
25
|
-
"Cotton-tail, and",
|
26
|
-
"Peter."]
|
27
|
-
|
28
|
-
"""
|
29
|
-
|
30
|
-
Scenario: Two arguments
|
31
|
-
Given a file with:
|
32
|
-
"""
|
33
|
-
require "cute_print"
|
34
|
-
qq 1, "foo"
|
35
|
-
"""
|
36
|
-
Then stderr should be
|
37
|
-
"""
|
38
|
-
1
|
39
|
-
"foo"
|
40
|
-
|
41
|
-
"""
|
@@ -1,73 +0,0 @@
|
|
1
|
-
Feature: Pretty-print with source location
|
2
|
-
|
3
|
-
Kernel#qql works just like Kernel#pp from the built-in pp library,
|
4
|
-
except that it writes to $stderr _and_ it labels the output with
|
5
|
-
the source location.
|
6
|
-
|
7
|
-
If the filename is long, then the source location is printed on a
|
8
|
-
line of its own.
|
9
|
-
|
10
|
-
Scenario: One argument
|
11
|
-
Given a file named "example.rb" with:
|
12
|
-
"""
|
13
|
-
require "cute_print"
|
14
|
-
a = [
|
15
|
-
"Once upon a time there were four little Rabbits, ",
|
16
|
-
"and their names were",
|
17
|
-
"Flopsy,",
|
18
|
-
"Mopsy,",
|
19
|
-
"Cotton-tail, and",
|
20
|
-
"Peter.",
|
21
|
-
]
|
22
|
-
qql a
|
23
|
-
"""
|
24
|
-
Then stderr should be
|
25
|
-
"""
|
26
|
-
example.rb:10: ["Once upon a time there were four little Rabbits, ",
|
27
|
-
"and their names were",
|
28
|
-
"Flopsy,",
|
29
|
-
"Mopsy,",
|
30
|
-
"Cotton-tail, and",
|
31
|
-
"Peter."]
|
32
|
-
|
33
|
-
"""
|
34
|
-
|
35
|
-
Scenario: Two arguments
|
36
|
-
Given a file named "example.rb" with:
|
37
|
-
"""
|
38
|
-
require "cute_print"
|
39
|
-
qql 1, "foo"
|
40
|
-
"""
|
41
|
-
Then stderr should be
|
42
|
-
"""
|
43
|
-
example.rb:2: 1
|
44
|
-
example.rb:2: "foo"
|
45
|
-
|
46
|
-
"""
|
47
|
-
|
48
|
-
Scenario: Very long label
|
49
|
-
|
50
|
-
Given a file named "long____________________________filename.rb" with:
|
51
|
-
"""
|
52
|
-
require "cute_print"
|
53
|
-
a = [
|
54
|
-
"Once upon a time there were four little Rabbits, ",
|
55
|
-
"and their names were",
|
56
|
-
"Flopsy,",
|
57
|
-
"Mopsy,",
|
58
|
-
"Cotton-tail, and",
|
59
|
-
"Peter.",
|
60
|
-
]
|
61
|
-
qql a
|
62
|
-
"""
|
63
|
-
Then stderr should be
|
64
|
-
"""
|
65
|
-
long____________________________filename.rb:10:
|
66
|
-
["Once upon a time there were four little Rabbits, ",
|
67
|
-
"and their names were",
|
68
|
-
"Flopsy,",
|
69
|
-
"Mopsy,",
|
70
|
-
"Cotton-tail, and",
|
71
|
-
"Peter."]
|
72
|
-
|
73
|
-
"""
|
@@ -1,27 +0,0 @@
|
|
1
|
-
Feature: Pretty-print with source
|
2
|
-
|
3
|
-
Kernel#pp, if given a block, prints the source for the block and then
|
4
|
-
the pretty-printed result of running the block.
|
5
|
-
|
6
|
-
Scenario: Label and pretty-print an object
|
7
|
-
Given a file with:
|
8
|
-
"""
|
9
|
-
require "cute_print"
|
10
|
-
a = [
|
11
|
-
"Once upon a time there were four little Rabbits, and their names were",
|
12
|
-
"Flopsy,",
|
13
|
-
"Mopsy,",
|
14
|
-
"Cotton-tail, and",
|
15
|
-
"Peter.",
|
16
|
-
]
|
17
|
-
qq {a}
|
18
|
-
"""
|
19
|
-
Then stderr should be
|
20
|
-
"""
|
21
|
-
a is ["Once upon a time there were four little Rabbits, and their names were",
|
22
|
-
"Flopsy,",
|
23
|
-
"Mopsy,",
|
24
|
-
"Cotton-tail, and",
|
25
|
-
"Peter."]
|
26
|
-
|
27
|
-
"""
|
data/features/readme.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Write debug output to the console, with flair.
|
data/features/support/env.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require_relative "example_runner"
|
2
|
-
require_relative "temp_dir"
|
3
|
-
|
4
|
-
class Example
|
5
|
-
|
6
|
-
def initialize(contents, opts = {})
|
7
|
-
@contents = contents
|
8
|
-
@filename = opts.fetch(:filename, "example.rb")
|
9
|
-
@temp_dir = TempDir.new
|
10
|
-
create_file
|
11
|
-
end
|
12
|
-
|
13
|
-
def run
|
14
|
-
ExampleRunner.run(path) do |stdout, stderr, exit_status|
|
15
|
-
@stdout = stdout
|
16
|
-
@stderr = stderr
|
17
|
-
@exit_status = exit_status
|
18
|
-
if @exit_status != 0
|
19
|
-
fail "Failed: #{@stdout}\n#{@stderr}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def stdout
|
25
|
-
filter_output(@stdout)
|
26
|
-
end
|
27
|
-
|
28
|
-
def stderr
|
29
|
-
filter_output(@stderr)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def create_file
|
35
|
-
File.open(path, 'w') do |file|
|
36
|
-
file.write @contents
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def path
|
41
|
-
File.join(@temp_dir.path, @filename)
|
42
|
-
end
|
43
|
-
|
44
|
-
def filter_output(output)
|
45
|
-
redact_tmp_path(output)
|
46
|
-
end
|
47
|
-
|
48
|
-
def redact_tmp_path(output)
|
49
|
-
output.sub(/\/tmp\/.*\//, "/tmp/.../")
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
|
3
|
-
require_relative "fork_example_runner"
|
4
|
-
require_relative "shell_example_runner"
|
5
|
-
|
6
|
-
class ExampleRunner
|
7
|
-
|
8
|
-
def self.run(*args, &block)
|
9
|
-
instance.run(*args, &block)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.instance
|
13
|
-
@instance ||= make
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.make
|
17
|
-
if ForkExampleRunner.supported?
|
18
|
-
ForkExampleRunner.new
|
19
|
-
else
|
20
|
-
ShellExampleRunner.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require_relative "../../../test_support/captures_stderr"
|
2
|
-
require_relative "../../../test_support/captures_stdout"
|
3
|
-
require_relative "lib_path"
|
4
|
-
|
5
|
-
require "open3"
|
6
|
-
|
7
|
-
# This example runner is relatively fast, but isn't available on all
|
8
|
-
# platforms.
|
9
|
-
class ForkExampleRunner
|
10
|
-
|
11
|
-
include CapturesStderr
|
12
|
-
include CapturesStdout
|
13
|
-
include LibPath
|
14
|
-
|
15
|
-
def self.supported?
|
16
|
-
Process.respond_to?(:fork)
|
17
|
-
end
|
18
|
-
|
19
|
-
def run(path)
|
20
|
-
stdout_rd, stdout_wr = IO.pipe
|
21
|
-
stderr_rd, stderr_wr = IO.pipe
|
22
|
-
pid = fork do
|
23
|
-
$stdout.reopen stdout_wr
|
24
|
-
$stderr.reopen stderr_wr
|
25
|
-
load path
|
26
|
-
exit! 0
|
27
|
-
end
|
28
|
-
Process.wait(pid)
|
29
|
-
exit_status = $?
|
30
|
-
stdout_wr.close
|
31
|
-
stderr_wr.close
|
32
|
-
stdout = stdout_rd.read
|
33
|
-
stderr = stderr_rd.read
|
34
|
-
yield stdout, stderr, exit_status
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
|
3
|
-
require_relative "lib_path"
|
4
|
-
|
5
|
-
# This example runner is relatively slow, but should work on platforms
|
6
|
-
# which do not support fork, such as Windows.
|
7
|
-
class ShellExampleRunner
|
8
|
-
|
9
|
-
include LibPath
|
10
|
-
|
11
|
-
def run(path)
|
12
|
-
command = [
|
13
|
-
"ruby",
|
14
|
-
"-I", lib_path,
|
15
|
-
path,
|
16
|
-
]
|
17
|
-
Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
|
18
|
-
stdin.close
|
19
|
-
stdout = stdout.read
|
20
|
-
stderr = stderr.read
|
21
|
-
exit_status = wait_thr.value
|
22
|
-
yield stdout, stderr, exit_status
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,49 +0,0 @@
|
|
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
|
-
|
33
|
-
Given(/^a file with:$/) do |contents|
|
34
|
-
@example = Example.new(contents)
|
35
|
-
@example.run
|
36
|
-
end
|
37
|
-
|
38
|
-
Given(/^a file named "(.*?)" with:$/) do |filename, contents|
|
39
|
-
@example = Example.new(contents, :filename => filename)
|
40
|
-
@example.run
|
41
|
-
end
|
42
|
-
|
43
|
-
Then(/^stderr should be$/) do |expected|
|
44
|
-
expect(@example.stderr).to eq expected
|
45
|
-
end
|
46
|
-
|
47
|
-
Then(/^stdout should be$/) do |expected|
|
48
|
-
expect(@example.stdout).to eq expected
|
49
|
-
end
|
data/spec/cute_print_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
require "stringio"
|
4
|
-
|
5
|
-
require "cute_print"
|
6
|
-
|
7
|
-
# This spec tests the parts of the library, as the user sees it, that
|
8
|
-
# are not covered by a Cucumber feature.
|
9
|
-
#
|
10
|
-
# The other specs test internals.
|
11
|
-
|
12
|
-
describe CutePrint do
|
13
|
-
|
14
|
-
before(:each) do
|
15
|
-
CutePrint.configure { |c| c.reset }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#q" do
|
19
|
-
When(:stderr) do
|
20
|
-
capture_stderr do
|
21
|
-
@result = q 123
|
22
|
-
end
|
23
|
-
end
|
24
|
-
Then { expect(@result).to be_nil }
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#ql" do
|
28
|
-
When(:stderr) do
|
29
|
-
capture_stderr do
|
30
|
-
@result = ql 123
|
31
|
-
end
|
32
|
-
end
|
33
|
-
Then { expect(@result).to be_nil }
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#qq" do
|
37
|
-
When do
|
38
|
-
@stderr = capture_stderr do
|
39
|
-
@result = qq 123
|
40
|
-
end
|
41
|
-
end
|
42
|
-
Then { expect(@result).to be_nil }
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#qql" do
|
46
|
-
When do
|
47
|
-
@stderr = capture_stderr do
|
48
|
-
@result = qql 123
|
49
|
-
end
|
50
|
-
end
|
51
|
-
Then { expect(@result).to be_nil }
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|