server.rb 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/server/dir.rb +2 -2
- data/lib/server/version.rb +1 -1
- data/lib/server.rb +15 -11
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c1f5315cd2fe6ceaa25725d372a53dbf52f61477cf0798c15fd20a348b28b4d
|
4
|
+
data.tar.gz: 35df8a5fb406a8445cbb3c3bd151740dea62635c2c24e167c19bf81dce35fa1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93f99747c53464ebd6781d75a99945b0e2f90e1614a5e2627e1cb08450bf92f0f7984156ae5ee4773200d191eb2da1e50c55fae3ea7b5cc406001320eb7a4574
|
7
|
+
data.tar.gz: ab565ff1c8c9e3c9fe9f6be21134582835d8c87b434012d584829618c005fba27b38ad5ae288849fe189ad9076aa356c5c4707005b9a089e4d0c1acf34d0e7df
|
data/lib/server/dir.rb
CHANGED
data/lib/server/version.rb
CHANGED
data/lib/server.rb
CHANGED
@@ -9,10 +9,9 @@ class Server
|
|
9
9
|
|
10
10
|
##
|
11
11
|
# @param [String] path
|
12
|
-
# The path to a directory
|
13
|
-
#
|
12
|
+
# The path to a directory
|
14
13
|
# @return [Rack::Builder]
|
15
|
-
# Returns a Rack app
|
14
|
+
# Returns a Rack app
|
16
15
|
def self.app(path)
|
17
16
|
Rack::Builder.app do
|
18
17
|
use Server::ETag
|
@@ -24,13 +23,21 @@ class Server
|
|
24
23
|
##
|
25
24
|
# @param [String] path
|
26
25
|
# The path to a directory
|
27
|
-
#
|
28
26
|
# @param [Hash] options
|
29
27
|
# Hash of options
|
30
|
-
#
|
31
28
|
# @return [Server]
|
32
29
|
# Returns an instance of {Server Server}
|
33
30
|
def self.for(path, options = {})
|
31
|
+
new app(path), prepare(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Prepares options for {Server#initialize Server#initialize}
|
36
|
+
# @param [#to_h] options
|
37
|
+
# @return [Hash]
|
38
|
+
# Returns a Hash object
|
39
|
+
def self.prepare(options)
|
40
|
+
options = options.to_h.dup
|
34
41
|
host = options.delete(:host) ||
|
35
42
|
options.delete("host") ||
|
36
43
|
options.delete(:bind) ||
|
@@ -42,10 +49,12 @@ class Server
|
|
42
49
|
unix = options.delete(:unix) ||
|
43
50
|
options.delete("unix") ||
|
44
51
|
nil
|
45
|
-
|
52
|
+
options.merge!(
|
46
53
|
binds: [unix ? "unix://#{unix}" : "tcp://#{host}:#{port}"]
|
47
54
|
)
|
55
|
+
options
|
48
56
|
end
|
57
|
+
|
49
58
|
class << self
|
50
59
|
alias_method :dir, :for
|
51
60
|
end
|
@@ -53,10 +62,8 @@ class Server
|
|
53
62
|
##
|
54
63
|
# @param [Rack::Builder] app
|
55
64
|
# Rack application
|
56
|
-
#
|
57
65
|
# @param [Hash] options
|
58
66
|
# Hash of options
|
59
|
-
#
|
60
67
|
# @return [Server]
|
61
68
|
# Returns an instance of {Server Server}
|
62
69
|
def initialize(app, options = {})
|
@@ -68,10 +75,8 @@ class Server
|
|
68
75
|
|
69
76
|
##
|
70
77
|
# Starts the web server
|
71
|
-
#
|
72
78
|
# @param [Boolean] block
|
73
79
|
# When given as true, this method will block
|
74
|
-
#
|
75
80
|
# @return [Thread]
|
76
81
|
# Returns a thread
|
77
82
|
def start(block: false)
|
@@ -82,7 +87,6 @@ class Server
|
|
82
87
|
|
83
88
|
##
|
84
89
|
# Stops the web server
|
85
|
-
#
|
86
90
|
# @return [void]
|
87
91
|
def stop
|
88
92
|
@server.stop
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: server.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puma
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.5'
|
83
|
-
description: A static file web server
|
83
|
+
description: A static file web server
|
84
84
|
email:
|
85
85
|
- 0x1eef@protonmail.com
|
86
86
|
executables: []
|
@@ -112,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
|
-
rubygems_version: 3.5.
|
115
|
+
rubygems_version: 3.5.13
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
|
-
summary: A static file web server
|
118
|
+
summary: A static file web server
|
119
119
|
test_files: []
|