AbsoluteRenamer 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AbsoluteRenamer.gemspec +40 -0
- data/COPYING +340 -0
- data/ChangeLog +0 -0
- data/LICENCE +17 -0
- data/Manifest.txt +42 -0
- data/README +34 -0
- data/Rakefile +20 -0
- data/bin/absrenamer +54 -0
- data/conf/absrenamer/absrenamer.conf +34 -0
- data/lib/absolute_renamer.rb +119 -0
- data/lib/absolute_renamer/config.rb +40 -0
- data/lib/absolute_renamer/external.rb +56 -0
- data/lib/absolute_renamer/external/modules/core/case/module.rb +31 -0
- data/lib/absolute_renamer/external/modules/core/general/module.rb +126 -0
- data/lib/absolute_renamer/external/parsers/core/general/parser.rb +74 -0
- data/lib/absolute_renamer/external/parsers/interactive/parser.rb +20 -0
- data/lib/absolute_renamer/external/parsers/listing/parser.rb +9 -0
- data/lib/absolute_renamer/external/plugins/interactive/plugin.rb +35 -0
- data/lib/absolute_renamer/external/plugins/listing/plugin.rb +14 -0
- data/lib/absolute_renamer/file_info.rb +90 -0
- data/lib/absolute_renamer/imodule.rb +68 -0
- data/lib/absolute_renamer/iparser.rb +8 -0
- data/lib/absolute_renamer/iplugin.rb +11 -0
- data/lib/absolute_renamer/libs/file.rb +11 -0
- data/lib/absolute_renamer/libs/string.rb +27 -0
- data/lib/absolute_renamer/parser.rb +91 -0
- data/lib/absolute_renamer/use_config.rb +11 -0
- data/lib/absolute_renamer/with_children.rb +22 -0
- data/man/man8/absrenamer.8 +67 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/setup.rb +1585 -0
- data/test/unit/features/test_absrenamer.conf +34 -0
- data/test/unit/tc_config.rb +28 -0
- data/test/unit/tc_file.rb +16 -0
- data/test/unit/tc_fileinfo.rb +17 -0
- data/test/unit/tc_imodule.rb +29 -0
- data/test/unit/tc_iplugin.rb +8 -0
- data/test/unit/tc_parser.rb +13 -0
- data/test/unit/tc_string.rb +24 -0
- data/test/unit/test_suite.rb +28 -0
- metadata +120 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
:debug: false
|
2
|
+
|
3
|
+
:options:
|
4
|
+
# Prompt :never, :once or :always before renaming
|
5
|
+
:interactive: :never
|
6
|
+
:format: '$'
|
7
|
+
:ext_format: '$'
|
8
|
+
|
9
|
+
# Renaming mode: :rename, :copy, :move, :link
|
10
|
+
:mode: :rename
|
11
|
+
:maxdepth: 0
|
12
|
+
|
13
|
+
# used when a value is not available (pdfAuthor for a PNG file, ...)
|
14
|
+
:default_string: '---'
|
15
|
+
|
16
|
+
# Word separator, regular expression statements can be used
|
17
|
+
# default: '\W_'
|
18
|
+
# This string will be used in AbsoluteRenamer just like this :
|
19
|
+
# [^WORD_SEPARATOR]
|
20
|
+
# Then, \W_ => [^\W_]
|
21
|
+
:word_separator: '\W_'
|
22
|
+
|
23
|
+
:path:
|
24
|
+
:modules: absolute_renamer/external/modules
|
25
|
+
:parsers: absolute_renamer/external/parsers
|
26
|
+
:plugins: absolute_renamer/external/plugins
|
27
|
+
|
28
|
+
:parsers:
|
29
|
+
- listing
|
30
|
+
- interactive
|
31
|
+
|
32
|
+
:plugins:
|
33
|
+
- listing
|
34
|
+
- interactive
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'absolute_renamer/config'
|
3
|
+
|
4
|
+
class TC_ConfigTest < Test::Unit::TestCase
|
5
|
+
def test_load
|
6
|
+
p $:
|
7
|
+
assert_raise(Errno::ENOENT) do
|
8
|
+
AbsoluteRenamer::Config.load('a file that must not be found')
|
9
|
+
end
|
10
|
+
|
11
|
+
assert_nothing_raised(Errno::ENOENT) do
|
12
|
+
AbsoluteRenamer::Config.load(TEST_CONF_FILE)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_set_and_get
|
17
|
+
AbsoluteRenamer::Config.set(:test_key, :test_val)
|
18
|
+
assert_equal(:test_val, AbsoluteRenamer::Config.get(:test_key))
|
19
|
+
|
20
|
+
AbsoluteRenamer::Config.set(nil, :test_val)
|
21
|
+
assert_equal(:test_val, AbsoluteRenamer::Config.get(nil))
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_set_and_get_2
|
25
|
+
AbsoluteRenamer::Config[:test_key] = :test_val
|
26
|
+
assert_equal(:test_val, AbsoluteRenamer::Config[:test_key])
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'absolute_renamer/libs/file'
|
3
|
+
|
4
|
+
class TC_FileTest < Test::Unit::TestCase
|
5
|
+
def test_extname
|
6
|
+
assert_equal("txt", File.extname('a_file.txt'))
|
7
|
+
assert_equal("", File.extname('a_file'))
|
8
|
+
|
9
|
+
assert_equal("tar.gz", File.extname('archive.tar.gz', 2))
|
10
|
+
assert_not_equal("tar.gz", File.extname('archive.tar.gz'))
|
11
|
+
|
12
|
+
assert_equal("", File.extname('.'))
|
13
|
+
assert_equal("", File.extname('fichier.'))
|
14
|
+
assert_equal("test", File.extname('.test'))
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'absolute_renamer/use_config'
|
3
|
+
require 'absolute_renamer/file_info'
|
4
|
+
|
5
|
+
class TC_FileInfoTest < Test::Unit::TestCase
|
6
|
+
def test_initialize
|
7
|
+
pwd = Dir.pwd
|
8
|
+
fi = AbsoluteRenamer::FileInfo.new('some/path/to/a_file.txt')
|
9
|
+
|
10
|
+
assert_equal('a_file', fi.name)
|
11
|
+
assert_equal(pwd + '/some/path/to', fi.dir_path)
|
12
|
+
assert_equal('some/path/to/a_file.txt', fi.path)
|
13
|
+
assert_equal(pwd + '/some/path/to/a_file.txt', fi.real_path)
|
14
|
+
assert_equal('txt', fi.ext)
|
15
|
+
assert_equal(false, fi.dir)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'absolute_renamer/file_info'
|
3
|
+
require 'absolute_renamer/imodule'
|
4
|
+
|
5
|
+
class TC_IModuleTest < Test::Unit::TestCase
|
6
|
+
def test_symbol
|
7
|
+
assert_equal(:"AbsoluteRenamer::IModule", AbsoluteRenamer::IModule.symbol)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_process
|
11
|
+
mod = AbsoluteRenamer::IModule.new
|
12
|
+
file = AbsoluteRenamer::FileInfo.new('/some/path/to/a_file.txt')
|
13
|
+
|
14
|
+
assert_equal('format', mod.process(file, 'format', :name))
|
15
|
+
assert_equal('format', mod.process(file, 'format', :ext))
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_interpret
|
19
|
+
AbsoluteRenamer::Config.load(TEST_CONF_FILE)
|
20
|
+
mod = AbsoluteRenamer::IModule.new
|
21
|
+
file = AbsoluteRenamer::FileInfo.new('/some/path/to/a_file.txt')
|
22
|
+
|
23
|
+
def_str = AbsoluteRenamer::Config[:options][:default_string]
|
24
|
+
infos = [nil, nil, '', 'matched']
|
25
|
+
|
26
|
+
assert_equal(def_str, mod.interpret(file, infos, :name))
|
27
|
+
assert_equal(def_str, mod.interpret(file, infos, :ext))
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'absolute_renamer/parser'
|
3
|
+
|
4
|
+
class TC_ParserTest < Test::Unit::TestCase
|
5
|
+
def test_parse_cmd_line
|
6
|
+
AbsoluteRenamer::Config.load(TEST_CONF_FILE)
|
7
|
+
ARGV << '-f'
|
8
|
+
ARGV << 'format'
|
9
|
+
|
10
|
+
AbsoluteRenamer::Parser.parse_cmd_line
|
11
|
+
assert_equal('format', AbsoluteRenamer::Config[:options][:format])
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'absolute_renamer/libs/string'
|
3
|
+
|
4
|
+
class TC_StringTest < Test::Unit::TestCase
|
5
|
+
def test_simple_camelize
|
6
|
+
assert_equal("Hello World", "hello world".camelize)
|
7
|
+
assert_equal("Hello.World", "hello.world".camelize)
|
8
|
+
|
9
|
+
assert_equal("Hello The.World", "hello THE.world".camelize)
|
10
|
+
|
11
|
+
assert_equal("Hello..World", "hello..world".camelize)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_parametred_camelize
|
15
|
+
assert_equal("Hello.World", "hello.world".camelize(/\./))
|
16
|
+
assert_equal("Hello The.world", "hello THE.world".camelize(/ /))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_camelize!
|
20
|
+
str = "hello world"
|
21
|
+
assert_equal("Hello World", str.camelize!)
|
22
|
+
assert_equal("Hello World", str)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
lib_path = File.dirname(__FILE__) << '/lib/absolute_renamer'
|
3
|
+
$:.unshift(lib_path) unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
|
4
|
+
|
5
|
+
require 'test/unit/testsuite'
|
6
|
+
|
7
|
+
require 'tc_config'
|
8
|
+
require 'tc_file'
|
9
|
+
require 'tc_fileinfo'
|
10
|
+
require 'tc_imodule'
|
11
|
+
require 'tc_iplugin'
|
12
|
+
require 'tc_parser'
|
13
|
+
require 'tc_string'
|
14
|
+
|
15
|
+
TEST_CONF_FILE = File.dirname(__FILE__) << '/features/test_absrenamer.conf'
|
16
|
+
|
17
|
+
class TS_AbsoluteRenamer
|
18
|
+
def self.suite
|
19
|
+
absrenamer_suite = Test::Unit::TestSuite.new
|
20
|
+
absrenamer_suite << TC_FileTest.suite
|
21
|
+
absrenamer_suite << TC_FileInfoTest.suite
|
22
|
+
absrenamer_suite << TS_IModuleTest.suite
|
23
|
+
absrenamer_suite << TS_IPluginTest.suite
|
24
|
+
absrenamer_suite << TS_ParserTest.suite
|
25
|
+
absrenamer_suite << TS_StringTest.suite
|
26
|
+
return absrenamer_suite
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: AbsoluteRenamer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simon COURTOIS
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-08 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.4.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
version:
|
35
|
+
description: |-
|
36
|
+
AbsoluteRenamer is a very powerful tool that helps files and directories renaming using the Krename syntax.
|
37
|
+
Documentation can be found at http://absrenamer.happynoff.fr
|
38
|
+
email:
|
39
|
+
- happynoff@free.fr
|
40
|
+
executables:
|
41
|
+
- absrenamer
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- Manifest.txt
|
46
|
+
files:
|
47
|
+
- AbsoluteRenamer.gemspec
|
48
|
+
- COPYING
|
49
|
+
- ChangeLog
|
50
|
+
- LICENCE
|
51
|
+
- Manifest.txt
|
52
|
+
- README
|
53
|
+
- Rakefile
|
54
|
+
- bin/absrenamer
|
55
|
+
- conf/absrenamer/absrenamer.conf
|
56
|
+
- lib/absolute_renamer.rb
|
57
|
+
- lib/absolute_renamer/config.rb
|
58
|
+
- lib/absolute_renamer/external.rb
|
59
|
+
- lib/absolute_renamer/external/modules/core/case/module.rb
|
60
|
+
- lib/absolute_renamer/external/modules/core/general/module.rb
|
61
|
+
- lib/absolute_renamer/external/parsers/core/general/parser.rb
|
62
|
+
- lib/absolute_renamer/external/parsers/interactive/parser.rb
|
63
|
+
- lib/absolute_renamer/external/parsers/listing/parser.rb
|
64
|
+
- lib/absolute_renamer/external/plugins/interactive/plugin.rb
|
65
|
+
- lib/absolute_renamer/external/plugins/listing/plugin.rb
|
66
|
+
- lib/absolute_renamer/file_info.rb
|
67
|
+
- lib/absolute_renamer/imodule.rb
|
68
|
+
- lib/absolute_renamer/iparser.rb
|
69
|
+
- lib/absolute_renamer/iplugin.rb
|
70
|
+
- lib/absolute_renamer/libs/file.rb
|
71
|
+
- lib/absolute_renamer/libs/string.rb
|
72
|
+
- lib/absolute_renamer/parser.rb
|
73
|
+
- lib/absolute_renamer/use_config.rb
|
74
|
+
- lib/absolute_renamer/with_children.rb
|
75
|
+
- man/man8/absrenamer.8
|
76
|
+
- script/console
|
77
|
+
- script/destroy
|
78
|
+
- script/generate
|
79
|
+
- setup.rb
|
80
|
+
- test/unit/features/test_absrenamer.conf
|
81
|
+
- test/unit/tc_config.rb
|
82
|
+
- test/unit/tc_file.rb
|
83
|
+
- test/unit/tc_fileinfo.rb
|
84
|
+
- test/unit/tc_imodule.rb
|
85
|
+
- test/unit/tc_iplugin.rb
|
86
|
+
- test/unit/tc_parser.rb
|
87
|
+
- test/unit/tc_string.rb
|
88
|
+
- test/unit/test_suite.rb
|
89
|
+
has_rdoc: true
|
90
|
+
homepage: http://absrenamer.happynoff.fr
|
91
|
+
licenses: []
|
92
|
+
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options:
|
95
|
+
- --main
|
96
|
+
- README
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
- ext
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "0"
|
105
|
+
version:
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: "0"
|
111
|
+
version:
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project: AbsoluteRenamer
|
115
|
+
rubygems_version: 1.3.3
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: AbsoluteRenamer is a very powerful tool that helps files and directories renaming using the Krename syntax
|
119
|
+
test_files:
|
120
|
+
- test/unit/test_suite.rb
|