elia 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/path_operator.rb +16 -0
- data/spec/lib/path_operator_spec.rb +15 -0
- metadata +3 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/path_operator.rb
CHANGED
@@ -2,6 +2,10 @@ module PathOperator
|
|
2
2
|
def / *others
|
3
3
|
File.join self, *others.map(&:to_s)
|
4
4
|
end
|
5
|
+
|
6
|
+
def to_path
|
7
|
+
Pathname.new(self.to_s)
|
8
|
+
end
|
5
9
|
end
|
6
10
|
|
7
11
|
String.class_eval{include PathOperator}
|
@@ -12,4 +16,16 @@ class Pathname
|
|
12
16
|
def / *others
|
13
17
|
join *others.map(&:to_s)
|
14
18
|
end
|
19
|
+
|
20
|
+
def from other_path
|
21
|
+
self.relative_path_from( other_path.to_path )
|
22
|
+
end
|
23
|
+
|
24
|
+
def absolute
|
25
|
+
"/#{self}".to_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_path
|
29
|
+
self
|
30
|
+
end
|
15
31
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'path_operator'
|
3
|
+
|
4
|
+
describe PathOperator do
|
5
|
+
it 'should join strings as paths' do
|
6
|
+
('a' / 'b').should == 'a/b'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should transform strings and symbols to paths' do
|
10
|
+
[:asdf, 'asdf', Pathname.new('asdf')].each do |s|
|
11
|
+
s.to_path.should == Pathname.new(s.to_s)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/world_logger.rb
|
43
43
|
- spec/lib/bit_fields_spec.rb
|
44
44
|
- spec/lib/elia_spec.rb
|
45
|
+
- spec/lib/path_operator_spec.rb
|
45
46
|
- spec/spec.opts
|
46
47
|
- spec/spec_helper.rb
|
47
48
|
has_rdoc: true
|
@@ -75,4 +76,5 @@ summary: Elia Schito's utility belt
|
|
75
76
|
test_files:
|
76
77
|
- spec/lib/bit_fields_spec.rb
|
77
78
|
- spec/lib/elia_spec.rb
|
79
|
+
- spec/lib/path_operator_spec.rb
|
78
80
|
- spec/spec_helper.rb
|