awestruct-ibeams 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awestruct/ibeams/datadir.rb +44 -0
- data/lib/awestruct/ibeams/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9674b0bea4083541c8880609d66fd4fbd1b7ded7
|
4
|
+
data.tar.gz: 8120f7ed5ac0f503ac8c37b27dcfaad8d584685a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bc36c699c9843a81a2fd66a0d8fa844623caf57a96ac0c9b2b2e8fc445347a3e93fbdf731eb8718b8ae75b9841eadc9e37987345255bc9405d2cff76724d2b8
|
7
|
+
data.tar.gz: a4567397114a112466e54c6c5c44b8974773224a996a12d8f74925263f53e53f5114d5abdf79975beb5cd333b0ab1501640a45f2b6fa158ac68f3cee12b8f6b0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Awestruct
|
4
|
+
module IBeams
|
5
|
+
# The +DataDir+ extension provided in +Awestruct::IBeams+ is a fork
|
6
|
+
# of the original +Awestruct::Extensions::DataDir+ with some cleaned up
|
7
|
+
# code to generate paths in a more cross-platform manner but to also
|
8
|
+
# support +.yml+ files as native providers of data.
|
9
|
+
#
|
10
|
+
# That is to say, you can create a directory "bar/" which contains +foo.yml+ and
|
11
|
+
# that will be loaded into +site.bar[:foo]+ directly
|
12
|
+
class DataDir
|
13
|
+
DEFAULT_DATADIR = '_data'.freeze
|
14
|
+
|
15
|
+
def initialize(data_dir=DEFAULT_DATADIR)
|
16
|
+
@data_dir = data_dir
|
17
|
+
end
|
18
|
+
|
19
|
+
def watch(watched_dirs)
|
20
|
+
watched_dirs << @data_dir
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute(site)
|
24
|
+
Dir.glob(File.join(site.dir, @datadir, '*')).each do |entry|
|
25
|
+
next unless File.directory? entry
|
26
|
+
data_key = File.basename(entry)
|
27
|
+
data_map = {}
|
28
|
+
Dir.glob(File.join(entry, '*')).each do |chunk|
|
29
|
+
File.basename(chunk) =~ /^([^\.]+)/
|
30
|
+
key = $1.to_sym
|
31
|
+
chunk_page = nil
|
32
|
+
if chunk.end_with?('.yml')
|
33
|
+
chunk_page = YAML.load_file(chunk)
|
34
|
+
else
|
35
|
+
chunk_page = site.engine.load_page(chunk)
|
36
|
+
end
|
37
|
+
data_map[key] = chunk_page
|
38
|
+
end
|
39
|
+
site.send("#{data_key}=", data_map)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awestruct-ibeams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- R. Tyler Croy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awestruct
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- awestruct-ibeams.gemspec
|
40
40
|
- lib/awestruct/ibeams.rb
|
41
41
|
- lib/awestruct/ibeams/asciidoc_sections.rb
|
42
|
+
- lib/awestruct/ibeams/datadir.rb
|
42
43
|
- lib/awestruct/ibeams/debuggable_partial.rb
|
43
44
|
- lib/awestruct/ibeams/errors.rb
|
44
45
|
- lib/awestruct/ibeams/version.rb
|