prettier_print 1.1.0 → 1.2.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/.github/dependabot.yml +4 -0
- data/.github/workflows/auto-merge.yml +1 -1
- data/.github/workflows/main.yml +4 -2
- data/CHANGELOG.md +15 -1
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile.lock +5 -4
- data/README.md +3 -0
- data/lib/prettier_print/version.rb +1 -1
- data/lib/prettier_print.rb +19 -7
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7e2d82792d59bc2b9c28ef209091c7a258fa6e7729cccf7e182de3021c1533
|
4
|
+
data.tar.gz: 9a9d0b4689234dc396354279f07c13337ff8b423b974f43ba3f1bf411aa8d793
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ccf56fb3f3887e6d2dd3f72b1ac5944e2ad9e754cd15cc41541e36e79b481cc50a429feaac41302bc9363415bdc2242a8bc0b1719f8e779794ec66a7ae0087
|
7
|
+
data.tar.gz: c7304db0e58c2898a26f92a698d633dbf8df419faa77aa3b82815db191bffeb26d37dacad8793964a6a87517ae5a78a990491607df03f270c98d7e540edf1956
|
data/.github/dependabot.yml
CHANGED
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.2.1] - 2023-03-09
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Fixed a bug where having line suffixes on the final line without a breakable could cause an infinite loop.
|
14
|
+
|
15
|
+
## [1.2.0] - 2022-12-23
|
16
|
+
|
17
|
+
### Added
|
18
|
+
|
19
|
+
- You can now supply the base indentation level for the output buffer.
|
20
|
+
|
9
21
|
## [1.1.0] - 2022-11-08
|
10
22
|
|
11
23
|
### Added
|
@@ -49,7 +61,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
49
61
|
|
50
62
|
- 🎉 Initial release! 🎉
|
51
63
|
|
52
|
-
[unreleased]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.1
|
64
|
+
[unreleased]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.1...HEAD
|
65
|
+
[1.2.1]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.0...v1.2.1
|
66
|
+
[1.2.0]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.1.0...v1.2.0
|
53
67
|
[1.1.0]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.0.2...v1.1.0
|
54
68
|
[1.0.2]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.0.1...v1.0.2
|
55
69
|
[1.0.1]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.0.0...v1.0.1
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
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, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and 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 kddnewton@gmail.com. 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 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
prettier_print (1.1
|
4
|
+
prettier_print (1.2.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
docile (1.4.0)
|
10
|
-
power_assert (2.0.
|
10
|
+
power_assert (2.0.2)
|
11
11
|
rake (13.0.6)
|
12
|
-
simplecov (0.
|
12
|
+
simplecov (0.22.0)
|
13
13
|
docile (~> 1.1)
|
14
14
|
simplecov-html (~> 0.11)
|
15
15
|
simplecov_json_formatter (~> 0.1)
|
16
16
|
simplecov-html (0.12.3)
|
17
17
|
simplecov_json_formatter (0.1.4)
|
18
|
-
test-unit (3.5.
|
18
|
+
test-unit (3.5.7)
|
19
19
|
power_assert
|
20
20
|
|
21
21
|
PLATFORMS
|
22
22
|
arm64-darwin-21
|
23
|
+
arm64-darwin-22
|
23
24
|
x86_64-darwin-21
|
24
25
|
x86_64-linux
|
25
26
|
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# PrettierPrint
|
2
2
|
|
3
|
+
[](https://github.com/ruby-syntax-tree/prettier_print/actions)
|
4
|
+
[](https://rubygems.org/gems/prettier_print)
|
5
|
+
|
3
6
|
A drop-in replacement for the `prettyprint` gem with more functionality.
|
4
7
|
|
5
8
|
## Installation
|
data/lib/prettier_print.rb
CHANGED
@@ -360,6 +360,11 @@ class PrettierPrint
|
|
360
360
|
# a forced line, or the maximum width.
|
361
361
|
MODE_FLAT = 2
|
362
362
|
|
363
|
+
# The default indentation for printing is zero, assuming that the code starts
|
364
|
+
# at the top level. That can be changed if desired to start from a different
|
365
|
+
# indentation level.
|
366
|
+
DEFAULT_INDENTATION = 0
|
367
|
+
|
363
368
|
# This is a convenience method which is same as follows:
|
364
369
|
#
|
365
370
|
# begin
|
@@ -373,11 +378,12 @@ class PrettierPrint
|
|
373
378
|
output = "".dup,
|
374
379
|
maxwidth = 80,
|
375
380
|
newline = DEFAULT_NEWLINE,
|
376
|
-
genspace = DEFAULT_GENSPACE
|
381
|
+
genspace = DEFAULT_GENSPACE,
|
382
|
+
indentation = DEFAULT_INDENTATION
|
377
383
|
)
|
378
384
|
q = new(output, maxwidth, newline, &genspace)
|
379
385
|
yield q
|
380
|
-
q.flush
|
386
|
+
q.flush(indentation)
|
381
387
|
output
|
382
388
|
end
|
383
389
|
|
@@ -481,17 +487,20 @@ class PrettierPrint
|
|
481
487
|
|
482
488
|
# Flushes all of the generated print tree onto the output buffer, then clears
|
483
489
|
# the generated tree from memory.
|
484
|
-
def flush
|
490
|
+
def flush(base_indentation = DEFAULT_INDENTATION)
|
485
491
|
# First, get the root group, since we placed one at the top to begin with.
|
486
492
|
doc = groups.first
|
487
493
|
|
488
494
|
# This represents how far along the current line we are. It gets reset
|
489
495
|
# back to 0 when we encounter a newline.
|
490
|
-
position =
|
496
|
+
position = base_indentation
|
497
|
+
|
498
|
+
# Start the buffer with the base indentation level.
|
499
|
+
buffer << genspace.call(base_indentation) if base_indentation > 0
|
491
500
|
|
492
501
|
# This is our command stack. A command consists of a triplet of an
|
493
502
|
# indentation level, the mode (break or flat), and a doc node.
|
494
|
-
commands = [[
|
503
|
+
commands = [[base_indentation, MODE_BREAK, doc]]
|
495
504
|
|
496
505
|
# This is a small optimization boolean. It keeps track of whether or not
|
497
506
|
# when we hit a group node we should check if it fits on the same line.
|
@@ -607,8 +616,11 @@ class PrettierPrint
|
|
607
616
|
end
|
608
617
|
|
609
618
|
if commands.empty? && line_suffixes.any?
|
610
|
-
|
611
|
-
|
619
|
+
line_suffixes.sort_by(&line_suffix_sort).each do |(indent, mode, doc)|
|
620
|
+
commands += doc.contents.reverse.map { |part| [indent, mode, part] }
|
621
|
+
end
|
622
|
+
|
623
|
+
line_suffixes.clear
|
612
624
|
end
|
613
625
|
end
|
614
626
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prettier_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- ".github/workflows/main.yml"
|
23
23
|
- ".gitignore"
|
24
24
|
- CHANGELOG.md
|
25
|
+
- CODE_OF_CONDUCT.md
|
25
26
|
- Gemfile
|
26
27
|
- Gemfile.lock
|
27
28
|
- LICENSE
|
@@ -52,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '0'
|
54
55
|
requirements: []
|
55
|
-
rubygems_version: 3.
|
56
|
+
rubygems_version: 3.4.1
|
56
57
|
signing_key:
|
57
58
|
specification_version: 4
|
58
59
|
summary: A drop-in replacement for the prettyprint gem with more functionality.
|