atomos 0.1.1 → 0.1.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: 0e516ea2ae8f0137457b60e049ec68d0b5747e0575fe59f42c76428e927a4667
4
- data.tar.gz: a335860613caaa9b0b6bf6c9c59dcd3d08f97de2fc4aa1cc80f3aa0f823bdc05
3
+ metadata.gz: 6b6b642bdf041beee0148d33c2ca0af28c9e3a98886a45d9772da527551354fb
4
+ data.tar.gz: 19bd5261c787806e8cf3b833653bc18008ec40b8ce261bcb5798c98df3277e1a
5
5
  SHA512:
6
- metadata.gz: 3859a521d54d27668c6eafff4ed1f2057a38440d37030484031cee76fa808cd4408f84f68f4a1a1d6c682b36c955b2fabdbe87eb70d767028f3fb3c4e668473a
7
- data.tar.gz: c51ab4488e563dad38f6b9446d00c6eb8e21ef8e94a325f0f13f842309adc0fa0b3a306d2cd040104532de604b9fc1084cf733b7952dfc562b728aeb7064d317
6
+ metadata.gz: 57dae199e4896dbc9ad5f26fee36f96310bf5f6647db913ea343fdb03a69e0606631ecf40161a473c764eb603475ac7317631503ee876fa59dcbef0965100808
7
+ data.tar.gz: 1c59ba0f89730e73af035a9720e9d72aa21b94a1ef9a20e85744fcff04d7474e2ad9948b2b7daa7f8155eaf0dd961337d7802b8b2d79b647f34c111a3ac5ab43
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-01-17 16:28:34 -0800 using RuboCop version 0.52.1.
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: 13
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: 6
28
+ # Offense count: 7
29
29
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
30
30
  # URISchemes: http, https
31
31
  Metrics/LineLength:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atomos (0.1.1)
4
+ atomos (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -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: Dir.tmpdir, &block)
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
- require 'tempfile'
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.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-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler