yarrow 0.3.3 → 0.3.4
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 +4 -4
- data/lib/yarrow/defaults.yml +3 -1
- data/lib/yarrow/server.rb +43 -15
- data/lib/yarrow/tools/output_file.rb +3 -3
- data/lib/yarrow/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc35279dd3d2e8d12c883c813391011aeb64656f
|
4
|
+
data.tar.gz: eb12a310c3fb88687d69e4602a4dbac50d6010d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6d3cc965dcc26c80d564f776f2eeefc8e66e9db8c9bda124c15c2d1dbef2927c523656c6a93092ceaeb5fdc175b9fa3b9796ad7f84eee4444862998bbd8b5b6
|
7
|
+
data.tar.gz: 1b6f155d6b036f0ab25cb002fc83f2c0e82c647aa9520ef7f8c0d70c7b4b02e666d1ec0afa548fbc88d725fa7adf265d5644b978feedea6070a211e5ba50a82e
|
data/lib/yarrow/defaults.yml
CHANGED
@@ -18,6 +18,9 @@ assets:
|
|
18
18
|
- js
|
19
19
|
manifest_file: manifest.json
|
20
20
|
server:
|
21
|
+
auto_index: true
|
22
|
+
default_index: index.html
|
23
|
+
default_type: text/plain
|
21
24
|
port: 8888
|
22
25
|
host: localhost
|
23
26
|
handler: thin
|
@@ -25,4 +28,3 @@ server:
|
|
25
28
|
- Rack::ShowExceptions
|
26
29
|
- Rack::CommonLogger
|
27
30
|
- Rack::ContentLength
|
28
|
-
|
data/lib/yarrow/server.rb
CHANGED
@@ -43,16 +43,26 @@ module Yarrow
|
|
43
43
|
# @return [Yarrow::Server::StaticFiles]
|
44
44
|
def app
|
45
45
|
root = docroot
|
46
|
-
index =
|
47
|
-
|
46
|
+
index = default_index
|
47
|
+
middleware_stack = middleware_map
|
48
|
+
auto_index = auto_index?
|
49
|
+
mime_type = default_type
|
48
50
|
|
49
51
|
Rack::Builder.new do
|
50
|
-
|
51
|
-
|
52
|
-
use plugin
|
52
|
+
middleware_stack.each do |middleware|
|
53
|
+
use middleware
|
53
54
|
end
|
55
|
+
|
54
56
|
use DirectoryIndex, root: root, index: index
|
55
|
-
|
57
|
+
|
58
|
+
app_args = [root, {}].tap { |args| args.push(mime_type) if mime_type }
|
59
|
+
static_app = Rack::File.new(*app_args)
|
60
|
+
|
61
|
+
if auto_index
|
62
|
+
run Rack::Directory.new(root, static_app)
|
63
|
+
else
|
64
|
+
run static_app
|
65
|
+
end
|
56
66
|
end
|
57
67
|
end
|
58
68
|
|
@@ -63,8 +73,8 @@ module Yarrow
|
|
63
73
|
# provided in the config.
|
64
74
|
#
|
65
75
|
def run
|
66
|
-
server = Rack::Handler.get(
|
67
|
-
server.run(app,
|
76
|
+
server = Rack::Handler.get(run_options[:server])
|
77
|
+
server.run(app, run_options)
|
68
78
|
end
|
69
79
|
|
70
80
|
private
|
@@ -75,19 +85,37 @@ module Yarrow
|
|
75
85
|
config.output_dir || Dir.pwd
|
76
86
|
end
|
77
87
|
|
88
|
+
##
|
89
|
+
# @return [String]
|
90
|
+
def default_index
|
91
|
+
config.server.default_index || 'index.html'
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# @return [TrueClass, FalseClass]
|
96
|
+
def auto_index?
|
97
|
+
return true if config.server.auto_index.nil?
|
98
|
+
config.server.auto_index
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# @return [String]
|
103
|
+
def default_type
|
104
|
+
config.server.default_type
|
105
|
+
end
|
106
|
+
|
78
107
|
##
|
79
108
|
# @return [Array<Class>]
|
80
|
-
def
|
81
|
-
|
82
|
-
|
109
|
+
def middleware_map
|
110
|
+
middleware = config.server.middleware || []
|
111
|
+
middleware.map { |class_name| Kernel.const_get(class_name) }
|
83
112
|
end
|
84
113
|
|
85
114
|
##
|
86
|
-
#
|
87
|
-
# provided by config.
|
115
|
+
# Provides options required by the Rack server on startup.
|
88
116
|
#
|
89
|
-
#
|
90
|
-
def
|
117
|
+
# @return [Hash]
|
118
|
+
def run_options
|
91
119
|
{
|
92
120
|
:Port => config.server.port,
|
93
121
|
:Host => config.server.port,
|
@@ -2,7 +2,7 @@ module Yarrow
|
|
2
2
|
module Tools
|
3
3
|
# TODO: consider renaming this to OutputDocument.
|
4
4
|
class OutputFile
|
5
|
-
include ::Configurable
|
5
|
+
include Yarrow::Configurable
|
6
6
|
|
7
7
|
WRITE_MODE = 'w+:UTF-8'.freeze
|
8
8
|
|
@@ -13,7 +13,7 @@ module Yarrow
|
|
13
13
|
|
14
14
|
# @return [String] Docroot of the output target
|
15
15
|
def docroot
|
16
|
-
@docroot ||= config.output_dir
|
16
|
+
@docroot ||= config.output_dir || 'public'
|
17
17
|
end
|
18
18
|
|
19
19
|
# Write an output file to the specified path under the docroot.
|
@@ -27,7 +27,7 @@ module Yarrow
|
|
27
27
|
path = "#{path}#{index_name}"
|
28
28
|
end
|
29
29
|
|
30
|
-
target_path = Pathname.new("docroot#{path}")
|
30
|
+
target_path = Pathname.new("#{docroot}#{path}")
|
31
31
|
|
32
32
|
FileUtils.mkdir_p(target_path.dirname)
|
33
33
|
|
data/lib/yarrow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yarrow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -208,4 +208,3 @@ signing_key:
|
|
208
208
|
specification_version: 4
|
209
209
|
summary: Documentation generator based on a fluent data model.
|
210
210
|
test_files: []
|
211
|
-
has_rdoc:
|