nanoc-core 4.12.13 → 4.12.14

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: 94f41a5b7ba9b534f61e42a82dc9df7bebed20e7f2aadc6610d6b9523e2a3e8a
4
- data.tar.gz: a40f9d8498cf715052ba691850e0e59c0877c107a7b0973594645ce7548cc289
3
+ metadata.gz: f6002d238861027abd84a4b7499c56f95be1e8bf3dec412eb21051c91c11fcce
4
+ data.tar.gz: 3788262a93f33920e549372a34d5fcacc4a2c6d120d3acf1562499eaaaca0cfb
5
5
  SHA512:
6
- metadata.gz: 9c28483387d092e48b15f568fb910b60aa237dde2c152938ed4e36174ada46f56edbb29742ad7da98e903d5ed44066b40bc0821891ee48b1e1d48ff607d08370
7
- data.tar.gz: b1d14a6cdbb245eb97b7820060406aa545571430214d835110f15d47bd721c49b28a66ee0473130699f4c4be2493cbd8267c81938c4dbc5981b5ce763a3a9437
6
+ metadata.gz: 869cddca22933872511ec0b10d7a09c9d37ff3dd89de4340f88b2d6fcceee725779d0c0dd9e891f2c28e2a25adb6f7a909f378537d8d88bd5a4f128fc76b86de
7
+ data.tar.gz: 208bd267925b4d51df67bd0293fe6f903671089f4899c529fc63cc8d5ecd0130c434662211b2e232e115bb532a2234301c6c44e5b74fff4acfc74e93288d703d
@@ -11,7 +11,7 @@ module Nanoc
11
11
 
12
12
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
13
13
  def initialize(config:)
14
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'rule_memory'), 1)
14
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'rule_memory'), 2)
15
15
 
16
16
  @action_sequences = {}
17
17
  end
@@ -11,7 +11,7 @@ module Nanoc
11
11
 
12
12
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
13
13
  def initialize(config:)
14
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'binary_content'), 2)
14
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'binary_content'), 3)
15
15
 
16
16
  @cache = {}
17
17
  end
@@ -16,7 +16,7 @@ module Nanoc
16
16
 
17
17
  contract C::KeywordArgs[config: Nanoc::Core::Configuration, objects: C::IterOf[c_obj]] => C::Any
18
18
  def initialize(config:, objects:)
19
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'checksums'), 2)
19
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'checksums'), 3)
20
20
 
21
21
  @objects = objects
22
22
 
@@ -42,7 +42,7 @@ module Nanoc
42
42
 
43
43
  contract Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection, Nanoc::Core::Configuration => C::Any
44
44
  def initialize(items, layouts, config)
45
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'dependencies'), 5)
45
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'dependencies'), 6)
46
46
 
47
47
  @config = config
48
48
  @items = items
@@ -8,7 +8,7 @@ module Nanoc
8
8
 
9
9
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
10
10
  def initialize(config:)
11
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'outdatedness'), 1)
11
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'outdatedness'), 2)
12
12
 
13
13
  @outdated_refs = Set.new
14
14
  end
@@ -128,12 +128,16 @@ module Nanoc
128
128
  self.data = read_obj_from_file(data_filename)
129
129
  end
130
130
 
131
- def write_obj_to_file(fn, obj)
132
- File.binwrite(fn, Marshal.dump(obj))
131
+ def write_obj_to_file(filename, obj)
132
+ data = Marshal.dump(obj)
133
+ compressed_data = Zlib::Deflate.deflate(data, Zlib::BEST_SPEED)
134
+ write_data_to_file(filename, compressed_data)
133
135
  end
134
136
 
135
137
  def read_obj_from_file(fn)
136
- Marshal.load(File.binread(fn))
138
+ compressed_data = File.binread(fn)
139
+ data = Zlib::Inflate.inflate(compressed_data)
140
+ Marshal.load(data)
137
141
  end
138
142
 
139
143
  def version_filename
@@ -143,6 +147,28 @@ module Nanoc
143
147
  def data_filename
144
148
  "#{filename}.data.db"
145
149
  end
150
+
151
+ def write_data_to_file(filename, data)
152
+ basename = File.basename(filename)
153
+ dirname = File.dirname(filename)
154
+
155
+ # Write to a temporary file first, and then (atomically) move it into
156
+ # place.
157
+ Tempfile.open(".#{basename}", dirname) do |temp_file|
158
+ temp_file.binmode
159
+
160
+ # Write the data as a stream, because File.binwrite can’t
161
+ # necessarily deal with writing that much data all at once.
162
+ #
163
+ # See https://github.com/nanoc/nanoc/issues/1635.
164
+ reader = StringIO.new(data)
165
+ IO.copy_stream(reader, temp_file)
166
+ temp_file.close
167
+
168
+ # Rename (atomic)
169
+ File.rename(temp_file.path, filename)
170
+ end
171
+ end
146
172
  end
147
173
  end
148
174
  end
@@ -11,7 +11,7 @@ module Nanoc
11
11
 
12
12
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
13
13
  def initialize(config:)
14
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'compiled_content'), 3)
14
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'compiled_content'), 4)
15
15
 
16
16
  @cache = {}
17
17
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.12.13'
5
+ VERSION = '4.12.14'
6
6
  end
7
7
  end
data/lib/nanoc/core.rb CHANGED
@@ -7,6 +7,7 @@ require 'pstore'
7
7
  require 'singleton'
8
8
  require 'tmpdir'
9
9
  require 'yaml'
10
+ require 'zlib'
10
11
 
11
12
  # External gems
12
13
  require 'concurrent-ruby'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.13
4
+ version: 4.12.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-30 00:00:00.000000000 Z
11
+ date: 2022-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby