nut 0.1.8 → 0.1.9

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: 0729629973ea40de0756c9d11e78eac76dca956b
4
- data.tar.gz: 083c29fa714de61ea64b195f27cd73dd9db41cd7
3
+ metadata.gz: b3940e270e2cc95bb67ddce97c6b9dd3c3d32e6b
4
+ data.tar.gz: f740dc860ba682bf81b774f5bea8d9314c3c29d0
5
5
  SHA512:
6
- metadata.gz: de45a553736a1adee1f1f094dfe766caf2876b5d3ff74ecd7f7bf085074e5f466536043de3bd3d56c737c63d45ebade775f3e219cf1f07a38ac7b7ac8288c42d
7
- data.tar.gz: d52caa94685ce6a82e988e56872e06ec8da243f1845eb24ddd6f4c7f929aa3e2802b2777c8b5bc99d4848c180365691d8499bb316d28160bebab32a6abd55221
6
+ metadata.gz: 6f443ec23b4c8501ae4e59fa8bb68470ea2888ea7b829dc656d08e9b19badd32831aa468c21740e2bec5dae1c75b22183a1caedca7e36ddbfadac65963ec6744
7
+ data.tar.gz: b3dd3b2d103cbb92f58fa28d1551e0a7d181e9e337540d91ab8e131cface3461f8d6f9e47ae7795d40c5a590e4e3590bcd4e35a3808cb247aa9ce309ed333035
data/lib/nut/handler.rb CHANGED
@@ -27,22 +27,22 @@ module Nut
27
27
  # Only handle HTTP/1.1 Requests
28
28
  SUPPORTED_VERSION = 'http/1.1'
29
29
 
30
- # On Join
31
- # : RxIO Service Interface Callback - Triggered each time a Client connects.
30
+ # On Join:
31
+ # RxIO Service Interface Callback - Triggered each time a Client connects.
32
32
  # @param [Hash] client An RxIO Client Hash
33
33
  def self.on_join client
34
34
  # NoOp
35
35
  end
36
36
 
37
- # On Drop
38
- # : RxIO Service Interface Callback - Triggered each time a Client disconnects.
37
+ # On Drop:
38
+ # RxIO Service Interface Callback - Triggered each time a Client disconnects.
39
39
  # @param [Hash] client An RxIO Client Hash
40
40
  def self.on_drop client
41
41
  # NoOp
42
42
  end
43
43
 
44
- # Handle Message
45
- # : RxIO Service Interface Callback - Triggered each time a message is received from a Client.
44
+ # Handle Message:
45
+ # RxIO Service Interface Callback - Triggered each time a message is received from a Client.
46
46
  # @param [Hash] client An RxIO Client Hash
47
47
  # @param [String] msg The message received from the Client
48
48
  def self.handle_msg client, msg
@@ -51,8 +51,8 @@ module Nut
51
51
  handle_req_dline client, msg + @msg_delim
52
52
  end
53
53
 
54
- # Sub-Process Input
55
- # : RxIO Service Interface Callback - Triggered each time a chunk of data is received from a Client.
54
+ # Sub-Process Input:
55
+ # RxIO Service Interface Callback - Triggered each time a chunk of data is received from a Client.
56
56
  # Some Content-Length-based Requests may not end with a CRLF - this pulls in any left-over data directly from the RxIO Input Buffer.
57
57
  # @param [Hash] client Client Hash
58
58
  def self.subprocess_input client
@@ -64,8 +64,8 @@ module Nut
64
64
  handle_req_dline client, creq[:client][:ibuf].slice!(0, creq[:client][:ibuf].bytesize) if Request.is_content_len? creq
65
65
  end
66
66
 
67
- # Handle Request Data Line
68
- # : Ensures availability of a Client Request Context before passing Assembling & Processing.
67
+ # Handle Request Data Line:
68
+ # Ensures availability of a Client Request Context before passing Assembling & Processing.
69
69
  # @param [Hash] client An RxIO Client Hash
70
70
  # @param [String] msg The message received from the Client (including newline)
71
71
  def self.handle_req_dline client, msg
@@ -77,8 +77,8 @@ module Nut
77
77
  assemble_process_req creq, msg unless creq[:body_complete]
78
78
  end
79
79
 
80
- # Ensure Client Request Hash
81
- # : Ensures existence of Client Request Hash inside Client Context.
80
+ # Ensure Client Request Hash:
81
+ # Ensures existence of Client Request Hash inside Client Context.
82
82
  # @param [Hash] client An RxIO Client Hash
83
83
  def self.ensure_creq client
84
84
 
@@ -106,8 +106,8 @@ module Nut
106
106
  }
107
107
  end
108
108
 
109
- # Assemble & Process Request
110
- # : Assembles and processes HTTP Requests from individual data lines.
109
+ # Assemble & Process Request:
110
+ # Assembles and processes HTTP Requests from individual data lines.
111
111
  # @param [Hash] creq Client Request Context
112
112
  # @param [String] msg The message received from the Client (including newline)
113
113
  def self.assemble_process_req creq, msg
@@ -131,8 +131,8 @@ module Nut
131
131
  process_req creq[:client]
132
132
  end
133
133
 
134
- # Process Request for Client
135
- # : Constructs a complete Request Hash from a Client Request Context and passes it to the Request Handler Module's _handle_req_ method.
134
+ # Process Request for Client:
135
+ # Constructs a complete Request Hash from a Client Request Context and passes it to the Request Handler Module's _handle_req_ method.
136
136
  # @param [Hash] client An RxIO Client Hash
137
137
  def self.process_req client
138
138
 
@@ -165,8 +165,8 @@ module Nut
165
165
  serve_response client, response
166
166
  end
167
167
 
168
- # Serve Response
169
- # : Sends out an HTTP Response to the Client.
168
+ # Serve Response:
169
+ # Sends out an HTTP Response to the Client.
170
170
  # @param [Hash] response Response Hash
171
171
  def self.serve_response client, response
172
172
 
data/lib/nut/request.rb CHANGED
@@ -16,8 +16,8 @@ module Nut
16
16
  # Multipart Field Regex
17
17
  MULTIPART_FIELD_REX = /^([^=]+)=(.+)$/
18
18
 
19
- # Pull Request Details
20
- # : Extracts any possible Form Data and extended Request details from a Request Hash.
19
+ # Pull Request Details:
20
+ # Extracts any possible Form Data and extended Request details from a Request Hash.
21
21
  # @param [Hash] req Request Hash
22
22
  def self.extract_req_data req
23
23
 
@@ -34,8 +34,8 @@ module Nut
34
34
  end
35
35
  end
36
36
 
37
- # Extract Multipart Form Data
38
- # : Extracts Multipart Form Data from the Request Body and merges it into _req[:params]_.
37
+ # Extract Multipart Form Data:
38
+ # Extracts Multipart Form Data from the Request Body and merges it into _req[:params]_.
39
39
  # @param [Hash] req Request Hash
40
40
  def self.extract_multipart_form_data req
41
41
 
@@ -75,8 +75,8 @@ module Nut
75
75
  end
76
76
  end
77
77
 
78
- # Extract URL-Encoded Form Data
79
- # : Extracts URL-Encoded Form Data from the Request Body and merges it into _req[:params]_.
78
+ # Extract URL-Encoded Form Data:
79
+ # Extracts URL-Encoded Form Data from the Request Body and merges it into _req[:params]_.
80
80
  # @param [Hash] req Request Hash
81
81
  def self.extract_urlencoded_form_data req
82
82
 
@@ -87,8 +87,8 @@ module Nut
87
87
  .each { |name, val| req[:params][name] = val }
88
88
  end
89
89
 
90
- # Build Request Line
91
- # : Parses *msg* as the Request Line unless already set, extracting HTTP Verb, URI & Version.
90
+ # Build Request Line:
91
+ # Parses *msg* as the Request Line unless already set, extracting HTTP Verb, URI & Version.
92
92
  # @param [Hash] creq Client Request Context
93
93
  # @param [String] msg A line of text to be processed
94
94
  def self.build_req_line creq, msg
@@ -107,8 +107,8 @@ module Nut
107
107
  creq[:uri].chomp! ' '
108
108
  end
109
109
 
110
- # Build Header
111
- # : Extracts HTTP Headers from Request if available and not already set, returning true on success, false otherwise.
110
+ # Build Header:
111
+ # Extracts HTTP Headers from Request if available and not already set, returning true on success, false otherwise.
112
112
  # @param [Hash] creq Client Request Context
113
113
  # @param [String] msg A line of text to be processed
114
114
  def self.build_header creq, msg
@@ -124,8 +124,8 @@ module Nut
124
124
  end
125
125
  end
126
126
 
127
- # Build Generic Headers
128
- # : Constructs a structured Header Hash from an Array of text lines.
127
+ # Build Generic Headers:
128
+ # Constructs a structured Header Hash from an Array of text lines.
129
129
  # @param [Array] lines A bunch of lines containing header data
130
130
  # @return [Hash] A Hash representation of the Headers
131
131
  def self.build_gen_head lines
@@ -144,8 +144,8 @@ module Nut
144
144
  Hash[*(headz.inject([]) { |a, h| a + [h.first.downcase.gsub('-', '_').to_sym, h.last.join(',')] })]
145
145
  end
146
146
 
147
- # Build Request Body
148
- # : Builds Request Body according to Request Headers (Content-Length / Transfer-Encoding).
147
+ # Build Request Body:
148
+ # Builds Request Body according to Request Headers (Content-Length / Transfer-Encoding).
149
149
  # @param [Hash] creq Client Request Context
150
150
  # @param [String] msg A line of text to be processed
151
151
  def self.build_req_body creq, msg
@@ -163,8 +163,8 @@ module Nut
163
163
  build_no_body creq
164
164
  end
165
165
 
166
- # Build Body - Chunked
167
- # : Assembles Chunks from *msg* (if Headers are complete) and assembles Request Body from them.
166
+ # Build Body - Chunked:
167
+ # Assembles Chunks from *msg* (if Headers are complete) and assembles Request Body from them.
168
168
  # @param [Hash] creq Client Request Context
169
169
  # @param [String] msg A line of text to be processed
170
170
  def self.build_body_chunked creq, msg
@@ -198,8 +198,8 @@ module Nut
198
198
  end
199
199
  end
200
200
 
201
- # Build Body - Normal (Content-Length)
202
- # : Assembles Request Body from *msg* if Headers are complete, until Content-Length is reached.
201
+ # Build Body - Normal (Content-Length):
202
+ # Assembles Request Body from *msg* if Headers are complete, until Content-Length is reached.
203
203
  # @param [Hash] creq Client Request Context
204
204
  # @param [String] msg A line of text to be processed
205
205
  def self.build_body_normal creq, msg
@@ -223,8 +223,8 @@ module Nut
223
223
  end
224
224
  end
225
225
 
226
- # Build without Body
227
- # : Marks Request Body as Complete if no Body should be present (no content-length & no chunked encoding).
226
+ # Build without Body:
227
+ # Marks Request Body as Complete if no Body should be present (no content-length & no chunked encoding).
228
228
  # @param [Hash] creq Client Request Context
229
229
  def self.build_no_body creq
230
230
 
@@ -235,24 +235,24 @@ module Nut
235
235
  creq[:body_complete] = true
236
236
  end
237
237
 
238
- # Is Content-Length?
239
- # : Determines whether request is bound by a content-length header.
238
+ # Is Content-Length?:
239
+ # Determines whether request is bound by a content-length header.
240
240
  # @param [Hash] creq Client Request Context
241
241
  # @return [Boolean]
242
242
  def self.is_content_len? creq
243
243
  creq[:headz].try(:[], :content_length) && (!(creq[:headz].try(:[], :transfer_encoding)) || (creq[:headz].try(:[], :transfer_encoding) == 'identity'))
244
244
  end
245
245
 
246
- # Is Chunked?
247
- # : Determines whether request is chunked (as per transfer-encoding header).
246
+ # Is Chunked?:
247
+ # Determines whether request is chunked (as per transfer-encoding header).
248
248
  # @param [Hash] creq Client Request Context
249
249
  # @return [Boolean]
250
250
  def self.is_chunked? creq
251
251
  creq[:headz].try(:[], :transfer_encoding) && (creq[:headz].try(:[], :transfer_encoding) != 'identity')
252
252
  end
253
253
 
254
- # Expects Body?
255
- # : Determines whether request expects a body (according to headers).
254
+ # Expects Body?:
255
+ # Determines whether request expects a body (according to headers).
256
256
  # @param [Hash] creq Client Request Context
257
257
  # @return [Boolean]
258
258
  def self.expects_body? creq
data/lib/nut/response.rb CHANGED
@@ -18,8 +18,8 @@ module Nut
18
18
  # Response Module
19
19
  module Response
20
20
 
21
- # Build Response
22
- # : Constructs a complete Response from a preliminary Response Hash (code, body).
21
+ # Build Response:
22
+ # Constructs a complete Response from a preliminary Response Hash (code, body).
23
23
  # @param [Hash] response Preliminary Response Information
24
24
  def self.build_response response
25
25
 
@@ -51,8 +51,8 @@ module Nut
51
51
  compile_response response
52
52
  end
53
53
 
54
- # Compile Response
55
- # : Sends out an HTTP Response to the Client.
54
+ # Compile Response:
55
+ # Sends out an HTTP Response to the Client.
56
56
  # @param [Hash] response Response Hash
57
57
  def self.compile_response response
58
58
  "HTTP/1.1 #{response[:code]} #{CODES[response[:code]]}\r\n" +
data/lib/nut/service.rb CHANGED
@@ -22,8 +22,8 @@ module Nut
22
22
  # Attribute Access
23
23
  attr_reader :request_handler
24
24
 
25
- # Construct
26
- # : Builds a *Service* set to listen for incoming connections @ _addr_ on _port_.
25
+ # Construct:
26
+ # Builds a *Service* set to listen for incoming connections @ _addr_ on _port_.
27
27
  # @param [String] addr
28
28
  # @param [Fixnum] port
29
29
  # @param [Module] request_handler
data/lib/nut/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
  module Nut
6
6
 
7
7
  # Version
8
- VERSION = '0.1.8'
8
+ VERSION = '0.1.9'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eresse