yarrow 0.3.0 → 0.3.1
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/bin/yarrow-server +2 -2
- data/lib/yarrow/assets/manifest.rb +6 -6
- data/lib/yarrow/configuration.rb +0 -1
- data/lib/yarrow/console_runner.rb +28 -27
- data/lib/yarrow/server.rb +90 -5
- data/lib/yarrow/version.rb +2 -2
- data/lib/yarrow.rb +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ac7d475a5d695a78ef24f94d64637deae4b2c70
|
4
|
+
data.tar.gz: 243ea4a6f7db3dd7b9f2e414b2d2b6bb9e20963f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 286765ed5b70e517868705c25cc545fa31ff109bcbcd3f727e323be6e858bae8e8c9175f6d536cf422ed523516f9c457e79faaca65414e3ea5155d8a0f992f8a
|
7
|
+
data.tar.gz: 2dc1154778db5e8ffc6656f0af62f1e7604ae0ba2ec0dde0d65fcb75af8ff8a7a796964e6493a21454dca9289d6222396c3a91510f7b4c01e6588fa1cbf2cff2
|
data/bin/yarrow-server
CHANGED
@@ -46,7 +46,7 @@ module Yarrow
|
|
46
46
|
# @param logical_path [String]
|
47
47
|
# @return Boolean
|
48
48
|
def exists?(logical_path)
|
49
|
-
|
49
|
+
@manifest_index['assets'].key? logical_path
|
50
50
|
end
|
51
51
|
|
52
52
|
##
|
@@ -55,7 +55,7 @@ module Yarrow
|
|
55
55
|
# @param logical_path [String]
|
56
56
|
# @return [String]
|
57
57
|
def digest_path(logical_path)
|
58
|
-
|
58
|
+
@manifest_index['assets'][logical_path]
|
59
59
|
end
|
60
60
|
|
61
61
|
##
|
@@ -64,7 +64,7 @@ module Yarrow
|
|
64
64
|
# @param logical_path [String]
|
65
65
|
# @return [Hash]
|
66
66
|
def file(logical_path)
|
67
|
-
|
67
|
+
@manifest_index['files'][digest_path(logical_path)]
|
68
68
|
end
|
69
69
|
|
70
70
|
##
|
@@ -72,7 +72,7 @@ module Yarrow
|
|
72
72
|
#
|
73
73
|
# @return [Array<String>]
|
74
74
|
def logical_paths
|
75
|
-
|
75
|
+
@manifest_index['assets'].keys
|
76
76
|
end
|
77
77
|
|
78
78
|
##
|
@@ -80,7 +80,7 @@ module Yarrow
|
|
80
80
|
#
|
81
81
|
# @return [Array<String>]
|
82
82
|
def digest_paths
|
83
|
-
|
83
|
+
@manifest_index['files'].keys
|
84
84
|
end
|
85
85
|
|
86
86
|
##
|
@@ -88,7 +88,7 @@ module Yarrow
|
|
88
88
|
#
|
89
89
|
# @return [Array<Hash>]
|
90
90
|
def files
|
91
|
-
|
91
|
+
@manifest_index['files'].values
|
92
92
|
end
|
93
93
|
|
94
94
|
##
|
data/lib/yarrow/configuration.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
module Yarrow
|
2
|
-
|
2
|
+
|
3
3
|
class ConsoleRunner
|
4
|
-
|
4
|
+
|
5
5
|
SUCCESS = 0
|
6
6
|
FAILURE = 1
|
7
|
-
|
7
|
+
|
8
8
|
ENABLED_OPTIONS = {
|
9
9
|
:h => :help,
|
10
10
|
:v => :version,
|
11
11
|
:c => :config,
|
12
12
|
:t => :theme,
|
13
13
|
}
|
14
|
-
|
14
|
+
|
15
15
|
ALLOWED_CONFIG_FILES = [
|
16
16
|
'.yarrowdoc',
|
17
17
|
'Yarrowdoc'
|
18
18
|
]
|
19
|
-
|
19
|
+
|
20
20
|
def initialize(arguments, io=STDOUT)
|
21
21
|
@out = io
|
22
22
|
@arguments = arguments
|
@@ -24,11 +24,11 @@ module Yarrow
|
|
24
24
|
@targets = []
|
25
25
|
@config = Configuration.load(File.dirname(__FILE__) + "/defaults.yml")
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def config
|
29
29
|
@config
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def run_application
|
33
33
|
print_header
|
34
34
|
|
@@ -58,7 +58,7 @@ module Yarrow
|
|
58
58
|
FAILURE
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def process_arguments
|
63
63
|
@arguments.each do |arg|
|
64
64
|
if is_option?(arg)
|
@@ -68,7 +68,7 @@ module Yarrow
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
# def load_configuration(path)
|
73
73
|
# ALLOWED_CONFIG_FILES.each do |filename|
|
74
74
|
# config_path = path + '/' + filename
|
@@ -78,9 +78,9 @@ module Yarrow
|
|
78
78
|
# end
|
79
79
|
# end
|
80
80
|
# end
|
81
|
-
|
81
|
+
|
82
82
|
def process_configuration
|
83
|
-
#load_configuration(Dir.pwd)
|
83
|
+
# load_configuration(Dir.pwd)
|
84
84
|
|
85
85
|
# @targets.each do |input_path|
|
86
86
|
# @config.deep_merge! load_configuration(input_path)
|
@@ -93,16 +93,17 @@ module Yarrow
|
|
93
93
|
|
94
94
|
@config.options = @options.to_hash
|
95
95
|
|
96
|
-
#normalize_theme_path
|
96
|
+
# normalize_theme_path
|
97
97
|
|
98
|
-
#theme = @config.options.theme
|
99
|
-
|
98
|
+
# theme = @config.options.theme
|
99
|
+
# @config.append load_configuration(theme)
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
def normalize_theme_path
|
103
|
-
|
103
|
+
|
104
|
+
# noop
|
104
105
|
end
|
105
|
-
|
106
|
+
|
106
107
|
def register_option(raw_option)
|
107
108
|
option = raw_option.gsub(":", "=")
|
108
109
|
if option.include? "="
|
@@ -129,35 +130,35 @@ module Yarrow
|
|
129
130
|
|
130
131
|
raise "Unrecognized option: #{raw_option}"
|
131
132
|
end
|
132
|
-
|
133
|
+
|
133
134
|
def is_option?(argument)
|
134
135
|
argument[0] == "-"
|
135
136
|
end
|
136
|
-
|
137
|
+
|
137
138
|
def has_option?(option)
|
138
139
|
@options.has_key? option
|
139
140
|
end
|
140
|
-
|
141
|
+
|
141
142
|
def run_input_process
|
142
|
-
|
143
|
+
# noop
|
143
144
|
end
|
144
145
|
|
145
146
|
def run_output_process
|
146
|
-
|
147
|
+
# noop
|
147
148
|
end
|
148
|
-
|
149
|
+
|
149
150
|
def print_header
|
150
151
|
@out.puts Yarrow::APP_NAME + " " + Yarrow::VERSION
|
151
152
|
end
|
152
|
-
|
153
|
+
|
153
154
|
def print_footer
|
154
155
|
@out.puts "Content generated at {path}!"
|
155
156
|
end
|
156
|
-
|
157
|
+
|
157
158
|
def print_error(e)
|
158
159
|
@out.puts "Error! " + e.to_s
|
159
160
|
end
|
160
|
-
|
161
|
+
|
161
162
|
def print_help
|
162
163
|
help = <<HELP
|
163
164
|
See http://yarrowdoc.org for more information.
|
@@ -197,4 +198,4 @@ HELP
|
|
197
198
|
|
198
199
|
end
|
199
200
|
|
200
|
-
end
|
201
|
+
end
|
data/lib/yarrow/server.rb
CHANGED
@@ -2,16 +2,101 @@ require 'rack'
|
|
2
2
|
|
3
3
|
module Yarrow
|
4
4
|
##
|
5
|
-
# Little server for
|
5
|
+
# Little web server for browsing local files.
|
6
6
|
class Server
|
7
|
+
include Configurable
|
7
8
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
9
|
+
def initialize
|
10
|
+
if config.server.nil?
|
11
|
+
config.server = default_server_config
|
11
12
|
end
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Rack Middleware for detecting and serving an 'index.html' file
|
17
|
+
# instead of a directory index.
|
18
|
+
#
|
19
|
+
# TODO: Add configurable mapping and media types for README files as an alternative
|
20
|
+
class DirectoryIndex
|
21
|
+
def initialize(app, options={})
|
22
|
+
@app = app
|
23
|
+
@root = options[:root]
|
24
|
+
@index_file = options[:index]
|
25
|
+
end
|
26
|
+
|
27
|
+
def call(env)
|
28
|
+
index_path = ::File.join(@root, Rack::Request.new(env).path.split('/'), @index_file)
|
29
|
+
if ::File.exists?(index_path)
|
30
|
+
return [200, {"Content-Type" => "text/html"}, [::File.read(index_path)]]
|
31
|
+
else
|
32
|
+
@app.call(env)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Builds a Rack application to serve files in the output directory.
|
39
|
+
#
|
40
|
+
# If no output directory is specified, defaults to the current working
|
41
|
+
# directory.
|
42
|
+
#
|
43
|
+
# @return [Yarrow::Server::StaticFiles]
|
44
|
+
def app
|
45
|
+
root = docroot
|
46
|
+
|
47
|
+
Rack::Builder.new do
|
48
|
+
use Rack::ShowExceptions
|
49
|
+
use Rack::CommonLogger
|
50
|
+
use Rack::ContentLength
|
51
|
+
use DirectoryIndex, root: root, index: 'index.html'
|
52
|
+
run Rack::Directory.new(root)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# Starts the server.
|
58
|
+
#
|
59
|
+
# Listens on `localhost:8888` unless `server.host` and `server.port` are
|
60
|
+
# provided in the config.
|
61
|
+
#
|
62
|
+
def run
|
63
|
+
server = Rack::Handler.get(rack_options[:server])
|
64
|
+
server.run(app, rack_options)
|
65
|
+
end
|
12
66
|
|
13
|
-
|
67
|
+
private
|
68
|
+
|
69
|
+
##
|
70
|
+
# @return [String]
|
71
|
+
def docroot
|
72
|
+
config.output_dir || Dir.pwd
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# @return [Hash]
|
77
|
+
def default_server_config
|
78
|
+
{
|
79
|
+
port: 8888,
|
80
|
+
host: 'localhost',
|
81
|
+
handler: :thin
|
82
|
+
}
|
14
83
|
end
|
15
84
|
|
85
|
+
##
|
86
|
+
# Stub to fill in default Rack options that will eventually be
|
87
|
+
# provided by config.
|
88
|
+
#
|
89
|
+
# TODO: remove this and use config.merge to build a single access point
|
90
|
+
def rack_options
|
91
|
+
rack_options = {
|
92
|
+
:Port => config.server.port,
|
93
|
+
:Host => config.server.port,
|
94
|
+
:server => config.server.handler,
|
95
|
+
:daemonize => false,
|
96
|
+
:quiet => false,
|
97
|
+
:warn => true,
|
98
|
+
:debug => true,
|
99
|
+
}
|
100
|
+
end
|
16
101
|
end
|
17
102
|
end
|
data/lib/yarrow/version.rb
CHANGED
data/lib/yarrow.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.1
|
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-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rack-test
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
description: Yarrow is a tool for generating well structured documentation from a
|
140
154
|
variety of input sources.
|
141
155
|
email: me@maetl.net
|
@@ -188,8 +202,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
202
|
version: '0'
|
189
203
|
requirements: []
|
190
204
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
205
|
+
rubygems_version: 2.2.2
|
192
206
|
signing_key:
|
193
207
|
specification_version: 4
|
194
208
|
summary: Documentation generator based on a fluent data model.
|
195
209
|
test_files: []
|
210
|
+
has_rdoc:
|