fi 0.0.2 → 0.0.3
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/fi/dir.rb +11 -8
- data/lib/fi/version.rb +1 -1
- data/spec/fi/dir_spec.rb +11 -3
- 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: 1c829e95f99f7419b0617c5e2bf679e702bd29e9
|
4
|
+
data.tar.gz: 34f6403ecfaf73dd264c0cd8acc3f1d6843a636c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 482bc1b6f52443e7209ee5040c2b3cb98a70d4b4a0ba8fcbb10c194af5625dec63d6b24876a3343226257d1dfa6f11f95ba73f27f6b0e0a498777ff4c0bf51a7
|
7
|
+
data.tar.gz: aefbde7e28ffaa70e50f2673b99dafcf90add678799f24eabb68588177da9e376b847d97474a30efa682739750e830159f05f4898dadfe5f0b7f70600119a34e
|
data/lib/fi/dir.rb
CHANGED
@@ -7,10 +7,18 @@ module Fi
|
|
7
7
|
::Dir.pwd
|
8
8
|
end
|
9
9
|
|
10
|
+
@previous_dir = current
|
11
|
+
@history = [current]
|
12
|
+
|
10
13
|
def self.change(dir=home)
|
14
|
+
@history << current
|
11
15
|
::Dir.chdir dir
|
12
16
|
end
|
13
17
|
|
18
|
+
def self.back
|
19
|
+
change(@history.pop || current)
|
20
|
+
end
|
21
|
+
|
14
22
|
def self.list(path=current)
|
15
23
|
directories = list! path
|
16
24
|
directories.reject { |d| d =~ /^\./ }
|
@@ -41,14 +49,9 @@ module Fi
|
|
41
49
|
::Dir.home
|
42
50
|
end
|
43
51
|
|
44
|
-
def initialize(*
|
45
|
-
|
46
|
-
|
47
|
-
base_dir = Dir.current
|
48
|
-
dirs.each do |dir|
|
49
|
-
base_dir = Path.join base_dir, dir
|
50
|
-
::Dir.mkdir base_dir
|
51
|
-
end
|
52
|
+
def initialize(*dirs)
|
53
|
+
dirs.each do |dir|
|
54
|
+
::FileUtils.mkdir_p dir
|
52
55
|
end
|
53
56
|
end
|
54
57
|
end
|
data/lib/fi/version.rb
CHANGED
data/spec/fi/dir_spec.rb
CHANGED
@@ -19,6 +19,15 @@ module Fi
|
|
19
19
|
expect(Dir.exist? 'nope').to be false
|
20
20
|
end
|
21
21
|
|
22
|
+
it "can go back to the previous directory" do
|
23
|
+
original_dir = Dir.current
|
24
|
+
new_dir = Fi::Path.expand(Dir.current + '/../')
|
25
|
+
Dir.change new_dir
|
26
|
+
expect(Dir.current).to eq new_dir
|
27
|
+
Dir.back
|
28
|
+
expect(Dir.current).to eq original_dir
|
29
|
+
end
|
30
|
+
|
22
31
|
it "can rename a directory" do
|
23
32
|
Dir.new 't'
|
24
33
|
Dir.rename 't', 'temp'
|
@@ -82,11 +91,10 @@ module Fi
|
|
82
91
|
Dir.delete! "#{testdir}1"
|
83
92
|
end
|
84
93
|
|
85
|
-
it "
|
94
|
+
it "does nothing when a directory alreads exists" do
|
95
|
+
Dir.new testdir
|
86
96
|
Dir.new testdir
|
87
|
-
|
88
97
|
expect(testdir).to be_directory
|
89
|
-
expect { Dir.new testdir }.to raise_error
|
90
98
|
end
|
91
99
|
end
|
92
100
|
|