segregate 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00c26832bb6ab7be4cb90fcdc05c33619b9e1a46
4
- data.tar.gz: c26a45764b6b70156f3dc1abf8ab05bd2661807a
3
+ metadata.gz: 96b4059a490bf0c58abeae11ab8c0540799a7ec6
4
+ data.tar.gz: c1f1e6da2dc72b17051991272f1ddc34b9ef6737
5
5
  SHA512:
6
- metadata.gz: dbd93e8b75a52fa3a59cc50e2745cc30f1ff2d7a494a37c87e8b306ead379f98341645f2cc64c9f46c5b3de35cfa42a24f4e528ace9b9043f0a294440256fd3e
7
- data.tar.gz: 69d129517e6220d11686e0a1447f6c678a1056d0a60c5923964c465b48050ea64382b2aad00d0af00f5ba03060e9e754dd733164510189cc5351bb624a98deed
6
+ metadata.gz: 8e10f62346236a7a67782334697c5ee1c9d796c2b4187d29970e277a2aac414bd7c7fe679efefc97bfd00740db0c420e9295dab648bd9188e850f159e742faf4
7
+ data.tar.gz: 3edd3f5888ce6a106ef259d4eb662ac4a5823cd0a126c21c1ce3c96d878e29da30a145d1135d555258b72c9e85abe7235c9c0f2b1b1ee0c9f5842331406b6c2d
data/README.md CHANGED
@@ -33,7 +33,7 @@ Require Segregate at the start of your code
33
33
  require 'segregate'
34
34
  ```
35
35
 
36
- ### Basic useage
36
+ ### Basic usage
37
37
  #### Parsing data:
38
38
 
39
39
  ```ruby
@@ -81,7 +81,7 @@ parser.headers['accept'] = "application/json"
81
81
  parser.body.sub! "data", "information"
82
82
  ```
83
83
 
84
- ### Callback useage
84
+ ### Callback usage
85
85
 
86
86
  ```Ruby
87
87
  class Callback_object
@@ -132,4 +132,4 @@ end
132
132
 
133
133
  ```Ruby
134
134
  socket.write parser.raw_data
135
- ```
135
+ ```
@@ -1,4 +1,4 @@
1
1
  class Segregate
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  DATE = "2014-02-03".freeze
4
4
  end
data/lib/segregate.rb CHANGED
@@ -85,8 +85,6 @@ class Segregate
85
85
  @header_orders.push 'content-length' unless @header_orders.include? 'content-length'
86
86
  @headers.delete 'content-encoding'
87
87
  @header_orders.delete 'content-encoding'
88
- else
89
- raise "ERROR: parsing message body not complete"
90
88
  end
91
89
  end
92
90
 
@@ -104,8 +102,6 @@ class Segregate
104
102
  end
105
103
 
106
104
  def parse data
107
- raise "ERROR: parsing completed" if @body_complete
108
-
109
105
  data = StringIO.new data
110
106
 
111
107
  read_first_line data unless @first_line_complete
@@ -131,10 +127,6 @@ class Segregate
131
127
  parse_request_line line
132
128
  elsif line =~ STATUS_LINE
133
129
  parse_status_line line
134
- elsif line =~ UNKNOWN_REQUEST_LINE
135
- raise "ERROR: Unknown http method: %s" % line[/^\S+/]
136
- else
137
- raise "ERROR: Unknown first line: %s" % line
138
130
  end
139
131
 
140
132
  @first_line_complete = true
@@ -38,14 +38,6 @@ describe Segregate do
38
38
  it 'accepts one argument' do
39
39
  expect(@parser).to respond_to(:parse).with(1).argument
40
40
  end
41
-
42
- it 'errors if an incorrect first line is received' do
43
- expect{ @parser.parse "fail\r\n" }.to raise_error RuntimeError, 'ERROR: Unknown first line: fail'
44
- end
45
-
46
- it 'errors if an incorrect http method is received' do
47
- expect{ @parser.parse "FAIL /endpoint HTTP/1.1\r\n" }.to raise_error RuntimeError, 'ERROR: Unknown http method: FAIL'
48
- end
49
41
  end
50
42
 
51
43
  context 'a request line has been parsed' do
@@ -79,6 +71,18 @@ describe Segregate do
79
71
  expect(@parser.request_line).to match Segregate::REQUEST_LINE
80
72
  expect(@parser.request_line).to eq "GET /endpoint HTTP/2.3"
81
73
  end
74
+
75
+ it 'returns a modified major http version request line' do
76
+ @parser.major_http_version = 2
77
+ expect(@parser.request_line).to match Segregate::REQUEST_LINE
78
+ expect(@parser.request_line).to eq "GET /endpoint HTTP/2.1"
79
+ end
80
+
81
+ it 'returns a modified minor http version request line' do
82
+ @parser.minor_http_version = 2
83
+ expect(@parser.request_line).to match Segregate::REQUEST_LINE
84
+ expect(@parser.request_line).to eq "GET /endpoint HTTP/1.2"
85
+ end
82
86
  end
83
87
 
84
88
  describe '#status_line' do
@@ -171,10 +175,6 @@ describe Segregate do
171
175
  it 'returns the uri methods' do
172
176
  expect(@parser.path).to eq '/endpoint'
173
177
  end
174
-
175
- it 'raises an error if uri does not respond to the method' do
176
- expect{ @parser.not_present }.to raise_error NoMethodError, /undefined method `not_present'/
177
- end
178
178
  end
179
179
 
180
180
  describe '#respond_to?' do
@@ -429,18 +429,6 @@ describe Segregate do
429
429
  end
430
430
  end
431
431
 
432
- describe '#update_content_length' do
433
- it 'raises an error if the body is not complete' do
434
- expect{ @parser.update_content_length }.to raise_error RuntimeError, 'ERROR: parsing message body not complete'
435
- end
436
- end
437
-
438
- describe '#raw_data' do
439
- it 'raises an error if the body is not complete' do
440
- expect{ @parser.raw_data }.to raise_error RuntimeError, 'ERROR: parsing message body not complete'
441
- end
442
- end
443
-
444
432
  context 'the body parsing is completed' do
445
433
  before(:each) do
446
434
  @parser.parse "27\r\nThis is the second content!\r\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: segregate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Slaughter