cute_print 0.3.0 → 0.4.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 +10 -1
- data/README.md +42 -1
- data/VERSION +1 -1
- data/cute_print.gemspec +25 -4
- data/features/call_chain.feature +6 -5
- data/features/configuring/configure_position_format.feature +1 -2
- data/features/inspect/core.feature +18 -0
- data/features/inspect/inspect_with_location.feature +1 -1
- data/features/support/env.rb +3 -3
- data/features/support/helpers/example.rb +11 -13
- data/features/support/helpers/example_runner.rb +24 -0
- data/features/support/helpers/fork_example_runner.rb +37 -0
- data/features/support/helpers/lib_path.rb +7 -0
- data/features/support/helpers/shell_example_runner.rb +26 -0
- data/features/support/step_definitions.rb +0 -6
- data/lib/cute_print/core.rb +3 -0
- data/lib/cute_print/core_ext.rb +2 -0
- data/lib/cute_print/cute_print.rb +83 -0
- data/lib/cute_print/format/inspect.rb +12 -0
- data/lib/cute_print/format/pretty_print.rb +17 -0
- data/lib/cute_print/format.rb +2 -0
- data/lib/cute_print/formatter.rb +15 -81
- data/lib/cute_print/inline_labeler.rb +36 -0
- data/lib/cute_print/labeler.rb +71 -0
- data/lib/cute_print/location.rb +4 -10
- data/lib/cute_print/location_label/filename.rb +19 -0
- data/lib/cute_print/location_label/path.rb +19 -0
- data/lib/cute_print/location_label.rb +23 -0
- data/lib/cute_print/mixin.rb +13 -12
- data/lib/cute_print/outline_labeler.rb +38 -0
- data/lib/cute_print/printer.rb +4 -36
- data/lib/cute_print/source_label.rb +26 -0
- data/lib/cute_print.rb +1 -25
- data/spec/format/inspect_spec.rb +20 -0
- data/spec/format/pretty_print_spec.rb +36 -0
- data/spec/inline_labeler_spec.rb +39 -0
- data/spec/labeler_spec.rb +97 -0
- data/spec/outline_labeler_spec.rb +37 -0
- metadata +24 -3
- data/lib/cute_print/default_printer.rb +0 -14
@@ -0,0 +1,97 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
require "cute_print/labeler"
|
4
|
+
|
5
|
+
module CutePrint
|
6
|
+
describe Labeler do
|
7
|
+
|
8
|
+
WIDTH = 5
|
9
|
+
WIDTHS = {
|
10
|
+
fits: WIDTH,
|
11
|
+
too_wide: WIDTH + 1,
|
12
|
+
way_too_wide: WIDTH + 2,
|
13
|
+
}
|
14
|
+
|
15
|
+
def make_lines(opts)
|
16
|
+
size = opts.fetch(:size)
|
17
|
+
width = WIDTHS.fetch(opts.fetch(:width))
|
18
|
+
line = ('x' * width) + "\n"
|
19
|
+
Array.new(size, line)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:format) {double "format" }
|
23
|
+
let(:label) { double "label" }
|
24
|
+
let(:value) { double "value" }
|
25
|
+
before(:each) do
|
26
|
+
allow(OutlineLabeler)
|
27
|
+
.to receive(:label)
|
28
|
+
.with(format, WIDTH, label, value)
|
29
|
+
.and_return(outlined_lines)
|
30
|
+
allow(InlineLabeler)
|
31
|
+
.to receive(:label)
|
32
|
+
.with(format, WIDTH, label, value)
|
33
|
+
.and_return(inlined_lines)
|
34
|
+
end
|
35
|
+
subject { Labeler.label(format, WIDTH, label, value) }
|
36
|
+
|
37
|
+
context "the inline format fits on one line" do
|
38
|
+
let(:outlined_lines) { make_lines(size: 1, width: :fits) }
|
39
|
+
let(:inlined_lines) { double "inlined lines" }
|
40
|
+
it "should return inline lines" do
|
41
|
+
expect(subject).to equal outlined_lines
|
42
|
+
end
|
43
|
+
it "should not compute outlined lines" do
|
44
|
+
expect(OutlineLabeler).to_not have_received(:label)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "both formats fit in the width; the inlined has fewer lines" do
|
49
|
+
let(:outlined_lines) { make_lines(size: 3, width: :fits) }
|
50
|
+
let(:inlined_lines) { make_lines(size: 2, width: :fits) }
|
51
|
+
it "should return inlined lines" do
|
52
|
+
expect(subject).to equal inlined_lines
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "both formats fit in the width, are multiline, and have same size" do
|
57
|
+
let(:outlined_lines) { make_lines(size: 2, width: :fits) }
|
58
|
+
let(:inlined_lines) { make_lines(size: 2, width: :fits) }
|
59
|
+
it "should return inline lines" do
|
60
|
+
expect(subject).to equal outlined_lines
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "inlined format fits in the width; inline format does not" do
|
65
|
+
let(:outlined_lines) { make_lines(size: 2, width: :too_wide) }
|
66
|
+
let(:inlined_lines) { make_lines(size: 2, width: :fits) }
|
67
|
+
it "should return inlined lines" do
|
68
|
+
expect(subject).to equal inlined_lines
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "inlined format does not fits in the width; inline format does" do
|
73
|
+
let(:outlined_lines) { make_lines(size: 2, width: :fits) }
|
74
|
+
let(:inlined_lines) { make_lines(size: 2, width: :too_wide) }
|
75
|
+
it "should return inline lines" do
|
76
|
+
expect(subject).to equal outlined_lines
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "neither format fits in the width; inlined is narrower" do
|
81
|
+
let(:outlined_lines) { make_lines(size: 2, width: :way_too_wide) }
|
82
|
+
let(:inlined_lines) { make_lines(size: 2, width: :too_wide) }
|
83
|
+
it "should return inlined lines" do
|
84
|
+
expect(subject).to equal inlined_lines
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "neither format fits in width; are same width; inlined is shorter" do
|
89
|
+
let(:outlined_lines) { make_lines(size: 3, width: :too_wide) }
|
90
|
+
let(:inlined_lines) { make_lines(size: 2, width: :too_wide) }
|
91
|
+
it "should return inlined lines" do
|
92
|
+
expect(subject).to equal inlined_lines
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
require "cute_print/outline_labeler"
|
4
|
+
|
5
|
+
module CutePrint
|
6
|
+
describe OutlineLabeler do
|
7
|
+
|
8
|
+
let(:label) { "foo.rb:1: " }
|
9
|
+
let(:value) { [1, 2, 3, 4, 5] }
|
10
|
+
subject { OutlineLabeler.label(formatter, width, label, value) }
|
11
|
+
|
12
|
+
context "single line" do
|
13
|
+
let(:formatter) { Format::Inspect.new }
|
14
|
+
let(:width) { 80 }
|
15
|
+
specify do
|
16
|
+
expect(subject).to eq [
|
17
|
+
"foo.rb:1: [1, 2, 3, 4, 5]\n",
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "multiple lines" do
|
23
|
+
let(:formatter) { Format::PrettyPrint.new }
|
24
|
+
let(:width) { 4 }
|
25
|
+
specify do
|
26
|
+
expect(subject).to eq [
|
27
|
+
"foo.rb:1: [1,\n",
|
28
|
+
" 2,\n",
|
29
|
+
" 3,\n",
|
30
|
+
" 4,\n",
|
31
|
+
" 5]\n",
|
32
|
+
]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cute_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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: 2014-
|
11
|
+
date: 2014-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby_parser
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- features/configuring/configure_position_format.feature
|
67
67
|
- features/configuring/readme.md
|
68
68
|
- features/configuring/reset_configuration.feature
|
69
|
+
- features/inspect/core.feature
|
69
70
|
- features/inspect/inspect.feature
|
70
71
|
- features/inspect/inspect_with_location.feature
|
71
72
|
- features/inspect/inspect_with_source.feature
|
@@ -76,18 +77,32 @@ files:
|
|
76
77
|
- features/readme.md
|
77
78
|
- features/support/env.rb
|
78
79
|
- features/support/helpers/example.rb
|
80
|
+
- features/support/helpers/example_runner.rb
|
81
|
+
- features/support/helpers/fork_example_runner.rb
|
82
|
+
- features/support/helpers/lib_path.rb
|
83
|
+
- features/support/helpers/shell_example_runner.rb
|
79
84
|
- features/support/helpers/temp_dir.rb
|
80
85
|
- features/support/step_definitions.rb
|
81
86
|
- lib/cute_print.rb
|
82
87
|
- lib/cute_print/configure.rb
|
88
|
+
- lib/cute_print/core.rb
|
83
89
|
- lib/cute_print/core_ext.rb
|
84
90
|
- lib/cute_print/core_ext/irb.rb
|
85
91
|
- lib/cute_print/core_ext/object.rb
|
86
|
-
- lib/cute_print/
|
92
|
+
- lib/cute_print/cute_print.rb
|
87
93
|
- lib/cute_print/finds_foreign_caller.rb
|
94
|
+
- lib/cute_print/format.rb
|
95
|
+
- lib/cute_print/format/inspect.rb
|
96
|
+
- lib/cute_print/format/pretty_print.rb
|
88
97
|
- lib/cute_print/formatter.rb
|
98
|
+
- lib/cute_print/inline_labeler.rb
|
99
|
+
- lib/cute_print/labeler.rb
|
89
100
|
- lib/cute_print/location.rb
|
101
|
+
- lib/cute_print/location_label.rb
|
102
|
+
- lib/cute_print/location_label/filename.rb
|
103
|
+
- lib/cute_print/location_label/path.rb
|
90
104
|
- lib/cute_print/mixin.rb
|
105
|
+
- lib/cute_print/outline_labeler.rb
|
91
106
|
- lib/cute_print/printer.rb
|
92
107
|
- lib/cute_print/ruby_generator.rb
|
93
108
|
- lib/cute_print/ruby_parser.rb
|
@@ -95,9 +110,15 @@ files:
|
|
95
110
|
- lib/cute_print/ruby_parser/method_call.rb
|
96
111
|
- lib/cute_print/ruby_parser/parsed_code.rb
|
97
112
|
- lib/cute_print/ruby_parser/wraps_sexp.rb
|
113
|
+
- lib/cute_print/source_label.rb
|
98
114
|
- lib/cute_print/stderr_out.rb
|
99
115
|
- spec/cute_print_spec.rb
|
116
|
+
- spec/format/inspect_spec.rb
|
117
|
+
- spec/format/pretty_print_spec.rb
|
118
|
+
- spec/inline_labeler_spec.rb
|
100
119
|
- spec/irb_spec.rb
|
120
|
+
- spec/labeler_spec.rb
|
121
|
+
- spec/outline_labeler_spec.rb
|
101
122
|
- spec/printer_spec.rb
|
102
123
|
- spec/spec_helper.rb
|
103
124
|
- spec/support/captures_stderr.rb
|