comment_strip-ruby 0.0.13 → 0.1.2
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 +5 -5
- data/README.md +21 -2
- data/lib/comment_strip/language_families/c.rb +250 -0
- data/lib/comment_strip/strip.rb +34 -201
- data/lib/comment_strip/version.rb +3 -3
- data/lib/comment_strip.rb +10 -3
- data/test/scratch/ex1.rb +7 -0
- data/test/unit/tc_strip.rb +9 -1
- data/test/unit/tc_version.rb +1 -1
- data/test/unit/ts_all.rb +1 -1
- metadata +16 -52
- data/lib/comment_strip/comment_strip.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69539de8b13faa339084af8667f5e062f1b7d3244861a3008d74622d74af5eb6
|
4
|
+
data.tar.gz: acc60fe0c8e9d094b204ad35e2d6b6370d4e11d5f5e677103ffd2ba943f0fc7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76a23018cbd60b02fc811132a103676158603b6dfd8c038b15f5671a0704d983ba3bfe54c0e70dedd72e98cf3e9de1cf972c48c3268cdc4385c6f685c9e04332
|
7
|
+
data.tar.gz: d4c21de13d0bf22a7b482b71899bd9a7163dc712c685d4b336234b30d4318d04f9621769723a9e56a914fbe8e58f1ddf0f7dec7d2ee1a2b3bff98ba70f2fb6fb
|
data/README.md
CHANGED
@@ -16,7 +16,17 @@ T.B.C.
|
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
19
|
-
Install
|
19
|
+
Install directly:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ gem install comment_strip-ruby
|
23
|
+
```
|
24
|
+
|
25
|
+
or add it to your `Gemfile`:
|
26
|
+
|
27
|
+
```plaintext
|
28
|
+
gem 'comment_strip-ruby'
|
29
|
+
```
|
20
30
|
|
21
31
|
## Components
|
22
32
|
|
@@ -24,7 +34,16 @@ T.B.C.
|
|
24
34
|
|
25
35
|
## Examples
|
26
36
|
|
27
|
-
|
37
|
+
It is as simple as the following:
|
38
|
+
|
39
|
+
```Ruby
|
40
|
+
require 'comment_strip'
|
41
|
+
|
42
|
+
stripped = CommentStrip.strip($stdin.read, :C)
|
43
|
+
|
44
|
+
puts "Stripped form of input:\n#{stripped}"
|
45
|
+
```
|
46
|
+
|
28
47
|
|
29
48
|
## Project Information
|
30
49
|
|
@@ -0,0 +1,250 @@
|
|
1
|
+
# ######################################################################## #
|
2
|
+
# File: comment_strip/language_families/c.rb
|
3
|
+
#
|
4
|
+
# Purpose: Definition of strip() function for C-family languages.
|
5
|
+
#
|
6
|
+
# Created: 14th September 2020
|
7
|
+
# Updated: 11th July 2022
|
8
|
+
#
|
9
|
+
# Home: http://github.com/synesissoftware/comment_strip.r
|
10
|
+
#
|
11
|
+
# Copyright (c) 2020-2022, Matthew Wilson and Synesis Information Systems
|
12
|
+
# All rights reserved.
|
13
|
+
#
|
14
|
+
# Redistribution and use in source and binary forms, with or without
|
15
|
+
# modification, are permitted provided that the following conditions are
|
16
|
+
# met:
|
17
|
+
#
|
18
|
+
# * Redistributions of source code must retain the above copyright notice,
|
19
|
+
# this list of conditions and the following disclaimer.
|
20
|
+
#
|
21
|
+
# * Redistributions in binary form must reproduce the above copyright
|
22
|
+
# notice, this list of conditions and the following disclaimer in the
|
23
|
+
# documentation and/or other materials provided with the distribution.
|
24
|
+
#
|
25
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
26
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
27
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
28
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
29
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
31
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
32
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
33
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
34
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
35
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36
|
+
#
|
37
|
+
# ######################################################################## #
|
38
|
+
|
39
|
+
|
40
|
+
require 'xqsr3/quality/parameter_checking'
|
41
|
+
|
42
|
+
=begin
|
43
|
+
=end
|
44
|
+
|
45
|
+
module CommentStrip
|
46
|
+
module LanguageFamilies
|
47
|
+
|
48
|
+
module C
|
49
|
+
|
50
|
+
def self.strip input, lf, **options
|
51
|
+
|
52
|
+
return nil if input.nil?
|
53
|
+
return input if input.empty?
|
54
|
+
|
55
|
+
line = 0
|
56
|
+
column = 0
|
57
|
+
|
58
|
+
state = :text
|
59
|
+
|
60
|
+
r = ''
|
61
|
+
|
62
|
+
cc_lines = 0
|
63
|
+
|
64
|
+
input.each_char do |c|
|
65
|
+
|
66
|
+
case c
|
67
|
+
when ?\r, ?\n
|
68
|
+
|
69
|
+
line += 1
|
70
|
+
column = 0
|
71
|
+
else
|
72
|
+
|
73
|
+
column += 1
|
74
|
+
end
|
75
|
+
|
76
|
+
skip = false
|
77
|
+
|
78
|
+
case c
|
79
|
+
when ?\r, ?\n
|
80
|
+
|
81
|
+
case state
|
82
|
+
when :c_comment, :c_comment_star
|
83
|
+
|
84
|
+
cc_lines += 1
|
85
|
+
|
86
|
+
state = :c_comment
|
87
|
+
when :cpp_comment
|
88
|
+
|
89
|
+
state = :text
|
90
|
+
when :sq_string, :sq_string_escape, :sq_string_closing
|
91
|
+
|
92
|
+
state = :text
|
93
|
+
when :dq_string_escape
|
94
|
+
|
95
|
+
state = :dq_string
|
96
|
+
when :slash_start
|
97
|
+
|
98
|
+
r << '/'
|
99
|
+
|
100
|
+
state = :text
|
101
|
+
end
|
102
|
+
else
|
103
|
+
|
104
|
+
# special cases:
|
105
|
+
#
|
106
|
+
# - for escaped single/double quote
|
107
|
+
# - for slash-start
|
108
|
+
# - for comment-star
|
109
|
+
|
110
|
+
case state
|
111
|
+
when :sq_string_open
|
112
|
+
|
113
|
+
state = (?\\ == c) ? :sq_string_escape : :sq_string_closing
|
114
|
+
when :sq_string_escape
|
115
|
+
|
116
|
+
state = :sq_string_closing
|
117
|
+
when :dq_string_escape
|
118
|
+
|
119
|
+
state = :dq_string
|
120
|
+
when :c_comment_star
|
121
|
+
|
122
|
+
case c
|
123
|
+
when ?/
|
124
|
+
|
125
|
+
r << ?\n * cc_lines
|
126
|
+
cc_lines = 0
|
127
|
+
|
128
|
+
state = :text
|
129
|
+
skip = true
|
130
|
+
when '*'
|
131
|
+
|
132
|
+
;
|
133
|
+
else
|
134
|
+
|
135
|
+
state = :c_comment
|
136
|
+
end
|
137
|
+
else
|
138
|
+
|
139
|
+
if false
|
140
|
+
elsif state == :slash_start && ('/' != c && '*' != c)
|
141
|
+
|
142
|
+
state = :text
|
143
|
+
r << '/'
|
144
|
+
else
|
145
|
+
|
146
|
+
case c
|
147
|
+
when '/'
|
148
|
+
|
149
|
+
case state
|
150
|
+
when :text
|
151
|
+
|
152
|
+
state = :slash_start
|
153
|
+
when :slash_start
|
154
|
+
|
155
|
+
state = :cpp_comment
|
156
|
+
when :c_comment_star
|
157
|
+
|
158
|
+
r << ?\n * cc_lines
|
159
|
+
cc_lines = 0
|
160
|
+
|
161
|
+
state = :text
|
162
|
+
skip = true
|
163
|
+
end
|
164
|
+
when '*'
|
165
|
+
|
166
|
+
case state
|
167
|
+
when :slash_start
|
168
|
+
|
169
|
+
state = :c_comment
|
170
|
+
when :c_comment
|
171
|
+
|
172
|
+
state = :c_comment_star
|
173
|
+
else
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
when ?\'
|
178
|
+
|
179
|
+
case state
|
180
|
+
when :text
|
181
|
+
|
182
|
+
state = :sq_string_open
|
183
|
+
when :sq_string_closing
|
184
|
+
|
185
|
+
state = :text
|
186
|
+
else
|
187
|
+
|
188
|
+
end
|
189
|
+
when '"'
|
190
|
+
|
191
|
+
case state
|
192
|
+
when :text
|
193
|
+
|
194
|
+
state = :dq_string
|
195
|
+
when :dq_string
|
196
|
+
|
197
|
+
state = :text
|
198
|
+
else
|
199
|
+
end
|
200
|
+
when ?\\
|
201
|
+
|
202
|
+
case state
|
203
|
+
when :sq_string_open
|
204
|
+
|
205
|
+
state = :sq_string_escape
|
206
|
+
when :sq_string_escape
|
207
|
+
|
208
|
+
state = :sq_string
|
209
|
+
when :dq_string
|
210
|
+
|
211
|
+
state = :dq_string_escape
|
212
|
+
else
|
213
|
+
|
214
|
+
end
|
215
|
+
else
|
216
|
+
|
217
|
+
case state
|
218
|
+
when :sq_string_escape
|
219
|
+
|
220
|
+
state = :sq_string_closing
|
221
|
+
else
|
222
|
+
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
|
230
|
+
case state
|
231
|
+
when :slash_start
|
232
|
+
when :cpp_comment
|
233
|
+
when :c_comment
|
234
|
+
when :c_comment_star
|
235
|
+
|
236
|
+
else
|
237
|
+
|
238
|
+
r << c unless skip
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
r
|
243
|
+
end
|
244
|
+
end # module C
|
245
|
+
|
246
|
+
end # module LanguageFamilies
|
247
|
+
end # module CommentStrip
|
248
|
+
|
249
|
+
# ############################## end of file ############################# #
|
250
|
+
|
data/lib/comment_strip/strip.rb
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
# Purpose: Definition of strip() function
|
5
5
|
#
|
6
6
|
# Created: 14th September 2020
|
7
|
-
# Updated:
|
7
|
+
# Updated: 11th July 2022
|
8
8
|
#
|
9
9
|
# Home: http://github.com/synesissoftware/comment_strip.r
|
10
10
|
#
|
11
|
-
# Copyright (c) 2020, Matthew Wilson and Synesis Information Systems
|
11
|
+
# Copyright (c) 2020-2022, Matthew Wilson and Synesis Information Systems
|
12
12
|
# All rights reserved.
|
13
13
|
#
|
14
14
|
# Redistribution and use in source and binary forms, with or without
|
@@ -37,216 +37,49 @@
|
|
37
37
|
# ######################################################################## #
|
38
38
|
|
39
39
|
|
40
|
+
require File.join(__dir__, 'language_families', 'c')
|
41
|
+
|
42
|
+
require 'xqsr3/quality/parameter_checking'
|
40
43
|
|
41
44
|
=begin
|
42
45
|
=end
|
43
46
|
|
44
47
|
module CommentStrip
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
when ?\r, ?\n
|
74
|
-
|
75
|
-
line += 1
|
76
|
-
column = 0
|
49
|
+
include ::Xqsr3::Quality::ParameterChecking
|
50
|
+
|
51
|
+
# Strips comments from an input string, according to the rules and
|
52
|
+
# conventions of a given language-family
|
53
|
+
#
|
54
|
+
# === Signature
|
55
|
+
#
|
56
|
+
# * *Parameters:*
|
57
|
+
# - +input+ (::String, +nil+) the input source code
|
58
|
+
# - +lf+ (::String) the name of the language family. Currently only
|
59
|
+
# the value +'C'+ is accepted
|
60
|
+
# - +options+ (::Hash) options that moderate the behaviour
|
61
|
+
#
|
62
|
+
# * *Options:*
|
63
|
+
# None currently defined.
|
64
|
+
#
|
65
|
+
# === Signature
|
66
|
+
# (String) The stripped for of the input.
|
67
|
+
def strip input, lf, **options
|
68
|
+
|
69
|
+
check_parameter input, 'input', responds_to: [ :each_char, :empty?, :nil?, ], nil: true
|
70
|
+
check_parameter lf, 'lf', types: [ ::String, ::Symbol ]
|
71
|
+
|
72
|
+
case lf.to_s.upcase
|
73
|
+
when 'C'
|
74
|
+
|
75
|
+
LanguageFamilies::C.strip input, lf, **options
|
77
76
|
else
|
78
77
|
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
skip = false
|
83
|
-
|
84
|
-
case c
|
85
|
-
when ?\r, ?\n
|
86
|
-
|
87
|
-
case state
|
88
|
-
when :c_comment, :c_comment_star
|
89
|
-
|
90
|
-
cc_lines += 1
|
91
|
-
|
92
|
-
state = :c_comment
|
93
|
-
when :cpp_comment
|
94
|
-
|
95
|
-
state = :text
|
96
|
-
when :sq_string, :sq_string_escape, :sq_string_closing
|
97
|
-
|
98
|
-
state = :text
|
99
|
-
when :dq_string_escape
|
100
|
-
|
101
|
-
state = :dq_string
|
102
|
-
when :slash_start
|
103
|
-
|
104
|
-
r << '/'
|
105
|
-
|
106
|
-
state = :text
|
107
|
-
end
|
108
|
-
else
|
109
|
-
|
110
|
-
# special cases:
|
111
|
-
#
|
112
|
-
# - for escaped single/double quote
|
113
|
-
# - for slash-start
|
114
|
-
# - for comment-star
|
115
|
-
|
116
|
-
case state
|
117
|
-
when :sq_string_open
|
118
|
-
|
119
|
-
state = (?\\ == c) ? :sq_string_escape : :sq_string_closing
|
120
|
-
when :sq_string_escape
|
121
|
-
|
122
|
-
state = :sq_string_closing
|
123
|
-
when :dq_string_escape
|
124
|
-
|
125
|
-
state = :dq_string
|
126
|
-
when :c_comment_star
|
127
|
-
|
128
|
-
case c
|
129
|
-
when ?/
|
130
|
-
|
131
|
-
r << ?\n * cc_lines
|
132
|
-
cc_lines = 0
|
133
|
-
|
134
|
-
state = :text
|
135
|
-
skip = true
|
136
|
-
when '*'
|
137
|
-
|
138
|
-
;
|
139
|
-
else
|
140
|
-
|
141
|
-
state = :c_comment
|
142
|
-
end
|
143
|
-
else
|
144
|
-
|
145
|
-
if false
|
146
|
-
elsif state == :slash_start && ('/' != c && '*' != c)
|
147
|
-
|
148
|
-
state = :text
|
149
|
-
r << '/'
|
150
|
-
else
|
151
|
-
|
152
|
-
case c
|
153
|
-
when '/'
|
154
|
-
|
155
|
-
case state
|
156
|
-
when :text
|
157
|
-
|
158
|
-
state = :slash_start
|
159
|
-
when :slash_start
|
160
|
-
|
161
|
-
state = :cpp_comment
|
162
|
-
when :c_comment_star
|
163
|
-
|
164
|
-
r << ?\n * cc_lines
|
165
|
-
cc_lines = 0
|
166
|
-
|
167
|
-
state = :text
|
168
|
-
skip = true
|
169
|
-
end
|
170
|
-
when '*'
|
171
|
-
|
172
|
-
case state
|
173
|
-
when :slash_start
|
174
|
-
|
175
|
-
state = :c_comment
|
176
|
-
when :c_comment
|
177
|
-
|
178
|
-
state = :c_comment_star
|
179
|
-
else
|
180
|
-
|
181
|
-
end
|
182
|
-
|
183
|
-
when ?\'
|
184
|
-
|
185
|
-
case state
|
186
|
-
when :text
|
187
|
-
|
188
|
-
state = :sq_string_open
|
189
|
-
when :sq_string_closing
|
190
|
-
|
191
|
-
state = :text
|
192
|
-
else
|
193
|
-
|
194
|
-
end
|
195
|
-
when '"'
|
196
|
-
|
197
|
-
case state
|
198
|
-
when :text
|
199
|
-
|
200
|
-
state = :dq_string
|
201
|
-
when :dq_string
|
202
|
-
|
203
|
-
state = :text
|
204
|
-
else
|
205
|
-
end
|
206
|
-
when ?\\
|
207
|
-
|
208
|
-
case state
|
209
|
-
when :sq_string_open
|
210
|
-
|
211
|
-
state = :sq_string_escape
|
212
|
-
when :sq_string_escape
|
213
|
-
|
214
|
-
state = :sq_string
|
215
|
-
when :dq_string
|
216
|
-
|
217
|
-
state = :dq_string_escape
|
218
|
-
else
|
219
|
-
|
220
|
-
end
|
221
|
-
else
|
222
|
-
|
223
|
-
case state
|
224
|
-
when :sq_string_escape
|
225
|
-
|
226
|
-
state = :sq_string_closing
|
227
|
-
else
|
228
|
-
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
case state
|
236
|
-
when :slash_start
|
237
|
-
when :cpp_comment
|
238
|
-
when :c_comment
|
239
|
-
when :c_comment_star
|
240
|
-
|
241
|
-
else
|
242
|
-
|
243
|
-
r << c unless skip
|
78
|
+
raise "language family '#{lf}' unrecognised or not supported1"
|
244
79
|
end
|
245
80
|
end
|
246
81
|
|
247
|
-
|
248
|
-
end
|
249
|
-
|
82
|
+
extend self
|
250
83
|
end # module CommentStrip
|
251
84
|
|
252
85
|
# ############################## end of file ############################# #
|
@@ -4,11 +4,11 @@
|
|
4
4
|
# Purpose: Version for comment_strip.r library
|
5
5
|
#
|
6
6
|
# Created: 14th September 2020
|
7
|
-
# Updated:
|
7
|
+
# Updated: 11th July 2022
|
8
8
|
#
|
9
9
|
# Home: http://github.com/synesissoftware/comment_strip.r
|
10
10
|
#
|
11
|
-
# Copyright (c) 2020, Matthew Wilson and Synesis Information Systems
|
11
|
+
# Copyright (c) 2020-2022, Matthew Wilson and Synesis Information Systems
|
12
12
|
# All rights reserved.
|
13
13
|
#
|
14
14
|
# Redistribution and use in source and binary forms, with or without
|
@@ -43,7 +43,7 @@
|
|
43
43
|
module CommentStrip
|
44
44
|
|
45
45
|
# Current version of the comment_strip.r library
|
46
|
-
VERSION = '0.
|
46
|
+
VERSION = '0.1.2'
|
47
47
|
|
48
48
|
private
|
49
49
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
data/lib/comment_strip.rb
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
# Purpose: Top-level include for comment_strip.r library
|
5
5
|
#
|
6
6
|
# Created: 14th September 2020
|
7
|
-
# Updated:
|
7
|
+
# Updated: 11th July 2022
|
8
8
|
#
|
9
9
|
# Home: http://github.com/synesissoftware/comment_strip.r
|
10
10
|
#
|
11
|
-
# Copyright (c) 2020, Matthew Wilson and Synesis Information Systems
|
11
|
+
# Copyright (c) 2020-2022, Matthew Wilson and Synesis Information Systems
|
12
12
|
# All rights reserved.
|
13
13
|
#
|
14
14
|
# Redistribution and use in source and binary forms, with or without
|
@@ -37,10 +37,17 @@
|
|
37
37
|
# ######################################################################## #
|
38
38
|
|
39
39
|
|
40
|
+
%w{
|
41
|
+
strip
|
42
|
+
version
|
43
|
+
}.each { |mod_name| require File.join(__dir__, 'comment_strip', mod_name) }
|
44
|
+
|
40
45
|
=begin
|
41
46
|
=end
|
42
47
|
|
43
|
-
|
48
|
+
# Main module for comment_strip.r library
|
49
|
+
module CommentStrip
|
50
|
+
end # module CommentStrip
|
44
51
|
|
45
52
|
# ############################## end of file ############################# #
|
46
53
|
|
data/test/scratch/ex1.rb
ADDED
data/test/unit/tc_strip.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
-
$:.unshift File.join(
|
3
|
+
$:.unshift File.join(__dir__, '../..', 'lib')
|
4
4
|
|
5
5
|
|
6
6
|
require 'comment_strip'
|
@@ -16,6 +16,8 @@ class Test_strip_1 < Test::Unit::TestCase
|
|
16
16
|
def test_nil
|
17
17
|
|
18
18
|
assert_nil strip(nil, 'C')
|
19
|
+
|
20
|
+
assert_nil ::CommentStrip.strip(nil, 'C')
|
19
21
|
end
|
20
22
|
|
21
23
|
def test_unrecognised_families
|
@@ -36,12 +38,14 @@ class Test_strip_1 < Test::Unit::TestCase
|
|
36
38
|
unrecognised_families.each do |family|
|
37
39
|
|
38
40
|
assert_raise_with_message(::RuntimeError, /family.*unrecognised/) { strip('', family) }
|
41
|
+
assert_raise_with_message(::RuntimeError, /family.*unrecognised/) { ::CommentStrip.strip('', family) }
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
42
45
|
def test_empty
|
43
46
|
|
44
47
|
assert_equal "", strip('', 'C')
|
48
|
+
assert_equal "", ::CommentStrip.strip('', :C)
|
45
49
|
end
|
46
50
|
|
47
51
|
def test_simple_main
|
@@ -56,6 +60,7 @@ EOF_main
|
|
56
60
|
expected = input
|
57
61
|
|
58
62
|
assert_equal expected, strip(input, 'C')
|
63
|
+
assert_equal expected, ::CommentStrip.strip(input, 'C')
|
59
64
|
end
|
60
65
|
|
61
66
|
def test_x_1
|
@@ -88,6 +93,7 @@ EOF_main
|
|
88
93
|
EOF_main
|
89
94
|
|
90
95
|
actual = strip(input, 'C')
|
96
|
+
actual = ::CommentStrip.strip(input, 'C')
|
91
97
|
|
92
98
|
assert_equal expected, actual
|
93
99
|
end
|
@@ -104,6 +110,7 @@ EOF_main
|
|
104
110
|
EOF_main
|
105
111
|
|
106
112
|
actual = strip(input, 'C')
|
113
|
+
actual = ::CommentStrip.strip(input, 'C')
|
107
114
|
|
108
115
|
assert_equal expected, actual
|
109
116
|
end
|
@@ -120,6 +127,7 @@ EOF_main
|
|
120
127
|
EOF_main
|
121
128
|
|
122
129
|
actual = strip(input, 'C')
|
130
|
+
actual = ::CommentStrip.strip(input, 'C')
|
123
131
|
|
124
132
|
assert_equal expected, actual
|
125
133
|
end
|
data/test/unit/tc_version.rb
CHANGED
data/test/unit/ts_all.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comment_strip-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: xqsr3
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
19
|
+
version: '0.37'
|
20
|
+
- - ">="
|
25
21
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: libclimate-ruby
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.15'
|
22
|
+
version: 0.37.2
|
34
23
|
type: :runtime
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
38
27
|
- - "~>"
|
39
28
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
41
|
-
-
|
42
|
-
name: recls-ruby
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: xqsr3
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.36'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
29
|
+
version: '0.37'
|
30
|
+
- - ">="
|
67
31
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
32
|
+
version: 0.37.2
|
69
33
|
description: "Source code comment stripping library\n\n"
|
70
34
|
email: matthew@synesis.com.au
|
71
35
|
executables: []
|
@@ -75,9 +39,10 @@ files:
|
|
75
39
|
- LICENSE
|
76
40
|
- README.md
|
77
41
|
- lib/comment_strip.rb
|
78
|
-
- lib/comment_strip/
|
42
|
+
- lib/comment_strip/language_families/c.rb
|
79
43
|
- lib/comment_strip/strip.rb
|
80
44
|
- lib/comment_strip/version.rb
|
45
|
+
- test/scratch/ex1.rb
|
81
46
|
- test/unit/tc_strip.rb
|
82
47
|
- test/unit/tc_version.rb
|
83
48
|
- test/unit/ts_all.rb
|
@@ -85,7 +50,7 @@ homepage: https://github.com/synesissoftware/comment_strip.r
|
|
85
50
|
licenses:
|
86
51
|
- BSD-3-Clause
|
87
52
|
metadata: {}
|
88
|
-
post_install_message:
|
53
|
+
post_install_message:
|
89
54
|
rdoc_options: []
|
90
55
|
require_paths:
|
91
56
|
- lib
|
@@ -93,16 +58,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
58
|
requirements:
|
94
59
|
- - "~>"
|
95
60
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2
|
61
|
+
version: '2'
|
97
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
63
|
requirements:
|
99
64
|
- - ">="
|
100
65
|
- !ruby/object:Gem::Version
|
101
66
|
version: '0'
|
102
67
|
requirements: []
|
103
|
-
|
104
|
-
|
105
|
-
signing_key:
|
68
|
+
rubygems_version: 3.1.4
|
69
|
+
signing_key:
|
106
70
|
specification_version: 4
|
107
71
|
summary: comment_strip.r
|
108
72
|
test_files: []
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# ######################################################################## #
|
2
|
-
# File: comment_strip/comment_strip.rb
|
3
|
-
#
|
4
|
-
# Purpose: Main file for comment_strip.r library
|
5
|
-
#
|
6
|
-
# Created: 14th September 2020
|
7
|
-
# Updated: 14th September 2020
|
8
|
-
#
|
9
|
-
# Home: http://github.com/synesissoftware/comment_strip.r
|
10
|
-
#
|
11
|
-
# Copyright (c) 2020, Matthew Wilson and Synesis Information Systems
|
12
|
-
# All rights reserved.
|
13
|
-
#
|
14
|
-
# Redistribution and use in source and binary forms, with or without
|
15
|
-
# modification, are permitted provided that the following conditions are
|
16
|
-
# met:
|
17
|
-
#
|
18
|
-
# * Redistributions of source code must retain the above copyright notice,
|
19
|
-
# this list of conditions and the following disclaimer.
|
20
|
-
#
|
21
|
-
# * Redistributions in binary form must reproduce the above copyright
|
22
|
-
# notice, this list of conditions and the following disclaimer in the
|
23
|
-
# documentation and/or other materials provided with the distribution.
|
24
|
-
#
|
25
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
26
|
-
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
27
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
28
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
29
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30
|
-
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
31
|
-
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
32
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
33
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
34
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
35
|
-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36
|
-
#
|
37
|
-
# ######################################################################## #
|
38
|
-
|
39
|
-
|
40
|
-
require File.join(File.dirname(__FILE__), 'strip')
|
41
|
-
require File.join(File.dirname(__FILE__), 'version')
|
42
|
-
|
43
|
-
=begin
|
44
|
-
=end
|
45
|
-
|
46
|
-
# Main module for comment_strip.r library
|
47
|
-
module CommentStrip
|
48
|
-
end # module CommentStrip
|
49
|
-
|
50
|
-
# ############################## end of file ############################# #
|
51
|
-
|
52
|
-
|