stream_parser 0.1 → 0.2

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: 0e47f922c40712cf85591d6fe3f5e39b8fd974964a9c8604bc1d91dcaebedd36
4
- data.tar.gz: fed08e64284d9b798822d620d06d7618932ff3ac3546e5033186aba807befc54
3
+ metadata.gz: 1b99a423c7791ac03b0e45b390d22c10b455b45e51066edb1912eb4c9aec7a65
4
+ data.tar.gz: edb3c225aeaff8d4400e0929a8bde7120326ab95c39fe42c11c8d4bf6f8ba2ee
5
5
  SHA512:
6
- metadata.gz: d25b559fb053168d5637ad0f774eb291b98ee34cd7baf30858699b1584e533f8322fdcd677685f4647bc101df997251cea1cb843b9d3d5d511fbd234b75e1ce7
7
- data.tar.gz: e2fa502f87ed3285044086780c0e615641edccdb1e3680418a004e247f19dbd389a2f6465068bfb1081b44a2599e159ede05101f5f1e691d1f6f89802d967b4c
6
+ metadata.gz: 24ae770c7090a31b80abc9b7c216de440e61ca38d87476e17ef855ba37aa90a30bd1cb7f990831b0ebd68fead35a385d98c7307b608e9f34759d54dfcfd43fe3
7
+ data.tar.gz: 2ce893bdd9e79aa3b094ba15bc612ac598f1e11b0325bf5fa3e44a521ff678ada20705e805cef40314eeb4a274d7e877603b5dfc4ee6ffbebc96b23980e370aa
data/lib/stream_parser.rb CHANGED
@@ -24,7 +24,7 @@ module StreamParser
24
24
  # end
25
25
 
26
26
  def eos?
27
- @index >= (@source.size - 1)
27
+ @index >= (@source.size - 0)
28
28
  end
29
29
 
30
30
  def scan_until(r)
@@ -39,13 +39,13 @@ module StreamParser
39
39
  else
40
40
  @match = nil
41
41
  @old_index = @index
42
- @index = @source.size - 1
42
+ @index = @source.size
43
43
  end
44
44
  match
45
45
  end
46
46
 
47
47
  def pre_match
48
- @source[@old_index...(@index-@match.size)]
48
+ @source[@old_index...(@index-(@match&.size || 0))]
49
49
  end
50
50
 
51
51
  def rewind(by=1)
@@ -63,7 +63,7 @@ module StreamParser
63
63
  end
64
64
 
65
65
  def next_char
66
- @source[@index+1]
66
+ @source[@index]
67
67
  end
68
68
 
69
69
  def prev_char
@@ -103,4 +103,18 @@ module StreamParser
103
103
  output
104
104
  end
105
105
 
106
+ def quoted_value(quote_char = '"', escape_chars = ["\\"])
107
+ ret_value = ""
108
+ while scan_until(/(#{quote_char}|\Z)/)
109
+ if match != quote_char
110
+ raise Net::HTTPHeaderSyntaxError.new("Invalid Set-Cookie header format: unbalanced quotes (#{quote_char})")
111
+ elsif !escape_chars.include?(pre_match[-1])
112
+ ret_value << pre_match
113
+ return ret_value
114
+ else
115
+ ret_value << pre_match[0...-1] << match
116
+ end
117
+ end
118
+ end
119
+
106
120
  end
@@ -1,3 +1,3 @@
1
1
  module StreamParser
2
- VERSION = '0.1'
2
+ VERSION = '0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-06 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description:
98
112
  email:
99
113
  - jonbracy@gmail.com