adsf 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d209e17b4b260c9bc77e4c435a94d51b8b6cf4e0ce7b38a4f77d90bc8bf27fc3
4
- data.tar.gz: 472632fb8c5f1e29e1fe773b30cc2c6a341c35725e7942546bdaefe7b3326223
3
+ metadata.gz: 0d10dbc0c7655c4d10cfc4fd23f2c3dd4d80e6c39c2ea67f88e3ab85dcc38797
4
+ data.tar.gz: 428273f5866ac20c98e634d8a17fb4d2b79666e87620f5982205ebf062d59eb9
5
5
  SHA512:
6
- metadata.gz: cefc44acb68c0f56faaa5495f824b266e2d4267dce825afa950ec61a9b5c2c92c2e4a27dd526cb8e00b0085979e695f61d853bf04c64a41a7ed516657bc7904c
7
- data.tar.gz: 154c0da23d3c09430e5813a1c613ad6bcdb0530057aa98d0e6b785ce8a59505a1832d63dacd98f1fe9a16a0979f27e95819fc3106546bbcded63c57bec18a6e5
6
+ metadata.gz: 8c2f39e4e2e95d1a8e8800595b9e8efb50f1db75fca481f8f0c40a17b22fa138bac641c72edddcd9980c6a6c39f1a432afe9c1d8843c29f6ab88317b43bffd50
7
+ data.tar.gz: 03c8c274075be4b448c38dfa0a7d59c9790403d02f20693f9eaf52d858dfdd4d1d632b77e21d6edace1623eca076078bf82a37af074919fae02745c30fe518f1
data/NEWS.md CHANGED
@@ -1,4 +1,10 @@
1
- # adsf News
1
+ # Release notes for adsf
2
+
3
+ ## 1.4.0 (2017-11-26)
4
+
5
+ Features:
6
+
7
+ * Added `--live-reload` option (requires `adsf-live`)
2
8
 
3
9
  ## 1.3.1 (2017-11-25)
4
10
 
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-life` 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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Adsf
2
4
  module Rack
3
5
  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,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Adsf
2
4
  class Server
3
5
  DEFAULT_HANDLER_NAME = :thin
4
6
 
5
- def initialize(root:, index_filenames: ['index.html'], host: '127.0.0.1', port: 3000, handler: nil)
7
+ def initialize(root:, live: false, index_filenames: ['index.html'], host: '127.0.0.1', port: 3000, handler: nil)
6
8
  @root = root
9
+ @live = live
7
10
  @index_filenames = index_filenames
8
11
  @host = host
9
12
  @port = port
@@ -15,6 +18,7 @@ module Adsf
15
18
  def run
16
19
  handler = build_handler
17
20
  app = build_app(root: @root, index_filenames: @index_filenames)
21
+ start_watcher if @live
18
22
 
19
23
  url = "http://#{@host}:#{@port}/"
20
24
  puts "View the site at #{url}"
@@ -30,6 +34,12 @@ module Adsf
30
34
 
31
35
  private
32
36
 
37
+ def start_watcher
38
+ require 'adsf/live'
39
+
40
+ ::Adsf::Live::Watcher.new(root_dir: File.absolute_path(@root)).tap(&:start)
41
+ end
42
+
33
43
  def wait_for_stop_async(server)
34
44
  Thread.new { wait_for_stop(server) }
35
45
  end
@@ -40,6 +50,8 @@ module Adsf
40
50
  end
41
51
 
42
52
  def build_app(root:, index_filenames:)
53
+ is_live = @live
54
+
43
55
  ::Rack::Builder.new do
44
56
  use ::Rack::CommonLogger
45
57
  use ::Rack::ShowExceptions
@@ -50,6 +62,11 @@ module Adsf
50
62
  root: root,
51
63
  index_filenames: index_filenames
52
64
 
65
+ if is_live
66
+ require 'adsf/live'
67
+ use ::Rack::LiveReload, source: :vendored
68
+ end
69
+
53
70
  run ::Rack::File.new(root)
54
71
  end.to_app
55
72
  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.0'
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.0
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: 2017-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -37,12 +37,8 @@ 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
@@ -60,9 +56,9 @@ require_paths:
60
56
  - lib
61
57
  required_ruby_version: !ruby/object:Gem::Requirement
62
58
  requirements:
63
- - - ">="
59
+ - - "~>"
64
60
  - !ruby/object:Gem::Version
65
- version: 2.2.0
61
+ version: '2.3'
66
62
  required_rubygems_version: !ruby/object:Gem::Requirement
67
63
  requirements:
68
64
  - - ">="
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]