stashify 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -1
- data/lib/stashify/directory/local.rb +13 -7
- data/lib/stashify/directory.rb +16 -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: e973c2f24b46e43537a97ef45788e7d01857acee21951387431256dd5c78e5ab
|
4
|
+
data.tar.gz: 5f5ec864ba95d82d669fc0682ecf7b57f248926eb7dd0599a2e7d07e9ed7f58a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c48b8022c40151ead151db9cca51ae45cde5d8f921d17e544b46c3a90418818025d1fbf8748dd09f9814432d0b8e4b4cb75a555d400cc22980dd37208edd873
|
7
|
+
data.tar.gz: bb9c80f96a94b1484d4eb22627c11f5331b68e24765549ec95e1680cec022a80d87858bd11e2bcd17140c8ade63f18f19cf937d79c19010b770c74a00d9cefc3
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -13,13 +13,13 @@ module Stashify
|
|
13
13
|
super(name: ::File.basename(path))
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def write_directory(directory)
|
17
|
+
FileUtils.mkdir(path_of(directory.name))
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def write_file(file)
|
22
|
+
::File.write(path_of(file.name), file.contents)
|
23
23
|
end
|
24
24
|
|
25
25
|
def delete(name)
|
@@ -31,6 +31,12 @@ module Stashify
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def files
|
35
|
+
Dir.entries(@path).grep_v(/^[.][.]?$/).map do |file_name|
|
36
|
+
find(::File.basename(file_name))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
34
40
|
def ==(other)
|
35
41
|
@path == other.path
|
36
42
|
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,18 @@ 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
|
27
|
+
|
28
|
+
def write_directory(directory)
|
29
|
+
subdir = self.directory(directory.name)
|
30
|
+
directory.files.each { |file| subdir.write(file) }
|
31
|
+
end
|
18
32
|
end
|
19
33
|
end
|
data/lib/stashify/version.rb
CHANGED