diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4695914..9f77688 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,7 @@ updates: directory: "/" schedule: interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 9b28abf..e54c910 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.3 + uses: dependabot/fetch-metadata@v1.3.6 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Enable auto-merge for Dependabot PRs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcd3384..16f2807 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,16 +1,18 @@ name: Main + on: - push -- pull_request_target +- pull_request + jobs: ci: strategy: fail-fast: false matrix: ruby: - - '2.7' - '3.0' - '3.1' + - '3.2' - head name: CI runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 506beb8..1b59deb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +## [1.2.1] - 2023-03-09 + +### Changed + +- Fixed a bug where having line suffixes on the final line without a breakable could cause an infinite loop. + ## [1.2.0] - 2022-12-23 ### Added @@ -55,7 +61,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - 🎉 Initial release! 🎉 -[unreleased]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.0...HEAD +[unreleased]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.1...HEAD +[1.2.1]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.2.0...v1.2.1 [1.2.0]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.1.0...v1.2.0 [1.1.0]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.0.2...v1.1.0 [1.0.2]: https://github.com/ruby-syntax-tree/prettier_print/compare/v1.0.1...v1.0.2 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..b0c6bcf --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at kddnewton@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/Gemfile.lock b/Gemfile.lock index 02476d5..5c2e15b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - prettier_print (1.2.0) + prettier_print (1.2.1) GEM remote: https://rubygems.org/ @@ -9,7 +9,7 @@ GEM docile (1.4.0) power_assert (2.0.2) rake (13.0.6) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) @@ -20,6 +20,7 @@ GEM PLATFORMS arm64-darwin-21 + arm64-darwin-22 x86_64-darwin-21 x86_64-linux diff --git a/README.md b/README.md index 48da3f2..0e29038 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # PrettierPrint +[![Build Status](https://github.com/ruby-syntax-tree/prettier_print/workflows/Main/badge.svg)](https://github.com/ruby-syntax-tree/prettier_print/actions) +[![Gem Version](https://img.shields.io/gem/v/prettier_print.svg)](https://rubygems.org/gems/prettier_print) + A drop-in replacement for the `prettyprint` gem with more functionality. ## Installation diff --git a/lib/prettier_print.rb b/lib/prettier_print.rb index 8cc72ad..a0ac1cc 100644 --- a/lib/prettier_print.rb +++ b/lib/prettier_print.rb @@ -616,8 +616,11 @@ def flush(base_indentation = DEFAULT_INDENTATION) end if commands.empty? && line_suffixes.any? - commands += line_suffixes.sort_by(&line_suffix_sort) - line_suffixes = [] + line_suffixes.sort_by(&line_suffix_sort).each do |(indent, mode, doc)| + commands += doc.contents.reverse.map { |part| [indent, mode, part] } + end + + line_suffixes.clear end end diff --git a/lib/prettier_print/version.rb b/lib/prettier_print/version.rb index 2677aff..bd23d3f 100644 --- a/lib/prettier_print/version.rb +++ b/lib/prettier_print/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class PrettierPrint - VERSION = "1.2.0" + VERSION = "1.2.1" end diff --git a/test/prettier_print_test.rb b/test/prettier_print_test.rb index 51c2faa..66068ca 100644 --- a/test/prettier_print_test.rb +++ b/test/prettier_print_test.rb @@ -152,6 +152,15 @@ class PrettierPrintTest < Test::Unit::TestCase assert_equal "content # suffix\n", result end + test "PrettierPrint#line_suffix without a break" do + result = + PrettierPrint.format do |q| + q.line_suffix { q.text("# suffix") } + end + + assert_equal "# suffix", result + end + test "PrettierPrint#trim" do result = PrettierPrint.format do |q|