build-files 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/build/files/path.rb +7 -1
- data/lib/build/files/version.rb +1 -1
- data/spec/build/files/path_spec.rb +6 -0
- 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: c5298ff2018cafcc8c18f9319af1027d92c5f5a1b2c11cb683f916d65e0ba5ba
|
4
|
+
data.tar.gz: ab00474b4117ae16729255445285d9b835fe1d92a6de7b5c7a10207bb684c4e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd0603af29ac1189dd43b9b8beee290e091709cb218389a47dce5489bfed64aa716d9534c6848d2a735341cf7ed34149fb815d46605020f2c1806743ed7e7a44
|
7
|
+
data.tar.gz: b47e003284e29761c501d27e82032011e9350e816627d16223f24657c5f8ffdb155e69753c179ffc08b7c7bd95e633bc6aa851b55c1feab64be834cbce6e5529
|
data/lib/build/files/path.rb
CHANGED
@@ -55,7 +55,13 @@ module Build
|
|
55
55
|
# The difference between the root path and the required path, taking into account the common prefix:
|
56
56
|
up = root_components.size - i
|
57
57
|
|
58
|
-
|
58
|
+
components = [".."] * up + path_components[i..-1]
|
59
|
+
|
60
|
+
if components.empty?
|
61
|
+
return "."
|
62
|
+
else
|
63
|
+
return File.join(components)
|
64
|
+
end
|
59
65
|
end
|
60
66
|
|
61
67
|
def self.relative_path(root, full_path)
|
data/lib/build/files/version.rb
CHANGED
@@ -28,6 +28,12 @@ RSpec.describe Build::Files::Path do
|
|
28
28
|
expect(Build::Files::Path.expand("foo", "/bar")).to be == "/bar/foo"
|
29
29
|
end
|
30
30
|
|
31
|
+
it "should give current path" do
|
32
|
+
path = Build::Files::Path.new("/a/b/c/file.cpp")
|
33
|
+
|
34
|
+
expect(path.shortest_path(path)).to be == "."
|
35
|
+
end
|
36
|
+
|
31
37
|
it "should give the shortest path for outer paths" do
|
32
38
|
input = Build::Files::Path.new("/a/b/c/file.cpp")
|
33
39
|
output = Build::Files::Path.new("/a/b/c/d/e/")
|