stashify 1.0.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek.yml +4 -0
- data/Gemfile.lock +1 -1
- data/lib/stashify/directory/local.rb +7 -22
- data/lib/stashify/directory.rb +20 -3
- data/lib/stashify/file/local.rb +1 -6
- data/lib/stashify/file.rb +6 -4
- data/lib/stashify/version.rb +1 -1
- 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: 72261627ef443188786450d298ba1b7223c0297466b7991979ab34aa3b348bff
|
4
|
+
data.tar.gz: 9544398bc63888267cafbb8ead584340fb7b2597a526a8b9e04adf2672fe1c9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e143737520b394cf9e5a652a34cb018f1a351bc9d0fe9ff2b5e6a4a8940f8de6b20e1a33a28ac3d42ab894d885b133fe64ebc2172889feaa70f5298e326407a9
|
7
|
+
data.tar.gz: 73e3b1d0b25a2ed60d0654dadac1b65b8ee44b5359f5100ad2019e81b9fd79dd6660d478edb0d64a22198a3f2f355d7cdf2dd6442da04b022da62edd2653905f
|
data/.reek.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -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,24 +16,20 @@ module Stashify
|
|
23
16
|
end
|
24
17
|
|
25
18
|
def delete(name)
|
26
|
-
|
27
|
-
if ::File.directory?(
|
28
|
-
FileUtils.rm_r(
|
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(
|
23
|
+
::File.delete(name_path)
|
31
24
|
end
|
32
25
|
end
|
33
26
|
|
34
27
|
def files
|
35
|
-
Dir.entries(
|
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
35
|
def file?(name)
|
@@ -48,7 +37,7 @@ module Stashify
|
|
48
37
|
end
|
49
38
|
|
50
39
|
def file(name)
|
51
|
-
Stashify::File::Local.new(path_of(name))
|
40
|
+
Stashify::File::Local.new(path: path_of(name))
|
52
41
|
end
|
53
42
|
|
54
43
|
def directory?(name)
|
@@ -56,11 +45,7 @@ module Stashify
|
|
56
45
|
end
|
57
46
|
|
58
47
|
def directory(name)
|
59
|
-
Stashify::Directory::Local.new(path_of(name))
|
60
|
-
end
|
61
|
-
|
62
|
-
def path_of(name)
|
63
|
-
::File.join(@path, name)
|
48
|
+
Stashify::Directory::Local.new(path: path_of(name))
|
64
49
|
end
|
65
50
|
end
|
66
51
|
end
|
data/lib/stashify/directory.rb
CHANGED
@@ -2,10 +2,13 @@
|
|
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
|
8
|
-
|
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
|
|
@@ -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
|
data/lib/stashify/file/local.rb
CHANGED
@@ -5,13 +5,8 @@ require "stashify/file"
|
|
5
5
|
module Stashify
|
6
6
|
class File
|
7
7
|
class Local < Stashify::File
|
8
|
-
def initialize(path)
|
9
|
-
@path = path
|
10
|
-
super(name: ::File.basename(path), contents: nil)
|
11
|
-
end
|
12
|
-
|
13
8
|
def contents
|
14
|
-
::File.read(
|
9
|
+
::File.read(path)
|
15
10
|
end
|
16
11
|
end
|
17
12
|
end
|
data/lib/stashify/file.rb
CHANGED
@@ -4,12 +4,14 @@ require "stashify"
|
|
4
4
|
|
5
5
|
module Stashify
|
6
6
|
class File
|
7
|
-
attr_reader :name, :contents
|
7
|
+
attr_reader :name, :path, :contents
|
8
8
|
|
9
|
-
def initialize(name
|
10
|
-
raise
|
9
|
+
def initialize(name: nil, path: nil, contents: "")
|
10
|
+
raise StandardError, "name or path must be defined" unless name || path
|
11
|
+
raise Stashify::InvalidFile, "Name '#{name}' contains a /" if name && name =~ %r{/}
|
11
12
|
|
12
|
-
@
|
13
|
+
@path = path
|
14
|
+
@name = name || ::File.basename(path)
|
13
15
|
@contents = contents
|
14
16
|
end
|
15
17
|
|
data/lib/stashify/version.rb
CHANGED
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:
|
4
|
+
version: 2.0.0
|
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-
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provides an abstraction to various services (local filesystem, S3, etc)
|
14
14
|
email:
|