jekyll-write-and-commit-changes 0.1.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d11364244720840dee84dc75c1b3e0ff4df4d6dda09bbda344bc4b8249f1d05
4
- data.tar.gz: 0d398ab0f33984e5f20c89114f35ed8ed4eb3b98e26ceb4773430093dfb71509
3
+ metadata.gz: 9584f3c27924752c92b9fa988e06b107050b4cf23db2a518c619e414c1801d92
4
+ data.tar.gz: 324e71a46203e346d4c15470b09a6a13f9b5202dbcc0790111cbd683dc500634
5
5
  SHA512:
6
- metadata.gz: 136a964da322f74fb36f42072accf4f1e2fa4b6a219819432dc7ffbb19e6c1d19dcc2990f26d0de3e8f817258d819e1c7fff2f886837e7aff6999d00ec3652c3
7
- data.tar.gz: 29c48b360a49e1188ff2524ac10ba1aa67b7e3e4ace6b4f07c5f40a05c8468f4f10c96ba44e0545b0163f1d1ae88dd256737060d347b50162206ac993517a331
6
+ metadata.gz: f91a9807a710ad4f2c1db811c880c55a6c60b95c18b67d557b57302a2954de63efdae2f38caaf13d0f5ba6977a23d5e821c1eb778efd37ebd7016342f0f1cca9
7
+ data.tar.gz: d5e0f93391e23cc5e4e437484e8b41a133c2ae9856c99e06f34a8fc5dba639ae217718eda486851a684807639e4955803b58752d152afb30441819abf03c381d
data/README.md CHANGED
@@ -29,6 +29,9 @@ plugins:
29
29
  - jekyll-write-and-commit-changes
30
30
  ```
31
31
 
32
+ If you don't want a post to be saved, add `save: false` to its metadata.
33
+ It's useful on other plugins.
34
+
32
35
  ### Example
33
36
 
34
37
  An ad-hoc plugin at `_plugins/change_something.rb`
@@ -8,7 +8,9 @@ module Jekyll
8
8
  base.class_eval do
9
9
  # Writes changes to the file and adds it to git staged changes
10
10
  def save
11
- Jekyll.logger.debug "Writing #{relative_path}"
11
+ return unless data.fetch('save', true)
12
+
13
+ Jekyll.logger.debug "Writing #{real_path}"
12
14
 
13
15
  file = File.open(path, File::RDWR | File::CREAT, 0o640) do |f|
14
16
  f.flock(File::LOCK_EX)
@@ -22,11 +24,17 @@ module Jekyll
22
24
  f.truncate(f.pos)
23
25
  end
24
26
 
25
- site.staged_files << relative_path if file.zero?
27
+ site.staged_files << real_path if file.zero?
26
28
 
27
29
  file.zero?
28
30
  end
29
31
 
32
+ # Resolves the real path for the document
33
+ # @return [String]
34
+ def real_path
35
+ @real_path ||= Pathname.new(relative_path).realpath.relative_path_from(site.source).to_s
36
+ end
37
+
30
38
  # Prepares the data for dumping, by excluding some keys and
31
39
  # transforming other Documents replaced by jekyll-linked-posts.
32
40
  #
@@ -38,13 +46,19 @@ module Jekyll
38
46
  case value
39
47
  when Jekyll::Document
40
48
  value.data['uuid']
49
+ when Jekyll::Convertible
50
+ value.data['uuid']
51
+ when Set
52
+ value.map do |v|
53
+ v.respond_to?(:data) ? v.data['uuid'] : v
54
+ end
41
55
  when Array
42
56
  value.map do |v|
43
- v.is_a?(Jekyll::Document) ? v.data['uuid'] : v
57
+ v.respond_to?(:data) ? v.data['uuid'] : v
44
58
  end
45
59
  when Hash
46
60
  value.transform_values do |v|
47
- v.is_a?(Jekyll::Document) ? v.data['uuid'] : v
61
+ v.respond_to?(:data) ? v.data['uuid'] : v
48
62
  end
49
63
  else
50
64
  value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-write-and-commit-changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2022-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.1.2
87
+ rubygems_version: 3.3.8
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Write changes to the repository