strip_comments 0.1.0 → 0.1.3
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/.byebug_history +7 -2
- data/README.md +16 -8
- data/lib/strip_comments/version.rb +1 -1
- data/lib/strip_comments.rb +21 -2
- metadata +5 -6
- data/Gemfile.lock +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 920c33ca0c4a842363383bed65166eab6cf46adda7b1ab1a711c3aa6ddb3c4e6
|
4
|
+
data.tar.gz: 72bfd7bcb770d381ef6b443f627b6685f3d265f5e06a900a17fd26fc4e022194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff254735ef99f9320c76f8e4f4410b2be2b1a855821e6ac5c84acd2e5d41c3b3c61de806130dd39f5ae72a2fc68922e05b7fc5c8d8ac7199d262590e8f801a1
|
7
|
+
data.tar.gz: 3fb1ec51ea8917396b06724437f477a68042b5b25e7d7dc478d5d5d4939bd6ae603fb743c6e52e7060bd7cc70e85f5289f5ec0bb9f088f2c2b330d68a031c16f
|
data/.byebug_history
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# StripComments
|
1
|
+
# StripComments [](https://badge.fury.io/rb/strip_comments)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Uses regular expressions to strip things that look like comments from strings.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,17 +20,27 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```rb
|
24
|
+
require 'strip_comments'
|
25
|
+
input = File.open("your.yml").read
|
26
|
+
stripped = StripComments::strip_yaml(input)
|
27
|
+
```
|
28
|
+
|
29
|
+
You can use this to, for example, rewrite all source files in a folder:
|
30
|
+
|
31
|
+
```rb
|
32
|
+
TODO
|
33
|
+
```
|
26
34
|
|
27
35
|
## Development
|
28
36
|
|
29
37
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
38
|
|
31
|
-
To
|
39
|
+
To release a new version, update the version number in `version.rb`, and then push into `release` branch. GitHub actions will automatically publish the new gem version to [rubygems.org](https://rubygems.org).
|
32
40
|
|
33
41
|
## Contributing
|
34
42
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/soundasleep/strip_comments.
|
36
44
|
|
37
45
|
## License
|
38
46
|
|
@@ -40,4 +48,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
48
|
|
41
49
|
## Code of Conduct
|
42
50
|
|
43
|
-
Everyone interacting in the
|
51
|
+
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/soundasleep/strip_comments/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/strip_comments.rb
CHANGED
@@ -23,7 +23,27 @@ module StripComments
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.strip_yaml(str)
|
26
|
-
|
26
|
+
stripped_strings_to_not_be_uncommented = {}
|
27
|
+
|
28
|
+
str.gsub!(/"([^\n"]+)"/) do |m|
|
29
|
+
strip_key = "__STRIPPED_KEY_#{stripped_strings_to_not_be_uncommented.size}__"
|
30
|
+
stripped_strings_to_not_be_uncommented[strip_key] = m
|
31
|
+
strip_key
|
32
|
+
end
|
33
|
+
|
34
|
+
str.gsub!(/'([^\n']+)'/) do |m|
|
35
|
+
strip_key = "__STRIPPED_KEY_#{stripped_strings_to_not_be_uncommented.size}__"
|
36
|
+
stripped_strings_to_not_be_uncommented[strip_key] = m
|
37
|
+
strip_key
|
38
|
+
end
|
39
|
+
|
40
|
+
str.gsub!(/#[^\n]+/, '')
|
41
|
+
|
42
|
+
stripped_strings_to_not_be_uncommented.each do |k,v|
|
43
|
+
str[k] = v
|
44
|
+
end
|
45
|
+
|
46
|
+
str
|
27
47
|
end
|
28
48
|
|
29
49
|
def self.strip_properties(str)
|
@@ -38,7 +58,6 @@ module StripComments
|
|
38
58
|
strip_c_like(str)
|
39
59
|
end
|
40
60
|
|
41
|
-
|
42
61
|
def self.strip_c_like(str)
|
43
62
|
str.gsub(/\/\/[^\n]+/, '')
|
44
63
|
.gsub(/\/\*.+?\*\//m, '')
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strip_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jevon Wright
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-10-19 00:00:00.000000000 Z
|
@@ -24,7 +24,6 @@ files:
|
|
24
24
|
- CHANGELOG.md
|
25
25
|
- CODE_OF_CONDUCT.md
|
26
26
|
- Gemfile
|
27
|
-
- Gemfile.lock
|
28
27
|
- LICENSE.txt
|
29
28
|
- README.md
|
30
29
|
- Rakefile
|
@@ -40,7 +39,7 @@ metadata:
|
|
40
39
|
homepage_uri: https://github.com/soundasleep/strip_comments
|
41
40
|
source_code_uri: https://github.com/soundasleep/strip_comments
|
42
41
|
changelog_uri: https://github.com/soundasleep/strip_comments/blob/main/CHANGELOG.md
|
43
|
-
post_install_message:
|
42
|
+
post_install_message:
|
44
43
|
rdoc_options: []
|
45
44
|
require_paths:
|
46
45
|
- lib
|
@@ -55,8 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
54
|
- !ruby/object:Gem::Version
|
56
55
|
version: '0'
|
57
56
|
requirements: []
|
58
|
-
rubygems_version: 3.
|
59
|
-
signing_key:
|
57
|
+
rubygems_version: 3.1.6
|
58
|
+
signing_key:
|
60
59
|
specification_version: 4
|
61
60
|
summary: Simple gem to strip comments from source files
|
62
61
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
strip_comments (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.4.4)
|
10
|
-
rake (13.0.6)
|
11
|
-
rspec (3.10.0)
|
12
|
-
rspec-core (~> 3.10.0)
|
13
|
-
rspec-expectations (~> 3.10.0)
|
14
|
-
rspec-mocks (~> 3.10.0)
|
15
|
-
rspec-core (3.10.1)
|
16
|
-
rspec-support (~> 3.10.0)
|
17
|
-
rspec-expectations (3.10.1)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.10.0)
|
20
|
-
rspec-mocks (3.10.2)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.10.0)
|
23
|
-
rspec-support (3.10.3)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
x64-mingw32
|
27
|
-
x86_64-linux
|
28
|
-
|
29
|
-
DEPENDENCIES
|
30
|
-
rake (~> 13.0)
|
31
|
-
rspec (~> 3.0)
|
32
|
-
strip_comments!
|
33
|
-
|
34
|
-
BUNDLED WITH
|
35
|
-
2.2.30
|