stashify 1.0.3 → 1.0.5

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: e973c2f24b46e43537a97ef45788e7d01857acee21951387431256dd5c78e5ab
4
- data.tar.gz: 5f5ec864ba95d82d669fc0682ecf7b57f248926eb7dd0599a2e7d07e9ed7f58a
3
+ metadata.gz: 86e630e47b96968aa141bde2d9d3375c02ca8384a762700e3bbac3bd00ca77c5
4
+ data.tar.gz: 85e2e7c64db43516d71934fab8a77f0d7becbc870170a7288979823bb0519a88
5
5
  SHA512:
6
- metadata.gz: 3c48b8022c40151ead151db9cca51ae45cde5d8f921d17e544b46c3a90418818025d1fbf8748dd09f9814432d0b8e4b4cb75a555d400cc22980dd37208edd873
7
- data.tar.gz: bb9c80f96a94b1484d4eb22627c11f5331b68e24765549ec95e1680cec022a80d87858bd11e2bcd17140c8ade63f18f19cf937d79c19010b770c74a00d9cefc3
6
+ metadata.gz: 8fec69068fb61f01f2bf0050dbafcf8769bda490b3d9fe9e1929c36c622ddba240e790346eff9cb8dc66a5b9aa6d4c4d27c5237776ec5512435691c402140450
7
+ data.tar.gz: 6552faa0bb0db1920b5629885f02c0827c96a087bfaeb5e3604c8b875aef6d164925feb185159ad9299d230e3d0a23ad200693e41ec33789e079fe2b7db3af85
data/.reek.yml CHANGED
@@ -13,3 +13,7 @@ detectors:
13
13
  FeatureEnvy:
14
14
  exclude:
15
15
  - Stashify::Directory::Local#write
16
+
17
+ ControlParameter:
18
+ exclude:
19
+ - Stashify::Directory#initialize
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stashify (1.0.3)
4
+ stashify (1.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -6,13 +6,6 @@ require "stashify/directory"
6
6
  module Stashify
7
7
  class Directory
8
8
  class Local < Stashify::Directory
9
- attr_reader :path
10
-
11
- def initialize(path)
12
- @path = path
13
- super(name: ::File.basename(path))
14
- end
15
-
16
9
  def write_directory(directory)
17
10
  FileUtils.mkdir(path_of(directory.name))
18
11
  super
@@ -23,40 +16,36 @@ module Stashify
23
16
  end
24
17
 
25
18
  def delete(name)
26
- path = ::File.join(@path, name)
27
- if ::File.directory?(path)
28
- FileUtils.rm_r(path)
19
+ name_path = ::File.join(path, name)
20
+ if ::File.directory?(name_path)
21
+ FileUtils.rm_r(name_path)
29
22
  else
30
- ::File.delete(path)
23
+ ::File.delete(name_path)
31
24
  end
32
25
  end
33
26
 
34
27
  def files
35
- Dir.entries(@path).grep_v(/^[.][.]?$/).map do |file_name|
28
+ Dir.entries(path).grep_v(/^[.][.]?$/).map do |file_name|
36
29
  find(::File.basename(file_name))
37
30
  end
38
31
  end
39
32
 
40
- def ==(other)
41
- @path == other.path
42
- end
43
-
44
33
  private
45
34
 
46
- def directory?(name)
47
- ::File.directory?(path_of(name))
35
+ def file?(name)
36
+ ::File.exist?(path_of(name))
48
37
  end
49
38
 
50
39
  def file(name)
51
40
  Stashify::File::Local.new(path_of(name))
52
41
  end
53
42
 
54
- def directory(name)
55
- Stashify::Directory::Local.new(path_of(name))
43
+ def directory?(name)
44
+ ::File.directory?(path_of(name))
56
45
  end
57
46
 
58
- def path_of(name)
59
- ::File.join(@path, name)
47
+ def directory(name)
48
+ Stashify::Directory::Local.new(path: path_of(name))
60
49
  end
61
50
  end
62
51
  end
@@ -2,17 +2,20 @@
2
2
 
3
3
  module Stashify
4
4
  class Directory
5
- attr_reader :name, :files
5
+ attr_reader :name, :files, :path
6
6
 
7
- def initialize(name:, files: [])
8
- @name = name
7
+ def initialize(name: nil, path: nil, files: [])
8
+ raise StandardError, "name or path must be defined" unless name || path
9
+
10
+ @path = path
11
+ @name = name || ::File.basename(path)
9
12
  @files = files
10
13
  end
11
14
 
12
15
  def find(name)
13
16
  if directory?(name)
14
17
  directory(name)
15
- else
18
+ elsif file?(name)
16
19
  file(name)
17
20
  end
18
21
  end
@@ -29,5 +32,19 @@ module Stashify
29
32
  subdir = self.directory(directory.name)
30
33
  directory.files.each { |file| subdir.write(file) }
31
34
  end
35
+
36
+ def ==(other)
37
+ files == other.files
38
+ end
39
+
40
+ def eql?(other)
41
+ self.class == other.class && name == other.name && path == other.path
42
+ end
43
+
44
+ private
45
+
46
+ def path_of(name)
47
+ ::File.join(path, name)
48
+ end
32
49
  end
33
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stashify
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stashify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lambda Null
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-25 00:00:00.000000000 Z
11
+ date: 2023-03-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Provides an abstraction to various services (local filesystem, S3, etc)
14
14
  email: