lifer 0.4.1 → 0.5.1
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/CHANGELOG.md +10 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -3
- data/README.md +17 -0
- data/lib/lifer/builder/html/from_liquid/liquid_env.rb +0 -0
- data/lib/lifer/builder/html.rb +28 -18
- data/lib/lifer/builder/rss.rb +1 -1
- data/lib/lifer/builder/txt.rb +33 -14
- data/lib/lifer/shared.rb +0 -0
- data/lib/lifer/utilities.rb +25 -0
- data/lib/lifer/version.rb +1 -1
- data/lifer.gemspec +7 -6
- metadata +28 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9ccb1942c2bb2b9cc5dafc28700275358f43579761c8039a621b082445da70d
|
|
4
|
+
data.tar.gz: 48e0f8e204cc65fae8f1ddec4d10da85b9b7bb0d2f87a875d57896b54e4c02a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21497c604f22994484a1dfe7fe082052aa2cc07b9fe0bd27161046a346eb465caa6afdd2f1620fc1052b6cce19654523bcdf6371f97ca7d0643122f102079b26
|
|
7
|
+
data.tar.gz: 58f941ae10d2a95157c20c88b4a7c657f3810f783441b09e4093f49008ee267182458387ed6b4e383e383889473d5a6a1fdf5e12d1725dfbb32f1de2e21d2dca
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## Next
|
|
2
2
|
|
|
3
|
+
## v0.5.1
|
|
4
|
+
|
|
5
|
+
Resolved warnings output by `gem build`.
|
|
6
|
+
|
|
7
|
+
## v0.5.0
|
|
8
|
+
|
|
9
|
+
This release refactors all of our builders to use parallelization, meaning that
|
|
10
|
+
`lifer build` process should be faster. It should be much faster for larger
|
|
11
|
+
projects. I'm using the `parallel` gem for parallelization at this time.
|
|
12
|
+
|
|
3
13
|
## v0.4.1
|
|
4
14
|
|
|
5
15
|
Resolves a bug where Liquid templates using the `{% layout %}` tag were not able
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
lifer (0.
|
|
4
|
+
lifer (0.5.1)
|
|
5
5
|
i18n (< 2)
|
|
6
6
|
kramdown (~> 2.4)
|
|
7
7
|
liquid (~> 5.6, < 6)
|
|
8
8
|
listen (< 4)
|
|
9
|
+
parallel (~> 1.26, < 2)
|
|
9
10
|
puma (< 7)
|
|
10
11
|
rack (< 4)
|
|
11
|
-
rss
|
|
12
|
+
rss (< 1)
|
|
12
13
|
|
|
13
14
|
GEM
|
|
14
15
|
remote: https://rubygems.org/
|
|
@@ -83,7 +84,7 @@ GEM
|
|
|
83
84
|
regexp_parser (2.9.2)
|
|
84
85
|
reline (0.5.10)
|
|
85
86
|
io-console (~> 0.5)
|
|
86
|
-
rexml (3.4.
|
|
87
|
+
rexml (3.4.1)
|
|
87
88
|
rspec (3.13.0)
|
|
88
89
|
rspec-core (~> 3.13.0)
|
|
89
90
|
rspec-expectations (~> 3.13.0)
|
data/README.md
CHANGED
|
@@ -87,6 +87,23 @@ suite can run on your machine:
|
|
|
87
87
|
$ bundle install
|
|
88
88
|
$ bundle exec rspec
|
|
89
89
|
|
|
90
|
+
### Releases
|
|
91
|
+
|
|
92
|
+
We use the Bump gem to manage releases. Before releasing a version of Lifer:
|
|
93
|
+
|
|
94
|
+
1. Ensure unreleased changes have entries in the CHANGELOG file.
|
|
95
|
+
2. Ensure all tests pass locally.
|
|
96
|
+
|
|
97
|
+
Then use Bump to perform release chores and create a version tag:
|
|
98
|
+
|
|
99
|
+
$ bundle exec bump <minor|patch> --tag --changelog --edit-changelog
|
|
100
|
+
$ git push origin <new_version>
|
|
101
|
+
$ gem build
|
|
102
|
+
$ gem push lifer-<new_version_without_the_v_prefix>.gem
|
|
103
|
+
|
|
104
|
+
(Where `new_version` is the version you intend to release. For example:
|
|
105
|
+
`v1.2.3`.)
|
|
106
|
+
|
|
90
107
|
## Contributing
|
|
91
108
|
|
|
92
109
|
I'm not currently accepting unsolicited contributions to Lifer. I'm still
|
|
File without changes
|
data/lib/lifer/builder/html.rb
CHANGED
|
@@ -54,12 +54,8 @@ class Lifer::Builder::HTML < Lifer::Builder
|
|
|
54
54
|
# @return [void]
|
|
55
55
|
def execute
|
|
56
56
|
Lifer.collections(without_selections: true).each do |collection|
|
|
57
|
-
collection
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
generate_output_directories_for entry
|
|
61
|
-
generate_output_file_for entry
|
|
62
|
-
end
|
|
57
|
+
generate_output_directories_for collection
|
|
58
|
+
generate_output_entries_for collection
|
|
63
59
|
end
|
|
64
60
|
end
|
|
65
61
|
|
|
@@ -75,24 +71,39 @@ class Lifer::Builder::HTML < Lifer::Builder
|
|
|
75
71
|
end
|
|
76
72
|
|
|
77
73
|
# @private
|
|
78
|
-
# For the given
|
|
79
|
-
# can be safely written to.
|
|
74
|
+
# For the given collection, ensure all required directories and
|
|
75
|
+
# subdirectories exist so the entry output can be safely written to.
|
|
80
76
|
#
|
|
81
|
-
# @param entry [Lifer::
|
|
82
|
-
# @return [
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
# @param entry [Lifer::Collection] A collection.
|
|
78
|
+
# @return [void]
|
|
79
|
+
def generate_output_directories_for(collection)
|
|
80
|
+
directories = collection.entries
|
|
81
|
+
.map { |entry| File.dirname(output_file entry) }
|
|
82
|
+
.uniq
|
|
83
|
+
|
|
84
|
+
Lifer::Utilities.parallelized(directories) do |directory|
|
|
85
|
+
FileUtils.mkdir_p directory unless Dir.exist?(directory)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def generate_output_entries_for(collection)
|
|
90
|
+
Lifer::Utilities.parallelized(collection.entries) do |entry|
|
|
91
|
+
generate_output_file_for entry
|
|
92
|
+
end
|
|
87
93
|
end
|
|
88
94
|
|
|
89
95
|
# @private
|
|
90
96
|
# For the given entry, generate the production entry.
|
|
91
97
|
#
|
|
92
98
|
# @param entry [Lifer::Entry] An entry.
|
|
93
|
-
# @
|
|
94
|
-
#
|
|
99
|
+
# @raise [StandardError] If the file already exists, we kill the program. The
|
|
100
|
+
# end user needs to ensure there are no entry conflicts.
|
|
101
|
+
# @return [Integer, NilClass] The length of the written file, or nil if the
|
|
102
|
+
# entry cannot be output to HTML. We should not care about this return
|
|
103
|
+
# value.
|
|
95
104
|
def generate_output_file_for(entry)
|
|
105
|
+
return unless entry.class.output_extension == :html
|
|
106
|
+
|
|
96
107
|
relative_path = output_file entry
|
|
97
108
|
absolute_path = File.join(Lifer.output_directory, relative_path)
|
|
98
109
|
|
|
@@ -117,12 +128,11 @@ class Lifer::Builder::HTML < Lifer::Builder
|
|
|
117
128
|
when /.*\.liquid$/ then FromLiquid
|
|
118
129
|
else
|
|
119
130
|
file = entry.collection.setting(:layout_file)
|
|
120
|
-
|
|
131
|
+
raise I18n.t(
|
|
121
132
|
"builder.html.no_builder_error",
|
|
122
133
|
file:,
|
|
123
134
|
type: File.extname(file)
|
|
124
135
|
)
|
|
125
|
-
exit
|
|
126
136
|
end
|
|
127
137
|
end
|
|
128
138
|
|
data/lib/lifer/builder/rss.rb
CHANGED
|
@@ -27,7 +27,7 @@ class Lifer::Builder::RSS < Lifer::Builder
|
|
|
27
27
|
#
|
|
28
28
|
# @return [void]
|
|
29
29
|
def execute
|
|
30
|
-
|
|
30
|
+
Lifer::Utilities.parallelized collections_with_feeds do |collection|
|
|
31
31
|
next unless (filename = output_filename(collection))
|
|
32
32
|
|
|
33
33
|
FileUtils.mkdir_p File.dirname(filename)
|
data/lib/lifer/builder/txt.rb
CHANGED
|
@@ -26,20 +26,8 @@ class Lifer::Builder::TXT < Lifer::Builder
|
|
|
26
26
|
# @return [void]
|
|
27
27
|
def execute
|
|
28
28
|
Lifer.collections(without_selections: true).each do |collection|
|
|
29
|
-
collection
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
relative_path = output_file entry
|
|
33
|
-
absolute_path = File.join(Lifer.output_directory, relative_path)
|
|
34
|
-
|
|
35
|
-
FileUtils.mkdir_p File.dirname(relative_path)
|
|
36
|
-
|
|
37
|
-
if File.exist?(absolute_path)
|
|
38
|
-
raise I18n.t("builder.file_conflict_error", path: absolute_path)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
File.open(relative_path, "w") { |file| file.write entry.full_text }
|
|
42
|
-
end
|
|
29
|
+
generate_output_directories_for collection
|
|
30
|
+
generate_output_entries_for collection
|
|
43
31
|
end
|
|
44
32
|
end
|
|
45
33
|
|
|
@@ -51,6 +39,37 @@ class Lifer::Builder::TXT < Lifer::Builder
|
|
|
51
39
|
@root = root
|
|
52
40
|
end
|
|
53
41
|
|
|
42
|
+
def generate_output_directories_for(collection)
|
|
43
|
+
directories = collection.entries
|
|
44
|
+
.map { |entry| File.dirname(output_file entry) }
|
|
45
|
+
.uniq
|
|
46
|
+
|
|
47
|
+
Lifer::Utilities.parallelized(directories) do |directory|
|
|
48
|
+
FileUtils.mkdir_p directory unless Dir.exist?(directory)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def generate_output_entries_for(collection)
|
|
53
|
+
Lifer::Utilities.parallelized(collection.entries) do |entry|
|
|
54
|
+
generate_output_file_for entry
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def generate_output_file_for(entry)
|
|
59
|
+
return unless entry.class.output_extension == :txt
|
|
60
|
+
|
|
61
|
+
relative_path = output_file entry
|
|
62
|
+
absolute_path = File.join(Lifer.output_directory, relative_path)
|
|
63
|
+
|
|
64
|
+
FileUtils.mkdir_p File.dirname(relative_path)
|
|
65
|
+
|
|
66
|
+
if File.exist?(absolute_path)
|
|
67
|
+
raise I18n.t("builder.file_conflict_error", path: absolute_path)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
File.open(relative_path, "w") { |file| file.write entry.full_text }
|
|
71
|
+
end
|
|
72
|
+
|
|
54
73
|
def output_file(entry)
|
|
55
74
|
Lifer::URIStrategy
|
|
56
75
|
.find(entry.collection.setting :uri_strategy)
|
data/lib/lifer/shared.rb
CHANGED
|
File without changes
|
data/lib/lifer/utilities.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "parallel"
|
|
2
|
+
|
|
1
3
|
# A module namespace for any weird utilities that are used pseudo-globally.
|
|
2
4
|
# Ensure that these are actually useful globally, though. :-)
|
|
3
5
|
#
|
|
@@ -66,6 +68,29 @@ module Lifer::Utilities
|
|
|
66
68
|
# @return [String] The kabab-cased output.
|
|
67
69
|
def handleize(string) = parameterize(string, separator: "-")
|
|
68
70
|
|
|
71
|
+
# Parallelize and fan out a collection of work in child processes. If any of
|
|
72
|
+
# the child processes results in an error, we raise it and halt the program.
|
|
73
|
+
#
|
|
74
|
+
# @param collection [Array] A collection to operate on.
|
|
75
|
+
# @yield [Object] A function to transform each collection item (in
|
|
76
|
+
# parallel).
|
|
77
|
+
# @raise [Exception] Any exception thrown by a child process.
|
|
78
|
+
# @return [Array] The mapped results of the operation.
|
|
79
|
+
def parallelized(collection, &block)
|
|
80
|
+
results = Parallel.map(collection) do |collection_item|
|
|
81
|
+
begin
|
|
82
|
+
yield collection_item
|
|
83
|
+
rescue => error
|
|
84
|
+
error
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
first_error = results.detect { _1.is_a? Exception }
|
|
89
|
+
raise first_error if first_error
|
|
90
|
+
|
|
91
|
+
results
|
|
92
|
+
end
|
|
93
|
+
|
|
69
94
|
# Given a hash, take all of its keys (and sub-keys) and convert them into
|
|
70
95
|
# strings.
|
|
71
96
|
#
|
data/lib/lifer/version.rb
CHANGED
data/lifer.gemspec
CHANGED
|
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
|
|
|
7
7
|
spec.version = Lifer::VERSION
|
|
8
8
|
spec.authors = ["benjamin wil"]
|
|
9
9
|
spec.email = ["benjamin@super.gd"]
|
|
10
|
+
spec.licenses = ["MIT"]
|
|
10
11
|
|
|
11
12
|
spec.summary = "Minimal static weblog generator."
|
|
12
13
|
spec.description = "Minimal static weblog generator. Good RSS feeds."
|
|
@@ -15,8 +16,10 @@ Gem::Specification.new do |spec|
|
|
|
15
16
|
|
|
16
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
17
18
|
|
|
18
|
-
spec.metadata["homepage_uri"] =
|
|
19
|
-
|
|
19
|
+
spec.metadata["homepage_uri"] =
|
|
20
|
+
"%s/blob/%s/README.md" % [spec.homepage, Lifer::VERSION]
|
|
21
|
+
spec.metadata["source_code_uri"] =
|
|
22
|
+
"%s/tree/%s" % [spec.homepage, Lifer::VERSION]
|
|
20
23
|
spec.metadata["changelog_uri"] = "%s/blob/main/CHANGELOG.md" % spec.homepage
|
|
21
24
|
|
|
22
25
|
# Specify which files should be added to the gem when it is released. The
|
|
@@ -37,10 +40,8 @@ Gem::Specification.new do |spec|
|
|
|
37
40
|
spec.add_dependency "kramdown", "~> 2.4"
|
|
38
41
|
spec.add_dependency "liquid", ["~> 5.6", "< 6"]
|
|
39
42
|
spec.add_dependency "listen", "< 4"
|
|
43
|
+
spec.add_dependency "parallel", ["~> 1.26", "< 2"]
|
|
40
44
|
spec.add_dependency "puma", "< 7"
|
|
41
45
|
spec.add_dependency "rack", "< 4"
|
|
42
|
-
spec.add_dependency "rss"
|
|
43
|
-
|
|
44
|
-
spec.add_development_dependency "debug"
|
|
45
|
-
spec.add_development_dependency "nokogiri"
|
|
46
|
+
spec.add_dependency "rss", "< 1"
|
|
46
47
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lifer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- benjamin wil
|
|
@@ -73,75 +73,67 @@ dependencies:
|
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
74
|
version: '4'
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
76
|
+
name: parallel
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '1.26'
|
|
79
82
|
- - "<"
|
|
80
83
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
84
|
+
version: '2'
|
|
82
85
|
type: :runtime
|
|
83
86
|
prerelease: false
|
|
84
87
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
88
|
requirements:
|
|
89
|
+
- - "~>"
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '1.26'
|
|
86
92
|
- - "<"
|
|
87
93
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
94
|
+
version: '2'
|
|
89
95
|
- !ruby/object:Gem::Dependency
|
|
90
|
-
name:
|
|
96
|
+
name: puma
|
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
|
92
98
|
requirements:
|
|
93
99
|
- - "<"
|
|
94
100
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
101
|
+
version: '7'
|
|
96
102
|
type: :runtime
|
|
97
103
|
prerelease: false
|
|
98
104
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
105
|
requirements:
|
|
100
106
|
- - "<"
|
|
101
107
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
108
|
+
version: '7'
|
|
103
109
|
- !ruby/object:Gem::Dependency
|
|
104
|
-
name:
|
|
110
|
+
name: rack
|
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
|
106
112
|
requirements:
|
|
107
|
-
- - "
|
|
113
|
+
- - "<"
|
|
108
114
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
115
|
+
version: '4'
|
|
110
116
|
type: :runtime
|
|
111
117
|
prerelease: false
|
|
112
118
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
119
|
requirements:
|
|
114
|
-
- - "
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '0'
|
|
117
|
-
- !ruby/object:Gem::Dependency
|
|
118
|
-
name: debug
|
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - ">="
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '0'
|
|
124
|
-
type: :development
|
|
125
|
-
prerelease: false
|
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - ">="
|
|
120
|
+
- - "<"
|
|
129
121
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '
|
|
122
|
+
version: '4'
|
|
131
123
|
- !ruby/object:Gem::Dependency
|
|
132
|
-
name:
|
|
124
|
+
name: rss
|
|
133
125
|
requirement: !ruby/object:Gem::Requirement
|
|
134
126
|
requirements:
|
|
135
|
-
- - "
|
|
127
|
+
- - "<"
|
|
136
128
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '
|
|
138
|
-
type: :
|
|
129
|
+
version: '1'
|
|
130
|
+
type: :runtime
|
|
139
131
|
prerelease: false
|
|
140
132
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
133
|
requirements:
|
|
142
|
-
- - "
|
|
134
|
+
- - "<"
|
|
143
135
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '
|
|
136
|
+
version: '1'
|
|
145
137
|
description: Minimal static weblog generator. Good RSS feeds.
|
|
146
138
|
email:
|
|
147
139
|
- benjamin@super.gd
|
|
@@ -211,11 +203,12 @@ files:
|
|
|
211
203
|
- lifer.gemspec
|
|
212
204
|
- locales/en.yml
|
|
213
205
|
homepage: https://github.com/benjaminwil/lifer
|
|
214
|
-
licenses:
|
|
206
|
+
licenses:
|
|
207
|
+
- MIT
|
|
215
208
|
metadata:
|
|
216
209
|
allowed_push_host: https://rubygems.org
|
|
217
|
-
homepage_uri: https://github.com/benjaminwil/lifer
|
|
218
|
-
source_code_uri: https://github.com/benjaminwil/lifer
|
|
210
|
+
homepage_uri: https://github.com/benjaminwil/lifer/blob/0.5.1/README.md
|
|
211
|
+
source_code_uri: https://github.com/benjaminwil/lifer/tree/0.5.1
|
|
219
212
|
changelog_uri: https://github.com/benjaminwil/lifer/blob/main/CHANGELOG.md
|
|
220
213
|
post_install_message:
|
|
221
214
|
rdoc_options: []
|