servel 0.30.0 → 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/servel +1 -1
- data/lib/servel.rb +6 -0
- data/lib/servel/cli.rb +14 -18
- data/lib/servel/config_parser.rb +23 -0
- data/lib/servel/version.rb +1 -1
- data/servel.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9764905c7e72d90eecf301bf30c25c5542602d70df065803e18c03ab8353322
|
4
|
+
data.tar.gz: cf989ead1073528b04fc5c2c86d2f57ce37beace6c110fe40955c802390e4d58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed18495a7e3c37f25fd22655f7eebd8e78e712782d3970f15a46b205cc9c5e92da2ddb884277cae0558043b66754dac9936fd8dfcbd9dd9333c324caed2931b3
|
7
|
+
data.tar.gz: fadfa698ea51f4c95deee988c4ecfbd8edfff80776cf406fb780b5551f0d0207826110d8058ec150af763422d16901bb2a17431d2111cce855bd0346dd30933a
|
data/bin/servel
CHANGED
data/lib/servel.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rack/handler/puma'
|
|
3
3
|
require 'hamlit'
|
4
4
|
require 'active_support/all'
|
5
5
|
require 'lru_redux'
|
6
|
+
require 'tty-config'
|
6
7
|
|
7
8
|
require 'thread'
|
8
9
|
require 'pathname'
|
@@ -15,6 +16,10 @@ module Servel
|
|
15
16
|
|
16
17
|
Rack::URLMap.new(url_map)
|
17
18
|
end
|
19
|
+
|
20
|
+
def self.config
|
21
|
+
@config ||= Servel::ConfigParser.new.config
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
require "servel/version"
|
@@ -25,4 +30,5 @@ require "servel/haml_context"
|
|
25
30
|
require "servel/index"
|
26
31
|
require "servel/app"
|
27
32
|
require "servel/home_app"
|
33
|
+
require "servel/config_parser"
|
28
34
|
require "servel/cli"
|
data/lib/servel/cli.rb
CHANGED
@@ -1,18 +1,14 @@
|
|
1
|
-
class Servel::CLI
|
2
|
-
def
|
3
|
-
|
4
|
-
end
|
5
|
-
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
[root, url_root || "/"]
|
16
|
-
end.to_h
|
17
|
-
end
|
18
|
-
end
|
1
|
+
class Servel::CLI
|
2
|
+
def start
|
3
|
+
Rack::Handler::Puma.run(Servel.build_app(path_map))
|
4
|
+
end
|
5
|
+
|
6
|
+
def path_map
|
7
|
+
Servel.config.fetch(:listings).map do |listing|
|
8
|
+
listing = { listing => nil } if listing.is_a?(String)
|
9
|
+
|
10
|
+
root, url_root = listing.keys.first, listing.values.first || "/"
|
11
|
+
[Pathname.new(root).realpath, url_root]
|
12
|
+
end.to_h
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Servel::ConfigParser
|
2
|
+
attr_reader :config
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@config = TTY::Config.new
|
6
|
+
@config.filename = "servel"
|
7
|
+
@config.append_path(Dir.pwd)
|
8
|
+
@config.append_path((Pathname.new(Dir.home) + ".servel").to_s)
|
9
|
+
@config.append_path(Dir.home)
|
10
|
+
@config.env_prefix = "servel"
|
11
|
+
@config.autoload_env
|
12
|
+
@config.read if @config.exist?
|
13
|
+
|
14
|
+
@config.append(*parse_argv, to: :listings)
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_argv
|
18
|
+
ARGV.map do |arg|
|
19
|
+
root, url_root = arg.split(":" , 2)
|
20
|
+
{ root => url_root }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/servel/version.rb
CHANGED
data/servel.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brenton "B-Train" Fletcher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: tty-config
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Serves files and directories over HTTP.
|
112
126
|
email:
|
113
127
|
- i@bloople.net
|
@@ -143,6 +157,7 @@ files:
|
|
143
157
|
- lib/servel.rb
|
144
158
|
- lib/servel/app.rb
|
145
159
|
- lib/servel/cli.rb
|
160
|
+
- lib/servel/config_parser.rb
|
146
161
|
- lib/servel/entry.rb
|
147
162
|
- lib/servel/entry_factory.rb
|
148
163
|
- lib/servel/haml_context.rb
|