cute_print 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.config/cucumber.yml +1 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +6 -0
  5. data/Gemfile +18 -0
  6. data/Gemfile.lock +99 -0
  7. data/LICENSE +20 -0
  8. data/README.md +109 -0
  9. data/Rakefile +14 -0
  10. data/VERSION +1 -0
  11. data/basic101.gemspec +64 -0
  12. data/cute_print.gemspec +96 -0
  13. data/features/.nav +6 -0
  14. data/features/configuring/configure_output.feature +21 -0
  15. data/features/configuring/configure_position_format.feature +30 -0
  16. data/features/configuring/readme.md +1 -0
  17. data/features/configuring/reset_configuration.feature +27 -0
  18. data/features/inspect_call_chain.feature +39 -0
  19. data/features/inspect_objects/inspect.feature +29 -0
  20. data/features/inspect_objects/label_and_inspect.feature +16 -0
  21. data/features/inspect_objects/print_source_location.feature +41 -0
  22. data/features/inspect_objects/readme.md +1 -0
  23. data/features/readme.md +1 -0
  24. data/features/support/env.rb +9 -0
  25. data/features/support/helpers/example.rb +54 -0
  26. data/features/support/helpers/temp_dir.rb +15 -0
  27. data/features/support/step_definitions.rb +23 -0
  28. data/lib/cute_print/configure.rb +37 -0
  29. data/lib/cute_print/core_ext/object.rb +5 -0
  30. data/lib/cute_print/core_ext.rb +1 -0
  31. data/lib/cute_print/default_printer.rb +14 -0
  32. data/lib/cute_print/finds_foreign_caller.rb +19 -0
  33. data/lib/cute_print/mixin.rb +44 -0
  34. data/lib/cute_print/printer.rb +106 -0
  35. data/lib/cute_print/ruby_generator.rb +17 -0
  36. data/lib/cute_print/ruby_parser/block.rb +12 -0
  37. data/lib/cute_print/ruby_parser/method_call.rb +27 -0
  38. data/lib/cute_print/ruby_parser/parsed_code.rb +38 -0
  39. data/lib/cute_print/ruby_parser/wraps_sexp.rb +19 -0
  40. data/lib/cute_print/ruby_parser.rb +60 -0
  41. data/lib/cute_print/stderr_out.rb +13 -0
  42. data/lib/cute_print.rb +26 -0
  43. data/spec/cute_print_spec.rb +69 -0
  44. data/spec/printer_spec.rb +64 -0
  45. data/spec/spec_helper.rb +13 -0
  46. data/spec/support/captures_stderr.rb +5 -0
  47. data/tasks/cucumber.rake +8 -0
  48. data/tasks/default.rake +1 -0
  49. data/tasks/jeweler.rake +29 -0
  50. data/tasks/spec.rake +5 -0
  51. data/tasks/test.rake +2 -0
  52. data/tasks/yard.rake +3 -0
  53. data/test_support/captures_stderr.rb +16 -0
  54. data/test_support/captures_stdout.rb +16 -0
  55. metadata +130 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c81ac7440cf8ecc4b2e2957630e8a8d103f1091
4
+ data.tar.gz: 04d54e1adfc14c9ca499d2f267a1600c64962c9d
5
+ SHA512:
6
+ metadata.gz: b8f5c915635c2e033d36af1bb55eea49b478e76e97e27993173e29055ae18f0084cc083cdeea0c188e148129f1b272b1ca119e1b5d941f6fae9ac8e8c1f02599
7
+ data.tar.gz: eb6cdda8838c7261337e4c76a9549729fb7174fc20f6c882ddb459ffb2a5086e6a6ccc64202047fe2d661eb408cdc27d581c4870d292e2d7fe16c3af97e82bf7
@@ -0,0 +1 @@
1
+ default: --require features/support/env.rb
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --exclude '[~#]$'
2
+ --markup markdown
3
+ --readme README.md
4
+ lib/**/*.rb
5
+ -
6
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "ruby_parser", "~> 3.6"
4
+ gem "ruby2ruby", "~> 2.1"
5
+
6
+ group :test do
7
+ gem "bundler", "~> 1.7"
8
+ gem "cucumber", "~> 1.3"
9
+ gem "rake", "~> 10.3"
10
+ gem "rspec", "~> 3.0"
11
+ gem "rspec-given", "~> 3.5"
12
+ end
13
+
14
+ group :develop do
15
+ gem "jeweler", "~> 2.0"
16
+ gem "redcarpet", "~> 3.1"
17
+ gem "yard", "~> 0.8.7"
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.6)
5
+ builder (3.2.2)
6
+ cucumber (1.3.16)
7
+ builder (>= 2.1.2)
8
+ diff-lcs (>= 1.1.3)
9
+ gherkin (~> 2.12)
10
+ multi_json (>= 1.7.5, < 2.0)
11
+ multi_test (>= 0.1.1)
12
+ descendants_tracker (0.0.4)
13
+ thread_safe (~> 0.3, >= 0.3.1)
14
+ diff-lcs (1.2.5)
15
+ faraday (0.9.0)
16
+ multipart-post (>= 1.2, < 3)
17
+ gherkin (2.12.2)
18
+ multi_json (~> 1.3)
19
+ git (1.2.8)
20
+ github_api (0.12.1)
21
+ addressable (~> 2.3)
22
+ descendants_tracker (~> 0.0.4)
23
+ faraday (~> 0.8, < 0.10)
24
+ hashie (>= 3.2)
25
+ multi_json (>= 1.7.5, < 2.0)
26
+ nokogiri (~> 1.6.3)
27
+ oauth2
28
+ given_core (3.5.4)
29
+ sorcerer (>= 0.3.7)
30
+ hashie (3.3.1)
31
+ highline (1.6.21)
32
+ jeweler (2.0.1)
33
+ builder
34
+ bundler (>= 1.0)
35
+ git (>= 1.2.5)
36
+ github_api
37
+ highline (>= 1.6.15)
38
+ nokogiri (>= 1.5.10)
39
+ rake
40
+ rdoc
41
+ json (1.8.1)
42
+ jwt (1.0.0)
43
+ mini_portile (0.6.0)
44
+ multi_json (1.10.1)
45
+ multi_test (0.1.1)
46
+ multi_xml (0.5.5)
47
+ multipart-post (2.0.0)
48
+ nokogiri (1.6.3.1)
49
+ mini_portile (= 0.6.0)
50
+ oauth2 (1.0.0)
51
+ faraday (>= 0.8, < 0.10)
52
+ jwt (~> 1.0)
53
+ multi_json (~> 1.3)
54
+ multi_xml (~> 0.5)
55
+ rack (~> 1.2)
56
+ rack (1.5.2)
57
+ rake (10.3.2)
58
+ rdoc (4.1.1)
59
+ json (~> 1.4)
60
+ redcarpet (3.1.2)
61
+ rspec (3.0.0)
62
+ rspec-core (~> 3.0.0)
63
+ rspec-expectations (~> 3.0.0)
64
+ rspec-mocks (~> 3.0.0)
65
+ rspec-core (3.0.4)
66
+ rspec-support (~> 3.0.0)
67
+ rspec-expectations (3.0.4)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.0.0)
70
+ rspec-given (3.5.4)
71
+ given_core (= 3.5.4)
72
+ rspec (>= 2.12)
73
+ rspec-mocks (3.0.4)
74
+ rspec-support (~> 3.0.0)
75
+ rspec-support (3.0.4)
76
+ ruby2ruby (2.1.2)
77
+ ruby_parser (~> 3.1)
78
+ sexp_processor (~> 4.0)
79
+ ruby_parser (3.6.2)
80
+ sexp_processor (~> 4.1)
81
+ sexp_processor (4.4.4)
82
+ sorcerer (1.0.2)
83
+ thread_safe (0.3.4)
84
+ yard (0.8.7.4)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ bundler (~> 1.7)
91
+ cucumber (~> 1.3)
92
+ jeweler (~> 2.0)
93
+ rake (~> 10.3)
94
+ redcarpet (~> 3.1)
95
+ rspec (~> 3.0)
96
+ rspec-given (~> 3.5)
97
+ ruby2ruby (~> 2.1)
98
+ ruby_parser (~> 3.6)
99
+ yard (~> 0.8.7)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Wayne Conrad
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # cute_print
2
+
3
+ Write debug output to the console, with flair. Features:
4
+
5
+ * Inspects its output, like Kernel#p
6
+ * Writes to $stderr by default (good when $stdout is redirected)
7
+ * Can print the filename and line number
8
+ * Can print the source of the value
9
+ * Can print a value in the middle of a call chain
10
+ * Configurable output device
11
+
12
+ This is for those who prefer to debug by writing things to the
13
+ console.
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ gem "cute_print"
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install cute_print
28
+
29
+ ## Usage
30
+
31
+ Start with:
32
+
33
+ require "cute_print"
34
+
35
+ You can use q just like you use Kernel#p. It will work the same,
36
+ except that its output goes to $stderr instead of $stdout:
37
+
38
+ q "abc" # "abc"
39
+ q [1, 2, 3 + 4] # [1, 2, 7]
40
+
41
+ You can have the debug source printed along with the value:
42
+
43
+ i = 1
44
+ q {i + 2} # i + 2 is 3
45
+
46
+ Kernel#ql will add the source position:
47
+
48
+ ql "abc" # foo.rb:12: "abc"
49
+ ql {1 + 2} # foo.rb:13: 1 + 2 is 3
50
+
51
+ Call chains can be a pain to debug, but it's easy with Kernel#tapq and
52
+ Kernel#tapql:
53
+
54
+ ["1", "2"].map(&:to_i).tapq.inject(&:+)
55
+ # [1, 2]
56
+
57
+ ["1", "2"].map(&:to_i).tapql.inject(&:+)
58
+ # prints: bar.rb:12: [1, 2]
59
+
60
+ ## Documentation
61
+
62
+ [Full documentation (relishapp)][2]
63
+
64
+ ## Rubies supported
65
+
66
+ This gem is known to work with these Rubies:
67
+
68
+ * ruby-1.9.3
69
+ * ruby-2.1.2
70
+
71
+ ## Platforms supported
72
+
73
+ This gem is developed and tested with Linux. It should work on
74
+ Windows and OSX as well. If it does not work for you, please file an
75
+ issue on github.
76
+
77
+ ## Other gems with similar functions
78
+
79
+ The [_wrong_][1] gem includes the excellent #d method, which is very
80
+ much like this gem's #q method. This gem's ability to read the debug
81
+ statement's source is derived from the _wrong_ gem.
82
+
83
+ Differences between the _wrong_ gem and this gem:
84
+
85
+ * The _wrong_ gem supports color output
86
+ * The _wrong_ gem writes only to stdout
87
+ * The _wrong_ gem supports Ruby 1.8
88
+
89
+ ## Versioning
90
+
91
+ This gem uses [semantic versioning 2.0][3].
92
+
93
+ While the version is < 1.0.0, the API can change with any version
94
+ increment. If you need stability, lock the gem down to a minor
95
+ version, e.g.:
96
+
97
+ gem "cute_print", "~> 0.1.0"
98
+
99
+ ## Contributing
100
+
101
+ 1. Fork it ( http://github.com/wconrad/cute_print/fork )
102
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
103
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
104
+ 4. Push to the branch (`git push origin my-new-feature`)
105
+ 5. Create new Pull Request
106
+
107
+ [1]: http://rubygems.org/gems/wrong
108
+ [2]: https://www.relishapp.com/wconrad/cute-print/docs
109
+ [3]: http://semver.org/spec/v2.0.0.html
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'bundler'
4
+
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
+ exit e.status_code
11
+ end
12
+
13
+ $:.unshift(File.dirname(__FILE__) + '/lib')
14
+ Dir['tasks/**/*.rake'].sort.each { |path| load path }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/basic101.gemspec ADDED
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: basic101 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "basic101"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Wayne Conrad"]
14
+ s.date = "2014-08-29"
15
+ s.description = "Write debug output to stderr. Optionally print the source filename and line number, or the source of the debug statement. Easily print debug from the middle of call chains. This is for those who prefer to debug by writing things to the console. Since it writes to stderr, it's more useful than Kernel#p when working with a program that is run with stdout redirection. Output goes to $stderr by default, but that's configurable."
16
+ s.email = "wconrad@yagni.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/cute_print.rb",
29
+ "spec/cute_print_spec.rb",
30
+ "spec/spec_helper.rb"
31
+ ]
32
+ s.homepage = "http://github.com/wconrad/basic101"
33
+ s.licenses = ["MIT"]
34
+ s.rubygems_version = "2.2.2"
35
+ s.summary = "print debug to stderr, with flair"
36
+
37
+ if s.respond_to? :specification_version then
38
+ s.specification_version = 4
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ s.add_development_dependency(%q<bundler>, ["~> 1.7"])
42
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
43
+ s.add_development_dependency(%q<rake>, ["~> 10.3"])
44
+ s.add_development_dependency(%q<redcarpet>, ["~> 3.1"])
45
+ s.add_development_dependency(%q<rspec>, ["~> 3.0"])
46
+ s.add_development_dependency(%q<yard>, ["~> 0.8.7"])
47
+ else
48
+ s.add_dependency(%q<bundler>, ["~> 1.7"])
49
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
50
+ s.add_dependency(%q<rake>, ["~> 10.3"])
51
+ s.add_dependency(%q<redcarpet>, ["~> 3.1"])
52
+ s.add_dependency(%q<rspec>, ["~> 3.0"])
53
+ s.add_dependency(%q<yard>, ["~> 0.8.7"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<bundler>, ["~> 1.7"])
57
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
58
+ s.add_dependency(%q<rake>, ["~> 10.3"])
59
+ s.add_dependency(%q<redcarpet>, ["~> 3.1"])
60
+ s.add_dependency(%q<rspec>, ["~> 3.0"])
61
+ s.add_dependency(%q<yard>, ["~> 0.8.7"])
62
+ end
63
+ end
64
+
@@ -0,0 +1,96 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: cute_print 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "cute_print"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Wayne Conrad"]
14
+ s.date = "2014-09-02"
15
+ s.description = "Write debug output to the console, with flair. Features: * Inspects its output, like Kernel#p * Writes to $stderr by default (good when $stdout is redirected) * Can print the filename and line number * Can print the source of the value * Can print a value in the middle of a call chain * Configurable output device This is for those who prefer to debug by writing things to the console."
16
+ s.email = "wconrad@yagni.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".config/cucumber.yml",
23
+ ".rspec",
24
+ ".yardopts",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "basic101.gemspec",
32
+ "cute_print.gemspec",
33
+ "features/.nav",
34
+ "features/configuring/configure_output.feature",
35
+ "features/configuring/configure_position_format.feature",
36
+ "features/configuring/readme.md",
37
+ "features/configuring/reset_configuration.feature",
38
+ "features/inspect_call_chain.feature",
39
+ "features/inspect_objects/inspect.feature",
40
+ "features/inspect_objects/label_and_inspect.feature",
41
+ "features/inspect_objects/print_source_location.feature",
42
+ "features/inspect_objects/readme.md",
43
+ "features/readme.md",
44
+ "features/support/env.rb",
45
+ "features/support/helpers/example.rb",
46
+ "features/support/helpers/temp_dir.rb",
47
+ "features/support/step_definitions.rb",
48
+ "lib/cute_print.rb",
49
+ "lib/cute_print/configure.rb",
50
+ "lib/cute_print/core_ext.rb",
51
+ "lib/cute_print/core_ext/object.rb",
52
+ "lib/cute_print/default_printer.rb",
53
+ "lib/cute_print/finds_foreign_caller.rb",
54
+ "lib/cute_print/mixin.rb",
55
+ "lib/cute_print/printer.rb",
56
+ "lib/cute_print/ruby_generator.rb",
57
+ "lib/cute_print/ruby_parser.rb",
58
+ "lib/cute_print/ruby_parser/block.rb",
59
+ "lib/cute_print/ruby_parser/method_call.rb",
60
+ "lib/cute_print/ruby_parser/parsed_code.rb",
61
+ "lib/cute_print/ruby_parser/wraps_sexp.rb",
62
+ "lib/cute_print/stderr_out.rb",
63
+ "spec/cute_print_spec.rb",
64
+ "spec/printer_spec.rb",
65
+ "spec/spec_helper.rb",
66
+ "spec/support/captures_stderr.rb",
67
+ "tasks/cucumber.rake",
68
+ "tasks/default.rake",
69
+ "tasks/jeweler.rake",
70
+ "tasks/spec.rake",
71
+ "tasks/test.rake",
72
+ "tasks/yard.rake",
73
+ "test_support/captures_stderr.rb",
74
+ "test_support/captures_stdout.rb"
75
+ ]
76
+ s.homepage = "http://github.com/wconrad/cute_print"
77
+ s.licenses = ["MIT"]
78
+ s.rubygems_version = "2.2.2"
79
+ s.summary = "print debug to stderr, with flair"
80
+
81
+ if s.respond_to? :specification_version then
82
+ s.specification_version = 4
83
+
84
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
85
+ s.add_runtime_dependency(%q<ruby_parser>, ["~> 3.6"])
86
+ s.add_runtime_dependency(%q<ruby2ruby>, ["~> 2.1"])
87
+ else
88
+ s.add_dependency(%q<ruby_parser>, ["~> 3.6"])
89
+ s.add_dependency(%q<ruby2ruby>, ["~> 2.1"])
90
+ end
91
+ else
92
+ s.add_dependency(%q<ruby_parser>, ["~> 3.6"])
93
+ s.add_dependency(%q<ruby2ruby>, ["~> 2.1"])
94
+ end
95
+ end
96
+
data/features/.nav ADDED
@@ -0,0 +1,6 @@
1
+ - inspect_objects:
2
+ - inspect.feature
3
+ - label_and_inspect.feature
4
+ - print_source_location.feature
5
+ - inspect_call_chain.feature
6
+ - configuring:
@@ -0,0 +1,21 @@
1
+ Feature: Configure output
2
+
3
+ By default, output is written to $stderr. You can change where
4
+ output goes.
5
+
6
+ Scenario: Write to $stdout
7
+ Given a file with:
8
+ """
9
+ require "cute_print"
10
+
11
+ CutePrint.configure do |c|
12
+ c.out = $stdout
13
+ end
14
+
15
+ q "abc"
16
+ """
17
+ Then stdout should be
18
+ """
19
+ "abc"
20
+
21
+ """
@@ -0,0 +1,30 @@
1
+ Feature: Configure position format
2
+
3
+ You can change the format which Kernel#ql uses to print the source
4
+ position. String#% is called on the string you supply, with
5
+ a hash argument having these keys:
6
+
7
+ * :path
8
+ * :filename
9
+ * :line_number
10
+
11
+ The default position format is:
12
+
13
+ "%<filename>s:%<line_number>d: "
14
+
15
+ Scenario: Write full path
16
+ Given a file named "example.rb" with:
17
+ """
18
+ require "cute_print"
19
+
20
+ CutePrint.configure do |c|
21
+ c.position_format = "%<path>s:%<line_number>d: "
22
+ end
23
+
24
+ ql 123
25
+ """
26
+ Then stderr should be
27
+ """
28
+ /tmp/.../example.rb:7: 123
29
+
30
+ """
@@ -0,0 +1 @@
1
+ You can configure several things:
@@ -0,0 +1,27 @@
1
+ Feature: Reset configuration
2
+
3
+ You can reset the configuration to its defaults.
4
+
5
+ Scenario: Write to $stdout
6
+ Given a file with:
7
+ """
8
+ require "cute_print"
9
+
10
+ CutePrint.configure do |c|
11
+ c.out = $stdout
12
+ end
13
+
14
+ q "abc"
15
+ CutePrint.configure { |c| c.reset }
16
+ q 123
17
+ """
18
+ Then stdout should be
19
+ """
20
+ "abc"
21
+
22
+ """
23
+ And stderr should be
24
+ """
25
+ 123
26
+
27
+ """
@@ -0,0 +1,39 @@
1
+ Feature: Inspect a call chain
2
+
3
+ Call chains (aka "train wrecks") can be a bother to debug.
4
+ Kernel#tapq prints a value in a call chain and then continues the
5
+ chain.
6
+
7
+ Scenario: Without source position
8
+ Given a file with:
9
+ """
10
+ require "cute_print"
11
+ puts ["1", "2"].map(&:to_i).tapq.inject(:+)
12
+ """
13
+ Then stdout should be
14
+ """
15
+ 3
16
+
17
+ """
18
+ And stderr should be
19
+ """
20
+ [1, 2]
21
+
22
+ """
23
+
24
+ Scenario: With source position
25
+ Given a file named "example.rb" with:
26
+ """
27
+ require "cute_print"
28
+ puts ["1", "2"].map(&:to_i).tapql.inject(:+)
29
+ """
30
+ Then stdout should be
31
+ """
32
+ 3
33
+
34
+ """
35
+ And stderr should be
36
+ """
37
+ example.rb:2: [1, 2]
38
+
39
+ """
@@ -0,0 +1,29 @@
1
+ Feature: Inspect an object
2
+
3
+ Kernel#q inspects its arguments and prints them, one per line. This
4
+ is just like Kernel#p, except that it writes to $stderr by default.
5
+
6
+ Scenario: One argument
7
+ Given a file with:
8
+ """
9
+ require "cute_print"
10
+ q "abc"
11
+ """
12
+ Then stderr should be
13
+ """
14
+ "abc"
15
+
16
+ """
17
+
18
+ Scenario: Two arguments
19
+ Given a file with:
20
+ """
21
+ require "cute_print"
22
+ q "abc", 123
23
+ """
24
+ Then stderr should be
25
+ """
26
+ "abc"
27
+ 123
28
+
29
+ """
@@ -0,0 +1,16 @@
1
+ Feature: Label and inspect an object
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 and 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
+ """
@@ -0,0 +1,41 @@
1
+ Feature: Print the source location
2
+
3
+ Kernel#ql works just like Kernel#q, except that it also prints the
4
+ source location
5
+
6
+ Scenario: Inspect an object
7
+ Given a file named "example.rb" with:
8
+ """
9
+ require "cute_print"
10
+ ql "abc"
11
+ """
12
+ Then stderr should be
13
+ """
14
+ example.rb:2: "abc"
15
+
16
+ """
17
+
18
+ Scenario: Inspect two objects
19
+ Given a file named "example.rb" with:
20
+ """
21
+ require "cute_print"
22
+ ql "abc", 123
23
+ """
24
+ Then stderr should be
25
+ """
26
+ example.rb:2: "abc"
27
+ example.rb:2: 123
28
+
29
+ """
30
+
31
+ Scenario: Label and inspect and object
32
+ Given a file named "example.rb" with:
33
+ """
34
+ require "cute_print"
35
+ ql {1 + 2}
36
+ """
37
+ Then stderr should be
38
+ """
39
+ example.rb:2: (1 + 2) is 3
40
+
41
+ """
@@ -0,0 +1 @@
1
+ There are several ways to inspect objects:
@@ -0,0 +1 @@
1
+ Write debug output to the console, with flair.