fled 0.0.1 → 0.0.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.
- data/README.md +33 -9
- data/bin/fled +1 -1
- data/lib/dtc/utils/file_visitor.rb +1 -0
- data/lib/fled/file_listing.rb +7 -2
- data/lib/fled.rb +1 -1
- data/tests/readme.rb +31 -8
- data/tests/test_operations.rb +27 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -3,11 +3,6 @@
|
|
3
3
|
|
4
4
|
`fled` lets you organise your files and folders in your favourite editor
|
5
5
|
|
6
|
-
## Disclaimer
|
7
|
-
|
8
|
-
Warning: This is a very dangerous tool. The author recommends you do not
|
9
|
-
use it. The author cannot be held responsible in any case.
|
10
|
-
|
11
6
|
## Introduction
|
12
7
|
|
13
8
|
`fled` enumerates a folder and its files, and generates a text listing.
|
@@ -17,13 +12,17 @@ your files and folders around as-per your edits.
|
|
17
12
|
|
18
13
|
**You should review that shell script very carefully before running it.**
|
19
14
|
|
15
|
+
### Install
|
16
|
+
|
17
|
+
You can install using `gem install fled`.
|
18
|
+
|
20
19
|
### Philosophy
|
21
20
|
|
22
21
|
`fled` only generates text, it does not perform any operation directly.
|
23
22
|
|
24
|
-
The design optimises for making the edits very simple.
|
25
|
-
|
26
|
-
|
23
|
+
The design optimises for making the edits very simple. This means that very small
|
24
|
+
edits can have large consequences, which makes this a **very dangerous** tool.
|
25
|
+
But so is `rm` and the rest of the shell anyway...
|
27
26
|
|
28
27
|
### Caveats
|
29
28
|
|
@@ -35,6 +34,10 @@ cases defined, any help is much appreciated.
|
|
35
34
|
|
36
35
|
You should be scared when using `fled`.
|
37
36
|
|
37
|
+
### Test status
|
38
|
+
|
39
|
+
[](http://travis-ci.org/ddlsmurf/fled)
|
40
|
+
|
38
41
|
### Examples
|
39
42
|
|
40
43
|
Print help text and option list
|
@@ -163,7 +166,7 @@ If an indent is forgotten:
|
|
163
166
|
|
164
167
|
Generates:
|
165
168
|
|
166
|
-
mv folder/folder_two/file_three folder/
|
169
|
+
mv folder/folder_two/file_three folder/file_three
|
167
170
|
|
168
171
|
### All together
|
169
172
|
|
@@ -224,7 +227,28 @@ Generates:
|
|
224
227
|
mv folder sub_sub_folder/sub_folder/folder
|
225
228
|
mv sub_sub_folder/file.txt sub_sub_folder/sub_folder/folder/file.txt
|
226
229
|
|
230
|
+
## Changelog
|
231
|
+
|
232
|
+
*Version v0.0.2*
|
233
|
+
|
234
|
+
- Fix: Unreadable directories now ignored
|
235
|
+
- Fix: Version display and DRYed
|
236
|
+
- Fix: Moving files under files now moves up to parent folder of destination
|
237
|
+
- Meta: Travis-CI integration
|
238
|
+
|
239
|
+
*Version v0.0.1*
|
240
|
+
|
241
|
+
- First version
|
242
|
+
|
243
|
+
## Disclaimer
|
244
|
+
|
245
|
+
Warning: This is a very dangerous tool. The author recommends you do not
|
246
|
+
use it. The author cannot be held responsible in any case.
|
247
|
+
|
227
248
|
## Contributors
|
228
249
|
|
229
250
|
- [Eric Doughty-Papassideris](http://github.com/ddlsmurf)
|
230
251
|
|
252
|
+
## Licence
|
253
|
+
|
254
|
+
[GPLv3](http://www.gnu.org/licenses/gpl-3.0.html)
|
data/bin/fled
CHANGED
data/lib/fled/file_listing.rb
CHANGED
@@ -89,7 +89,7 @@ module FlEd
|
|
89
89
|
next if path.any? { |o| o[:error] }
|
90
90
|
if target[:name] != "" && !target[:uid]
|
91
91
|
operations << [:mk, self.path_of(target).map { |o| o[:name] }]
|
92
|
-
fake_source = {:name => target[:name]}
|
92
|
+
fake_source = {:name => target[:name], :dir => true}
|
93
93
|
fake_source[:parent] = running_source[path.last[:source][:uid]] unless path.empty?
|
94
94
|
target_uid = "new_#{running_source.count}"
|
95
95
|
target_uid += "_" while @objects_by_id[target_uid] || running_source[target_uid]
|
@@ -111,11 +111,16 @@ module FlEd
|
|
111
111
|
if new_name != target[:name]
|
112
112
|
pending_renames << [:renamed, target, target[:name]]
|
113
113
|
end
|
114
|
+
if (target_parent = target[:parent])
|
115
|
+
until !target_parent || !target_parent[:source] || target_parent[:source][:dir]
|
116
|
+
target_parent = target_parent[:parent]
|
117
|
+
end
|
118
|
+
end
|
114
119
|
source_path = running_source.path_of(source).map { |o| o[:name] }
|
115
120
|
target[:name] = source[:name] = new_name
|
116
121
|
operations << [:moved,
|
117
122
|
source_path,
|
118
|
-
self.path_of(
|
123
|
+
self.path_of(target_parent).map { |o| o[:name] } + [target[:name]]
|
119
124
|
]
|
120
125
|
if target[:parent]
|
121
126
|
source[:parent] = running_source[target[:parent][:uid]]
|
data/lib/fled.rb
CHANGED
data/tests/readme.rb
CHANGED
@@ -75,11 +75,6 @@ end
|
|
75
75
|
readme = ExampleDSLWriter.run do
|
76
76
|
h1 "FlEd", '`fled` lets you organise your files and folders in your favourite editor'
|
77
77
|
|
78
|
-
h2 "Disclaimer", <<-MD
|
79
|
-
Warning: This is a very dangerous tool. The author recommends you do not
|
80
|
-
use it. The author cannot be held responsible in any case.
|
81
|
-
MD
|
82
|
-
|
83
78
|
h2 "Introduction", <<-MD
|
84
79
|
`fled` enumerates a folder and its files, and generates a text listing.
|
85
80
|
You can then edit that listing in your favourite editor, and save changes.
|
@@ -90,12 +85,16 @@ readme = ExampleDSLWriter.run do
|
|
90
85
|
|
91
86
|
MD
|
92
87
|
|
88
|
+
h3 "Install", <<-MD
|
89
|
+
You can install using `gem install fled`.
|
90
|
+
MD
|
91
|
+
|
93
92
|
h3 "Philosophy", <<-MD
|
94
93
|
`fled` only generates text, it does not perform any operation directly.
|
95
94
|
|
96
|
-
The design optimises for making the edits very simple.
|
97
|
-
|
98
|
-
|
95
|
+
The design optimises for making the edits very simple. This means that very small
|
96
|
+
edits can have large consequences, which makes this a **very dangerous** tool.
|
97
|
+
But so is `rm` and the rest of the shell anyway...
|
99
98
|
MD
|
100
99
|
|
101
100
|
h3 "Caveats", <<-MD
|
@@ -108,6 +107,8 @@ readme = ExampleDSLWriter.run do
|
|
108
107
|
You should be scared when using `fled`.
|
109
108
|
MD
|
110
109
|
|
110
|
+
h3 "Test status", "[](http://travis-ci.org/ddlsmurf/fled)"
|
111
|
+
|
111
112
|
h3 "Examples"
|
112
113
|
[
|
113
114
|
["Print help text and option list", "fled --help"],
|
@@ -250,7 +251,29 @@ readme = ExampleDSLWriter.run do
|
|
250
251
|
file.txt :3
|
251
252
|
EXAMPLE
|
252
253
|
|
254
|
+
h2 "Changelog"
|
255
|
+
({
|
256
|
+
'v0.0.1' => ['First version'],
|
257
|
+
'v0.0.2' => [
|
258
|
+
'Fix: Unreadable directories now ignored',
|
259
|
+
'Fix: Version display and DRYed',
|
260
|
+
'Fix: Moving files under files now moves up to parent folder of destination',
|
261
|
+
'Meta: Travis-CI integration',
|
262
|
+
],
|
263
|
+
}).sort { |a, b| b[0] <=> a[0] }.each do |version, changes|
|
264
|
+
em "Version #{version}"
|
265
|
+
changes.each { |change| li change }
|
266
|
+
end
|
267
|
+
|
268
|
+
h2 "Disclaimer", <<-MD
|
269
|
+
Warning: This is a very dangerous tool. The author recommends you do not
|
270
|
+
use it. The author cannot be held responsible in any case.
|
271
|
+
MD
|
272
|
+
|
253
273
|
h2 "Contributors"
|
254
274
|
li "[Eric Doughty-Papassideris](http://github.com/ddlsmurf)"
|
275
|
+
|
276
|
+
h2 "Licence", "[GPLv3](http://www.gnu.org/licenses/gpl-3.0.html)"
|
277
|
+
|
255
278
|
end
|
256
279
|
puts readme
|
data/tests/test_operations.rb
CHANGED
@@ -165,6 +165,33 @@ class TestOperations < Test::Unit::TestCase
|
|
165
165
|
TEST
|
166
166
|
assert_equal [[:mv, 'folder/sous/truc', 'truc']], ops
|
167
167
|
end
|
168
|
+
def test_reparent_under_file
|
169
|
+
ops = @fs.operations_if_edited_as <<-TEST
|
170
|
+
folder :0
|
171
|
+
sous :1
|
172
|
+
truc :2
|
173
|
+
truc.txt :3
|
174
|
+
TEST
|
175
|
+
assert_equal [[:mv, "folder/truc.txt", "folder/sous/truc.txt"]], ops
|
176
|
+
end
|
177
|
+
def test_reparent_under_file_at_root
|
178
|
+
ops = TestFS.new do
|
179
|
+
folder(0) {
|
180
|
+
file_one(1)
|
181
|
+
file_two(2)
|
182
|
+
file_three(3)
|
183
|
+
}
|
184
|
+
end.operations_if_edited_as <<-TEST
|
185
|
+
file_one :1
|
186
|
+
file_two :2
|
187
|
+
file_three :3
|
188
|
+
TEST
|
189
|
+
assert_equal [
|
190
|
+
[:mv, "folder/file_one", "file_one"],
|
191
|
+
[:mv, "folder/file_two", "file_two"],
|
192
|
+
[:mv, "folder/file_three", "file_three"],
|
193
|
+
], ops
|
194
|
+
end
|
168
195
|
def test_reparent_impact_on_mkdir
|
169
196
|
ops = @fs.operations_if_edited_as <<-TEST
|
170
197
|
folder :0
|