atomos 0.1.1 → 0.1.2
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/.rubocop_todo.yml +3 -3
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/atomos.rb +18 -8
- 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: 6b6b642bdf041beee0148d33c2ca0af28c9e3a98886a45d9772da527551354fb
|
|
4
|
+
data.tar.gz: 19bd5261c787806e8cf3b833653bc18008ec40b8ce261bcb5798c98df3277e1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57dae199e4896dbc9ad5f26fee36f96310bf5f6647db913ea343fdb03a69e0606631ecf40161a473c764eb603475ac7317631503ee876fa59dcbef0965100808
|
|
7
|
+
data.tar.gz: 1c59ba0f89730e73af035a9720e9d72aa21b94a1ef9a20e85744fcff04d7474e2ad9948b2b7daa7f8155eaf0dd961337d7802b8b2d79b647f34c111a3ac5ab43
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2018-
|
|
3
|
+
# on 2018-02-02 08:32:23 -0800 using RuboCop version 0.52.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -16,7 +16,7 @@ Gemspec/RequiredRubyVersion:
|
|
|
16
16
|
# Offense count: 1
|
|
17
17
|
# Configuration parameters: CountComments.
|
|
18
18
|
Metrics/MethodLength:
|
|
19
|
-
Max:
|
|
19
|
+
Max: 14
|
|
20
20
|
|
|
21
21
|
# Offense count: 1
|
|
22
22
|
Style/Documentation:
|
|
@@ -25,7 +25,7 @@ Style/Documentation:
|
|
|
25
25
|
- 'test/**/*'
|
|
26
26
|
- 'lib/atomos.rb'
|
|
27
27
|
|
|
28
|
-
# Offense count:
|
|
28
|
+
# Offense count: 7
|
|
29
29
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
30
30
|
# URISchemes: http, https
|
|
31
31
|
Metrics/LineLength:
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.2
|
data/lib/atomos.rb
CHANGED
|
@@ -5,19 +5,14 @@ require 'atomos/version'
|
|
|
5
5
|
module Atomos
|
|
6
6
|
module_function
|
|
7
7
|
|
|
8
|
-
def atomic_write(dest, contents = nil, tmpdir:
|
|
8
|
+
def atomic_write(dest, contents = nil, tmpdir: nil, &block)
|
|
9
9
|
unless contents.nil? ^ block.nil?
|
|
10
10
|
raise ArgumentError, 'must provide either contents or a block'
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# Ensure the destination is on the same device as tmpdir
|
|
16
|
-
if File.stat(tmpdir).dev != File.stat(File.dirname(dest)).dev
|
|
17
|
-
# If not, use the directory of the destination as the tmpdir.
|
|
18
|
-
tmpdir = File.dirname(dest)
|
|
19
|
-
end
|
|
13
|
+
tmpdir = Atomos.default_tmpdir_for_file(dest, tmpdir)
|
|
20
14
|
|
|
15
|
+
require 'tempfile'
|
|
21
16
|
Tempfile.open(".atomos.#{File.basename(dest)}", tmpdir) do |tmpfile|
|
|
22
17
|
if contents
|
|
23
18
|
tmpfile << contents
|
|
@@ -30,4 +25,19 @@ module Atomos
|
|
|
30
25
|
retval
|
|
31
26
|
end
|
|
32
27
|
end
|
|
28
|
+
|
|
29
|
+
def self.default_tmpdir_for_file(dest, tmpdir)
|
|
30
|
+
tmpdir ||= begin
|
|
31
|
+
require 'tmpdir'
|
|
32
|
+
Dir.tmpdir
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Ensure the destination is on the same device as tmpdir
|
|
36
|
+
if File.stat(tmpdir).dev != File.stat(File.dirname(dest)).dev
|
|
37
|
+
# If not, use the directory of the destination as the tmpdir.
|
|
38
|
+
tmpdir = File.dirname(dest)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
tmpdir
|
|
42
|
+
end
|
|
33
43
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: atomos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Giddins
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|