strip_comments 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +23 -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: a6f9367d9a2c983ee03ec2e9234c3dc5eecfefb0a23902d6c047c46e585e7c70
|
4
|
+
data.tar.gz: de618829cf9755f3126ecdd55701379f8bb8240daf798a398b21cb887cec6cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13ca27a702dff9178b92ca85dc317f79c023778e7f8917013919acea67332f721d9b9fb7e6cfcda0f87184f2068d5b9b9eb0222c521359886b7d32dafde4cec4
|
7
|
+
data.tar.gz: c141f78bbf7553ea09a834570362f7dd2bbb800bcb6b3748eb935d9e479eb5b7b6a985de1b99ecdda7c3758b91a08441d9729eae8c0dccfdbd28165b95643d98
|
data/.byebug_history
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# StripComments
|
1
|
+
# StripComments [![Gem Version](https://badge.fury.io/rb/strip_comments.svg)](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,29 @@ 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!(/'([^']+)'/) 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
|
+
puts "replacing '#{m}' with '#{strip_key}'"
|
32
|
+
strip_key
|
33
|
+
end
|
34
|
+
|
35
|
+
str.gsub!(/"([^"]+)"/) do |m|
|
36
|
+
strip_key = "__STRIPPED_KEY_#{stripped_strings_to_not_be_uncommented.size}__"
|
37
|
+
stripped_strings_to_not_be_uncommented[strip_key] = m
|
38
|
+
puts "replacing '#{m}' with '#{strip_key}'"
|
39
|
+
strip_key
|
40
|
+
end
|
41
|
+
|
42
|
+
str.gsub!(/#[^\n]+/, '')
|
43
|
+
|
44
|
+
stripped_strings_to_not_be_uncommented.each do |k,v|
|
45
|
+
str[k] = v
|
46
|
+
end
|
47
|
+
|
48
|
+
str
|
27
49
|
end
|
28
50
|
|
29
51
|
def self.strip_properties(str)
|
@@ -38,7 +60,6 @@ module StripComments
|
|
38
60
|
strip_c_like(str)
|
39
61
|
end
|
40
62
|
|
41
|
-
|
42
63
|
def self.strip_c_like(str)
|
43
64
|
str.gsub(/\/\/[^\n]+/, '')
|
44
65
|
.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.2
|
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
|