rfbeam 0.5.1 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.pre-commit-config.yaml +8 -0
  3. data/.tool-versions +1 -1
  4. data/CHANGELOG.md +39 -46
  5. data/Gemfile +10 -7
  6. data/Gemfile.lock +47 -44
  7. data/README.md +71 -113
  8. data/Rakefile +5 -9
  9. data/cliff.toml +74 -0
  10. data/cog.toml +7 -3
  11. data/exe/rfbeam +0 -1
  12. data/lib/rfbeam/cli.rb +37 -29
  13. data/lib/rfbeam/kld7/constants.rb +5 -4
  14. data/lib/rfbeam/kld7/detection_params.rb +149 -0
  15. data/lib/rfbeam/kld7/module_params.rb +96 -0
  16. data/lib/rfbeam/kld7/operation_params.rb +162 -0
  17. data/lib/rfbeam/kld7/radar_messages.rb +23 -39
  18. data/lib/rfbeam/kld7/serial_connection.rb +13 -14
  19. data/lib/rfbeam/kld7/streamer.rb +15 -14
  20. data/lib/rfbeam/version.rb +1 -1
  21. data/lib/rfbeam.rb +8 -7
  22. data/output.csv +257 -0
  23. data/rfbeam.gemspec +3 -8
  24. data/yarn.lock +221 -12
  25. metadata +12 -167
  26. data/.rubocop.yml +0 -25
  27. data/.streerc~1f4cd14e3c0a9afdf972aa5f3982d36a89869b72 +0 -2
  28. data/lib/rfbeam/kld7/cli_formatter.rb +0 -61
  29. data/lib/rfbeam/kld7/cli_output.rb +0 -141
  30. data/lib/rfbeam/kld7/radar_parameters.rb +0 -441
  31. data/node_modules/.bin/prettier +0 -1
  32. data/node_modules/.yarn-integrity +0 -19
  33. data/node_modules/@prettier/plugin-ruby/CHANGELOG.md +0 -1351
  34. data/node_modules/@prettier/plugin-ruby/CODE_OF_CONDUCT.md +0 -76
  35. data/node_modules/@prettier/plugin-ruby/CONTRIBUTING.md +0 -185
  36. data/node_modules/@prettier/plugin-ruby/LICENSE +0 -21
  37. data/node_modules/@prettier/plugin-ruby/README.md +0 -226
  38. data/node_modules/@prettier/plugin-ruby/docs/logo.png +0 -0
  39. data/node_modules/@prettier/plugin-ruby/node_modules/.bin/prettier +0 -1
  40. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/LICENSE +0 -5945
  41. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/README.md +0 -109
  42. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/bin-prettier.js +0 -62
  43. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/cli.js +0 -15136
  44. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/doc.js +0 -1473
  45. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-angular.mjs +0 -2
  46. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-babel.mjs +0 -29
  47. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-espree.mjs +0 -26
  48. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-flow.mjs +0 -35
  49. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-glimmer.mjs +0 -27
  50. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-graphql.mjs +0 -15
  51. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-html.mjs +0 -36
  52. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-markdown.mjs +0 -76
  53. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-meriyah.mjs +0 -19
  54. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-postcss.mjs +0 -76
  55. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-typescript.mjs +0 -257
  56. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-yaml.mjs +0 -150
  57. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/standalone.mjs +0 -116
  58. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/index.js +0 -37885
  59. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/package.json +0 -21
  60. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-angular.js +0 -2
  61. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-babel.js +0 -29
  62. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-espree.js +0 -26
  63. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-flow.js +0 -35
  64. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-glimmer.js +0 -27
  65. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-graphql.js +0 -15
  66. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-html.js +0 -36
  67. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-markdown.js +0 -76
  68. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-meriyah.js +0 -19
  69. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-postcss.js +0 -76
  70. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-typescript.js +0 -257
  71. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-yaml.js +0 -150
  72. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/standalone.js +0 -116
  73. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/third-party.js +0 -8978
  74. data/node_modules/@prettier/plugin-ruby/package.json +0 -64
  75. data/node_modules/@prettier/plugin-ruby/prettier.gemspec +0 -36
  76. data/node_modules/@prettier/plugin-ruby/rubocop.yml +0 -64
  77. data/node_modules/@prettier/plugin-ruby/src/getInfo.js +0 -23
  78. data/node_modules/@prettier/plugin-ruby/src/netcat.js +0 -13
  79. data/node_modules/@prettier/plugin-ruby/src/parseSync.js +0 -236
  80. data/node_modules/@prettier/plugin-ruby/src/plugin.js +0 -172
  81. data/node_modules/@prettier/plugin-ruby/src/server.rb +0 -199
  82. data/node_modules/prettier/LICENSE +0 -5970
  83. data/node_modules/prettier/README.md +0 -109
  84. data/node_modules/prettier/bin-prettier.js +0 -64
  85. data/node_modules/prettier/cli.js +0 -15364
  86. data/node_modules/prettier/doc.js +0 -1473
  87. data/node_modules/prettier/esm/parser-angular.mjs +0 -2
  88. data/node_modules/prettier/esm/parser-babel.mjs +0 -29
  89. data/node_modules/prettier/esm/parser-espree.mjs +0 -26
  90. data/node_modules/prettier/esm/parser-flow.mjs +0 -35
  91. data/node_modules/prettier/esm/parser-glimmer.mjs +0 -27
  92. data/node_modules/prettier/esm/parser-graphql.mjs +0 -15
  93. data/node_modules/prettier/esm/parser-html.mjs +0 -36
  94. data/node_modules/prettier/esm/parser-markdown.mjs +0 -76
  95. data/node_modules/prettier/esm/parser-meriyah.mjs +0 -19
  96. data/node_modules/prettier/esm/parser-postcss.mjs +0 -76
  97. data/node_modules/prettier/esm/parser-typescript.mjs +0 -49
  98. data/node_modules/prettier/esm/parser-yaml.mjs +0 -150
  99. data/node_modules/prettier/esm/standalone.mjs +0 -116
  100. data/node_modules/prettier/index.js +0 -38236
  101. data/node_modules/prettier/package.json +0 -21
  102. data/node_modules/prettier/parser-angular.js +0 -2
  103. data/node_modules/prettier/parser-babel.js +0 -29
  104. data/node_modules/prettier/parser-espree.js +0 -26
  105. data/node_modules/prettier/parser-flow.js +0 -35
  106. data/node_modules/prettier/parser-glimmer.js +0 -27
  107. data/node_modules/prettier/parser-graphql.js +0 -15
  108. data/node_modules/prettier/parser-html.js +0 -36
  109. data/node_modules/prettier/parser-markdown.js +0 -76
  110. data/node_modules/prettier/parser-meriyah.js +0 -19
  111. data/node_modules/prettier/parser-postcss.js +0 -76
  112. data/node_modules/prettier/parser-typescript.js +0 -49
  113. data/node_modules/prettier/parser-yaml.js +0 -150
  114. data/node_modules/prettier/standalone.js +0 -116
  115. data/node_modules/prettier/third-party.js +0 -8978
  116. data/package.json +0 -6
@@ -1,76 +0,0 @@
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 prettier-contact@googlegroups.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
@@ -1,185 +0,0 @@
1
- # Contributing
2
-
3
- Thanks so much for your interest in contributing! This page provides background on how prettier and this plugin work, links for understanding each step that prettier executes, various helpful utilities for analyzing the tree structures being manipulated, and frequently asked questions.
4
-
5
- Armed with the knowledge below, we would love to see your contribution! Please open an issue or a pull request at https://github.com/prettier/plugin-ruby.
6
-
7
- - [How it works](#how-it-works)
8
- - [Text to AST](#text-to-ast)
9
- - [AST to Doc](#ast-to-doc)
10
- - [Doc to text](#doc-to-text)
11
- - [FAQ](#faq)
12
- - [Useful links](#useful-links)
13
- - [Ruby](#ruby)
14
- - [Ripper](#ripper)
15
- - [Prettier](#prettier)
16
- - [Useful commands](#useful-commands)
17
- - [Testing](#testing)
18
-
19
- ## How it works
20
-
21
- In order to get printed, the code goes through a couple of transformations. The first is taking the entire file as text and parsing it into an abstract syntax tree (AST). The second is taking the AST and transforming it into prettier's intermediate representation, internally referred to as Docs. The final is taking the Doc nodes and converting them back into plain text, taking into account printing rules like max line length. Each of those steps is details below.
22
-
23
- ### Text to AST
24
-
25
- When the prettier process first spins up, it examines which files it's going to print and selects an appropriate plugin for each one. Once selected, it runs that plugin's `parse` function, seen [here](src/ruby/parser.js). For the case of the Ruby plugin, that entails spawning a Ruby process that runs [parser.rb](src/ruby/parser.rb) with the input code preloaded on stdin.
26
-
27
- `parser.rb` will read the text off of stdin and then feed it to a new `Ripper` instance, which is a Ruby standard library recursive-descent parser. Briefly, the way that `Ripper` works is by tokenizing the input and then matching those tokens against a grammar to form s-expressions. To extend `Ripper`, you overwrite the methods that control how those s-expressions are formed, e.g., to modify the s-expression that is formed when `Ripper` encounters a string literal, you would override the `#on_string_literal` method. Below is an example for seeing that in action.
28
-
29
- Let's assume you have the following code:
30
-
31
- ```ruby
32
- 1 + 1
33
- ```
34
-
35
- First, `Ripper` will tokenize:
36
-
37
- <!-- prettier-ignore -->
38
- ```ruby
39
- require 'ripper'
40
-
41
- pp Ripper.lex('1 + 1')
42
-
43
- =begin
44
- [[[1, 0], :on_int, "1", EXPR_END],
45
- [[1, 1], :on_sp, " ", EXPR_END],
46
- [[1, 2], :on_op, "+", EXPR_BEG],
47
- [[1, 3], :on_sp, " ", EXPR_BEG],
48
- [[1, 4], :on_int, "1", EXPR_END]]
49
- =end
50
- ```
51
-
52
- You can see it has location metadata (row and column), the token type, the value associated with that token type, and the lexer state when that token was encountered. Then, it will convert those tokens into s-expressions:
53
-
54
- <!-- prettier-ignore -->
55
- ```ruby
56
- require 'ripper'
57
-
58
- pp Ripper.sexp_raw('1 + 1')
59
-
60
- =begin
61
- [:program,
62
- [:stmts_add,
63
- [:stmts_new],
64
- [:binary, [:@int, "1", [1, 0]], :+, [:@int, "1", [1, 4]]]]]
65
- =end
66
- ```
67
-
68
- As you can see above, the resulting s-expressions will call the following methods in order on the instantiated `Ripper` instance: `on_int`, `on_int`, `on_stmts_new`, `on_binary`, `on_stmts_add`, `on_program`. You can hook into any part of this process by overriding any of those methods (we override all of them).
69
-
70
- Now that the text has been transformed into an AST that we can work with, `parser.rb` will serialize the result to JSON, write it back to stdout, and exit. The `parse` function will then parse that JSON by reading off the child process once it has exited, and return that value back to prettier.
71
-
72
- ### AST to Doc
73
-
74
- Once prettier has a working AST, it will take it and call the selected plugin's [`printNode` function](src/ruby/printer.js), whose purpose is to convert that AST into prettier's intermediate representation called Docs. It does this by handing the print function a `FastPath` object that keeps track of the state of the printing as it goes, and allows accessing various parts of the AST quickly.
75
-
76
- Effectively, it walks the AST in the reverse direction from the way `Ripper` built it (top-down instead of bottom-up). The first node that gets passed into the `print` function is the `program` node as that's always on top. Then it is the `program` node's responsibility to recursively call print on its child nodes as it best sees fit.
77
-
78
- As the nodes are printing themselves and their children, they're additionally building up a second AST. That AST is built using the `builder` commands from prettier core, described [here](https://github.com/prettier/prettier/blob/main/commands.md). As an example, below is how a `binary` node (like the one representing the `1 + 1` above) would handle printing itself:
79
-
80
- ```javascript
81
- const { group, indent, line } = require("prettier").doc.builders;
82
-
83
- const printBinary = (path, opts, print) =>
84
- group([
85
- [path.call(print, "body", 0), " "],
86
- path.getValue().body[1],
87
- indent([line, path.call(print, "body", 2)])
88
- ]);
89
- ```
90
-
91
- Recall that the `binary` node looks like this:
92
-
93
- ```
94
- [:binary, [:@int, "1", [1, 0]], :+, [:@int, "1", [1, 4]]]
95
- ```
96
-
97
- This means that there is a node in the `0` position of the array that represents the left-hand operand, and a node in the `2` position of the array that represents the right-hand operand. The operator is represented as a string literal in the `1` position of the array.
98
-
99
- So, the `printBinary` function is going to use the following `prettier` builders to build up the intermediate represention:
100
-
101
- - `group` - marks places where `prettier` could split text if the line gets too long; if the max line length is hit, `prettier` will break apart the outermost `group` node first
102
- - `indent` - increases the current print indent for the contents of the node if the parent node is broken, e.g., if the `binary` node is too long to fit on one line, it will indent the right-hand operand
103
- - `line` - puts a space if the group is not broken, otherwise puts a newline
104
-
105
- Once every node has been printed like the `binary` node above, the `print` node returns the intermediate representation to `prettier`.
106
-
107
- ### Doc to text
108
-
109
- At this point, this is where `prettier`'s printer takes over. Because the remainder of the process is language-agnostic and `prettier` knows how to handle its own `Doc` representation, the Ruby plugin no longer has a job to do. `prettier` will walk its own `Doc` nodes and print them out according to the rules established by the structure.
110
-
111
- ## FAQ
112
-
113
- Below are a couple of questions frequently asked about the prettier Ruby plugin.
114
-
115
- ### Why Ripper over the other available Ruby parsers?
116
-
117
- I've been asked this question a lot, and there are a lot of reasons for this:
118
-
119
- 1. Ripper is stdlib, and when the node process running prettier spawns the Ruby process performing the parsing, it's a lot easier to just require ripper than to worry about inconsistent environments having gems installed in myriad places.
120
- 2. Ripper is fast, which is nice as we need that to give the developer a good experience.
121
- 3. It was originally written in Ripper. Changing the parser at this point would entail an entire rewrite of the system, as the project is inextricably tied to the AST.
122
-
123
- ### Why are the Ruby options distinct from the JavaScript options?
124
-
125
- In order to support all preferences, the Ruby options need to be distinct from the JavaScript options, otherwise you would not be able to, for example, have single quotes in Ruby and double quotes in JavaScript. They also indicate somewhat different things. In JavaScript, nothing changes when you use single versus double quotes, whereas in Ruby single and doubles quotes change interpolation behavior.
126
-
127
- ### What versions of Ruby are supported?
128
-
129
- We support all Ruby versions that are under security maintenance or better (https://www.ruby-lang.org/en/downloads/branches/). This means at the moment we support back to Ruby 2.5. This is not to say that prettier can't parse and print code that was written while running earlier versions of Ruby, it's just that the Ruby process running prettier (whatever `ruby` resolves to when the process runs) must be >= 2.5.
130
-
131
- ### Do you support ERB files (.html.erb, .js.erb, etc.)?
132
-
133
- At the moment, prettier doesn't have baked-in support for template languages. The way it is accomplished in prettier core is to extend each of the individual parsers to have special placeholder AST nodes that then switch the printer over to the necessarily language. This is certainly possible to support ERB, but the work is still being investigated. See [this issue](https://github.com/prettier/plugin-ruby/issues/371) for more detail.
134
-
135
- ## Useful links
136
-
137
- For further understanding, below is a list of helpful resources.
138
-
139
- ### Ruby
140
-
141
- Links contained within the Ruby source that are relevant to this plugin.
142
-
143
- - [parse.y](https://github.com/ruby/ruby/blob/trunk/parse.y) - the parser generator within Ruby that gives you the names of the nodes as well as their structure
144
- - [test_parser_events.rb](https://github.com/ruby/ruby/blob/trunk/test/ripper/test_parser_events.rb) - the parser test file that gives you code examples of each kind of node
145
-
146
- ### Ripper
147
-
148
- Links relating to `ripper` and how it parses Ruby source.
149
-
150
- - [Ripper preview](https://ripper-preview.herokuapp.com) - a visualization of `ripper` and how it parses Ruby source
151
- - [How ripper parses variables](https://rmosolgo.github.io/blog/2018/05/21/how-ripper-parses-variables/) - blog post neatly explaining how `ripper` parses variables
152
- - [Ripper events](https://rmosolgo.github.io/ripper_events/) - documentation for each type of `ripper` node
153
-
154
- ### Prettier
155
-
156
- Links relating to `prettier` and its plugins.
157
-
158
- - [Prettier plugin documentation](https://prettier.io/docs/en/plugins.html) - documentation around `prettier`'s plugin system
159
- - [Builder commands](https://github.com/prettier/prettier/blob/main/commands.md) - the functions used to build the `prettier` IR
160
- - [Writing a Prettier plugin](https://medium.com/@fvictorio/how-to-write-a-plugin-for-prettier-a0d98c845e70) - a nice tutorial on how to build a `prettier` plugin
161
-
162
- ## Useful commands
163
-
164
- While developing, we've built a couple of small utilities for debugging the `prettier` printing process. To use them, first run `yarn` and `bundle` to install dependencies.
165
-
166
- - `bin/lex [file|source]` - outputs the tokens as ripper sees them
167
- - `bin/sexp [file|source]` - outputs the AST that ripper builds before it gets passed back to `prettier`
168
- - `bin/pragma [file]` - runs the `hasPragma` function against the given input file
169
- - `bin/print [file|source]` - outputs the printed source of a Ruby file after running it through `prettier`
170
-
171
- ## Testing
172
-
173
- There are two kinds of tests contained within this repository.
174
-
175
- The first are JavaScript tests (run with `jest`) that test the formatting against preconfigured fixtures to protect against regressions. They live in [test/js](test/js). To run them, run:
176
-
177
- ```
178
- $ yarn test
179
- ```
180
-
181
- The second are Ruby tests (run with `minitest`) that test the gem the wraps the `prettier` plugin as well as testing the various metadata attached to the AST nodes that `ripper` generates. They live in [test/rb](test/rb). To run them, run:
182
-
183
- ```
184
- $ bundle exec rake
185
- ```
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019-present Kevin Newton
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,226 +0,0 @@
1
- <div align="center">
2
- <img alt="Prettier Ruby" height="256px" src="./docs/logo.png">
3
- </div>
4
-
5
- <h1 align="center">Prettier for Ruby</h1>
6
-
7
- <p align="center">
8
- <a href="https://gitter.im/jlongster/prettier">
9
- <img alt="Gitter" src="https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square">
10
- </a>
11
- <a href="https://github.com/prettier/plugin-ruby/actions">
12
- <img alt="GitHub Actions" src="https://img.shields.io/github/workflow/status/prettier/plugin-ruby/Main?style=flat-square">
13
- </a>
14
- <a href="https://www.npmjs.com/package/@prettier/plugin-ruby">
15
- <img alt="NPM Version" src="https://img.shields.io/npm/v/@prettier/plugin-ruby.svg?style=flat-square">
16
- </a>
17
- <a href="#badge">
18
- <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square">
19
- </a>
20
- <a href="https://twitter.com/PrettierCode">
21
- <img alt="Follow+Prettier+on+Twitter" src="https://img.shields.io/twitter/follow/prettiercode.svg?label=follow+prettier&style=flat-square">
22
- </a>
23
- </p>
24
-
25
- `@prettier/plugin-ruby` is a [prettier](https://prettier.io/) plugin for the Ruby programming language and its ecosystem. `prettier` is an opinionated code formatter that supports multiple languages and integrates with most editors. The idea is to eliminate discussions of style in code review and allow developers to get back to thinking about code design instead.
26
-
27
- For example, the below [code segment](http://www.rubyinside.com/advent2006/4-ruby-obfuscation.html):
28
-
29
- <!-- prettier-ignore -->
30
- ```ruby
31
- d=[30644250780,9003106878,
32
- 30636278846,66641217692,4501790980,
33
- 671_24_603036,131_61973916,66_606629_920,
34
- 30642677916,30643069058];a,s=[],$*[0]
35
- s.each_byte{|b|a<<("%036b"%d[b.
36
- chr.to_i]).scan(/\d{6}/)}
37
- a.transpose.each{ |a|
38
- a.join.each_byte{\
39
- |i|print i==49?\
40
- ($*[1]||"#")\
41
- :32.chr}
42
- puts
43
- }
44
- ```
45
-
46
- when run through `@prettier/plugin-ruby` will generate:
47
-
48
- ```ruby
49
- d = [
50
- 30_644_250_780,
51
- 9_003_106_878,
52
- 30_636_278_846,
53
- 66_641_217_692,
54
- 4_501_790_980,
55
- 671_24_603036,
56
- 131_61973916,
57
- 66_606629_920,
58
- 30_642_677_916,
59
- 30_643_069_058
60
- ]
61
- a, s = [], $*[0]
62
- s.each_byte { |b| a << ("%036b" % d[b.chr.to_i]).scan(/\d{6}/) }
63
- a.transpose.each do |a|
64
- a.join.each_byte { |i| print i == 49 ? ($*[1] || "#") : 32.chr }
65
- puts
66
- end
67
- ```
68
-
69
- ## Getting started
70
-
71
- To run `prettier` with the Ruby plugin, you're going to need [`ruby`](https://www.ruby-lang.org/en/documentation/installation/) (version `2.7.3` or newer) and [`node`](https://nodejs.org/en/download/) (version `8.3` or newer). If you're integrating with a project that is not already using `prettier`, you should use the Ruby gem. Otherwise you can use the `npm` package directly.
72
-
73
- Note that currently the editor integrations work best with the `npm` package, as most of the major editor plugins expect a `node_modules` directory. You can get them to work with the Ruby gem, but it requires manually configuring the paths.
74
-
75
- This plugin currently supports formatting the following kinds of files:
76
-
77
- - All varieties of Ruby source files (e.g., `*.rb`, `*.gemspec`, `Gemfile`, etc.)
78
- - [RBS type language](https://github.com/ruby/rbs) files - requires having the `rbs` gem in your gem path
79
- - [HAML template language](https://haml.info/) files - requires having the `haml` gem in your gem path
80
-
81
- ### Ruby gem
82
-
83
- Add this line to your application's Gemfile:
84
-
85
- ```ruby
86
- gem "prettier"
87
- ```
88
-
89
- And then execute:
90
-
91
- ```bash
92
- bundle
93
- ```
94
-
95
- Or install it yourself as:
96
-
97
- ```bash
98
- gem install prettier
99
- ```
100
-
101
- The `rbprettier` executable is now installed and ready for use:
102
-
103
- ```bash
104
- bundle exec rbprettier --write '**/*'
105
- ```
106
-
107
- ### `npm` package
108
-
109
- If you're using the `npm` CLI, then add the plugin by:
110
-
111
- ```bash
112
- npm install --save-dev prettier @prettier/plugin-ruby
113
- ```
114
-
115
- Or if you're using `yarn`, then add the plugin by:
116
-
117
- ```bash
118
- yarn add --dev prettier @prettier/plugin-ruby
119
- ```
120
-
121
- You'll also need to add the necessary Ruby dependencies. You can do this by running:
122
-
123
- ```bash
124
- gem install bundler prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs
125
- ```
126
-
127
- The `prettier` executable is now installed and ready for use:
128
-
129
- ```bash
130
- ./node_modules/.bin/prettier --write '**/*'
131
- ```
132
-
133
- ## Configuration
134
-
135
- Below are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/plugin-ruby` currently supports:
136
-
137
- | API Option | CLI Option | Default | Description |
138
- | --------------- | ------------------ | :-----: | --------------------------------------------------------------------------------------------------------------------------------------------------- |
139
- | `printWidth` | `--print-width` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)). |
140
- | `requirePragma` | `--require-pragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)). |
141
- | `rubyPlugins` | `--ruby-plugins` | `""` | The comma-separated list of plugins to require. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins). |
142
- | `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). |
143
- | `singleQuote` | `--single-quote` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#quotes)). |
144
- | `trailingComma` | `--trailing-comma` | `es5` | Almost same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-commas)). Will be on for any value except `none`. |
145
-
146
- Any of these can be added to your existing [prettier configuration
147
- file](https://prettier.io/docs/en/configuration.html). For example:
148
-
149
- ```json
150
- {
151
- "tabWidth": 4
152
- }
153
- ```
154
-
155
- Or, they can be passed to `prettier` as arguments:
156
-
157
- ```bash
158
- bundle exec rbprettier --tab-width 4 --write '**/*'
159
- ```
160
-
161
- ### Usage with RuboCop
162
-
163
- RuboCop and Prettier for Ruby serve different purposes, but there is overlap
164
- with some of RuboCop's functionality.
165
-
166
- Prettier provides a RuboCop configuration file to disable the rules which clash.
167
- To enable, add the following config at the top of your project's `.rubocop.yml`:
168
-
169
- #### Ruby gem
170
-
171
- ```yaml
172
- inherit_gem:
173
- prettier: rubocop.yml
174
- ```
175
-
176
- #### `npm` package
177
-
178
- ```yaml
179
- inherit_from:
180
- - node_modules/@prettier/plugin-ruby/rubocop.yml
181
- ```
182
-
183
- ### Usage with an editor
184
-
185
- For [supported editor integrations](https://github.com/prettier/prettier/blob/main/website/data/editors.yml), you should follow the instructions for installing the integration, then install the npm version of this plugin as a development dependency of your project. For most integrations, that should be sufficient. For convenience, the instructions for integrating with VSCode are used as an example below:
186
-
187
- - Install the [Prettier - Code Formatter](https://github.com/prettier/prettier-vscode) extension.
188
- - Add the npm `@prettier/plugin-ruby` package to your project as described above.
189
- - Configure in your `settings.json` (`formatOnSave` is optional):
190
-
191
- ```json
192
- {
193
- "[ruby]": {
194
- "editor.defaultFormatter": "esbenp.prettier-vscode",
195
- "editor.formatOnSave": true
196
- }
197
- }
198
- ```
199
-
200
- Refer to [this issue](https://github.com/prettier/plugin-ruby/issues/113#issuecomment-783426539) if you're having difficulties.
201
-
202
- ## Contributing
203
-
204
- Check out our [contributing guide](CONTRIBUTING.md). Bug reports and pull requests are welcome on GitHub at https://github.com/prettier/plugin-ruby.
205
-
206
- You can support `prettier/plugin-ruby` [on OpenCollective](https://opencollective.com/prettier-ruby/contribute). Your organization's logo will show up here with a link to your website.
207
-
208
- <!-- prettier-ignore-start -->
209
- <!-- markdownlint-disable -->
210
- <a href="https://opencollective.com/prettier-ruby/organization/0/website"><img src="https://opencollective.com/prettier-ruby/organization/0/avatar.svg"></a>
211
- <a href="https://opencollective.com/prettier-ruby/organization/1/website"><img src="https://opencollective.com/prettier-ruby/organization/1/avatar.svg"></a>
212
- <a href="https://opencollective.com/prettier-ruby/organization/2/website"><img src="https://opencollective.com/prettier-ruby/organization/2/avatar.svg"></a>
213
- <a href="https://opencollective.com/prettier-ruby/organization/3/website"><img src="https://opencollective.com/prettier-ruby/organization/3/avatar.svg"></a>
214
- <a href="https://opencollective.com/prettier-ruby/organization/4/website"><img src="https://opencollective.com/prettier-ruby/organization/4/avatar.svg"></a>
215
- <a href="https://opencollective.com/prettier-ruby/organization/5/website"><img src="https://opencollective.com/prettier-ruby/organization/5/avatar.svg"></a>
216
- <a href="https://opencollective.com/prettier-ruby/organization/6/website"><img src="https://opencollective.com/prettier-ruby/organization/6/avatar.svg"></a>
217
- <a href="https://opencollective.com/prettier-ruby/organization/7/website"><img src="https://opencollective.com/prettier-ruby/organization/7/avatar.svg"></a>
218
- <a href="https://opencollective.com/prettier-ruby/organization/8/website"><img src="https://opencollective.com/prettier-ruby/organization/8/avatar.svg"></a>
219
- <a href="https://opencollective.com/prettier-ruby/organization/9/website"><img src="https://opencollective.com/prettier-ruby/organization/9/avatar.svg"></a>
220
-
221
- <!-- markdownlint-enable -->
222
- <!-- prettier-ignore-end -->
223
-
224
- ## License
225
-
226
- The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1 +0,0 @@
1
- ../prettier/bin-prettier.js