server.rb 0.1.1 → 0.2.2

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 +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1e9f252405fa8dfefb506be2f364ab0397e219b73de71de64d0b44d3afac915
4
- data.tar.gz: 8ea9be708ac06fa1c6828376948f2cd54e2743229dd4bdcf1643765e8fe82ba0
3
+ metadata.gz: d86d66d6dd85fd989a0c7cea5e0a89003da4f93c5bbb90e8e59cb24aa92a4273
4
+ data.tar.gz: 22d12221ead684c5897cd9138502370852d4869f47a965d0b4678648924baa64
5
5
  SHA512:
6
- metadata.gz: c591537a32ca5e8f8fb3808df201b68a1f554005f09a2668701a2aab57cb7077a7f3c134916ded8f52c6eeae149142ab8979cd55db014cb79ece01235e48aa20
7
- data.tar.gz: 1adc90d672fba8a1e6b57e9dc49aa3b7b90723b17d57304fadf82cee3cc42757ddb01bd1259dbe309cbb54ebf11f15e85625903d89ae1710471d8af778c26e16
6
+ metadata.gz: ba7756e35e925bb88b6dbd82d75ad098a349b0f27fb823a766650d5683df8bc4893cc6017da46458140d059ab6e0e683b34486ff4880da2546c9e41f4f77e8c6
7
+ data.tar.gz: 5fee378893a5c0f1c8984f396e2cda243f4fa24d866f2a6b0fe58dfb1db34b160320140cdc08a73196e52b6319317fae0e201290940c1294e9913e1547b50fd9
@@ -1,3 +1,3 @@
1
1
  class Server
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.2"
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.2
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
@@ -112,7 +112,7 @@ 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
118
  summary: A static file web server