bakker 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -3
- data/COPYING.txt +0 -2
- data/History.txt +18 -1
- data/Manifest.txt +3 -2
- data/{README.txt → README.rdoc} +81 -11
- data/Rakefile +8 -4
- data/bin/bakker +37 -39
- data/lib/bakker.rb +11 -51
- data/lib/bakker/bakker.rb +73 -0
- data/spec/bakker_spec.rb +170 -139
- metadata +26 -11
- metadata.gz.sig +1 -2
data.tar.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
��b��}����(t�{���R�����*���K���f%,F���F���Z�4�k�%v-�s�jU��6�����1��"Q&V�h��&�8��c&>���T�jl�ļ�pˣ=Z��1j�:�o�Kߗ�Bm����b9��zC��l�@��Х�q?,����s}�-,6~O�� �
|
3
|
-
��Y��ꋑV�3o,̺�|�P�}**��s�a!-�#�C�:
|
1
|
+
t�:�s�\�8-���g��ilA��6z���sgw�S�&�S��[��F�%� �ڀ�����|Y�q,�����3�ŭ���XcXp�je��$Gԥa���\�#�ayD�)ńA�{�p�}R�ߌ'8Ͷ{f�`��_�Ě��φ2V�%�� ن2)�8��W��J8N�F��1uV��%.��ӆNc�c.����1jO����I�����N��(P��{�n� ���#.��,$Ómˊ��[
|
data/COPYING.txt
CHANGED
@@ -672,5 +672,3 @@ may consider it more useful to permit linking proprietary applications with
|
|
672
672
|
the library. If this is what you want to do, use the GNU Lesser General
|
673
673
|
Public License instead of this License. But first, please read
|
674
674
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
675
|
-
|
676
|
-
|
data/History.txt
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
+
=== 1.1.0 / 2009-04-05
|
2
|
+
|
3
|
+
* 1 major enhancement
|
4
|
+
|
5
|
+
* Namespaced into module Aef
|
6
|
+
|
7
|
+
* 5 minor enhancements
|
8
|
+
|
9
|
+
* Better metadata for gem
|
10
|
+
* Test refactoring
|
11
|
+
* Minor refactorings
|
12
|
+
* Improved documentation
|
13
|
+
* Added test for --version command
|
14
|
+
|
15
|
+
* 1 minor bugfix
|
16
|
+
|
17
|
+
* Fixed some bugs related to Ruby 1.8.6
|
18
|
+
|
1
19
|
=== 1.0.0 / 2009-03-01
|
2
20
|
|
3
21
|
* 1 major enhancement
|
4
22
|
|
5
23
|
* Birthday!
|
6
|
-
|
data/Manifest.txt
CHANGED
data/{README.txt → README.rdoc}
RENAMED
@@ -2,20 +2,22 @@
|
|
2
2
|
|
3
3
|
* Project: https://rubyforge.org/projects/aef/
|
4
4
|
* RDoc: http://aef.rubyforge.org/bakker/
|
5
|
+
* Github: http://github.com/aef/bakker/
|
5
6
|
|
6
7
|
== DESCRIPTION:
|
7
8
|
|
8
|
-
Bakker
|
9
|
-
quick backup purposes. For instance by creating
|
10
|
-
while adding .bak to the copies filenames. Bakker
|
11
|
-
extension to be added to or removed from the file
|
12
|
-
moved or copied.
|
9
|
+
Bakker is a Ruby library and commandline tool to help with simple task of
|
10
|
+
renaming or copying files for quick backup purposes. For instance by creating
|
11
|
+
a copy of a list of files while adding .bak to the copies filenames. Bakker
|
12
|
+
gives you control over the extension to be added to or removed from the file
|
13
|
+
and whether it should be moved or copied.
|
13
14
|
|
14
15
|
== FEATURES/PROBLEMS:
|
15
16
|
|
16
17
|
* Usable as library and commandline tool
|
17
18
|
* Tested and fully working on:
|
18
19
|
* Ubuntu Linux 8.10 i386_64 (Ruby 1.8.7 and 1.9.1p0)
|
20
|
+
* Debian GNU/Linux 4.0 i386 (Ruby 1.8.6)
|
19
21
|
* On Windows XP i386 (Ruby 1.8.6)
|
20
22
|
* On Windows XP i386 (Ruby 1.8.6) there were some problems testing the
|
21
23
|
environment variable choices. Two tests are failing but the programs seems
|
@@ -103,18 +105,86 @@ Load the gem:
|
|
103
105
|
|
104
106
|
Call Bakker:
|
105
107
|
|
106
|
-
Bakker.process('config.ini', '.backup', :add, :copy)
|
108
|
+
Aef::Bakker.process('config.ini', '.backup', :add, :copy)
|
107
109
|
|
108
110
|
== REQUIREMENTS:
|
109
111
|
|
110
|
-
*
|
111
|
-
|
112
|
-
|
112
|
+
* rubygems
|
113
|
+
|
114
|
+
=== Additional for commandline
|
115
|
+
* user-choices
|
116
|
+
|
117
|
+
=== Additional for automated testing
|
118
|
+
* hoe
|
119
|
+
* rspec
|
120
|
+
* sys-uname
|
113
121
|
|
114
122
|
== INSTALL:
|
115
123
|
|
116
|
-
|
117
|
-
|
124
|
+
=== Normal
|
125
|
+
|
126
|
+
gem install bakker
|
127
|
+
|
128
|
+
Additionally for the commandline tool:
|
129
|
+
|
130
|
+
gem install user-choices
|
131
|
+
|
132
|
+
=== High security (recommended)
|
133
|
+
|
134
|
+
There is a high security installation option available through rubygems. It is
|
135
|
+
highly recommended over the normal installation, although it may be a bit less
|
136
|
+
comfortable. To use the installation method, you will need my public key, which
|
137
|
+
I use for cryptographic signatures on all my gems. You can find the public key
|
138
|
+
and more detailed verification information in the aef-certificates section of my
|
139
|
+
rubyforge project[https://rubyforge.org/frs/?group_id=7890&release_id=31749]
|
140
|
+
|
141
|
+
Add the key to your rubygems' trusted certificates by the following command:
|
142
|
+
|
143
|
+
gem cert --add aef.pem
|
144
|
+
|
145
|
+
Now you can install the gem while automatically verifying it's signature by the
|
146
|
+
following command:
|
147
|
+
|
148
|
+
gem install bakker -P HighSecurity
|
149
|
+
|
150
|
+
Please notice that you will need other keys for dependent libraries, so you may
|
151
|
+
have to install dependencies manually.
|
152
|
+
|
153
|
+
=== Automated testing
|
154
|
+
|
155
|
+
You can test this package through rspec on your system. First find the path
|
156
|
+
where the gem was installed to:
|
157
|
+
|
158
|
+
gem which bakker
|
159
|
+
|
160
|
+
Go into the root directory of the installed gem and run the following command
|
161
|
+
to start the test runner:
|
162
|
+
|
163
|
+
rake spec
|
164
|
+
|
165
|
+
On Windows systems you have to run the following instead:
|
166
|
+
|
167
|
+
spec spec/**/*_spec.rb
|
168
|
+
|
169
|
+
If something goes wrong you should be noticed through failing examples.
|
170
|
+
|
171
|
+
== DEVELOPMENT:
|
172
|
+
|
173
|
+
This software is developed in the source code management system git hosted
|
174
|
+
at github.com. You can download the most recent sourcecode through the following
|
175
|
+
command:
|
176
|
+
|
177
|
+
git clone git://github.com/aef/bakker.git
|
178
|
+
|
179
|
+
Help on making this software better is always very appreciated. If you want your
|
180
|
+
changes to be included in the official release, please send me a patch through
|
181
|
+
the project's tracker[https://rubyforge.org/tracker/?group_id=7890] at
|
182
|
+
rubyforge.org. You can generate a patch-file by the following command:
|
183
|
+
|
184
|
+
git diff > patch.diff
|
185
|
+
|
186
|
+
Please make sure to write tests for your changes and notice that I can't promise
|
187
|
+
to include your changes before reviewing them.
|
118
188
|
|
119
189
|
== LICENSE:
|
120
190
|
|
data/Rakefile
CHANGED
@@ -4,12 +4,16 @@ require 'rubygems'
|
|
4
4
|
require 'hoe'
|
5
5
|
require './lib/bakker.rb'
|
6
6
|
|
7
|
-
Hoe.new('bakker', Bakker::VERSION) do |p|
|
7
|
+
Hoe.new('bakker', Aef::Bakker::VERSION) do |p|
|
8
8
|
p.rubyforge_name = 'aef'
|
9
9
|
p.developer('Alexander E. Fischer', 'aef@raxys.net')
|
10
|
-
p.extra_dev_deps = %w{user-choices sys-uname}
|
11
|
-
p.
|
12
|
-
p.
|
10
|
+
p.extra_dev_deps = %w{user-choices rspec sys-uname}
|
11
|
+
p.url = 'https://rubyforge.org/projects/aef/'
|
12
|
+
p.readme_file = 'README.rdoc'
|
13
|
+
p.extra_rdoc_files = %w{README.rdoc}
|
14
|
+
p.spec_extras = {
|
15
|
+
:rdoc_options => ['--main', 'README.rdoc', '--inline-source', '--line-numbers', '--title', 'Bakker']
|
16
|
+
}
|
13
17
|
end
|
14
18
|
|
15
19
|
# vim: syntax=Ruby
|
data/bin/bakker
CHANGED
@@ -37,7 +37,7 @@ rescue LoadError
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# Application class for commandline interface
|
40
|
-
class Bakker::Application < UserChoices::Command
|
40
|
+
class Aef::Bakker::Application < UserChoices::Command
|
41
41
|
include UserChoices
|
42
42
|
|
43
43
|
# Prepare configuration sources
|
@@ -45,8 +45,8 @@ class Bakker::Application < UserChoices::Command
|
|
45
45
|
builder.add_source(CommandLineSource, :usage,
|
46
46
|
"Usage: #$PROGRAM_NAME [options] files\n\n",
|
47
47
|
"You can set the default behavior through environment variables:\n",
|
48
|
-
"BAKKER_MODE (#{Bakker::MODES.join(', ')}. Default: #{Bakker::MODES.first})",
|
49
|
-
"BAKKER_ACTION (#{Bakker::ACTIONS.join(', ')}. Default: #{Bakker::ACTIONS.first})",
|
48
|
+
"BAKKER_MODE (#{Aef::Bakker::MODES.join(', ')}. Default: #{Aef::Bakker::MODES.first})",
|
49
|
+
"BAKKER_ACTION (#{Aef::Bakker::ACTIONS.join(', ')}. Default: #{Aef::Bakker::ACTIONS.first})",
|
50
50
|
'BAKKER_EXTENSION (Default: .bak)',
|
51
51
|
"BAKKER_VERBOSE (true, false. Default: false)\n"
|
52
52
|
)
|
@@ -64,19 +64,19 @@ class Bakker::Application < UserChoices::Command
|
|
64
64
|
|
65
65
|
# Define configuration options
|
66
66
|
def add_choices(builder)
|
67
|
-
builder.add_choice(:mode, :type => Bakker::MODES.map{|item| item.to_s}, :default => Bakker::MODES.first.to_s) do |cli|
|
67
|
+
builder.add_choice(:mode, :type => Aef::Bakker::MODES.map{|item| item.to_s}, :default => Aef::Bakker::MODES.first.to_s) do |cli|
|
68
68
|
cli.uses_option('-m', '--mode MODE',
|
69
|
-
"Processing mode. Can be one of: #{Bakker::MODES.join(', ')}. " +
|
70
|
-
"Default: #{Bakker::MODES.first}")
|
69
|
+
"Processing mode. Can be one of: #{Aef::Bakker::MODES.join(', ')}. " +
|
70
|
+
"Default: #{Aef::Bakker::MODES.first}")
|
71
71
|
end
|
72
72
|
|
73
|
-
builder.add_choice(:action, :type => Bakker::ACTIONS.map{|item| item.to_s}, :default => Bakker::ACTIONS.first.to_s) do |cli|
|
73
|
+
builder.add_choice(:action, :type => Aef::Bakker::ACTIONS.map{|item| item.to_s}, :default => Aef::Bakker::ACTIONS.first.to_s) do |cli|
|
74
74
|
cli.uses_option('-a', '--action ACTION',
|
75
|
-
"Filesystem action. Can be one of: #{Bakker::ACTIONS.join(', ')}. " +
|
76
|
-
"Default: #{Bakker::ACTIONS.first}")
|
75
|
+
"Filesystem action. Can be one of: #{Aef::Bakker::ACTIONS.join(', ')}. " +
|
76
|
+
"Default: #{Aef::Bakker::ACTIONS.first}")
|
77
77
|
end
|
78
78
|
|
79
|
-
builder.add_choice(:extension, :default => Bakker::DEFAULT_EXTENSION) do |cli|
|
79
|
+
builder.add_choice(:extension, :default => Aef::Bakker::DEFAULT_EXTENSION) do |cli|
|
80
80
|
cli.uses_option('-e', '--extension EXTENSION',
|
81
81
|
"Suffix to be added/removed"
|
82
82
|
)
|
@@ -93,22 +93,40 @@ class Bakker::Application < UserChoices::Command
|
|
93
93
|
builder.add_choice(:filenames) {|cli| cli.uses_arglist }
|
94
94
|
end
|
95
95
|
|
96
|
+
# Manual option post processing
|
97
|
+
def postprocess_user_choices
|
98
|
+
version if @user_choices[:version]
|
99
|
+
end
|
100
|
+
|
101
|
+
# Version and licensing information output
|
102
|
+
def version
|
103
|
+
name = 'Bakker'
|
104
|
+
puts "#{name} #{Aef::Bakker::VERSION}"
|
105
|
+
puts
|
106
|
+
puts 'Project: https://rubyforge.org/projects/aef/'
|
107
|
+
puts "RDoc: http://aef.rubyforge.org/#{name.downcase}/"
|
108
|
+
puts "Github: http://github.com/aef/#{name.downcase}/"
|
109
|
+
puts
|
110
|
+
puts 'Copyright 2009 Alexander E. Fischer <aef@raxys.net>'
|
111
|
+
# Read and print licensing information from the top of this file
|
112
|
+
if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('1.8.6')
|
113
|
+
puts File.read(__FILE__).map{|line| line[2..-1]}[5..17]
|
114
|
+
else
|
115
|
+
puts File.read(__FILE__).lines.map{|line| line[2..-1]}[5..17]
|
116
|
+
end
|
117
|
+
exit
|
118
|
+
end
|
119
|
+
|
96
120
|
# Main program
|
97
121
|
def execute
|
98
|
-
if @user_choices[:version]
|
99
|
-
klass = Bakker
|
100
|
-
puts "\n#{klass.name} #{klass::VERSION}"
|
101
|
-
puts DATA.read; exit
|
102
|
-
end
|
103
|
-
|
104
122
|
if @user_choices[:filenames].empty?
|
105
123
|
warn 'No files given'; exit false
|
106
124
|
else
|
107
125
|
@user_choices[:filenames].each do |filename|
|
108
126
|
begin
|
109
|
-
Bakker.process(filename, @user_choices[:extension], @user_choices[:mode].to_sym,
|
127
|
+
Aef::Bakker.process(filename, @user_choices[:extension], @user_choices[:mode].to_sym,
|
110
128
|
@user_choices[:action].to_sym, { :verbose => @user_choices[:verbose] })
|
111
|
-
rescue BakkerWarning
|
129
|
+
rescue Aef::BakkerWarning
|
112
130
|
warn "Ignoring #{filename}: #$!"
|
113
131
|
end
|
114
132
|
end
|
@@ -116,24 +134,4 @@ class Bakker::Application < UserChoices::Command
|
|
116
134
|
end
|
117
135
|
end
|
118
136
|
|
119
|
-
S4tUtils.with_pleasant_exceptions {Bakker::Application.new.execute}
|
120
|
-
|
121
|
-
__END__
|
122
|
-
|
123
|
-
Project: https://rubyforge.org/projects/aef/
|
124
|
-
RDoc: http://aef.rubyforge.org/bakker/
|
125
|
-
|
126
|
-
Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
127
|
-
|
128
|
-
Bakker is free software: you can redistribute it and/or modify
|
129
|
-
it under the terms of the GNU General Public License as published by
|
130
|
-
the Free Software Foundation, either version 3 of the License, or
|
131
|
-
(at your option) any later version.
|
132
|
-
|
133
|
-
This program is distributed in the hope that it will be useful,
|
134
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
135
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
136
|
-
GNU General Public License for more details.
|
137
|
-
|
138
|
-
You should have received a copy of the GNU General Public License
|
139
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
137
|
+
S4tUtils.with_pleasant_exceptions {Aef::Bakker::Application.new.execute}
|
data/lib/bakker.rb
CHANGED
@@ -13,57 +13,17 @@
|
|
13
13
|
# GNU General Public License for more details.
|
14
14
|
#
|
15
15
|
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with this program. If not, see <http://www.gnu.org/licenses
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
ACTIONS = [:move, :copy]
|
27
|
-
|
28
|
-
# For possible options see FileUtils methods cp() and mv()
|
29
|
-
def self.process(filename, extension = DEFAULT_EXTENSION, mode = MODES.first, action = ACTIONS.first, options = {})
|
30
|
-
raise ArgumentError, 'Action can only be :copy or :move.' unless ACTIONS.include?(action)
|
31
|
-
raise ArgumentError, 'Mode can only be :toggle, :add or :remove.' unless MODES.include?(mode)
|
32
|
-
|
33
|
-
# Regex used for determining if an extension should be added or removed
|
34
|
-
regexp = /#{Regexp.escape(extension)}$/
|
35
|
-
|
36
|
-
# Find out both the basic file name and the extended file name for every
|
37
|
-
# situation possible
|
38
|
-
filename_without_extension = filename.gsub(regexp, '')
|
39
|
-
filename_with_extension = filename_without_extension + extension
|
40
|
-
|
41
|
-
# Check both cases for existence for further processing
|
42
|
-
without_exists = File.exists?(filename_without_extension)
|
43
|
-
with_exists = File.exists?(filename_with_extension)
|
18
|
+
# Namespace for projects of Alexander E. Fischer <aef@raxys.net>
|
19
|
+
#
|
20
|
+
# If you want to be able to simply type Example instead of Aef::Example to
|
21
|
+
# address classes in this namespace simply write the following before using the
|
22
|
+
# classes:
|
23
|
+
#
|
24
|
+
# include Aef
|
25
|
+
module Aef
|
44
26
|
|
45
|
-
# Error if both unextended and extended files or none of them exist
|
46
|
-
#
|
47
|
-
# The mode variable contains symbols :copy or :move which correspond to
|
48
|
-
# methods of class FileUtils which are invoked through the send() method.
|
49
|
-
if without_exists and with_exists
|
50
|
-
raise BakkerWarning, "Both #{filename_without_extension} and #{filename_with_extension} already exist."
|
51
|
-
elsif without_exists and not with_exists
|
52
|
-
if [:toggle, :add].include?(mode)
|
53
|
-
FileUtils.send(action, filename_without_extension, filename_with_extension, options)
|
54
|
-
filename_with_extension
|
55
|
-
else
|
56
|
-
filename_without_extension
|
57
|
-
end
|
58
|
-
elsif not without_exists and with_exists
|
59
|
-
if [:toggle, :remove].include?(mode)
|
60
|
-
FileUtils.send(action, filename_with_extension, filename_without_extension, options)
|
61
|
-
filename_without_extension
|
62
|
-
else
|
63
|
-
filename_with_extension
|
64
|
-
end
|
65
|
-
else
|
66
|
-
raise BakkerWarning, "Neither #{filename_without_extension} nor #{filename_with_extension} found."
|
67
|
-
end
|
68
|
-
end
|
69
27
|
end
|
28
|
+
|
29
|
+
require File.join(File.dirname(__FILE__), 'bakker/bakker')
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
2
|
+
#
|
3
|
+
# This file is part of Bakker.
|
4
|
+
#
|
5
|
+
# Bakker is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
17
|
+
|
18
|
+
require 'fileutils'
|
19
|
+
|
20
|
+
class Aef::BakkerWarning < StandardError; end
|
21
|
+
|
22
|
+
# Bakker is a Ruby library and commandline tool to help with simple task of
|
23
|
+
# renaming or copying files for quick backup purposes.
|
24
|
+
module Aef::Bakker
|
25
|
+
VERSION = '1.1.0'
|
26
|
+
DEFAULT_EXTENSION = '.bak'
|
27
|
+
MODES = [:toggle, :add, :remove]
|
28
|
+
ACTIONS = [:move, :copy]
|
29
|
+
|
30
|
+
module_function
|
31
|
+
|
32
|
+
# For possible options see FileUtils methods cp() and mv()
|
33
|
+
def process(filename, extension = DEFAULT_EXTENSION, mode = MODES.first, action = ACTIONS.first, options = {})
|
34
|
+
raise ArgumentError, 'Action can only be :copy or :move.' unless ACTIONS.include?(action)
|
35
|
+
raise ArgumentError, 'Mode can only be :toggle, :add or :remove.' unless MODES.include?(mode)
|
36
|
+
|
37
|
+
# Regex used for determining if an extension should be added or removed
|
38
|
+
regexp = /#{Regexp.escape(extension)}$/
|
39
|
+
|
40
|
+
# Find out both the basic file name and the extended file name for every
|
41
|
+
# situation possible
|
42
|
+
filename_without_extension = filename.gsub(regexp, '')
|
43
|
+
filename_with_extension = filename_without_extension + extension
|
44
|
+
|
45
|
+
# Check both cases for existence for further processing
|
46
|
+
without_exists = File.exists?(filename_without_extension)
|
47
|
+
with_exists = File.exists?(filename_with_extension)
|
48
|
+
|
49
|
+
# Error if both unextended and extended files or none of them exist
|
50
|
+
#
|
51
|
+
# The mode variable contains symbols :copy or :move which correspond to
|
52
|
+
# methods of class FileUtils which are invoked through the send() method.
|
53
|
+
if without_exists and with_exists
|
54
|
+
raise Aef::BakkerWarning, "Both #{filename_without_extension} and #{filename_with_extension} already exist."
|
55
|
+
elsif without_exists and not with_exists
|
56
|
+
if [:toggle, :add].include?(mode)
|
57
|
+
FileUtils.send(action, filename_without_extension, filename_with_extension, options)
|
58
|
+
filename_with_extension
|
59
|
+
else
|
60
|
+
filename_without_extension
|
61
|
+
end
|
62
|
+
elsif not without_exists and with_exists
|
63
|
+
if [:toggle, :remove].include?(mode)
|
64
|
+
FileUtils.send(action, filename_with_extension, filename_without_extension, options)
|
65
|
+
filename_without_extension
|
66
|
+
else
|
67
|
+
filename_with_extension
|
68
|
+
end
|
69
|
+
else
|
70
|
+
raise Aef::BakkerWarning, "Neither #{filename_without_extension} nor #{filename_with_extension} found."
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/bakker_spec.rb
CHANGED
@@ -17,25 +17,29 @@
|
|
17
17
|
|
18
18
|
require 'lib/bakker'
|
19
19
|
|
20
|
-
require '
|
20
|
+
require 'tmpdir'
|
21
21
|
require 'fileutils'
|
22
22
|
|
23
23
|
require 'rubygems'
|
24
24
|
require 'sys/uname'
|
25
25
|
|
26
|
-
# If there is a way to get the executable path of the currently running ruby
|
27
|
-
# interpreter, please tell me how.
|
28
|
-
warn 'Attention: If the ruby interpreter to be tested with is not ruby in the' +
|
29
|
-
'default path, you have to change this manually in spec/bakker_spec.rb'
|
30
|
-
RUBY_PATH = 'ruby'
|
31
|
-
|
32
26
|
module BakkerSpecHelper
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
# If there is a way to get the executable path of the currently running ruby
|
28
|
+
# interpreter, please tell me how.
|
29
|
+
warn 'Attention: If the ruby interpreter to be tested with is not ruby in the ' +
|
30
|
+
"default path, you have to change this manually in #{__FILE__} line #{__LINE__ + 1}"
|
31
|
+
RUBY_PATH = 'ruby'
|
32
|
+
|
33
|
+
def tempfile_path(name, options = {})
|
34
|
+
path = File.join(@folder_path, name)
|
35
|
+
|
36
|
+
FileUtils.touch(path) if options[:create]
|
37
37
|
|
38
|
-
|
38
|
+
path
|
39
|
+
end
|
40
|
+
|
41
|
+
def executable_path
|
42
|
+
"#{RUBY_PATH} bin/bakker"
|
39
43
|
end
|
40
44
|
|
41
45
|
def windows?
|
@@ -43,308 +47,309 @@ module BakkerSpecHelper
|
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
46
|
-
describe Bakker do
|
50
|
+
describe Aef::Bakker do
|
47
51
|
include BakkerSpecHelper
|
48
52
|
|
49
53
|
before(:each) do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
# Before ruby 1.8.7, the tmpdir standard library had no method to create
|
55
|
+
# a temporary directory (mktmpdir).
|
56
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.8.7')
|
57
|
+
@folder_path = File.join(Dir.tmpdir, 'bakker_spec')
|
58
|
+
Dir.mkdir(@folder_path)
|
59
|
+
else
|
60
|
+
@folder_path = Dir.mktmpdir('bakker_spec')
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
58
64
|
after(:each) do
|
59
65
|
FileUtils.rm_rf(@folder_path)
|
60
66
|
end
|
61
67
|
|
62
|
-
|
68
|
+
context 'library' do
|
63
69
|
it "should throw an exception when source file does not exist" do
|
64
|
-
source_path =
|
65
|
-
FileUtils.rm(source_path)
|
70
|
+
source_path = tempfile_path('abc')
|
66
71
|
|
67
72
|
lambda {
|
68
|
-
Bakker.process(source_path)
|
69
|
-
}.should raise_error(BakkerWarning)
|
73
|
+
Aef::Bakker.process(source_path)
|
74
|
+
}.should raise_error(Aef::BakkerWarning)
|
70
75
|
end
|
71
76
|
|
72
77
|
it "should throw an exception when source and target file do exist" do
|
73
|
-
source_path =
|
74
|
-
target_path =
|
78
|
+
source_path = tempfile_path('abc', :create => true)
|
79
|
+
target_path = tempfile_path('abc.bak', :create => true)
|
75
80
|
|
76
81
|
lambda {
|
77
|
-
Bakker.process(source_path)
|
78
|
-
}.should raise_error(BakkerWarning)
|
82
|
+
Aef::Bakker.process(source_path)
|
83
|
+
}.should raise_error(Aef::BakkerWarning)
|
79
84
|
end
|
80
85
|
|
81
86
|
it "should extend a non-extended file correctly" do
|
82
|
-
source_path =
|
83
|
-
target_path =
|
87
|
+
source_path = tempfile_path('def', :create => true)
|
88
|
+
target_path = tempfile_path('def.bak')
|
84
89
|
|
85
90
|
lambda {
|
86
|
-
Bakker.process(source_path, '.bak', :toggle, :move)
|
91
|
+
Aef::Bakker.process(source_path, '.bak', :toggle, :move)
|
87
92
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
88
93
|
change{ File.exist?(source_path) }.from(true).to(false)
|
89
94
|
end
|
90
95
|
|
91
96
|
it "should extend a non-extended file correctly even if only the target is given" do
|
92
|
-
source_path =
|
93
|
-
target_path =
|
97
|
+
source_path = tempfile_path('def', :create => true)
|
98
|
+
target_path = tempfile_path('def.bak')
|
94
99
|
|
95
100
|
lambda {
|
96
|
-
Bakker.process(target_path, '.bak', :toggle, :move)
|
101
|
+
Aef::Bakker.process(target_path, '.bak', :toggle, :move)
|
97
102
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
98
103
|
change{ File.exist?(source_path) }.from(true).to(false)
|
99
104
|
end
|
100
105
|
|
101
106
|
it "should not extend a non-extended file if mode is remove" do
|
102
|
-
source_path =
|
103
|
-
target_path =
|
107
|
+
source_path = tempfile_path('abc', :create => true)
|
108
|
+
target_path = tempfile_path('abc.ext')
|
104
109
|
|
105
110
|
lambda {
|
106
|
-
Bakker.process(source_path, '.ext', :remove, :move)
|
111
|
+
Aef::Bakker.process(source_path, '.ext', :remove, :move)
|
107
112
|
}.should_not change{ File.exist?(target_path) == false } and
|
108
113
|
change{ File.exist?(source_path) == true }
|
109
114
|
end
|
110
115
|
|
111
116
|
it "should not extend a non-extended file if mode is remove even if only the target is given" do
|
112
|
-
source_path =
|
113
|
-
target_path =
|
117
|
+
source_path = tempfile_path('abc', :create => true)
|
118
|
+
target_path = tempfile_path('abc.ext')
|
114
119
|
|
115
120
|
lambda {
|
116
|
-
Bakker.process(target_path, '.ext', :remove, :move)
|
121
|
+
Aef::Bakker.process(target_path, '.ext', :remove, :move)
|
117
122
|
}.should_not change{ File.exist?(target_path) == false } and
|
118
123
|
change{ File.exist?(source_path) == true }
|
119
124
|
end
|
120
125
|
|
121
126
|
it "should extend a non-extended file if mode is add" do
|
122
|
-
source_path =
|
123
|
-
target_path =
|
127
|
+
source_path = tempfile_path('abc', :create => true)
|
128
|
+
target_path = tempfile_path('abc.ext')
|
124
129
|
|
125
130
|
lambda {
|
126
|
-
Bakker.process(source_path, '.ext', :add, :move)
|
131
|
+
Aef::Bakker.process(source_path, '.ext', :add, :move)
|
127
132
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
128
133
|
change{ File.exist?(source_path) }.from(true).to(false)
|
129
134
|
end
|
130
135
|
|
131
136
|
it "should extend a non-extended file if mode is add even if only the target is given" do
|
132
|
-
source_path =
|
133
|
-
target_path =
|
137
|
+
source_path = tempfile_path('abc', :create => true)
|
138
|
+
target_path = tempfile_path('abc.ext')
|
134
139
|
|
135
140
|
lambda {
|
136
|
-
Bakker.process(source_path, '.ext', :add, :move)
|
141
|
+
Aef::Bakker.process(source_path, '.ext', :add, :move)
|
137
142
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
138
143
|
change{ File.exist?(source_path) }.from(true).to(false)
|
139
144
|
end
|
140
145
|
|
141
146
|
it "should create an extended copy of a non-extended file if action is copy" do
|
142
|
-
source_path =
|
143
|
-
target_path =
|
147
|
+
source_path = tempfile_path('xyz', :create => true)
|
148
|
+
target_path = tempfile_path('xyz.tar.gz')
|
144
149
|
|
145
150
|
lambda {
|
146
|
-
Bakker.process(source_path, '.tar.gz', :toggle, :copy)
|
151
|
+
Aef::Bakker.process(source_path, '.tar.gz', :toggle, :copy)
|
147
152
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
148
153
|
not change{ File.exists?(source_path) == true }
|
149
154
|
end
|
150
155
|
|
151
156
|
it "should create an extended copy of a non-extended file if action is copy even if only the target is given" do
|
152
|
-
source_path =
|
153
|
-
target_path =
|
157
|
+
source_path = tempfile_path('xyz', :create => true)
|
158
|
+
target_path = tempfile_path('xyz.tar.gz')
|
154
159
|
|
155
160
|
lambda {
|
156
|
-
Bakker.process(target_path, '.tar.gz', :toggle, :copy)
|
161
|
+
Aef::Bakker.process(target_path, '.tar.gz', :toggle, :copy)
|
157
162
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
158
163
|
not change{ File.exists?(source_path) == true }
|
159
164
|
end
|
160
165
|
|
161
166
|
it "should unextend an extended file correctly" do
|
162
|
-
source_path =
|
163
|
-
target_path =
|
167
|
+
source_path = tempfile_path('xyz.zirbel', :create => true)
|
168
|
+
target_path = tempfile_path('xyz')
|
164
169
|
|
165
170
|
lambda {
|
166
|
-
Bakker.process(source_path, '.zirbel', :toggle, :move)
|
171
|
+
Aef::Bakker.process(source_path, '.zirbel', :toggle, :move)
|
167
172
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
168
173
|
change{ File.exist?(source_path) }.from(true).to(false)
|
169
174
|
end
|
170
175
|
|
171
176
|
it "should unextend an extended file correctly even if only the target is given" do
|
172
|
-
source_path =
|
173
|
-
target_path =
|
177
|
+
source_path = tempfile_path('xyz.zirbel', :create => true)
|
178
|
+
target_path = tempfile_path('xyz')
|
174
179
|
|
175
180
|
lambda {
|
176
|
-
Bakker.process(target_path, '.zirbel', :toggle, :move)
|
181
|
+
Aef::Bakker.process(target_path, '.zirbel', :toggle, :move)
|
177
182
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
178
183
|
change{ File.exist?(source_path) }.from(true).to(false)
|
179
184
|
end
|
180
185
|
|
181
186
|
it "should not unextend an extended file if mode is add" do
|
182
|
-
source_path =
|
183
|
-
target_path =
|
187
|
+
source_path = tempfile_path('1234.bak', :create => true)
|
188
|
+
target_path = tempfile_path('1234')
|
184
189
|
|
185
190
|
lambda {
|
186
|
-
Bakker.process(source_path, '.bak', :add, :move)
|
191
|
+
Aef::Bakker.process(source_path, '.bak', :add, :move)
|
187
192
|
}.should_not change{ File.exist?(target_path) == false } and
|
188
193
|
change{ File.exist?(source_path) == true }
|
189
194
|
end
|
190
195
|
|
191
196
|
it "should not unextend an extended file if mode is add even if only the target is given" do
|
192
|
-
source_path =
|
193
|
-
target_path =
|
197
|
+
source_path = tempfile_path('1234.bak', :create => true)
|
198
|
+
target_path = tempfile_path('1234')
|
194
199
|
|
195
200
|
lambda {
|
196
|
-
Bakker.process(target_path, '.bak', :add, :move)
|
201
|
+
Aef::Bakker.process(target_path, '.bak', :add, :move)
|
197
202
|
}.should_not change{ File.exist?(target_path) == false } and
|
198
203
|
change{ File.exist?(source_path) == true }
|
199
204
|
end
|
200
205
|
|
201
206
|
it "should unextend an extended file if mode is remove" do
|
202
|
-
source_path =
|
203
|
-
target_path =
|
207
|
+
source_path = tempfile_path('testfile.1234', :create => true)
|
208
|
+
target_path = tempfile_path('testfile')
|
204
209
|
|
205
210
|
lambda {
|
206
|
-
Bakker.process(source_path, '.1234', :remove, :move)
|
211
|
+
Aef::Bakker.process(source_path, '.1234', :remove, :move)
|
207
212
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
208
213
|
change{ File.exist?(source_path) }.from(true).to(false)
|
209
214
|
end
|
210
215
|
|
211
216
|
it "should unextend an extended file if mode is remove even if only the target is given" do
|
212
|
-
source_path =
|
213
|
-
target_path =
|
217
|
+
source_path = tempfile_path('testfile.1234', :create => true)
|
218
|
+
target_path = tempfile_path('testfile')
|
214
219
|
|
215
220
|
lambda {
|
216
|
-
Bakker.process(target_path, '.1234', :remove, :move)
|
221
|
+
Aef::Bakker.process(target_path, '.1234', :remove, :move)
|
217
222
|
}.should change{ File.exist?(target_path) }.from(false).to(true) and
|
218
223
|
change{ File.exist?(source_path) }.from(true).to(false)
|
219
224
|
end
|
220
225
|
|
221
226
|
it "should create an unextended copy of an extended file if action is copy" do
|
222
|
-
source_path =
|
223
|
-
target_path =
|
227
|
+
source_path = tempfile_path('demo.exe', :create => true)
|
228
|
+
target_path = tempfile_path('demo')
|
224
229
|
|
225
230
|
lambda {
|
226
|
-
Bakker.process(source_path, '.exe', :toggle, :copy)
|
231
|
+
Aef::Bakker.process(source_path, '.exe', :toggle, :copy)
|
227
232
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
228
233
|
not change{ File.exists?(source_path) == true }
|
229
234
|
end
|
230
235
|
|
231
236
|
it "should create an unextended copy of an extended file if action is copy even if only the target is given" do
|
232
|
-
source_path =
|
233
|
-
target_path =
|
237
|
+
source_path = tempfile_path('demo.exe', :create => true)
|
238
|
+
target_path = tempfile_path('demo')
|
234
239
|
|
235
240
|
lambda {
|
236
|
-
Bakker.process(target_path, '.exe', :toggle, :copy)
|
241
|
+
Aef::Bakker.process(target_path, '.exe', :toggle, :copy)
|
237
242
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
238
243
|
not change{ File.exists?(source_path) == true }
|
239
244
|
end
|
240
245
|
end
|
241
246
|
|
242
|
-
|
247
|
+
context 'commandline tool' do
|
243
248
|
it "use action move, extension .bak and mode toggle by default" do
|
244
|
-
source_path =
|
245
|
-
target_path =
|
249
|
+
source_path = tempfile_path('test.bak', :create => true)
|
250
|
+
target_path = tempfile_path('test')
|
246
251
|
|
247
252
|
lambda {
|
248
|
-
`#{
|
253
|
+
`#{executable_path} #{source_path}`
|
249
254
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
250
255
|
change{ File.exists?(source_path) }.from(true).to(false)
|
251
256
|
|
252
257
|
lambda {
|
253
|
-
`#{
|
258
|
+
`#{executable_path} #{target_path}`
|
254
259
|
}.should change{ File.exists?(target_path) }.from(true).to(false) and
|
255
260
|
change{ File.exists?(source_path) }.from(false).to(true)
|
256
261
|
end
|
257
262
|
|
258
263
|
it "should use -a to select the action" do
|
259
|
-
source_path =
|
260
|
-
target_path =
|
264
|
+
source_path = tempfile_path('abc', :create => true)
|
265
|
+
target_path = tempfile_path('abc.bak')
|
261
266
|
|
262
267
|
lambda {
|
263
|
-
`#{
|
268
|
+
`#{executable_path} -a copy #{source_path}`
|
264
269
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
265
270
|
not change{ File.exists?(source_path) == true }
|
266
271
|
end
|
267
272
|
|
268
273
|
it "should use --action to select the action" do
|
269
|
-
source_path =
|
270
|
-
target_path =
|
274
|
+
source_path = tempfile_path('abc', :create => true)
|
275
|
+
target_path = tempfile_path('abc.bak')
|
271
276
|
|
272
277
|
lambda {
|
273
|
-
`#{
|
278
|
+
`#{executable_path} --action copy #{source_path}`
|
274
279
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
275
280
|
not change{ File.exists?(source_path) == true }
|
276
281
|
end
|
277
282
|
|
278
283
|
it "should use -e to select an extension" do
|
279
|
-
source_path =
|
280
|
-
target_path =
|
284
|
+
source_path = tempfile_path('abc', :create => true)
|
285
|
+
target_path = tempfile_path('abc.zirbel')
|
281
286
|
|
282
287
|
lambda {
|
283
|
-
`#{
|
288
|
+
`#{executable_path} -e .zirbel #{source_path}`
|
284
289
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
285
290
|
change{ File.exists?(source_path) }.from(true).to(false)
|
286
291
|
end
|
287
292
|
|
288
293
|
it "should use --extension to select an extension" do
|
289
|
-
source_path =
|
290
|
-
target_path =
|
294
|
+
source_path = tempfile_path('abc', :create => true)
|
295
|
+
target_path = tempfile_path('abc.zirbel')
|
291
296
|
|
292
297
|
lambda {
|
293
|
-
`#{
|
298
|
+
`#{executable_path} --extension .zirbel #{source_path}`
|
294
299
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
295
300
|
change{ File.exists?(source_path) }.from(true).to(false)
|
296
301
|
end
|
297
302
|
|
298
303
|
it "should use -m to select a processing mode" do
|
299
|
-
source_path =
|
300
|
-
target_path =
|
304
|
+
source_path = tempfile_path('abc', :create => true)
|
305
|
+
target_path = tempfile_path('abc.bak')
|
301
306
|
|
302
307
|
lambda {
|
303
|
-
`#{
|
308
|
+
`#{executable_path} -m remove #{source_path}`
|
304
309
|
}.should_not change{ File.exists?(target_path) == false } and
|
305
310
|
change{ File.exists?(source_path) == true }
|
306
311
|
|
307
312
|
lambda {
|
308
|
-
`#{
|
313
|
+
`#{executable_path} -m toggle #{source_path}`
|
309
314
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
310
315
|
change{ File.exists?(source_path) }.from(true).to(false)
|
311
316
|
|
312
317
|
lambda {
|
313
|
-
`#{
|
318
|
+
`#{executable_path} -m add #{source_path}`
|
314
319
|
}.should_not change{ File.exists?(target_path) == true } and
|
315
320
|
change{ File.exists?(source_path) == false }
|
316
321
|
end
|
317
322
|
|
318
323
|
it "should use --mode to select a processing mode" do
|
319
|
-
source_path =
|
320
|
-
target_path =
|
324
|
+
source_path = tempfile_path('abc', :create => true)
|
325
|
+
target_path = tempfile_path('abc.bak')
|
321
326
|
|
322
327
|
lambda {
|
323
|
-
`#{
|
328
|
+
`#{executable_path} --mode remove #{source_path}`
|
324
329
|
}.should_not change{ File.exists?(target_path) == false } and
|
325
330
|
change{ File.exists?(source_path) == true }
|
326
331
|
|
327
332
|
lambda {
|
328
|
-
`#{
|
333
|
+
`#{executable_path} --mode toggle #{source_path}`
|
329
334
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
330
335
|
change{ File.exists?(source_path) }.from(true).to(false)
|
331
336
|
|
332
337
|
lambda {
|
333
|
-
`#{
|
338
|
+
`#{executable_path} --mode add #{source_path}`
|
334
339
|
}.should_not change{ File.exists?(target_path) == true } and
|
335
340
|
change{ File.exists?(source_path) == false }
|
336
341
|
end
|
337
342
|
|
338
343
|
it "should allow multiple files as argument" do
|
339
|
-
source_path_a =
|
340
|
-
target_path_a =
|
341
|
-
source_path_b =
|
342
|
-
target_path_b =
|
343
|
-
source_path_c =
|
344
|
-
target_path_c =
|
344
|
+
source_path_a = tempfile_path('abc', :create => true)
|
345
|
+
target_path_a = tempfile_path('abc.bak')
|
346
|
+
source_path_b = tempfile_path('def.bak', :create => true)
|
347
|
+
target_path_b = tempfile_path('def')
|
348
|
+
source_path_c = tempfile_path('xyz', :create => true)
|
349
|
+
target_path_c = tempfile_path('xyz.bak')
|
345
350
|
|
346
351
|
lambda {
|
347
|
-
`#{
|
352
|
+
`#{executable_path} #{source_path_a} #{source_path_b} #{source_path_c}`
|
348
353
|
}.should change{ File.exists?(target_path_a) }.from(false).to(true) and
|
349
354
|
change{ File.exists?(source_path_a) }.from(true).to(false) and
|
350
355
|
change{ File.exists?(target_path_b) }.from(false).to(true) and
|
@@ -354,75 +359,75 @@ describe Bakker do
|
|
354
359
|
end
|
355
360
|
|
356
361
|
it "should accept action config via environment variables" do
|
357
|
-
source_path =
|
358
|
-
target_path =
|
362
|
+
source_path = tempfile_path('abc', :create => true)
|
363
|
+
target_path = tempfile_path('abc.bak')
|
359
364
|
|
360
365
|
lambda {
|
361
366
|
if windows?
|
362
367
|
`set BAKKER_ACTION=copy`
|
363
|
-
`#{
|
368
|
+
`#{executable_path} #{source_path}`
|
364
369
|
else
|
365
|
-
`env BAKKER_ACTION=copy #{
|
370
|
+
`env BAKKER_ACTION=copy #{executable_path} #{source_path}`
|
366
371
|
end
|
367
372
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
368
373
|
not change{ File.exists?(source_path) == true }
|
369
374
|
end
|
370
375
|
|
371
376
|
it "should prefer commandline setting over environment for action" do
|
372
|
-
source_path =
|
373
|
-
target_path =
|
377
|
+
source_path = tempfile_path('abc', :create => true)
|
378
|
+
target_path = tempfile_path('abc.bak')
|
374
379
|
|
375
380
|
lambda {
|
376
381
|
if windows?
|
377
382
|
`set BAKKER_ACTION=copy`
|
378
|
-
`#{
|
383
|
+
`#{executable_path} -a move #{source_path}`
|
379
384
|
else
|
380
|
-
`env BAKKER_ACTION=copy #{
|
385
|
+
`env BAKKER_ACTION=copy #{executable_path} -a move #{source_path}`
|
381
386
|
end
|
382
387
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
383
388
|
change{ File.exists?(source_path) }.from(true).to(false)
|
384
389
|
end
|
385
390
|
|
386
391
|
it "should accept extension config via environment variables" do
|
387
|
-
source_path =
|
388
|
-
target_path =
|
392
|
+
source_path = tempfile_path('abc', :create => true)
|
393
|
+
target_path = tempfile_path('abc.zirbel')
|
389
394
|
|
390
395
|
lambda {
|
391
396
|
if windows?
|
392
397
|
`set BAKKER_EXTENSION=.zirbel`
|
393
|
-
`#{
|
398
|
+
`#{executable_path} #{source_path}`
|
394
399
|
else
|
395
|
-
`env BAKKER_EXTENSION=.zirbel #{
|
400
|
+
`env BAKKER_EXTENSION=.zirbel #{executable_path} #{source_path}`
|
396
401
|
end
|
397
402
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
398
403
|
change{ File.exists?(source_path) }.from(true).to(false)
|
399
404
|
end
|
400
405
|
|
401
406
|
it "should prefer commandline setting over environment for extension" do
|
402
|
-
source_path =
|
403
|
-
target_path =
|
407
|
+
source_path = tempfile_path('abc', :create => true)
|
408
|
+
target_path = tempfile_path('abc.zirbel')
|
404
409
|
|
405
410
|
lambda {
|
406
411
|
if windows?
|
407
412
|
`set BAKKER_EXTENSION=.1234`
|
408
|
-
`#{
|
413
|
+
`#{executable_path} -e .zirbel #{source_path}`
|
409
414
|
else
|
410
|
-
`env BAKKER_EXTENSION=.1234 #{
|
415
|
+
`env BAKKER_EXTENSION=.1234 #{executable_path} -e .zirbel #{source_path}`
|
411
416
|
end
|
412
417
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
413
418
|
change{ File.exists?(source_path) }.from(true).to(false)
|
414
419
|
end
|
415
420
|
|
416
421
|
it "should accept extension config via environment variables" do
|
417
|
-
source_path =
|
418
|
-
target_path =
|
422
|
+
source_path = tempfile_path('abc', :create => true)
|
423
|
+
target_path = tempfile_path('abc.bak')
|
419
424
|
|
420
425
|
lambda {
|
421
426
|
if windows?
|
422
427
|
`set BAKKER_MODE=remove`
|
423
|
-
`#{
|
428
|
+
`#{executable_path} #{source_path}`
|
424
429
|
else
|
425
|
-
`env BAKKER_MODE=remove #{
|
430
|
+
`env BAKKER_MODE=remove #{executable_path} #{source_path}`
|
426
431
|
end
|
427
432
|
}.should_not change{ File.exists?(target_path) == false } and
|
428
433
|
change{ File.exists?(source_path) == true }
|
@@ -430,9 +435,9 @@ describe Bakker do
|
|
430
435
|
lambda {
|
431
436
|
if windows?
|
432
437
|
`set BAKKER_MODE=toggle`
|
433
|
-
`#{
|
438
|
+
`#{executable_path} #{source_path}`
|
434
439
|
else
|
435
|
-
`env BAKKER_MODE=toggle #{
|
440
|
+
`env BAKKER_MODE=toggle #{executable_path} #{source_path}`
|
436
441
|
end
|
437
442
|
}.should change{ File.exists?(target_path) }.from(false).to(true) and
|
438
443
|
change{ File.exists?(source_path) }.from(true).to(false)
|
@@ -440,27 +445,53 @@ describe Bakker do
|
|
440
445
|
lambda {
|
441
446
|
if windows?
|
442
447
|
`set BAKKER_MODE=add`
|
443
|
-
`#{
|
448
|
+
`#{executable_path} #{source_path}`
|
444
449
|
else
|
445
|
-
`env BAKKER_MODE=add #{
|
450
|
+
`env BAKKER_MODE=add #{executable_path} #{source_path}`
|
446
451
|
end
|
447
452
|
}.should_not change{ File.exists?(target_path) == true } and
|
448
453
|
change{ File.exists?(source_path) == false }
|
449
454
|
end
|
450
455
|
|
451
456
|
it "should prefer commandline setting over environment for mode" do
|
452
|
-
source_path =
|
453
|
-
target_path =
|
457
|
+
source_path = tempfile_path('abc', :create => true)
|
458
|
+
target_path = tempfile_path('abc.bak')
|
454
459
|
|
455
460
|
lambda {
|
456
461
|
if windows?
|
457
462
|
`set BAKKER_MODE=add`
|
458
|
-
`#{
|
463
|
+
`#{executable_path} -m remove #{source_path}`
|
459
464
|
else
|
460
|
-
`env BAKKER_MODE=add #{
|
465
|
+
`env BAKKER_MODE=add #{executable_path} -m remove #{source_path}`
|
461
466
|
end
|
462
467
|
}.should_not change{ File.exists?(target_path) == false } and
|
463
468
|
change{ File.exists?(source_path) == true }
|
464
469
|
end
|
470
|
+
|
471
|
+
it 'should display correct version and licensing information with the --version switch' do
|
472
|
+
message = <<-EOF
|
473
|
+
Bakker 1.1.0
|
474
|
+
|
475
|
+
Project: https://rubyforge.org/projects/aef/
|
476
|
+
RDoc: http://aef.rubyforge.org/bakker/
|
477
|
+
Github: http://github.com/aef/bakker/
|
478
|
+
|
479
|
+
Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
480
|
+
|
481
|
+
Bakker is free software: you can redistribute it and/or modify
|
482
|
+
it under the terms of the GNU General Public License as published by
|
483
|
+
the Free Software Foundation, either version 3 of the License, or
|
484
|
+
(at your option) any later version.
|
485
|
+
|
486
|
+
This program is distributed in the hope that it will be useful,
|
487
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
488
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
489
|
+
GNU General Public License for more details.
|
490
|
+
|
491
|
+
You should have received a copy of the GNU General Public License
|
492
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
493
|
+
EOF
|
494
|
+
`#{executable_path} --version`.should eql(message)
|
495
|
+
end
|
465
496
|
end
|
466
|
-
end
|
497
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bakker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander E. Fischer
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
55akF+N8NbO6tpVDy6TMagqa10LfEpiQH6dvDHe/xdAqYOCrXKpmqzwu2PI=
|
30
30
|
-----END CERTIFICATE-----
|
31
31
|
|
32
|
-
date: 2009-
|
32
|
+
date: 2009-04-05 00:00:00 +02:00
|
33
33
|
default_executable:
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,16 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: "0"
|
44
44
|
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
45
55
|
- !ruby/object:Gem::Dependency
|
46
56
|
name: sys-uname
|
47
57
|
type: :development
|
@@ -60,9 +70,9 @@ dependencies:
|
|
60
70
|
requirements:
|
61
71
|
- - ">="
|
62
72
|
- !ruby/object:Gem::Version
|
63
|
-
version: 1.
|
73
|
+
version: 1.11.0
|
64
74
|
version:
|
65
|
-
description: Bakker
|
75
|
+
description: Bakker is a Ruby library and commandline tool to help with simple task of renaming or copying files for quick backup purposes. For instance by creating a copy of a list of files while adding .bak to the copies filenames. Bakker gives you control over the extension to be added to or removed from the file and whether it should be moved or copied.
|
66
76
|
email:
|
67
77
|
- aef@raxys.net
|
68
78
|
executables:
|
@@ -72,23 +82,28 @@ extensions: []
|
|
72
82
|
extra_rdoc_files:
|
73
83
|
- History.txt
|
74
84
|
- Manifest.txt
|
75
|
-
- README.txt
|
76
85
|
- COPYING.txt
|
86
|
+
- README.rdoc
|
77
87
|
files:
|
78
88
|
- History.txt
|
79
89
|
- Manifest.txt
|
80
|
-
- README.
|
90
|
+
- README.rdoc
|
81
91
|
- COPYING.txt
|
82
92
|
- Rakefile
|
83
93
|
- bin/bakker
|
84
94
|
- lib/bakker.rb
|
95
|
+
- lib/bakker/bakker.rb
|
85
96
|
- spec/bakker_spec.rb
|
86
97
|
has_rdoc: true
|
87
|
-
homepage:
|
98
|
+
homepage: https://rubyforge.org/projects/aef/
|
88
99
|
post_install_message:
|
89
100
|
rdoc_options:
|
90
101
|
- --main
|
91
|
-
- README.
|
102
|
+
- README.rdoc
|
103
|
+
- --inline-source
|
104
|
+
- --line-numbers
|
105
|
+
- --title
|
106
|
+
- Bakker
|
92
107
|
require_paths:
|
93
108
|
- lib
|
94
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -109,6 +124,6 @@ rubyforge_project: aef
|
|
109
124
|
rubygems_version: 1.3.1
|
110
125
|
signing_key:
|
111
126
|
specification_version: 2
|
112
|
-
summary: Bakker
|
113
|
-
test_files:
|
114
|
-
|
127
|
+
summary: Bakker is a Ruby library and commandline tool to help with simple task of renaming or copying files for quick backup purposes
|
128
|
+
test_files: []
|
129
|
+
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
��sa$�첽*��ض���G lw� ,!htԱ��\�jqoY�DKM�5�k�6����i$O�Z-������+������a�xU5A��C�E��S䐗*
|
1
|
+
3��-߯�m�C.֜�ԣ�aֺ��s���~"G�/lY��������r�$j�m�i�f��ݙ�8�O�%6|aw�E�:a6��$u��e�����*.+G�� "�۷�{��ٱ}�b�e���=H%�L�E��s&�V�"�w����:w�5���������������;����g����[fj�T��)��Zd��e��q�G�0$�����F^˓#<nkv�QD�M#���sU0��7Ty{ڊH������D�
|