sew 0.0.2 → 0.0.3
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/sew.rb +15 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e72ba79aa0628e9351f5176043e06dcd84701be3
|
4
|
+
data.tar.gz: fa18e1240f09f18e70ac69ab969e57560b931849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6b867d5f3bf2c7a81b7f8874552116a69e4cad1200b3ebb1b7020624e6cf295d2b86d7687a547a803db96133c5a19b2159b419da263972dd5a37ef825bc7353
|
7
|
+
data.tar.gz: be96cc7faa11a1ece7cf47888441a6677f5e788112efe90d0cb96629b84d6e156ba934cbf36361a583f53b90da6463f04768118ee83cfd8ab028212daecbf4b7
|
data/lib/sew.rb
CHANGED
@@ -6,9 +6,12 @@ require "mote"
|
|
6
6
|
require "yaml"
|
7
7
|
|
8
8
|
class Sew
|
9
|
-
VERSION = "0.0.
|
9
|
+
VERSION = "0.0.3"
|
10
10
|
BUILD_DIR = "build"
|
11
11
|
FILE_REGEX = /\A---\n(.+?)\n---\n(.*)/m
|
12
|
+
PATH_MAP = Hash.new do |hash, key|
|
13
|
+
key == "index" ? "/" : "/%s/" % key.tr(".", "/")
|
14
|
+
end
|
12
15
|
|
13
16
|
def self.version
|
14
17
|
puts VERSION
|
@@ -18,12 +21,14 @@ class Sew
|
|
18
21
|
clean
|
19
22
|
pages = Dir["[^_]*.mote"].map do |template|
|
20
23
|
Hash.new.tap do |page|
|
21
|
-
|
24
|
+
parts = File.basename(template, ".mote").split(".")
|
25
|
+
page[:locale] = parts.pop.intern
|
26
|
+
page[:id] = parts.join(".")
|
22
27
|
frontmatter, page[:body] = File.read(template).match(FILE_REGEX)[1..2]
|
23
28
|
page.merge!(YAML.load(frontmatter))
|
24
|
-
page[:path] =
|
25
|
-
page[:
|
26
|
-
page[:
|
29
|
+
page[:path] = PATH_MAP[(page.delete("path") || page[:id])]
|
30
|
+
page[:destination_dir] = ("./%s/%s" % [BUILD_DIR, page[:locale]]) + page[:path]
|
31
|
+
page[:destination] = page[:destination_dir] + "index.html"
|
27
32
|
end
|
28
33
|
end
|
29
34
|
data = Hash.new.tap do |dat|
|
@@ -39,6 +44,7 @@ class Sew
|
|
39
44
|
file.write context.render(page)
|
40
45
|
end
|
41
46
|
end
|
47
|
+
context.after_build
|
42
48
|
end
|
43
49
|
|
44
50
|
def self.clean
|
@@ -62,7 +68,7 @@ class Sew
|
|
62
68
|
extend Sew::Helper
|
63
69
|
end
|
64
70
|
|
65
|
-
@site= site
|
71
|
+
@site = site
|
66
72
|
end
|
67
73
|
|
68
74
|
def render(page)
|
@@ -84,5 +90,8 @@ class Sew
|
|
84
90
|
mote(File.read(sprintf("%s.mote", template)))
|
85
91
|
end
|
86
92
|
end
|
93
|
+
|
94
|
+
def after_build
|
95
|
+
end
|
87
96
|
end
|
88
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Poots
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mote
|