adsf 1.3.0 → 1.3.1

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: 18fe44d3963307d81690a262c5fb57d06fed10e560499dac1fc9f8d1bacd9596
4
- data.tar.gz: dc1fc182824d28cb9d6cf532fe52b2681ba95bd9e3f6508008d70165c4b9a9b7
3
+ metadata.gz: d209e17b4b260c9bc77e4c435a94d51b8b6cf4e0ce7b38a4f77d90bc8bf27fc3
4
+ data.tar.gz: 472632fb8c5f1e29e1fe773b30cc2c6a341c35725e7942546bdaefe7b3326223
5
5
  SHA512:
6
- metadata.gz: 06f8d4b5a752c387cc7b36a1edf4ed00fd934d3201bafcbbffb565da3f6707c75aebe47eb34c408e3ee8be6689a5cf9da424aa93f78b30932885458c433b7529
7
- data.tar.gz: 3679850b8b89c0944ea9267396c3ea90e41e10ac7221aed043990e8e400730ce556b093009bc91afbfafd501e38347253cc6e713146d4eade053511cf7e05e2d
6
+ metadata.gz: cefc44acb68c0f56faaa5495f824b266e2d4267dce825afa950ec61a9b5c2c92c2e4a27dd526cb8e00b0085979e695f61d853bf04c64a41a7ed516657bc7904c
7
+ data.tar.gz: 154c0da23d3c09430e5813a1c613ad6bcdb0530057aa98d0e6b785ce8a59505a1832d63dacd98f1fe9a16a0979f27e95819fc3106546bbcded63c57bec18a6e5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adsf (1.3.0)
4
+ adsf (1.3.1)
5
5
  rack (>= 1.0.0, < 3.0.0)
6
6
 
7
7
  GEM
@@ -24,7 +24,7 @@ GEM
24
24
  ast (~> 2.3)
25
25
  powerpack (0.1.1)
26
26
  rack (2.0.3)
27
- rack-test (0.7.0)
27
+ rack-test (0.8.2)
28
28
  rack (>= 1.0, < 3)
29
29
  rainbow (2.2.2)
30
30
  rake
data/NEWS.md CHANGED
@@ -1,16 +1,22 @@
1
1
  # adsf News
2
2
 
3
+ ## 1.3.1 (2017-11-25)
4
+
5
+ Enhancements:
6
+
7
+ * Added headers for CORS (#9, #12)
8
+
3
9
  ## 1.3.0 (2017-11-19)
4
10
 
5
11
  Features:
6
12
 
7
13
  * Added `Adsf::Server`
8
14
 
9
- ## 1.2.1
15
+ ## 1.2.1 (2016-03-14)
10
16
 
11
17
  * Fixed compatibility with Ruby 2.3.0 (#3) [Vipul Amler]
12
18
 
13
- ## 1.2.0
19
+ ## 1.2.0 (2013-11-29)
14
20
 
15
21
  * Added `--local-only` and `--listen-address` options (#1) [Ed Brannin]
16
22
 
data/README.md CHANGED
@@ -50,6 +50,16 @@ It takes the following options:
50
50
  run Rack::File.new('public')
51
51
  ```
52
52
 
53
+ **Why not use `Rack::Static`?** Rack comes with `Rack::Static`, whose purpose is similar to, but not the same as, `Adsf::Rack::IndexFileFinder`. In particular:
54
+
55
+ * `Adsf::Rack::IndexFileFinder` does not serve files, unlike `Rack::Static`. `IndexFileFinder` only rewrites the incoming request and passes it on (usually to `Rack::File`).
56
+
57
+ * `Adsf::Rack::IndexFileFinder` supports multiple index files, while `Rack::Static` only supports one (you could have multiple `Rack::Static` middlewares, one for each index filenames, though).
58
+
59
+ * `Rack::Static` will report the wrong filename on 404 pages: when requesting a directory without an index file, it will e.g. report “File not found: /index.html” rather than “File not found: /”.
60
+
61
+ * When requesting a directory without specifying the trailing slash, `Adsf::Rack::IndexFileFinder` will redirect to the URL with a trailing slash, unlike `Rack::Static`. This mimics the behavior of typical HTTP servers. For example, when requesting `/foo`, when a `foo` directory exists and it contains `index.html`, `IndexFileFinder` will redirect to `/foo/`.
62
+
53
63
  ### Server
54
64
 
55
65
  `Adsf::Server` runs a web server programmatically. For example:
data/bin/adsf CHANGED
@@ -8,7 +8,7 @@ options = {
8
8
  port: 3000,
9
9
  index_filenames: %w[index.html],
10
10
  root: '.',
11
- host: '0.0.0.0'
11
+ host: '0.0.0.0',
12
12
  }
13
13
 
14
14
  OptionParser.new do |opts|
@@ -4,3 +4,4 @@ module Adsf
4
4
  end
5
5
 
6
6
  require 'adsf/rack/index_file_finder'
7
+ require 'adsf/rack/cors'
@@ -0,0 +1,19 @@
1
+ module Adsf::Rack
2
+ class CORS
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ status, headers, body = *@app.call(env)
9
+
10
+ new_headers =
11
+ headers.merge(
12
+ 'Access-Control-Allow-Origin' => '*',
13
+ 'Access-Control-Allow-Headers' => 'Origin, X-Requested-With, Content-Type, Accept, Range',
14
+ )
15
+
16
+ [status, new_headers, body]
17
+ end
18
+ end
19
+ end
@@ -17,7 +17,7 @@ module Adsf::Rack
17
17
  return [
18
18
  302,
19
19
  { 'Location' => new_path_info, 'Content-Type' => 'text/html' },
20
- ["Redirecting you to #{new_path_info}&hellip;"]
20
+ ["Redirecting you to #{new_path_info}&hellip;"],
21
21
  ]
22
22
  end
23
23
 
@@ -45,6 +45,7 @@ module Adsf
45
45
  use ::Rack::ShowExceptions
46
46
  use ::Rack::Lint
47
47
  use ::Rack::Head
48
+ use Adsf::Rack::CORS
48
49
  use Adsf::Rack::IndexFileFinder,
49
50
  root: root,
50
51
  index_filenames: index_filenames
@@ -1,3 +1,3 @@
1
1
  module Adsf
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.3.1'.freeze
3
3
  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.0
4
+ version: 1.3.1
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-19 00:00:00.000000000 Z
11
+ date: 2017-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -37,7 +37,6 @@ executables:
37
37
  extensions: []
38
38
  extra_rdoc_files: []
39
39
  files:
40
- - ChangeLog
41
40
  - Gemfile
42
41
  - Gemfile.lock
43
42
  - LICENSE
@@ -47,6 +46,7 @@ files:
47
46
  - bin/adsf
48
47
  - lib/adsf.rb
49
48
  - lib/adsf/rack.rb
49
+ - lib/adsf/rack/cors.rb
50
50
  - lib/adsf/rack/index_file_finder.rb
51
51
  - lib/adsf/server.rb
52
52
  - lib/adsf/version.rb
data/ChangeLog DELETED
@@ -1,3 +0,0 @@
1
- For a list of all changes, please see the changelog on the project repository
2
- instead (http://projects.stoneship.org/hg/shared/adsf/shortlog). For release
3
- notes, please see the NEWS file.