server.rb 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/server/version.rb +1 -1
  3. data/lib/server.rb +25 -14
  4. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1e9f252405fa8dfefb506be2f364ab0397e219b73de71de64d0b44d3afac915
4
- data.tar.gz: 8ea9be708ac06fa1c6828376948f2cd54e2743229dd4bdcf1643765e8fe82ba0
3
+ metadata.gz: 9d807489641411df5fe227174f05d079f1d48356a2d154392beef07fdbf10930
4
+ data.tar.gz: 4221e02a661ab7eff5fa3a7775855888c80db2085353c3db8a478fca43dcdd00
5
5
  SHA512:
6
- metadata.gz: c591537a32ca5e8f8fb3808df201b68a1f554005f09a2668701a2aab57cb7077a7f3c134916ded8f52c6eeae149142ab8979cd55db014cb79ece01235e48aa20
7
- data.tar.gz: 1adc90d672fba8a1e6b57e9dc49aa3b7b90723b17d57304fadf82cee3cc42757ddb01bd1259dbe309cbb54ebf11f15e85625903d89ae1710471d8af778c26e16
6
+ metadata.gz: 7644c7cf54fbcfab425ff5f036599a330bd4484c80d2b6314503ab29655d9a54a92571b313d0a9904780bc5b08122d6aa88854c78aceb6934dbd4d5e8758b4ae
7
+ data.tar.gz: 60523031a59d70f05d9730dbd7d7a7884ed048a236646fda363d1d8997d24f8539f43d55d1a497ea50ddd911484514b7bb7109018877d457d4a69463433f407f
@@ -1,3 +1,3 @@
1
1
  class Server
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/server.rb CHANGED
@@ -23,31 +23,42 @@ class Server
23
23
 
24
24
  ##
25
25
  # @param [String] path
26
- # The path to a directory.
26
+ # The path to a directory
27
27
  #
28
28
  # @param [Hash] options
29
- # A hash of options.
29
+ # Hash of options
30
30
  #
31
31
  # @return [Server]
32
- # Returns an instance of {Server Server}.
33
- def self.dir(path, options = {})
34
- host = options.delete(:host) || options.delete("host") || "127.0.0.1"
35
- port = options.delete(:port) || options.delete("port") || 3000
36
- unix = options.delete(:unix) || options.delete("unix") || nil
32
+ # Returns an instance of {Server Server}
33
+ def self.for(path, options = {})
34
+ host = options.delete(:host) ||
35
+ options.delete("host") ||
36
+ options.delete(:bind) ||
37
+ options.delete("bind") ||
38
+ "127.0.0.1"
39
+ port = options.delete(:port) ||
40
+ options.delete("port") ||
41
+ 3000
42
+ unix = options.delete(:unix) ||
43
+ options.delete("unix") ||
44
+ nil
37
45
  new app(path), options.merge!(
38
46
  binds: [unix ? "unix://#{unix}" : "tcp://#{host}:#{port}"]
39
47
  )
40
48
  end
49
+ class << self
50
+ alias_method :dir, :for
51
+ end
41
52
 
42
53
  ##
43
54
  # @param [Rack::Builder] app
44
- # A rack app.
55
+ # Rack application
45
56
  #
46
57
  # @param [Hash] options
47
- # A hash of options.
58
+ # Hash of options
48
59
  #
49
60
  # @return [Server]
50
- # Returns an instance of {Server Server}.
61
+ # Returns an instance of {Server Server}
51
62
  def initialize(app, options = {})
52
63
  @app = app
53
64
  @options = default_options.merge!(options)
@@ -56,13 +67,13 @@ class Server
56
67
  end
57
68
 
58
69
  ##
59
- # Starts the web server.
70
+ # Starts the web server
60
71
  #
61
72
  # @param [Boolean] block
62
- # When given as true, this method will block.
73
+ # When given as true, this method will block
63
74
  #
64
75
  # @return [Thread]
65
- # Returns a thread.
76
+ # Returns a thread
66
77
  def start(block: false)
67
78
  @server.binder.parse(@options[:binds])
68
79
  thr = @server.run
@@ -70,7 +81,7 @@ class Server
70
81
  end
71
82
 
72
83
  ##
73
- # Stops the web server.
84
+ # Stops the web server
74
85
  #
75
86
  # @return [void]
76
87
  def 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.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-27 00:00:00.000000000 Z
11
+ date: 2024-05-04 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.3
115
+ rubygems_version: 3.5.9
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: []