diamant 0.0.6 → 0.0.8

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: 92deda334209782c1d9e5c840900c91d446b2528bef1ecfe94d4aaa5f7a75e56
4
- data.tar.gz: fbead15265bbc9268652616833877584bec9f8bddb241a4837250ea4457a529c
3
+ metadata.gz: 78504900d38add8a76be57a468a7e3b86284ef964de1e75a6bc40f614649f78b
4
+ data.tar.gz: b0212f1c5b7180d0b7de192ab13c5abe37863d6fd5dbde61d5dea86dfcba3572
5
5
  SHA512:
6
- metadata.gz: 76406b4875304f04b95457704ab93d51e5e0f183d45defb74362169d7ca98105179202cbcb8ef5f36d779fa890aa8e3fc7da82e0ffabaa267ce1e7f4400edd06
7
- data.tar.gz: 9ea81c1019586c2351751d1b69aa0feaae4292dc4cfb597c94fcd5a6f3dd90136e941f8377413633ce612ca046054f46e902739c3cc8fe1bc10ff676bb57ae2c
6
+ metadata.gz: da679165a67588a03666ad9e12149927bdbaf6cf663165693cc42c26a70ec39f7f0e19a9b61214d27ba6b2c9ec13f64b55f8059a2d49d4a539940b82c9b39d29
7
+ data.tar.gz: 814580c5b14c5344b1e2432e7eb078e83c1421b939f11437f6a921f94dec7c066bd8329348d259749dacf7ac033e086d9a1d784773a389e4294b9e6794ef5118
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'net/gemini/request'
4
+ require 'uri/gemini'
5
+
3
6
  module Diamant
4
7
  # Methods to generate requests responses
5
8
  module Response
@@ -22,9 +25,10 @@ module Diamant
22
25
  end
23
26
 
24
27
  def read_file(client)
25
- r = Net::GeminiRequest.read_new(client)
28
+ r = Net::Gemini::Request.read_new(client)
26
29
  [r.uri, route(r.path)]
27
- rescue Net::GeminiBadRequest
30
+ rescue Net::Gemini::BadRequest, URI::InvalidURIError => e
31
+ @logger.error "59 - #{e}"
28
32
  [nil, ["59\r\n"]]
29
33
  end
30
34
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Diamant
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.8'
5
5
  end
data/lib/diamant.rb CHANGED
@@ -6,9 +6,6 @@ require 'English'
6
6
  require 'openssl'
7
7
  require 'fileutils'
8
8
 
9
- require 'net/gemini/request'
10
- require 'uri/gemini'
11
-
12
9
  require 'diamant/version'
13
10
  require 'diamant/mimetype'
14
11
  require 'diamant/response'
@@ -39,6 +36,9 @@ module Diamant
39
36
  loop do
40
37
  Thread.new(ssl_serv.accept) do |client|
41
38
  handle_client(client)
39
+ rescue Errno::ECONNRESET, Errno::ENOTCONN => e
40
+ @logger.error(e.message)
41
+ ensure
42
42
  client.close
43
43
  end
44
44
  rescue OpenSSL::SSL::SSLError => e
@@ -59,6 +59,7 @@ module Diamant
59
59
  def handle_client(client)
60
60
  current_load = Thread.list.length - 1
61
61
  return if reject_request?(client, current_load)
62
+
62
63
  uri, answer = read_file(client)
63
64
  log_line = [current_load, client.peeraddr[3], answer[0]]
64
65
  log_line << uri if uri
@@ -87,6 +88,7 @@ module Diamant
87
88
  def check_option_path_exist(option, default)
88
89
  path = File.expand_path(option || default)
89
90
  return path if File.exist?(path)
91
+
90
92
  raise ArgumentError, "#{path} does not exist!"
91
93
  end
92
94
 
metadata CHANGED
@@ -1,141 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diamant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Étienne Deparis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-04 00:00:00.000000000 Z
11
+ date: 2023-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-net-text
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.5
19
+ version: 0.0.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.0.5
27
- - !ruby/object:Gem::Dependency
28
- name: byebug
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '11.1'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '11.1'
41
- - !ruby/object:Gem::Dependency
42
- name: pry
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.14'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.14'
55
- - !ruby/object:Gem::Dependency
56
- name: pry-doc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.1'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
24
+ - - '='
67
25
  - !ruby/object:Gem::Version
68
- version: '1.1'
26
+ version: 0.0.9
69
27
  - !ruby/object:Gem::Dependency
70
28
  name: rspec
71
29
  requirement: !ruby/object:Gem::Requirement
72
30
  requirements:
73
31
  - - "~>"
74
32
  - !ruby/object:Gem::Version
75
- version: '3.10'
33
+ version: '3.12'
76
34
  type: :development
77
35
  prerelease: false
78
36
  version_requirements: !ruby/object:Gem::Requirement
79
37
  requirements:
80
38
  - - "~>"
81
39
  - !ruby/object:Gem::Version
82
- version: '3.10'
40
+ version: '3.12'
83
41
  - !ruby/object:Gem::Dependency
84
42
  name: rubocop
85
43
  requirement: !ruby/object:Gem::Requirement
86
44
  requirements:
87
45
  - - "~>"
88
46
  - !ruby/object:Gem::Version
89
- version: '1.18'
47
+ version: '1.57'
90
48
  type: :development
91
49
  prerelease: false
92
50
  version_requirements: !ruby/object:Gem::Requirement
93
51
  requirements:
94
52
  - - "~>"
95
53
  - !ruby/object:Gem::Version
96
- version: '1.18'
54
+ version: '1.57'
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: rubocop-performance
99
57
  requirement: !ruby/object:Gem::Requirement
100
58
  requirements:
101
59
  - - "~>"
102
60
  - !ruby/object:Gem::Version
103
- version: '1.11'
61
+ version: '1.19'
104
62
  type: :development
105
63
  prerelease: false
106
64
  version_requirements: !ruby/object:Gem::Requirement
107
65
  requirements:
108
66
  - - "~>"
109
67
  - !ruby/object:Gem::Version
110
- version: '1.11'
68
+ version: '1.19'
111
69
  - !ruby/object:Gem::Dependency
112
70
  name: rubocop-rspec
113
71
  requirement: !ruby/object:Gem::Requirement
114
72
  requirements:
115
73
  - - "~>"
116
74
  - !ruby/object:Gem::Version
117
- version: '2.4'
75
+ version: '2.24'
118
76
  type: :development
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
79
  requirements:
122
80
  - - "~>"
123
81
  - !ruby/object:Gem::Version
124
- version: '2.4'
82
+ version: '2.24'
125
83
  - !ruby/object:Gem::Dependency
126
84
  name: simplecov
127
85
  requirement: !ruby/object:Gem::Requirement
128
86
  requirements:
129
87
  - - "~>"
130
88
  - !ruby/object:Gem::Version
131
- version: '0.21'
89
+ version: '0.22'
132
90
  type: :development
133
91
  prerelease: false
134
92
  version_requirements: !ruby/object:Gem::Requirement
135
93
  requirements:
136
94
  - - "~>"
137
95
  - !ruby/object:Gem::Version
138
- version: '0.21'
96
+ version: '0.22'
139
97
  - !ruby/object:Gem::Dependency
140
98
  name: yard
141
99
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
144
  - !ruby/object:Gem::Version
187
145
  version: '0'
188
146
  requirements: []
189
- rubygems_version: 3.2.32
147
+ rubygems_version: 3.4.20
190
148
  signing_key:
191
149
  specification_version: 4
192
150
  summary: A simple Gemini server for static files.