utopia 2.1.1 → 2.1.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/lib/utopia/path.rb +11 -7
- data/lib/utopia/version.rb +1 -1
- data/spec/utopia/path_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3881efaedf6400b258104215042b8030b69ca3e
|
4
|
+
data.tar.gz: e59045a36657c40b04bc30331fa0c15acc19b41b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20c2d659623389861d7636e79f81f5349c85a039e629c7926e12afa59cd2fe339dd8ae8f279ca81b792c6c39a8a6a6ed263c336f8ac20e8841abd2328ae3de03
|
7
|
+
data.tar.gz: 9e7daab38c5752fe5d896dc0466b399a90947f30692b66f7505bb6051537d298ab435d17cefdbb2ee7476a250a6889ecc11ed971d4038a220564a4e1ac61c61b
|
data/lib/utopia/path.rb
CHANGED
@@ -117,11 +117,11 @@ module Utopia
|
|
117
117
|
return self.new([path])
|
118
118
|
end
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
def replace(other_path)
|
122
122
|
@components = other_path.components.dup
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
def include?(*args)
|
126
126
|
@components.include?(*args)
|
127
127
|
end
|
@@ -232,7 +232,15 @@ module Utopia
|
|
232
232
|
end
|
233
233
|
|
234
234
|
def basename
|
235
|
-
@components.last
|
235
|
+
basename, _ = @components.last.split('.', 2)
|
236
|
+
|
237
|
+
return basename || ''
|
238
|
+
end
|
239
|
+
|
240
|
+
def extension
|
241
|
+
_, extension = @components.last.split('.', 2)
|
242
|
+
|
243
|
+
return extension
|
236
244
|
end
|
237
245
|
|
238
246
|
def dirname(count = 1)
|
@@ -344,10 +352,6 @@ module Utopia
|
|
344
352
|
end
|
345
353
|
end
|
346
354
|
|
347
|
-
def extension
|
348
|
-
basename(true).extension
|
349
|
-
end
|
350
|
-
|
351
355
|
private
|
352
356
|
|
353
357
|
# We adjust the index slightly so that indices reference path components rather than the directory markers at the start and end of the path components array.
|
data/lib/utopia/version.rb
CHANGED
data/spec/utopia/path_spec.rb
CHANGED
@@ -72,6 +72,13 @@ RSpec.describe Utopia::Path do
|
|
72
72
|
expect(path.simplify.components).to be == ['', 'foo', 'baz', '']
|
73
73
|
end
|
74
74
|
|
75
|
+
it "should remove the extension from the basename" do
|
76
|
+
path = Utopia::Path["dir/foo.html"]
|
77
|
+
|
78
|
+
expect(path.basename).to be == 'foo'
|
79
|
+
expect(path.extension).to be == 'html'
|
80
|
+
end
|
81
|
+
|
75
82
|
it "should be able to convert into a directory" do
|
76
83
|
path = Utopia::Path["foo/bar"]
|
77
84
|
|
@@ -105,6 +112,18 @@ RSpec.describe Utopia::Path do
|
|
105
112
|
expect{path[0] = 'bob'}.to raise_exception(RuntimeError)
|
106
113
|
end
|
107
114
|
|
115
|
+
it "should give the correct locale" do
|
116
|
+
path = Utopia::Path["foo.en"]
|
117
|
+
|
118
|
+
expect(path.extension).to be == 'en'
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should give no locale" do
|
122
|
+
path = Utopia::Path["foo"]
|
123
|
+
|
124
|
+
expect(path.extension).to be == nil
|
125
|
+
end
|
126
|
+
|
108
127
|
it "should expand relative paths" do
|
109
128
|
root = Utopia::Path['/root']
|
110
129
|
path = Utopia::Path["dir/foo.html"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|