hermeneutics 1.9 → 1.10

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: c88fb0c48f5ce9d5130e858d86c155c7b2bb42dbb747b9fb5ed66abfad388ad5
4
- data.tar.gz: aae1bc88540bb33b77a4f4b6daea02155dac144932965cc8bb60e2da9f084444
3
+ metadata.gz: 721abdbe281ba643a27fefdcb8016c0f1a0202ed65e6c9741b5a90c3320c121e
4
+ data.tar.gz: c78e80af37ced64e8ab89d19b729da96f3b6d0e888f0bf0c5de96274bbdf30c3
5
5
  SHA512:
6
- metadata.gz: e42c54fb360a488b13031c430611a561415114b420538303edb23264116e7da2c905b8f4bebea560bbebf16341c3a73dd928b82346d2bcf4c5d7f2be80591079
7
- data.tar.gz: f2af0cc6d5352dcd191d6620f359c7e0f6b94624a8bbd863ef44a4a2aded797105899df102c4f14c8111548d6a76258b9213acddda63d16770dce123869368e1
6
+ metadata.gz: 30f6297db18bab61106428eee10338bfe4907dae30fa12bfbff8dc3e94a931b349befc4f5fa65bd21c9b053d9c9e8904d8c7d9920fc2f63f51d393167dc13a0b
7
+ data.tar.gz: 9f96a1b60536b83254252029fa36fa3e7ed739f270799bd8ccd155e068407a4b31de0073bb7049c5306b7096f5c9b54dca7ba53f8564966f7e82e6830cc644f4
@@ -70,11 +70,11 @@ module Hermeneutics
70
70
  document Html
71
71
  end
72
72
 
73
- def parameters inp = nil, &block
73
+ def parameters &block
74
74
  if block_given? then
75
75
  case request_method
76
76
  when "GET", "HEAD" then parse_query query_string, &block
77
- when "POST" then parse_posted inp||$stdin, &block
77
+ when "POST" then parse_posted &block
78
78
  else parse_input &block
79
79
  end
80
80
  else
@@ -107,8 +107,8 @@ module Hermeneutics
107
107
  URLText.decode_hash data, &block
108
108
  end
109
109
 
110
- def parse_posted inp, &block
111
- data = inp.read
110
+ def parse_posted &block
111
+ data = $stdin.read.force_encoding Encoding::ASCII_8BIT
112
112
  data.bytesize == content_length.to_i or
113
113
  @warn = "Content length #{content_length} is wrong (#{data.bytesize})."
114
114
  ct = ContentType.parse content_type
@@ -116,7 +116,7 @@ module Hermeneutics
116
116
  when "application/x-www-form-urlencoded" then
117
117
  parse_query data, &block
118
118
  when "multipart/form-data" then
119
- mp = Multipart.parse data, ct.hash
119
+ mp = Multipart.parse data, **ct.hash
120
120
  parse_multipart mp, &block
121
121
  when "text/plain" then
122
122
  # Suppose this is for testing purposes only.
@@ -130,7 +130,7 @@ module Hermeneutics
130
130
  mp.each { |part|
131
131
  cd = part.headers.content_disposition
132
132
  if cd.caption == "form-data" then
133
- yield cd.name, part.body, **cd.hash
133
+ yield cd.name, part.body_decoded, **cd.hash
134
134
  end
135
135
  }
136
136
  end
@@ -327,7 +327,7 @@ module Hermeneutics
327
327
 
328
328
  def parse_mime input
329
329
  m = Mime.find @caption
330
- m and m.parse input, @hash
330
+ m and m.parse input, **@hash
331
331
  end
332
332
 
333
333
  end
@@ -242,8 +242,8 @@ module Hermeneutics
242
242
  def single hash
243
243
  if block_given? then
244
244
  hash.map { |k,v|
245
- if Symbol === k then k = k.new_string ; k.gsub! /_/, "-" end
246
- if Array === v then v = v.join " " end
245
+ if Symbol === k then k = k.to_s ; k.gsub! /_/, "-" end
246
+ if Array === v then v = v.join " " end
247
247
  yield "#{k}: #{v};"
248
248
  }
249
249
  else
@@ -52,9 +52,9 @@ module Hermeneutics
52
52
  yield i
53
53
  end
54
54
  end
55
- def document *args, &block
55
+ def document *args, **kwargs, &block
56
56
  open do |i|
57
- i.document *args, &block
57
+ i.document *args, **kwargs, &block
58
58
  end
59
59
  end
60
60
  def write_file name = nil
@@ -81,9 +81,9 @@ module Hermeneutics
81
81
  end
82
82
  end
83
83
 
84
- def document *args, &block
84
+ def document *args, **kwargs, &block
85
85
  doctype_header
86
- build *args, &block
86
+ build *args, **kwargs, &block
87
87
  end
88
88
 
89
89
  def doctype_header
@@ -270,7 +270,7 @@ module Hermeneutics
270
270
  def mkattrs attrs
271
271
  attrs or return
272
272
  attrs.each { |k,v|
273
- if Symbol === k then k = k.new_string ; k.gsub! /_/, "-" end
273
+ if Symbol === k then k = k.to_s ; k.gsub! /_/, "-" end
274
274
  v = case v
275
275
  when Array then v.compact.join " "
276
276
  when true then k.to_s if @assign_attributes
@@ -65,7 +65,7 @@ module Hermeneutics
65
65
  MIME = /^multipart\//
66
66
 
67
67
  class IllegalBoundary < StandardError ; end
68
- class ParseError < StandardError ; end
68
+ class ParseError < StandardError ; end
69
69
 
70
70
  # :stopdoc:
71
71
  class PartFile
@@ -130,7 +130,7 @@ module Hermeneutics
130
130
 
131
131
  class <<self
132
132
 
133
- def parse input, parameters
133
+ def parse input, **parameters
134
134
  b = parameters[ :boundary]
135
135
  b or raise ParseError, "Missing boundary parameter."
136
136
  PartFile.open input, b do |partfile|
@@ -493,7 +493,7 @@ module Hermeneutics
493
493
 
494
494
  private :new
495
495
 
496
- def parse input, parameters = nil
496
+ def parse input
497
497
  parse_hb input do |h,b|
498
498
  new h, b
499
499
  end
@@ -596,11 +596,10 @@ module Hermeneutics
596
596
  when "base64" then
597
597
  (@body.unpack "m").join
598
598
  else
599
- @body.new_string
600
- end
601
- if (c = @headers.content_type) and (s = c[ :charset]) then
602
- r.force_encoding s
599
+ @body
603
600
  end
601
+ c = @headers.content_type
602
+ r.force_encoding c&&c[ :charset] || Encoding::ASCII_8BIT
604
603
  r
605
604
  end
606
605
 
@@ -14,7 +14,7 @@
14
14
  module Hermeneutics
15
15
 
16
16
  NAME = "hermeneutics"
17
- VERSION = "1.9".freeze
17
+ VERSION = "1.10".freeze
18
18
  SUMMARY = "CGI and mail handling"
19
19
 
20
20
  DESCRIPTION = <<~EOT
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hermeneutics
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.9'
4
+ version: '1.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-14 00:00:00.000000000 Z
11
+ date: 2020-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: supplement