strip_comments 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6366ef911c4a29335e87ec0480117ec8134d517d781ba0153954b0198cd15df
4
- data.tar.gz: 5752cb8c9bb24c6e01c1ae74d9312e9cf6900f411ae6c964c1b6a66d8364d149
3
+ metadata.gz: 920c33ca0c4a842363383bed65166eab6cf46adda7b1ab1a711c3aa6ddb3c4e6
4
+ data.tar.gz: 72bfd7bcb770d381ef6b443f627b6685f3d265f5e06a900a17fd26fc4e022194
5
5
  SHA512:
6
- metadata.gz: 93de3e3e0d9580d9336237fcd8f09cb022544648a0a72f7adc6647bf86fac855e29fbba8cb5378ce2d1afe4e1284f8722d130161c00271b6b55283c0cbed981e
7
- data.tar.gz: fb034e2a9e3b48307bf668e317be3afca4f1830c53a3430d736711290e6acf2c4560697901d59fc802bf8e078baacae393ab618f40680637203c454616d86757
6
+ metadata.gz: 5ff254735ef99f9320c76f8e4f4410b2be2b1a855821e6ac5c84acd2e5d41c3b3c61de806130dd39f5ae72a2fc68922e05b7fc5c8d8ac7199d262590e8f801a1
7
+ data.tar.gz: 3fb1ec51ea8917396b06724437f477a68042b5b25e7d7dc478d5d5d4939bd6ae603fb743c6e52e7060bd7cc70e85f5289f5ec0bb9f088f2c2b330d68a031c16f
data/.byebug_history CHANGED
@@ -1,2 +1,7 @@
1
- exit
2
- language
1
+ q
2
+ stripped_strings_to_not_be_uncommented
3
+ c
4
+ stripped_strings_to_not_be_uncommented
5
+ strip_strings_to_not_be_uncommented
6
+ exit
7
+ language
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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/strip_comments`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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 install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/strip_comments. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/strip_comments/blob/main/CODE_OF_CONDUCT.md).
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 StripComments project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/strip_comments/blob/main/CODE_OF_CONDUCT.md).
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).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StripComments
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -23,7 +23,27 @@ module StripComments
23
23
  end
24
24
 
25
25
  def self.strip_yaml(str)
26
- str.gsub(/#[^\n]+/, '')
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.0
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.2.22
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