Skip to content

Commit

Permalink
Update .write_json to use .atomic_write
Browse files Browse the repository at this point in the history
  • Loading branch information
acant committed May 30, 2019
1 parent 004a872 commit 27cfbb2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- :mode and :perm are now aliases for setting permissions on files in all the
related methods (i.e., .write, .write_json, .touch, .append)
- convert SugarUtils::File.write_json to use .atomic_write

## [0.5.0] - 2018-05-01
### Changed
Expand Down
2 changes: 1 addition & 1 deletion lib/sugar_utils/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def self.atomic_write(filename, data, options = {}) # rubocop:disable MethodLeng
#
# @return [void]
def self.write_json(filename, data, options = {})
write(filename, MultiJson.dump(data, pretty: true), options)
atomic_write(filename, MultiJson.dump(data, pretty: true), options)
end

# Append to an existing file, or create the file if it does not exist.
Expand Down
2 changes: 1 addition & 1 deletion spec/sugar_utils/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@
let(:data) { { 'key' => 'value' } }

before do
expect(described_class).to receive(:write).with(
expect(described_class).to receive(:atomic_write).with(
:filename, MultiJson.dump(data, pretty: true), :options
)
end
Expand Down

0 comments on commit 27cfbb2

Please sign in to comment.