adsf 1.3.1 → 1.4.4

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: d209e17b4b260c9bc77e4c435a94d51b8b6cf4e0ce7b38a4f77d90bc8bf27fc3
4
- data.tar.gz: 472632fb8c5f1e29e1fe773b30cc2c6a341c35725e7942546bdaefe7b3326223
3
+ metadata.gz: 60390346b41657096f88db3706f4a7c231c2f1b7556caacc7ba7e74eaad8c057
4
+ data.tar.gz: 83d02b5d039061ca9bf4bca4516cf2dcf2cfe0ecbe8618ea8d15deff7d1c9216
5
5
  SHA512:
6
- metadata.gz: cefc44acb68c0f56faaa5495f824b266e2d4267dce825afa950ec61a9b5c2c92c2e4a27dd526cb8e00b0085979e695f61d853bf04c64a41a7ed516657bc7904c
7
- data.tar.gz: 154c0da23d3c09430e5813a1c613ad6bcdb0530057aa98d0e6b785ce8a59505a1832d63dacd98f1fe9a16a0979f27e95819fc3106546bbcded63c57bec18a6e5
6
+ metadata.gz: 1ae356ddc04b843a65f841bc46f4799588bcbf8a0c3ba07a57b2749a08101e496049d9e8b05fc1630ed795a52deccc8a54b2818bcf19d29e0c3702f1863d14ce
7
+ data.tar.gz: 1869f1595e050c7f89aaacbb1b1a445e1340887942351c006783ec538b9fe250b0c03042c8ac20556b5b87188a113dd30c1b1bc131916a26bf870419ed39c238
data/NEWS.md CHANGED
@@ -1,4 +1,34 @@
1
- # adsf News
1
+ # Release notes for adsf
2
+
3
+ ## 1.4.4 (2020-12-18)
4
+
5
+ Enhancements:
6
+
7
+ * Let Rack handler default to what Rack considers to be default (not Thin)
8
+
9
+ ## 1.4.3 (2019-12-06)
10
+
11
+ Fixes:
12
+
13
+ * Fixed incorrect Cache-Control stale-if-error header value (#20) [Chris Chapman]
14
+
15
+ ## 1.4.2 (2019-05-26)
16
+
17
+ Enhancements:
18
+
19
+ * Set `Cache-Control` HTTP header to prevent caching (#17, #18) [Daniel Aleksandersen]
20
+
21
+ ## 1.4.1 (2018-02-02)
22
+
23
+ Fixes:
24
+
25
+ * [adsf-live] Fixed Windows compatibility (#14)
26
+
27
+ ## 1.4.0 (2017-11-26)
28
+
29
+ Features:
30
+
31
+ * Added `--live-reload` option (requires `adsf-live`)
2
32
 
3
33
  ## 1.3.1 (2017-11-25)
4
34
 
data/README.md CHANGED
@@ -25,6 +25,8 @@ _adsf_ (**A** **D**ead **S**imple **F**ileserver) is a tiny static web server th
25
25
 
26
26
  See `adsf --help` for details.
27
27
 
28
+ To use `adsf --live-reload`, please install the separate `adsf-live` gem. (The live-reload support is not part of adsf itself, because the dependencies of `adsf-live` make it difficult to install under some circumstances.)
29
+
28
30
  Using adsf programmatically
29
31
  ---------------------------
30
32
 
data/bin/adsf CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'optparse'
4
5
  require 'adsf'
@@ -9,6 +10,7 @@ options = {
9
10
  index_filenames: %w[index.html],
10
11
  root: '.',
11
12
  host: '0.0.0.0',
13
+ live: false,
12
14
  }
13
15
 
14
16
  OptionParser.new do |opts|
@@ -42,6 +44,10 @@ OptionParser.new do |opts|
42
44
  opts.on('-a', '--listen-address [host]', 'Specify the address to listen to') do |o|
43
45
  options[:host] = o
44
46
  end
47
+
48
+ opts.on('-L', '--live-reload', 'Reload on changes (requires adsf-live)') do
49
+ options[:live] = true
50
+ end
45
51
  end.parse!
46
52
 
47
53
  server = Adsf::Server.new(options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack'
2
4
 
3
5
  module Adsf
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Adsf
2
4
  module Rack
3
5
  end
4
6
  end
5
7
 
6
8
  require 'adsf/rack/index_file_finder'
9
+ require 'adsf/rack/caching'
7
10
  require 'adsf/rack/cors'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Adsf::Rack
4
+ class Caching
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ status, headers, body = *@app.call(env)
11
+
12
+ new_headers =
13
+ headers.merge(
14
+ 'Cache-Control' => 'max-age=0, stale-if-error=0',
15
+ )
16
+
17
+ [status, new_headers, body]
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Adsf::Rack
2
4
  class CORS
3
5
  def initialize(app)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Adsf::Rack
2
4
  class IndexFileFinder
3
5
  def initialize(app, root:, index_filenames: ['index.html'])
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Adsf
2
4
  class Server
3
- DEFAULT_HANDLER_NAME = :thin
4
-
5
- def initialize(root:, index_filenames: ['index.html'], host: '127.0.0.1', port: 3000, handler: nil)
5
+ def initialize(root:, live: false, index_filenames: ['index.html'], host: '127.0.0.1', port: 3000, handler: nil)
6
6
  @root = root
7
+ @live = live
7
8
  @index_filenames = index_filenames
8
9
  @host = host
9
10
  @port = port
@@ -15,6 +16,7 @@ module Adsf
15
16
  def run
16
17
  handler = build_handler
17
18
  app = build_app(root: @root, index_filenames: @index_filenames)
19
+ start_watcher if @live
18
20
 
19
21
  url = "http://#{@host}:#{@port}/"
20
22
  puts "View the site at #{url}"
@@ -30,6 +32,12 @@ module Adsf
30
32
 
31
33
  private
32
34
 
35
+ def start_watcher
36
+ require 'adsf/live'
37
+
38
+ ::Adsf::Live::Watcher.new(root_dir: File.absolute_path(@root)).tap(&:start)
39
+ end
40
+
33
41
  def wait_for_stop_async(server)
34
42
  Thread.new { wait_for_stop(server) }
35
43
  end
@@ -40,16 +48,24 @@ module Adsf
40
48
  end
41
49
 
42
50
  def build_app(root:, index_filenames:)
51
+ is_live = @live
52
+
43
53
  ::Rack::Builder.new do
44
54
  use ::Rack::CommonLogger
45
55
  use ::Rack::ShowExceptions
46
56
  use ::Rack::Lint
47
57
  use ::Rack::Head
58
+ use Adsf::Rack::Caching
48
59
  use Adsf::Rack::CORS
49
60
  use Adsf::Rack::IndexFileFinder,
50
61
  root: root,
51
62
  index_filenames: index_filenames
52
63
 
64
+ if is_live
65
+ require 'adsf/live'
66
+ use ::Rack::LiveReload, source: :vendored
67
+ end
68
+
53
69
  run ::Rack::File.new(root)
54
70
  end.to_app
55
71
  end
@@ -58,11 +74,7 @@ module Adsf
58
74
  if @handler
59
75
  ::Rack::Handler.get(@handler)
60
76
  else
61
- begin
62
- ::Rack::Handler.get(DEFAULT_HANDLER_NAME)
63
- rescue LoadError
64
- ::Rack::Handler::WEBrick
65
- end
77
+ ::Rack::Handler.default
66
78
  end
67
79
  end
68
80
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Adsf
2
- VERSION = '1.3.1'.freeze
4
+ VERSION = '1.4.4'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adsf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-25 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -37,15 +37,12 @@ executables:
37
37
  extensions: []
38
38
  extra_rdoc_files: []
39
39
  files:
40
- - Gemfile
41
- - Gemfile.lock
42
- - LICENSE
43
40
  - NEWS.md
44
41
  - README.md
45
- - Rakefile
46
42
  - bin/adsf
47
43
  - lib/adsf.rb
48
44
  - lib/adsf/rack.rb
45
+ - lib/adsf/rack/caching.rb
49
46
  - lib/adsf/rack/cors.rb
50
47
  - lib/adsf/rack/index_file_finder.rb
51
48
  - lib/adsf/server.rb
@@ -60,17 +57,16 @@ require_paths:
60
57
  - lib
61
58
  required_ruby_version: !ruby/object:Gem::Requirement
62
59
  requirements:
63
- - - ">="
60
+ - - "~>"
64
61
  - !ruby/object:Gem::Version
65
- version: 2.2.0
62
+ version: '2.3'
66
63
  required_rubygems_version: !ruby/object:Gem::Requirement
67
64
  requirements:
68
65
  - - ">="
69
66
  - !ruby/object:Gem::Version
70
67
  version: '0'
71
68
  requirements: []
72
- rubyforge_project:
73
- rubygems_version: 2.7.2
69
+ rubygems_version: 3.2.2
74
70
  signing_key:
75
71
  specification_version: 4
76
72
  summary: a tiny static file server
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem 'codecov', require: false
7
- gem 'm'
8
- gem 'minitest'
9
- gem 'rack-test'
10
- gem 'rake'
11
- gem 'rubocop'
12
- end
@@ -1,61 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- adsf (1.3.1)
5
- rack (>= 1.0.0, < 3.0.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.3.0)
11
- codecov (0.1.10)
12
- json
13
- simplecov
14
- url
15
- docile (1.1.5)
16
- json (2.1.0)
17
- m (1.5.1)
18
- method_source (>= 0.6.7)
19
- rake (>= 0.9.2.2)
20
- method_source (0.9.0)
21
- minitest (5.10.3)
22
- parallel (1.12.0)
23
- parser (2.4.0.2)
24
- ast (~> 2.3)
25
- powerpack (0.1.1)
26
- rack (2.0.3)
27
- rack-test (0.8.2)
28
- rack (>= 1.0, < 3)
29
- rainbow (2.2.2)
30
- rake
31
- rake (12.3.0)
32
- rubocop (0.51.0)
33
- parallel (~> 1.10)
34
- parser (>= 2.3.3.1, < 3.0)
35
- powerpack (~> 0.1)
36
- rainbow (>= 2.2.2, < 3.0)
37
- ruby-progressbar (~> 1.7)
38
- unicode-display_width (~> 1.0, >= 1.0.1)
39
- ruby-progressbar (1.9.0)
40
- simplecov (0.15.1)
41
- docile (~> 1.1.0)
42
- json (>= 1.8, < 3)
43
- simplecov-html (~> 0.10.0)
44
- simplecov-html (0.10.2)
45
- unicode-display_width (1.3.0)
46
- url (0.3.2)
47
-
48
- PLATFORMS
49
- ruby
50
-
51
- DEPENDENCIES
52
- adsf!
53
- codecov
54
- m
55
- minitest
56
- rack-test
57
- rake
58
- rubocop
59
-
60
- BUNDLED WITH
61
- 1.16.0
data/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2009 Denis Defreyne
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- require 'rubocop/rake_task'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.test_files = Dir['test/**/test_*.rb']
6
- t.libs << 'test'
7
- t.verbose = false
8
- end
9
-
10
- RuboCop::RakeTask.new(:rubocop)
11
-
12
- task default: %i[test rubocop]