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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dce6f55af17def653868138167feedca557e981ff15f3010585ece287e5f0e8d
4
- data.tar.gz: 8c1e5087a5f219b6523eb3e65daca81d91c149d50cfbe1607cc5bae3a8024dad
3
+ metadata.gz: b9764905c7e72d90eecf301bf30c25c5542602d70df065803e18c03ab8353322
4
+ data.tar.gz: cf989ead1073528b04fc5c2c86d2f57ce37beace6c110fe40955c802390e4d58
5
5
  SHA512:
6
- metadata.gz: 609b927a7d22c511a93b024cdb736a6553da2f6bd26301fa4ef716862a2ab9543f795d0fde3ad768c7bb8501a4fc3590045b0218abdba091e619471127014fc4
7
- data.tar.gz: 549e6337e9871ba4db2d851702a246a2ebf9174e3a76e08a9155ec0707a32208fd4514bcbf965b1de0cb54127415ba41b9bcbc49f2a04aa14ee72c13a93f8690
6
+ metadata.gz: ed18495a7e3c37f25fd22655f7eebd8e78e712782d3970f15a46b205cc9c5e92da2ddb884277cae0558043b66754dac9936fd8dfcbd9dd9333c324caed2931b3
7
+ data.tar.gz: fadfa698ea51f4c95deee988c4ecfbd8edfff80776cf406fb780b5551f0d0207826110d8058ec150af763422d16901bb2a17431d2111cce855bd0346dd30933a
data/bin/servel CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "servel"
4
4
 
5
- Servel::CLI.new(ARGV).start
5
+ Servel::CLI.new.start
@@ -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"
@@ -1,18 +1,14 @@
1
- class Servel::CLI
2
- def initialize(argv)
3
- @argv = argv
4
- end
5
-
6
- def start
7
- Rack::Handler::Puma.run(Servel.build_app(path_map))
8
- end
9
-
10
- def path_map
11
- @argv.map do |arg|
12
- root, url_root = arg.split(":" , 2)
13
- root = Pathname.new(root).realpath
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
@@ -1,3 +1,3 @@
1
1
  module Servel
2
- VERSION = "0.30.0"
2
+ VERSION = "0.31.0"
3
3
  end
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "hamlit"
29
29
  spec.add_dependency "activesupport"
30
30
  spec.add_dependency "lru_redux"
31
+ spec.add_dependency "tty-config"
31
32
  end
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.30.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-02-24 00:00:00.000000000 Z
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