awestruct-ibeams 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6efd8c9c2adb0cbc709e972e9ac6c1cc4f6802d4
4
- data.tar.gz: c342e9ca8b1e008fe8bb905beebc9c45cb12e5e5
3
+ metadata.gz: 9674b0bea4083541c8880609d66fd4fbd1b7ded7
4
+ data.tar.gz: 8120f7ed5ac0f503ac8c37b27dcfaad8d584685a
5
5
  SHA512:
6
- metadata.gz: 99d3cdb7d7171d39810e701263f59e87fbe98e3a59203eb0b72a87d0485f3c8dda451795b9444cc57fa0ff1a746738b21ce477d648ca8e4c423182c9750f5c3c
7
- data.tar.gz: 706e50e140035860e98d2cb2bde1cd4fa73d0e116a5088bbdb444265981e216c4fcefb642441542eba0f8b4ed7f2c8240611b2e727015d7436e43d6fe34741d9
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
@@ -1,5 +1,5 @@
1
1
  module Awestruct
2
2
  module Ibeams
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.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-04 00:00:00.000000000 Z
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