yass 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 +4 -4
- data/lib/yass/cli/helpers.rb +5 -3
- data/lib/yass/config.rb +1 -1
- data/lib/yass/generator.rb +8 -1
- data/lib/yass/liquid_template.rb +3 -3
- data/lib/yass/source.rb +9 -11
- data/lib/yass/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 664e04a8abbd128da8902e65d83a0ed305010982f18e30d24c08571ee70cd9d0
|
4
|
+
data.tar.gz: 3c1f2151246b638cdc23bb340abef6ae3136adc677fa4abd1f0a3e374fcfbd78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07c5522d3aa8e206d3fb49681378ec00e41b7009583ab245d905658927111a8f09f424a4915564967ee9a93bab225ed0ef78100b695bb23c7432b053d4117a3e
|
7
|
+
data.tar.gz: 0ba17529c477f1755e9e11a2976c44bd2155e8639ed205062b4a78e0057c30efe82f254f1af29efe9d5a546826953712653f641c35c2d84ba590055304b21860
|
data/lib/yass/cli/helpers.rb
CHANGED
@@ -33,7 +33,7 @@ module Yass
|
|
33
33
|
def self.option_parser(config)
|
34
34
|
OptionParser.new { |opts|
|
35
35
|
opts.banner = %(
|
36
|
-
Yet Another Static Site (generator)
|
36
|
+
Yet Another Static Site (generator) v#{VERSION}
|
37
37
|
|
38
38
|
yass <command> [options] [path/to/dir]
|
39
39
|
|
@@ -50,8 +50,9 @@ yass <command> [options] [path/to/dir]
|
|
50
50
|
|
51
51
|
Options:
|
52
52
|
).strip
|
53
|
-
opts.on("--
|
54
|
-
opts.on("--
|
53
|
+
opts.on("--clean", "Remove unknown files from dist/ when bulding") { config.clean = true }
|
54
|
+
opts.on("--local", "Build in local mode (with links to /index.html's)") { config.local = true }
|
55
|
+
opts.on("--debug", "Print stack traces") { config.debug = true }
|
55
56
|
opts.on("-h", "--help", "Prints this help") { config.stdout.puts opts; exit }
|
56
57
|
}
|
57
58
|
end
|
@@ -63,6 +64,7 @@ yass <command> [options] [path/to/dir]
|
|
63
64
|
layouts: "layouts",
|
64
65
|
templates: "templates",
|
65
66
|
dest: "dist",
|
67
|
+
clean: false,
|
66
68
|
local: false,
|
67
69
|
stdin: $stdin,
|
68
70
|
stdout: $stdout,
|
data/lib/yass/config.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Yass
|
2
|
-
Config = Struct.new(:root, :src, :dest, :layouts, :templates, :local, :stdin, :stdout, :stderr, :debug, keyword_init: true) do
|
2
|
+
Config = Struct.new(:root, :src, :dest, :layouts, :templates, :clean, :local, :stdin, :stdout, :stderr, :debug, keyword_init: true) do
|
3
3
|
def src_dir = root.join src
|
4
4
|
def dest_dir = root.join dest
|
5
5
|
def template_dir = root.join templates
|
data/lib/yass/generator.rb
CHANGED
@@ -19,6 +19,7 @@ module Yass
|
|
19
19
|
FileUtils.cp(source.path, outfile)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
clean if config.clean
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
@@ -36,10 +37,16 @@ module Yass
|
|
36
37
|
return outfile, content if source.layout.nil?
|
37
38
|
|
38
39
|
page = source.layout.render(source) { content }
|
39
|
-
return outfile.dirname.join(source.
|
40
|
+
return outfile.dirname.join(source.dest_path.basename), page
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
44
|
+
def clean
|
45
|
+
expected_files = config.sources.map { |s| config.dest_dir.join(s.dest_path).to_s }
|
46
|
+
actual_files = Dir[config.dest_dir.join("**/*")].reject { |p| Dir.exist? p }
|
47
|
+
(actual_files - expected_files).each { |f| FileUtils.rm f }
|
48
|
+
end
|
49
|
+
|
43
50
|
def dest_dirs
|
44
51
|
config.sources.map { |s| config.dest_dir.join(s.relative_path).dirname }.uniq
|
45
52
|
end
|
data/lib/yass/liquid_template.rb
CHANGED
@@ -29,11 +29,11 @@ module Yass
|
|
29
29
|
{
|
30
30
|
"title" => source.title,
|
31
31
|
"url" => source.url.to_s,
|
32
|
-
"path" => source.
|
32
|
+
"path" => source.dest_path.to_s,
|
33
33
|
"src_path" => source.relative_path.to_s,
|
34
34
|
"dirname" => source.relative_path.dirname.to_s,
|
35
|
-
"filename" => source.
|
36
|
-
"extname" => source.
|
35
|
+
"filename" => source.dest_path.basename.to_s,
|
36
|
+
"extname" => source.dest_path.basename.extname,
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
data/lib/yass/source.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
module Yass
|
2
2
|
class Source
|
3
3
|
EXT_CONVERSIONS = {"md" => "html"}.freeze
|
4
|
-
attr_reader :config, :path, :layout, :relative_path, :
|
4
|
+
attr_reader :config, :path, :layout, :relative_path, :dest_path
|
5
5
|
|
6
6
|
def initialize(config, path)
|
7
7
|
@config = config
|
8
8
|
@path = path
|
9
9
|
@relative_path = path.relative_path_from config.src_dir
|
10
|
-
|
10
|
+
dest_filename, @layout= parse_name
|
11
|
+
@dest_path = relative_path.dirname.join(dest_filename)
|
11
12
|
end
|
12
13
|
|
13
|
-
def url
|
14
|
-
url = relative_path.dirname.join(rendered_filename)
|
15
|
-
index? && !config.local ? url.dirname : url
|
16
|
-
end
|
14
|
+
def url = index? && !config.local ? dest_path.dirname : dest_path
|
17
15
|
|
18
16
|
def title
|
19
|
-
fname =
|
17
|
+
fname = dest_path.basename.sub(/\..+$/, "").to_s
|
20
18
|
fname = relative_path.dirname.basename.to_s if fname == "index"
|
21
19
|
fname = "Home" if fname == "."
|
22
20
|
fname.sub(/[_-]+/, " ").split(/ +/).map(&:capitalize).join(" ")
|
@@ -24,21 +22,21 @@ module Yass
|
|
24
22
|
|
25
23
|
def dynamic? = !!(/\.(liquid|md)(\..+)?$/ =~ path.basename.to_s || layout)
|
26
24
|
|
27
|
-
def index? =
|
25
|
+
def index? = dest_path.basename.to_s == "index.html"
|
28
26
|
|
29
27
|
private
|
30
28
|
|
31
29
|
def parse_name
|
32
30
|
name, exts = path.basename.to_s.split(".", 2)
|
33
|
-
return
|
31
|
+
return name, nil if exts.nil?
|
34
32
|
|
35
33
|
exts = exts.split(".").map { |x| EXT_CONVERSIONS[x] || x } - %w[liquid]
|
36
|
-
return
|
34
|
+
return "#{name}.#{exts.join "."}", nil if exts.size < 2
|
37
35
|
|
38
36
|
layout = config.layout_cache["#{exts[-2..].join(".")}"]
|
39
37
|
exts.delete_at(-2) if layout
|
40
38
|
|
41
|
-
return
|
39
|
+
return "#{name}.#{exts.join "."}", layout
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
data/lib/yass/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
11
|
+
date: 2025-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filewatcher
|