stashify 1.0.1 → 1.0.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.yml +3 -0
- data/Gemfile.lock +1 -1
- data/lib/stashify/directory/local.rb +15 -7
- data/lib/stashify/directory.rb +11 -2
- data/lib/stashify/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84f0655199b71b4079fc0405ed2bd68ccd65f0231f1531005c59f1ada5b88efe
|
4
|
+
data.tar.gz: b8f4d4b7491ea3d51271579e455fcbe08e4e9a74040f3deba84581b2d1b02538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 623475feb2be6768f59519458108029af6b244396d36d67c3d3529e60bbf231f8164921d1cd334a6a7eebdd6059578083be2f841e50e4b7dc20327e3853707ef
|
7
|
+
data.tar.gz: 33b63c2878050f49c35d24d00f81917f35503353019dc7b23c3f4f1a4fcfb7f95897b66d5dbb288012fcbd57b0a91bd162d8015b89802b70e7b81840222b77ed
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -13,13 +13,15 @@ module Stashify
|
|
13
13
|
super(name: ::File.basename(path))
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
path =
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def write_directory(directory)
|
17
|
+
path = path_of(directory.name)
|
18
|
+
FileUtils.mkdir(path)
|
19
|
+
subdir = Stashify::Directory::Local.new(path)
|
20
|
+
directory.files.each { |file| subdir.write(file) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def write_file(file)
|
24
|
+
::File.write(path_of(file.name), file.contents)
|
23
25
|
end
|
24
26
|
|
25
27
|
def delete(name)
|
@@ -31,6 +33,12 @@ module Stashify
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
36
|
+
def files
|
37
|
+
Dir.entries(@path).grep_v(/^[.][.]?$/).map do |file_name|
|
38
|
+
find(::File.basename(file_name))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
34
42
|
def ==(other)
|
35
43
|
@path == other.path
|
36
44
|
end
|
data/lib/stashify/directory.rb
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
module Stashify
|
4
4
|
class Directory
|
5
|
-
attr_reader :name
|
5
|
+
attr_reader :name, :files
|
6
6
|
|
7
|
-
def initialize(name:)
|
7
|
+
def initialize(name:, files: [])
|
8
8
|
@name = name
|
9
|
+
@files = files
|
9
10
|
end
|
10
11
|
|
11
12
|
def find(name)
|
@@ -15,5 +16,13 @@ module Stashify
|
|
15
16
|
file(name)
|
16
17
|
end
|
17
18
|
end
|
19
|
+
|
20
|
+
def write(file)
|
21
|
+
if file.is_a?(Stashify::Directory)
|
22
|
+
write_directory(file)
|
23
|
+
else
|
24
|
+
write_file(file)
|
25
|
+
end
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
data/lib/stashify/version.rb
CHANGED