AbsoluteRenamer 0.9.0 → 0.9.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/lib/absolute_renamer.rb +4 -1
- data/lib/absolute_renamer/file_info.rb +13 -1
- metadata +2 -2
data/ChangeLog
CHANGED
data/lib/absolute_renamer.rb
CHANGED
@@ -12,7 +12,7 @@ require 'absolute_renamer/use_config'
|
|
12
12
|
|
13
13
|
# top level module of AbsoluteRenamer.
|
14
14
|
module AbsoluteRenamer
|
15
|
-
VERSION = "0.9.0"
|
15
|
+
VERSION = "0.9.0.1"
|
16
16
|
|
17
17
|
# The main class of AbsoluteRenamer.
|
18
18
|
#
|
@@ -45,6 +45,9 @@ module AbsoluteRenamer
|
|
45
45
|
file.new_name = name
|
46
46
|
file.new_name << '.' << ext unless (file.dir or file.ext.empty?)
|
47
47
|
end
|
48
|
+
if (conf[:options][:dir] and conf[:options][:rec])
|
49
|
+
conf[:files].sort! { |a, b| AbsoluteRenamer::FileInfo.compare_level(a, b) }
|
50
|
+
end
|
48
51
|
mods.clear
|
49
52
|
end
|
50
53
|
|
@@ -12,7 +12,8 @@ module AbsoluteRenamer
|
|
12
12
|
|
13
13
|
attr_accessor :name, :new_name,
|
14
14
|
:path, :real_path,
|
15
|
-
:ext, :dir, :dir_path
|
15
|
+
:ext, :dir, :dir_path,
|
16
|
+
:level
|
16
17
|
|
17
18
|
# Initializes a FileInfo.
|
18
19
|
# path: the relative or absolute path of the file.
|
@@ -26,6 +27,9 @@ module AbsoluteRenamer
|
|
26
27
|
# TODO utiliser une conf :dot
|
27
28
|
@ext = File.extname(@name)
|
28
29
|
@name.gsub!(Regexp.new('.' << @ext << '$'), '') unless @ext.empty?
|
30
|
+
@level = 0
|
31
|
+
else
|
32
|
+
@level = @real_path.split('/').size
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
@@ -86,5 +90,13 @@ module AbsoluteRenamer
|
|
86
90
|
puts "Error: cannot create symlinks"
|
87
91
|
end
|
88
92
|
end
|
93
|
+
|
94
|
+
def self.compare_level(a, b)
|
95
|
+
if (a.level == b.level)
|
96
|
+
return (a.name <= b.name) ? -1 : 1
|
97
|
+
else
|
98
|
+
return (a.level < b.level) ? 1 : -1
|
99
|
+
end
|
100
|
+
end
|
89
101
|
end
|
90
102
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: AbsoluteRenamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0
|
4
|
+
version: 0.9.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon COURTOIS
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-09 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|