structuredtext 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +1 -0
  2. data/lib/structuredtext.rb +15 -16
  3. metadata +1 -1
data/README CHANGED
@@ -78,6 +78,7 @@ is parsed into these arrays:
78
78
  = History
79
79
 
80
80
  1.0.0:: Comment handling and field-delimited text
81
+ 1.0.1:: Source code refinement; no functionality change
81
82
 
82
83
  = Copyright
83
84
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  # Utilities for working with various kinds of structured text.
22
22
  module StructuredText
23
- VERSION = "1.0.0"
23
+ VERSION = "1.0.1"
24
24
 
25
25
 
26
26
  # Removes comments from text.
@@ -117,22 +117,22 @@ module StructuredText
117
117
  # identical to the left-hand field quote
118
118
  def initialize(source, delimiter = ",", lquote = '"', rquote = nil)
119
119
  @source = source
120
- # Escape the custom characters the caller provides a regular expression
121
- # control character.
120
+ # Escape the custom characters in case the caller provides a regular
121
+ # expression control character.
122
122
  delimiter = Regexp.escape(delimiter)
123
123
  lquote = Regexp.escape(lquote)
124
124
  rquote = rquote.nil? ? lquote : Regexp.escape(rquote)
125
125
  s = <<-EOTEXT
126
- (?: # Match delimiter
127
- (#{delimiter}) # field delimiter
128
- | # ...or...
129
- ($) # end of line
126
+ ( # Match delimiter
127
+ (?: #{delimiter}) # field delimiter
128
+ | # ...or...
129
+ (?: $) # end of line
130
130
  )
131
- | # ...or...
132
- ( # Match text
133
- (?: #{lquote}.*?#{rquote}) # quoted string
134
- | # ...or...
135
- (?: [^#{delimiter}]*) # text without delimiters
131
+ | # ...or...
132
+ ( # Match text
133
+ (?: #{lquote}.*?#{rquote}) # quoted string
134
+ | # ...or...
135
+ (?: [^#{delimiter}]*) # text without delimiters
136
136
  )
137
137
  EOTEXT
138
138
  @field_regex = Regexp.compile(s, Regexp::EXTENDED)
@@ -150,10 +150,9 @@ EOTEXT
150
150
  # double-quoted strings.
151
151
  field = ""
152
152
  line.scan(@field_regex) do |match|
153
- comma_delimiter = (not match[0].nil?)
154
- eol_delimiter = (not match[1].nil?)
155
- text = match[2]
156
- if not (comma_delimiter or eol_delimiter)
153
+ delimiter = match[0]
154
+ text = match[1]
155
+ if delimiter.nil?
157
156
  # Append text in the middle of a field.
158
157
  field += text if not text.nil?
159
158
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structuredtext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - W.P. McNeill