yarrow 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/yarrow/assets/manifest.rb +55 -0
- data/lib/yarrow/assets.rb +2 -1
- data/lib/yarrow/configuration.rb +15 -3
- data/lib/yarrow/defaults.yml +4 -1
- data/lib/yarrow/html/asset_tags.rb +40 -0
- data/lib/yarrow/html/content_tags.rb +7 -0
- data/lib/yarrow/html.rb +1 -0
- data/lib/yarrow/model/base.rb +13 -0
- data/lib/yarrow/model/index.rb +13 -0
- data/lib/yarrow/output/context.rb +24 -0
- data/lib/yarrow/output/generator.rb +43 -0
- data/lib/yarrow/output/mapper.rb +23 -0
- data/lib/yarrow/tools/front_matter.rb +1 -1
- data/lib/yarrow/version.rb +1 -1
- data/lib/yarrow.rb +5 -0
- metadata +26 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjViODEzNDFmNDI5OTgwNjNkODY1YWExMDE4ZTM4YWYzNDQ3ZDJiOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODYwNjY4Y2QxMDYzZjdjZDEwOWMzOWY1ZjdhZGU0ZDBjZThlOWNhMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGI4OWIxZTNjMDc1NWM4NGVlMGIwNGJiYzQwZWI3YTNhOTYxMWY0YWFjMjQy
|
10
|
+
MTlmODlhYmU3YTA5ZjJkNWQ3NTdjYjYzYmI3ZTNjMDc1ZjU3NDA3MDQ5NjY4
|
11
|
+
MzBmZmJlZTNmOTk4N2NmMzE1YjZkMDA4NDQyNDM2YmUxZTU5YzQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTRhZWNjNzcyNjcyM2M4YzkyZmQyNjMxYmMwNDVkMGVlNzYwYzcxMTVkOGYw
|
14
|
+
ZDBiOWY1Mjg4NzNiMjJkMTM2MWE0YzRiYzI4NDIzMzkyMDEzMzJkZGE4YWZl
|
15
|
+
NjEwNGYxN2RhMTQyM2UxZWU5ZTI3NjVkMzA2ODVlYTRlNzA5OGE=
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# TODO: where else is this used?
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Yarrow
|
5
|
+
module Assets
|
6
|
+
|
7
|
+
##
|
8
|
+
# Provides access to the bundle of compiled CSS and JS assets.
|
9
|
+
#
|
10
|
+
class Manifest
|
11
|
+
|
12
|
+
def initialize(config)
|
13
|
+
if config[:output_dir] && config[:manifest_path]
|
14
|
+
manifest_path = [config[:output_dir], config[:manifest_path]].join('/')
|
15
|
+
else
|
16
|
+
manifest_path = './manifest.json'
|
17
|
+
end
|
18
|
+
|
19
|
+
if File.exists?(manifest_path)
|
20
|
+
@manifest_index = JSON.parse(File.read(manifest_path))
|
21
|
+
else
|
22
|
+
@manifest_index = {
|
23
|
+
'assets' => {},
|
24
|
+
'files' => {}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def exists?(logical_path)
|
30
|
+
@manifest_index['assets'].key? logical_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def digest_path(logical_path)
|
34
|
+
@manifest_index['assets'][logical_path]
|
35
|
+
end
|
36
|
+
|
37
|
+
def file(logical_path)
|
38
|
+
@manifest_index['files'][digest_path(logical_path)]
|
39
|
+
end
|
40
|
+
|
41
|
+
def logical_paths
|
42
|
+
@manifest_index['assets'].keys
|
43
|
+
end
|
44
|
+
|
45
|
+
def digest_paths
|
46
|
+
@manifest_index['files'].keys
|
47
|
+
end
|
48
|
+
|
49
|
+
def files
|
50
|
+
@manifest_index['files'].values
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/yarrow/assets.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'assets/pipeline'
|
2
|
+
require_relative 'assets/manifest'
|
data/lib/yarrow/configuration.rb
CHANGED
@@ -1,9 +1,21 @@
|
|
1
1
|
module Yarrow
|
2
2
|
class Configuration < Hashie::Mash
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def instance
|
7
|
+
@@configuration || Hashie::Mash.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def register(file)
|
11
|
+
@@configuration = self.load(file)
|
12
|
+
end
|
13
|
+
|
14
|
+
def load(file)
|
15
|
+
configuration = self.new(YAML.load_file(file))
|
16
|
+
configuration
|
17
|
+
end
|
18
|
+
|
7
19
|
end
|
8
20
|
|
9
21
|
end
|
data/lib/yarrow/defaults.yml
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Yarrow
|
2
|
+
module HTML
|
3
|
+
module AssetTags
|
4
|
+
|
5
|
+
# TODO: make sprockets manifest optional/pluggable
|
6
|
+
def manifest
|
7
|
+
Yarrow::Assets::Manifest.new(config || {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def all_script_tags
|
11
|
+
out = []
|
12
|
+
manifest.digest_paths.each do |asset|
|
13
|
+
out << script_tag(:asset => asset)
|
14
|
+
end
|
15
|
+
out.join["\n"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def script_tag(options)
|
19
|
+
if options.has_key? :asset and manifest.exists?(options[:asset])
|
20
|
+
src_path = manifest.digest_path(options[:asset])
|
21
|
+
else
|
22
|
+
src_path = options[:src]
|
23
|
+
end
|
24
|
+
|
25
|
+
"<script src=\"#{src_path}\"></script>"
|
26
|
+
end
|
27
|
+
|
28
|
+
def link_tag(options)
|
29
|
+
if options.has_key? :asset and manifest.exists?(options[:asset])
|
30
|
+
href_path = manifest.digest_path(options[:asset])
|
31
|
+
else
|
32
|
+
href_path = options[:href]
|
33
|
+
end
|
34
|
+
|
35
|
+
"<link href=\"#{href_path}\" rel=\"stylesheet\" type=\"text/css\">"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/yarrow/html.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'html/asset_tags'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "active_support/inflector"
|
2
|
+
|
3
|
+
module Yarrow
|
4
|
+
module Model
|
5
|
+
class Index
|
6
|
+
def self.register(klass)
|
7
|
+
method_name = ActiveSupport::Inflector.pluralize(ActiveSupport::Inflector.underscore(klass.to_s)).to_sym
|
8
|
+
puts method_name
|
9
|
+
define_singleton_method method_name, lambda { klass.all }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Yarrow
|
2
|
+
module Output
|
3
|
+
|
4
|
+
##
|
5
|
+
# Provides a data context for rendering a template.
|
6
|
+
#
|
7
|
+
# Methods provided by this class become available as named variables in Mustache templates.
|
8
|
+
#
|
9
|
+
# Includes the library of helpers for dynamically generating HTML tags.
|
10
|
+
#
|
11
|
+
class Context
|
12
|
+
|
13
|
+
include Yarrow::HTML::AssetTags
|
14
|
+
|
15
|
+
def initialize(attributes)
|
16
|
+
metaclass = class << self; self; end
|
17
|
+
attributes.each do |name, value|
|
18
|
+
metaclass.send :define_method, name, lambda { value }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Yarrow
|
2
|
+
module Output
|
3
|
+
# Generates documentation from an object model.
|
4
|
+
class Generator
|
5
|
+
def initialize(config={})
|
6
|
+
@config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
# Mapping between template types and provided object model
|
10
|
+
def object_map
|
11
|
+
@config.output.object_map
|
12
|
+
end
|
13
|
+
|
14
|
+
# Mapping between template types and provided output templates.
|
15
|
+
def template_map
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
# Template converter used by this generator instance.
|
20
|
+
def converter
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def write_output_file(filename, content)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Builds the output documentation.
|
28
|
+
def build_docs
|
29
|
+
object_map.each do |index, objects|
|
30
|
+
objects.each do |object|
|
31
|
+
template_context = {
|
32
|
+
#:meta => Site
|
33
|
+
index => object
|
34
|
+
}
|
35
|
+
content = converter.render(template_map[index], template_context)
|
36
|
+
filename = converter.filename_for(object)
|
37
|
+
write_output_file(filename, content)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Yarrow
|
2
|
+
module Output
|
3
|
+
class Mapper
|
4
|
+
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
def object_map
|
10
|
+
@config.output.object_map
|
11
|
+
end
|
12
|
+
|
13
|
+
def template_map
|
14
|
+
@config.output.template_map
|
15
|
+
end
|
16
|
+
|
17
|
+
def model
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/yarrow/version.rb
CHANGED
data/lib/yarrow.rb
CHANGED
@@ -6,8 +6,13 @@ require_relative "yarrow/logging"
|
|
6
6
|
require_relative "yarrow/configuration"
|
7
7
|
require_relative "yarrow/console_runner"
|
8
8
|
require_relative "yarrow/generator"
|
9
|
+
require_relative "yarrow/model/index"
|
10
|
+
require_relative "yarrow/model/base"
|
11
|
+
require_relative "yarrow/output/mapper"
|
12
|
+
require_relative "yarrow/output/generator"
|
9
13
|
require_relative "yarrow/content_map"
|
10
14
|
require_relative "yarrow/assets"
|
15
|
+
require_relative "yarrow/html"
|
11
16
|
require_relative "yarrow/tools/front_matter"
|
12
17
|
|
13
18
|
# Dir[File.dirname(__FILE__) + "/yarrow/generators/*.rb"].each do |generator|
|
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,7 +109,7 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
description: Yarrow is a tool for generating well structured documentation from a
|
98
|
-
variety of input
|
112
|
+
variety of input sources.
|
99
113
|
email: me@maetl.net
|
100
114
|
executables:
|
101
115
|
- yarrow
|
@@ -103,6 +117,7 @@ extensions: []
|
|
103
117
|
extra_rdoc_files: []
|
104
118
|
files:
|
105
119
|
- bin/yarrow
|
120
|
+
- lib/yarrow/assets/manifest.rb
|
106
121
|
- lib/yarrow/assets/pipeline.rb
|
107
122
|
- lib/yarrow/assets.rb
|
108
123
|
- lib/yarrow/configuration.rb
|
@@ -110,7 +125,15 @@ files:
|
|
110
125
|
- lib/yarrow/content_map.rb
|
111
126
|
- lib/yarrow/defaults.yml
|
112
127
|
- lib/yarrow/generator.rb
|
128
|
+
- lib/yarrow/html/asset_tags.rb
|
129
|
+
- lib/yarrow/html/content_tags.rb
|
130
|
+
- lib/yarrow/html.rb
|
113
131
|
- lib/yarrow/logging.rb
|
132
|
+
- lib/yarrow/model/base.rb
|
133
|
+
- lib/yarrow/model/index.rb
|
134
|
+
- lib/yarrow/output/context.rb
|
135
|
+
- lib/yarrow/output/generator.rb
|
136
|
+
- lib/yarrow/output/mapper.rb
|
114
137
|
- lib/yarrow/tools/front_matter.rb
|
115
138
|
- lib/yarrow/version.rb
|
116
139
|
- lib/yarrow.rb
|