everything-piece-find 0.2.0 → 0.3.0
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/CHANGELOG.md +5 -0
- data/lib/everything/piece/find/version.rb +1 -1
- data/lib/everything/piece/find.rb +34 -7
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0bc51892fa9eec98831db48565fe87f54f6b3df0
|
|
4
|
+
data.tar.gz: fc8c816292b00d49fc87f588e8c7eeff866d39c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e811ffc26a1c0bbe7807825ffbe3436b0ff75c9f15a3ac576a82c9bf324303f4387842985dc38e232fb6511c700629d09acca3067091d26790cb101e142b01f
|
|
7
|
+
data.tar.gz: 16ed575c9f06c814d5ad9bb645c17b65f8c6fdbad0453162e38b8f2253c533e9a94f70fa8dcd6df999da1f6aa41b60af5e6eb39438e9451ddc13b64545e7864f
|
data/CHANGELOG.md
CHANGED
|
@@ -7,15 +7,42 @@ module Everything
|
|
|
7
7
|
def find_by_name(piece_name)
|
|
8
8
|
piece_path = File.join(Everything.path, piece_name)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
raise_no_piece_error(piece_name) unless File.exist?(piece_path)
|
|
11
|
+
raise_not_directory_error(piece_name, piece_path) unless Dir.exist?(piece_path)
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
Piece.new(piece_path)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def find_by_name_recursive(piece_name)
|
|
17
|
+
glob_path = File.join(Everything.path, '**', piece_name)
|
|
18
|
+
possible_dirs = Dir.glob(glob_path)
|
|
19
|
+
full_piece_path = possible_dirs.first
|
|
20
|
+
|
|
21
|
+
raise_no_piece_recursive_error(piece_name) unless full_piece_path
|
|
22
|
+
raise_not_directory_error(piece_name, full_piece_path) unless Dir.exist?(full_piece_path)
|
|
23
|
+
|
|
24
|
+
Piece.new(full_piece_path)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def raise_no_piece_error(piece_name)
|
|
30
|
+
error_message =
|
|
31
|
+
%Q{No piece "#{piece_name}" found in "#{Everything.path}"}
|
|
32
|
+
|
|
33
|
+
raise ArgumentError, error_message
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def raise_no_piece_recursive_error(piece_name)
|
|
37
|
+
error_message =
|
|
38
|
+
%Q{No piece "#{piece_name}" found in "#{Everything.path}" or subdirectories}
|
|
39
|
+
raise ArgumentError, error_message
|
|
40
|
+
end
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
def raise_not_directory_error(piece_name, piece_path)
|
|
43
|
+
error_message =
|
|
44
|
+
%Q{Found file "#{piece_name}" at "#{piece_path}", but was expecting a directory}
|
|
45
|
+
raise ArgumentError, error_message
|
|
19
46
|
end
|
|
20
47
|
end
|
|
21
48
|
end
|