comment_strip-ruby 0.2.0 → 0.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/AUTHORS.md +21 -0
- data/CHANGES.md +62 -0
- data/CONTRIBUTING.md +36 -0
- data/EXAMPLES.md +9 -0
- data/FAQ.md +28 -0
- data/INSTALL.md +41 -0
- data/LICENSE +19 -18
- data/NEWS.md +16 -0
- data/README.md +80 -19
- data/Rakefile +21 -0
- data/SECURITY.md +23 -0
- data/TODO.md +49 -0
- data/examples/read_c_family_source.rb +39 -0
- data/examples/read_c_family_source_from_stdin.rb +39 -0
- data/lib/comment_strip/language_families/c.rb +121 -18
- data/lib/comment_strip/language_families/hash_line.rb +106 -20
- data/lib/comment_strip/strip.rb +15 -11
- data/lib/comment_strip/version.rb +5 -4
- data/lib/comment_strip.rb +7 -6
- data/test/unit/tc_strip_c.rb +8 -8
- data/test/unit/tc_strip_c_defects.rb +179 -0
- data/test/unit/tc_strip_hash_line_defects.rb +154 -0
- metadata +34 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce57acda6cf3e2f63a1717ca7cd811d053310ad89720b94061ade6fc50d2501c
|
|
4
|
+
data.tar.gz: b1c52e35c592dba95ad3502317b647dd7adb8544d2ba4208ad54cd65cd76323f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1ee76b1430c2d1be6a818cc5ee8e9ddb44e5ca25b2e23de03cfc05890fbea2ec6c6726a6c3c73af7f259920d92e32bbece74d3445a0f38ad2ed21e6e6ad22b1
|
|
7
|
+
data.tar.gz: 03655e789aa5034e8390ace6aa0018210a317f67e2522bcbf781ae1614c792c53918f206911d0b18c2d2dde033b0a626646c8d79404945d969aa69f360b094b5
|
data/AUTHORS.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# comment_strip.r - Authors <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Major Contributors
|
|
5
|
+
|
|
6
|
+
| Name | GitHub |
|
|
7
|
+
| ----------- | --------------------------------- |
|
|
8
|
+
| Matt Wilson | [mwsis](https://github.com/mwsis) |
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Defect reports, fixes and suggestions (for which we are very grateful)
|
|
12
|
+
|
|
13
|
+
| Name | GitHub |
|
|
14
|
+
| ----------- | --------------------------------- |
|
|
15
|
+
| \<none> | |
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Contributions are welcomed.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<!-- ########################### end of file ########################### -->
|
data/CHANGES.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# comment_strip.r - Changes <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## 0.2.1 - 30th August 2026
|
|
5
|
+
|
|
6
|
+
* renamed **comment_strip.gemspec** to **comment_strip-ruby.gemspec** so the filename stem matches `spec.name`;
|
|
7
|
+
* **comment_strip-ruby.gemspec**: `required_ruby_version` is the range `>= 2.0` (dropped `< 4`); **Gemfile.lock** and **.ruby-version** excluded from `spec.files`; `spec.summary` matches the README tagline; packaged **AUTHORS**, **CHANGES**, **CONTRIBUTING**, **EXAMPLES**, **FAQ**, **INSTALL**, **NEWS**, **SECURITY**, **TODO**; runtime **xqsr3** is `>= 0.39.5`, `< 1.0`;
|
|
8
|
+
* **Gemfile** sets `lockfile false` when Bundler supports it; stop tracking **Gemfile.lock**;
|
|
9
|
+
* CI uses `bundler-cache: false` and explicit `bundle install`; **Warnings** job on Ruby **3.4**; `gem build comment_strip-ruby.gemspec`;
|
|
10
|
+
* **README.md**: tagline before badges; canonical five-badge row; TOC after badges; nested **Dependencies** (Efferent / Afferent);
|
|
11
|
+
* **EXAMPLES.md** catalogues **./examples/read_c_family_source.rb** and **./examples/read_c_family_source_from_stdin.rb**;
|
|
12
|
+
* library source `Home:` URLs now use `https`;
|
|
13
|
+
* **lib/** language-family `strip` methods build the result with Ruby **2.0**-compatible `String#force_encoding` so frozen string literals (Ruby **3.4** / `# frozen_string_literal: true`) do not raise `FrozenError`;
|
|
14
|
+
* removed unused local variables and a duplicate `when` clause reported by Ruby warnings;
|
|
15
|
+
* updated **run_all_unit_tests.sh** (from https://github.com/synesissoftware/misc-dev-scripts) to skip **tput** when **$TERM** is unset or stdout is not a TTY;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 0.2.0.1 - 11th April 2024
|
|
19
|
+
|
|
20
|
+
* added `# frozen_string_literal: true` to all **lib/** sources;
|
|
21
|
+
* various boilerplate improvements;
|
|
22
|
+
* fixed an unused test;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 0.2.0 - 31st March 2024
|
|
26
|
+
|
|
27
|
+
* added `:hash_line` language-family support;
|
|
28
|
+
* tidied `LanguageFamilies::C#strip()`;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## 0.1.2.1 - 1st December 2023
|
|
32
|
+
|
|
33
|
+
* updated dependencies;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## 0.1.2 - 11th July 2022
|
|
37
|
+
|
|
38
|
+
* prepared for supporting multiple languages;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## 0.1.1 - 11th February 2021
|
|
42
|
+
|
|
43
|
+
* removed currently unneeded dependencies;
|
|
44
|
+
* added **.ruby-version-exclusions** (for `--rbenv-versions`);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## 0.1.0 - 10th February 2021
|
|
48
|
+
|
|
49
|
+
* added `strip()` as a module method (exposed method);
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## 0.0.13 - 14th September 2020
|
|
53
|
+
|
|
54
|
+
* more test cases;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## 0.0.7 - 14th September 2020
|
|
58
|
+
|
|
59
|
+
* more work for multiline C-comments;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
<!-- ########################### end of file ########################### -->
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# comment_strip.r - Contributing <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Table of Contents <!-- omit in toc -->
|
|
5
|
+
|
|
6
|
+
- [Defects and features](#defects-and-features)
|
|
7
|
+
- [Pull requests](#pull-requests)
|
|
8
|
+
- [Tests](#tests)
|
|
9
|
+
- [License](#license)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Defects and features
|
|
13
|
+
|
|
14
|
+
Open an issue on https://github.com/synesissoftware/comment_strip.r/issues.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Pull requests
|
|
18
|
+
|
|
19
|
+
Pull requests are welcome on https://github.com/synesissoftware/comment_strip.r. Keep diffs local to the change; match existing indentation (2 spaces in Ruby) and the Synesis markdown set (**README.md**, **CHANGES.md**, **NEWS.md**, **TODO.md**, **INSTALL.md**, **CONTRIBUTING.md**, **SECURITY.md**).
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Tests
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
bundle exec rake test
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
or `./run_all_unit_tests.sh`.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
Contributions are accepted under the 3-clause BSD license. See [LICENSE](./LICENSE).
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<!-- ########################### end of file ########################### -->
|
data/EXAMPLES.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# comment_strip.r - Examples <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|Name|Source & Description|Summary|
|
|
4
|
+
|---|---|---|
|
|
5
|
+
|**read_c_family_source**|[./examples/read_c_family_source.rb](./examples/read_c_family_source.rb)|strip from a named file|
|
|
6
|
+
|**read_c_family_source_from_stdin**|[./examples/read_c_family_source_from_stdin.rb](./examples/read_c_family_source_from_stdin.rb)|strip from stdin|
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<!-- ########################### end of file ########################### -->
|
data/FAQ.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# comment_strip.r - FAQ <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
The FAQ list is under (constant) development. If you post a question on the
|
|
4
|
+
[Issues](https://github.com/synesissoftware/comment_strip.r/issues) forum
|
|
5
|
+
it will be used to create one.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Table of Contents <!-- omit in toc -->
|
|
9
|
+
|
|
10
|
+
- [Q1: "How do I install this library?"](#q1-how-do-i-install-this-library)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# FAQs: <!-- omit in toc -->
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Q1: "How do I install this library?"
|
|
17
|
+
|
|
18
|
+
Install via **gem**:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
gem install comment_strip-ruby
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
See [README.md](./README.md) for usage.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<!-- ########################### end of file ########################### -->
|
data/INSTALL.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# comment_strip.r - Installation and Use <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Table of Contents <!-- omit in toc -->
|
|
5
|
+
|
|
6
|
+
- [Install the gem](#install-the-gem)
|
|
7
|
+
- [From a source checkout](#from-a-source-checkout)
|
|
8
|
+
- [Using the library](#using-the-library)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Install the gem
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
gem install comment_strip-ruby
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
or add to a **Gemfile**:
|
|
18
|
+
|
|
19
|
+
```Ruby
|
|
20
|
+
gem 'comment_strip-ruby'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
then `bundle install`.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## From a source checkout
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
bundle install
|
|
30
|
+
bundle exec rake test
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Using the library
|
|
35
|
+
|
|
36
|
+
```Ruby
|
|
37
|
+
require 'comment_strip'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<!-- ########################### end of file ########################### -->
|
data/LICENSE
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
comment_strip.r
|
|
1
|
+
comment_strip.r - BSD 3-Clause License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021, Matthew Wilson and Synesis Information Systems
|
|
3
|
+
Copyright (c) 2021-2026, Matthew Wilson and Synesis Information Systems
|
|
4
4
|
Copyright (c) 2008-2019, Matthew Wilson and Synesis Software
|
|
5
5
|
All rights reserved.
|
|
6
6
|
|
|
7
7
|
Redistribution and use in source and binary forms, with or without
|
|
8
8
|
modification, are permitted provided that the following conditions are met:
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
and/or other materials provided with the distribution.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
18
|
+
contributors may be used to endorse or promote products derived from
|
|
19
|
+
this software without specific prior written permission.
|
|
20
20
|
|
|
21
21
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
22
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
24
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
25
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
26
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
27
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
28
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
29
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
30
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
24
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
25
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
26
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
27
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
28
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
29
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
30
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
31
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
31
32
|
|
data/NEWS.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# comment_strip.r - News <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
| Date | News Item |
|
|
4
|
+
| ------------------- | ---------------------------------------------------------------------------------------------- |
|
|
5
|
+
| 30th August 2026 | [**comment_strip.r** 0.2.1](https://github.com/synesissoftware/comment_strip.r/releases/tag/0.2.1) |
|
|
6
|
+
| 11th April 2024 | [**comment_strip.r** 0.2.0.1](https://github.com/synesissoftware/comment_strip.r/releases/tag/0.2.0.1) |
|
|
7
|
+
| 31st March 2024 | **comment_strip.r** 0.2.0 released |
|
|
8
|
+
| 1st December 2023 | **comment_strip.r** 0.1.2.1 released |
|
|
9
|
+
| 11th July 2022 | **comment_strip.r** 0.1.2 released |
|
|
10
|
+
| 11th February 2021 | **comment_strip.r** 0.1.1 released |
|
|
11
|
+
| 10th February 2021 | **comment_strip.r** 0.1.0 released |
|
|
12
|
+
| 10th February 2021 | **comment_strip.r** 0.0.13 released |
|
|
13
|
+
| 14th September 2020 | **comment_strip.r** 0.0.7 released |
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<!-- ########################### end of file ########################### -->
|
data/README.md
CHANGED
|
@@ -1,39 +1,58 @@
|
|
|
1
|
-
# comment_strip.r
|
|
2
|
-
Comment Strip for Ruby
|
|
1
|
+
# comment_strip.r <!-- omit in toc -->
|
|
3
2
|
|
|
3
|
+
Comment Strip, for Ruby
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
4
7
|
[](https://badge.fury.io/rb/comment_strip-ruby)
|
|
8
|
+
[](https://github.com/synesissoftware/comment_strip.r/commits/master)
|
|
9
|
+
[](https://github.com/synesissoftware/comment_strip.r/actions/workflows/ruby.yml)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Table of Contents <!-- omit in toc -->
|
|
13
|
+
|
|
14
|
+
- [Introduction](#introduction)
|
|
15
|
+
- [Installation](#installation)
|
|
16
|
+
- [Components](#components)
|
|
17
|
+
- [Examples](#examples)
|
|
18
|
+
- [Project Information](#project-information)
|
|
19
|
+
- [Where to get help](#where-to-get-help)
|
|
20
|
+
- [Contribution guidelines](#contribution-guidelines)
|
|
21
|
+
- [Dependencies](#dependencies)
|
|
22
|
+
- [Efferent (fan-out)](#efferent-fan-out)
|
|
23
|
+
- [Runtime Dependencies (aka "Normal Dependencies")](#runtime-dependencies-aka-normal-dependencies)
|
|
24
|
+
- [Development Dependencies](#development-dependencies)
|
|
25
|
+
- [Afferent (fan-in)](#afferent-fan-in)
|
|
26
|
+
- [Runtime dependents](#runtime-dependents)
|
|
27
|
+
- [Development dependents](#development-dependents)
|
|
28
|
+
- [Related projects](#related-projects)
|
|
29
|
+
- [License](#license)
|
|
5
30
|
|
|
6
|
-
## Introduction
|
|
7
31
|
|
|
8
|
-
|
|
32
|
+
## Introduction
|
|
9
33
|
|
|
10
|
-
|
|
34
|
+
**comment_strip.r** strips comments from source text for a small set of language families. Call `CommentStrip.strip(input, language_family)` (or the equivalent instance API) with a recognised family such as `:C` or `:Hash_Line`; the library returns the input with comments removed according to that family's rules.
|
|
11
35
|
|
|
12
|
-
1. [Introduction](#introduction)
|
|
13
|
-
2. [Installation](#installation)
|
|
14
|
-
3. [Components](#components)
|
|
15
|
-
4. [Project Information](#project-information)
|
|
16
36
|
|
|
17
37
|
## Installation
|
|
18
38
|
|
|
19
|
-
Install
|
|
39
|
+
Install via **gem** as in:
|
|
20
40
|
|
|
21
|
-
```
|
|
22
|
-
|
|
41
|
+
```
|
|
42
|
+
gem install comment_strip-ruby
|
|
23
43
|
```
|
|
24
44
|
|
|
25
|
-
or add it to your `Gemfile
|
|
45
|
+
or add it to your `Gemfile`.
|
|
26
46
|
|
|
27
|
-
```plaintext
|
|
28
|
-
gem 'comment_strip-ruby'
|
|
29
|
-
```
|
|
30
47
|
|
|
31
48
|
## Components
|
|
32
49
|
|
|
33
50
|
Current version supports following language families:
|
|
34
51
|
|
|
35
|
-
* `'C'` - C-family languages, recognising `//` line and `/*
|
|
36
|
-
* `'Hash_Line'` - Generic support for `#` line comments, as found in shell scripts and languages such as **Perl**, **Python**, and **Ruby**. Does
|
|
52
|
+
* `'C'` - C-family languages, recognising `//` line and `/* … */` block comments;
|
|
53
|
+
* `'Hash_Line'` - Generic support for `#` line comments, as found in shell scripts and languages such as **Perl**, **Python**, and **Ruby**. **NOTE**: Does not yet provide any language-specific smarts such as she-bang comments and directive comments;
|
|
54
|
+
|
|
55
|
+
|
|
37
56
|
## Examples
|
|
38
57
|
|
|
39
58
|
It is as simple as the following:
|
|
@@ -46,22 +65,64 @@ stripped = CommentStrip.strip($stdin.read, :C)
|
|
|
46
65
|
puts "Stripped form of input:\n#{stripped}"
|
|
47
66
|
```
|
|
48
67
|
|
|
68
|
+
Examples are provided in the ```examples``` directory. A detailed list TOC of them is provided in [EXAMPLES.md](./EXAMPLES.md).
|
|
69
|
+
|
|
49
70
|
|
|
50
71
|
## Project Information
|
|
51
72
|
|
|
73
|
+
|
|
52
74
|
### Where to get help
|
|
53
75
|
|
|
54
76
|
[GitHub Page](https://github.com/synesissoftware/comment_strip.r "GitHub Page")
|
|
55
77
|
|
|
78
|
+
|
|
56
79
|
### Contribution guidelines
|
|
57
80
|
|
|
58
81
|
Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/comment_strip.r.
|
|
59
82
|
|
|
83
|
+
|
|
84
|
+
### Dependencies
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#### Efferent (fan-out)
|
|
88
|
+
|
|
89
|
+
Libraries upon which **comment_strip.r** depends:
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
##### Runtime Dependencies (aka "Normal Dependencies")
|
|
93
|
+
|
|
94
|
+
* [**xqsr3**](https://github.com/synesissoftware/xqsr3);
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
##### Development Dependencies
|
|
98
|
+
|
|
99
|
+
* [**rake**](https://rubygems.org/gems/rake);
|
|
100
|
+
* [**test-unit**](https://rubygems.org/gems/test-unit);
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
#### Afferent (fan-in)
|
|
104
|
+
|
|
105
|
+
Projects that depend on **comment_strip.r**:
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
##### Runtime dependents
|
|
109
|
+
|
|
110
|
+
* \<none>;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
##### Development dependents
|
|
114
|
+
|
|
115
|
+
* \<none>;
|
|
116
|
+
|
|
117
|
+
|
|
60
118
|
### Related projects
|
|
61
119
|
|
|
62
|
-
|
|
120
|
+
* \<none> — no sibling-language **comment_strip** ports are published in freelibs at present;
|
|
121
|
+
|
|
63
122
|
|
|
64
123
|
### License
|
|
65
124
|
|
|
66
125
|
**comment_strip.r** is released under the 3-clause BSD license. See [LICENSE](./LICENSE) for details.
|
|
67
126
|
|
|
127
|
+
|
|
128
|
+
<!-- ########################### end of file ########################### -->
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Rakefile for comment_strip.r
|
|
4
|
+
|
|
5
|
+
require 'rake/testtask'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Rake::TestTask.new do |tt|
|
|
9
|
+
|
|
10
|
+
tt.libs << 'lib'
|
|
11
|
+
tt.libs << 'test'
|
|
12
|
+
tt.name = 'test'
|
|
13
|
+
tt.test_files = FileList['test/**/tc_*.rb']
|
|
14
|
+
tt.verbose = true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
task :default => :test
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# ############################## end of file ############################# #
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# comment_strip.r - Security <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Table of Contents <!-- omit in toc -->
|
|
5
|
+
|
|
6
|
+
- [Reporting a vulnerability](#reporting-a-vulnerability)
|
|
7
|
+
- [Supported versions](#supported-versions)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Reporting a vulnerability
|
|
11
|
+
|
|
12
|
+
Please report security issues privately via GitHub Security Advisories on https://github.com/synesissoftware/comment_strip.r/security, or by opening an issue if an advisory cannot be filed. Do not attach exploit proofs of concept against third-party systems.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Supported versions
|
|
16
|
+
|
|
17
|
+
| Version | Supported |
|
|
18
|
+
| ------- | --------- |
|
|
19
|
+
| 0.2.x | ✅ |
|
|
20
|
+
| < 0.2 | ❌ |
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<!-- ########################### end of file ########################### -->
|
data/TODO.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# comment_strip.r - TODO <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Functional improvements
|
|
5
|
+
|
|
6
|
+
* [x] ~~~**C** scanner defects~~~ - ✅:
|
|
7
|
+
* [x] ~~~preserve a trailing lone `/` at EOF (pending `:slash_start` must flush; see **test/unit/tc_strip_c_defects.rb**)~~~ - ✅;
|
|
8
|
+
* [x] ~~~unterminated `/* …` must still emit buffered newlines under the line-preserving policy (see **tc_strip_c_defects.rb**)~~~ - ✅;
|
|
9
|
+
* [x] ~~~count `\r\n` inside block comments as one line break when restoring newlines (CRLF currently doubles `cc_lines`; see **tc_strip_c_defects.rb**)~~~ - ✅;
|
|
10
|
+
* [x] ~~~treat C++14 digit separators (`1'000`) as digits, not character literals, so following `//` / `/*` still strip (see **tc_strip_c_defects.rb**)~~~ - ✅;
|
|
11
|
+
* [x] ~~~apply backslash-newline splicing (translation phase 2) before comment recognition (see **tc_strip_c_defects.rb**)~~~ - ✅;
|
|
12
|
+
* [x] ~~~either implement — or stop claiming — Go raw `` `…` ``, C# verbatim `@"…"`, Rust lifetimes, and C++ raw `R"(…)"` quoting (see **tc_strip_c_defects.rb** and rdoc on `CommentStrip.strip`)~~~ - ✅;
|
|
13
|
+
* [x] ~~~**C / dispatch:** fix `strip` unrecognised-family message typo (`supported1` → `supported`; see **tc_strip_c_defects.rb**)~~~ - ✅;
|
|
14
|
+
* [x] ~~~**Hash_Line** scanner defects~~~ - ✅:
|
|
15
|
+
* [x] ~~~replace the C one-character `'` machine with real single-quoted string lexing so `''`, `'alice'`, and `'it\'s'` close correctly and a following `#` is a comment (see **test/unit/tc_strip_hash_line_defects.rb**)~~~ - ✅;
|
|
16
|
+
* [x] ~~~protect `#` inside Python `'''…'''` / document limits if triple-quoting stays out of scope (see **tc_strip_hash_line_defects.rb**)~~~ - ✅;
|
|
17
|
+
* [x] ~~~protect `#` inside Ruby `%q{…}` / `%q(…)` / `%w[…]` (or narrow the README family claim; see **tc_strip_hash_line_defects.rb**)~~~ - ✅;
|
|
18
|
+
* [x] ~~~protect `#` inside Ruby heredocs (or narrow the README family claim; see **tc_strip_hash_line_defects.rb**)~~~ - ✅;
|
|
19
|
+
* [x] ~~~**other** warning cleanup~~~ - ✅:
|
|
20
|
+
* [x] ~~~quiet the assigned-but-unused variable warning in **lib/comment_strip/language_families/hash_line.rb** (`cc_lines`, `line`, `column`, `skip`; Ruby 3.4 `-W` / CI **Warnings** job)~~~ - ✅;
|
|
21
|
+
* [x] ~~~quiet the duplicate `when :hash_comment` warning in **lib/comment_strip/language_families/hash_line.rb** (Ruby 3.4 `-W` / CI **Warnings** job)~~~ - ✅;
|
|
22
|
+
* [x] ~~~quiet the assigned-but-unused variable warning in **lib/comment_strip/language_families/c.rb** (`line`, `column`; Ruby 3.4 `-W` / CI **Warnings** job)~~~ - ✅;
|
|
23
|
+
* [x] ~~~quiet the assigned-but-unused variable warning in **test/unit/tc_strip_c.rb** (`actual`; Ruby 3.4 `-W` / CI **Warnings** job)~~~ - ✅;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Maintenance improvements
|
|
27
|
+
|
|
28
|
+
* [ ] move code extracts, including those containing deliberate trailing whitespace, to fixture files or preprocess special string fragments such as `"\1SPACE\2"` and `"\1TAB\2"` before using them in tests;
|
|
29
|
+
* [ ] perform a full manual code review of the changes, especially to identify parts that could be simplified with helper functions or could permit regular expressions after entering a complex state such as a heredoc;
|
|
30
|
+
* [ ] separate general-purpose C-family and hash-family handling from language-specific handling, so C++ parsing does not apply C# `@`-strings and other languages' syntax unintentionally;
|
|
31
|
+
* [ ] add liberal explanatory comments to specific complex parts of the parsing code, especially state transitions and delimiter handling;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Performance improvements
|
|
35
|
+
|
|
36
|
+
* \<none>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Packaging improvements
|
|
40
|
+
|
|
41
|
+
* [x] ~~~Rename gemspec so the filename stem matches `spec.name` (`comment_strip.gemspec` → **comment_strip-ruby.gemspec**)~~~;
|
|
42
|
+
* [x] ~~~updated **run_all_unit_tests.sh** (from **misc-dev-scripts**) to skip `tput` when `$TERM` is unset or stdout is not a TTY~~~;
|
|
43
|
+
* [x] ~~~**Gemfile** `lockfile false`; stop tracking **Gemfile.lock**; CI `bundler-cache: false`~~~;
|
|
44
|
+
* [x] ~~~gemspec polish: README tagline as `spec.summary`, drop `< 4` upper bound, package docs, exclude **Gemfile.lock** / **.ruby-version**~~~;
|
|
45
|
+
* [x] ~~~README canonical structure (tagline before badges; **Dependencies**; CI badge → **ruby.yml**)~~~;
|
|
46
|
+
* [x] ~~~after the packaging/boilerplate/CI baseline: bump **VERSION** to **0.2.1** and align **CHANGES**/**NEWS**~~~;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<!-- ########################### end of file ########################### -->
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# ######################################################################## #
|
|
4
|
+
# File: examples/read_c_family_source.rb
|
|
5
|
+
#
|
|
6
|
+
# Purpose: Illustrates use of `strip()` via `include` operating on the
|
|
7
|
+
# contents read from a named source file
|
|
8
|
+
#
|
|
9
|
+
# ######################################################################## #
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# ######################################################################## #
|
|
13
|
+
# requires
|
|
14
|
+
|
|
15
|
+
require 'comment_strip'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ######################################################################## #
|
|
19
|
+
# includes
|
|
20
|
+
|
|
21
|
+
include CommentStrip
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# ######################################################################## #
|
|
25
|
+
# command-line handling
|
|
26
|
+
|
|
27
|
+
input_path = ARGV[0] or abort "#$0 <C-family-source-file-path>"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# ######################################################################## #
|
|
31
|
+
# main
|
|
32
|
+
|
|
33
|
+
stripped_form = strip(File.read(input_path), :C)
|
|
34
|
+
|
|
35
|
+
puts "stripped form of contents of '#{input_path}':\n#{stripped_form}"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# ############################## end of file ############################# #
|
|
39
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# ######################################################################## #
|
|
4
|
+
# File: examples/read_c_family_source.rb
|
|
5
|
+
#
|
|
6
|
+
# Purpose: Illustrates use of `strip()` via `include` operating on the
|
|
7
|
+
# contents read from `$stdin`
|
|
8
|
+
#
|
|
9
|
+
# ######################################################################## #
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# ######################################################################## #
|
|
13
|
+
# requires
|
|
14
|
+
|
|
15
|
+
require 'comment_strip'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ######################################################################## #
|
|
19
|
+
# includes
|
|
20
|
+
|
|
21
|
+
include CommentStrip
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# ######################################################################## #
|
|
25
|
+
# command-line handling
|
|
26
|
+
|
|
27
|
+
ARGV.empty? or abort "USAGE: #$0"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# ######################################################################## #
|
|
31
|
+
# main
|
|
32
|
+
|
|
33
|
+
stripped_form = strip($stdin.read, :C)
|
|
34
|
+
|
|
35
|
+
puts "stripped form of contents of input:\n#{stripped_form}"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# ############################## end of file ############################# #
|
|
39
|
+
|