tesler 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -20
- data/README.md +27 -27
- data/Rakefile +53 -53
- data/VERSION +1 -1
- data/example/main.rb +46 -43
- data/example/src/subdir2/file7 +1 -1
- data/lib/tesler.rb +9 -9
- data/lib/tesler/as.rb +23 -23
- data/lib/tesler/config.rb +42 -42
- data/lib/tesler/copier.rb +81 -81
- data/lib/tesler/dsl.rb +20 -20
- data/lib/tesler/ext.rb +29 -29
- data/lib/tesler/operators/base.rb +19 -19
- data/lib/tesler/operators/logger.rb +39 -39
- data/lib/tesler/operators/run.rb +26 -26
- data/test/helper.rb +22 -22
- data/test/src/subdir2/file7 +1 -1
- data/test/test_tesler.rb +347 -325
- metadata +3 -3
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2009 Rawane ZOSSOU
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2009 Rawane ZOSSOU
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
# tesler #
|
2
|
-
|
3
|
-
Tesler is a small DSl which allows you to describe a directory/file hierarchy where to copy some files.
|
4
|
-
|
5
|
-
## Installation ##
|
6
|
-
|
7
|
-
Just run the following command :
|
8
|
-
|
9
|
-
gem install tesler
|
10
|
-
|
11
|
-
## Usage ##
|
12
|
-
|
13
|
-
Look at the example in the gem directory for details.
|
14
|
-
|
15
|
-
## Note on Patches/Pull Requests ##
|
16
|
-
|
17
|
-
* Fork the project.
|
18
|
-
* Make your feature addition or bug fix.
|
19
|
-
* Add tests for it. This is important so I don't break it in a
|
20
|
-
future version unintentionally.
|
21
|
-
* Commit, do not mess with rakefile, version, or history.
|
22
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
23
|
-
* Send me a pull request. Bonus points for topic branches.
|
24
|
-
|
25
|
-
## Copyright ##
|
26
|
-
|
27
|
-
Copyright (c) 2010 Rawane ZOSSOU. See LICENSE for details.
|
1
|
+
# tesler #
|
2
|
+
|
3
|
+
Tesler is a small DSl which allows you to describe a directory/file hierarchy where to copy some files.
|
4
|
+
|
5
|
+
## Installation ##
|
6
|
+
|
7
|
+
Just run the following command :
|
8
|
+
|
9
|
+
gem install tesler
|
10
|
+
|
11
|
+
## Usage ##
|
12
|
+
|
13
|
+
Look at the example in the gem directory for details.
|
14
|
+
|
15
|
+
## Note on Patches/Pull Requests ##
|
16
|
+
|
17
|
+
* Fork the project.
|
18
|
+
* Make your feature addition or bug fix.
|
19
|
+
* Add tests for it. This is important so I don't break it in a
|
20
|
+
future version unintentionally.
|
21
|
+
* Commit, do not mess with rakefile, version, or history.
|
22
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
23
|
+
* Send me a pull request. Bonus points for topic branches.
|
24
|
+
|
25
|
+
## Copyright ##
|
26
|
+
|
27
|
+
Copyright (c) 2010 Rawane ZOSSOU. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,53 +1,53 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "tesler"
|
8
|
-
gem.summary = "A little DSL to describe how to copy files inside a directory."
|
9
|
-
gem.description = "Tesler is a DSL which allows you to describe a directory hierarchy where to copy some files."
|
10
|
-
gem.email = "dev@raw1z.fr"
|
11
|
-
gem.homepage = "http://github.com/raw1z/tesler"
|
12
|
-
gem.authors = ["Rawane ZOSSOU"]
|
13
|
-
gem.add_development_dependency "shoulda", ">= 0"
|
14
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
-
end
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'rake/testtask'
|
22
|
-
Rake::TestTask.new(:test) do |test|
|
23
|
-
test.libs << 'lib' << 'test'
|
24
|
-
test.pattern = 'test/**/test_*.rb'
|
25
|
-
test.verbose = true
|
26
|
-
end
|
27
|
-
|
28
|
-
begin
|
29
|
-
require 'rcov/rcovtask'
|
30
|
-
Rcov::RcovTask.new do |test|
|
31
|
-
test.libs << 'test'
|
32
|
-
test.pattern = 'test/**/test_*.rb'
|
33
|
-
test.verbose = true
|
34
|
-
end
|
35
|
-
rescue LoadError
|
36
|
-
task :rcov do
|
37
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
task :test => :check_dependencies
|
42
|
-
|
43
|
-
task :default => :test
|
44
|
-
|
45
|
-
require 'rake/rdoctask'
|
46
|
-
Rake::RDocTask.new do |rdoc|
|
47
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
-
|
49
|
-
rdoc.rdoc_dir = 'rdoc'
|
50
|
-
rdoc.title = "tesler #{version}"
|
51
|
-
rdoc.rdoc_files.include('README*')
|
52
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "tesler"
|
8
|
+
gem.summary = "A little DSL to describe how to copy files inside a directory."
|
9
|
+
gem.description = "Tesler is a DSL which allows you to describe a directory hierarchy where to copy some files."
|
10
|
+
gem.email = "dev@raw1z.fr"
|
11
|
+
gem.homepage = "http://github.com/raw1z/tesler"
|
12
|
+
gem.authors = ["Rawane ZOSSOU"]
|
13
|
+
gem.add_development_dependency "shoulda", ">= 0"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "tesler #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/example/main.rb
CHANGED
@@ -1,43 +1,46 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
|
3
|
-
require 'tesler'
|
4
|
-
|
5
|
-
#
|
6
|
-
FileUtils.rm_r("dest") if File.exists?("dest")
|
7
|
-
|
8
|
-
directory 'dest' do
|
9
|
-
|
10
|
-
#
|
11
|
-
copy 'src\file1'
|
12
|
-
copy 'src\file2'
|
13
|
-
copy 'src\subdir1\file4'
|
14
|
-
|
15
|
-
#
|
16
|
-
directory 'subdir1' do
|
17
|
-
copy 'src\file3'
|
18
|
-
copy 'src\subdir1\file5'
|
19
|
-
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
copy 'src\
|
26
|
-
|
27
|
-
# copie d'un
|
28
|
-
copy '
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
copy 'src\subdir2'
|
37
|
-
|
38
|
-
#
|
39
|
-
copy '
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require 'tesler'
|
4
|
+
|
5
|
+
# on supprime le repertoire de destination
|
6
|
+
FileUtils.rm_r("dest") if File.exists?("dest")
|
7
|
+
|
8
|
+
directory 'dest' do
|
9
|
+
|
10
|
+
# copie de fichiers dans le dossier de destination
|
11
|
+
copy 'src\file1'
|
12
|
+
copy 'src\file2'
|
13
|
+
copy 'src\subdir1\file4'
|
14
|
+
|
15
|
+
# creation d'un sous-dossier dans le dossier de destination
|
16
|
+
directory 'subdir1' do
|
17
|
+
copy 'src\file3'
|
18
|
+
copy 'src\subdir1\file5'
|
19
|
+
|
20
|
+
# copie avec un chemin absolu
|
21
|
+
copy 'c:\temp'
|
22
|
+
|
23
|
+
# sous-dossier dans le sous-dossier
|
24
|
+
directory 'subdir3' do
|
25
|
+
copy 'src\file8'
|
26
|
+
|
27
|
+
# copie d'un fichier en le renommant
|
28
|
+
copy 'src\file9', :rename => 'renamed'
|
29
|
+
|
30
|
+
# copie d'un ensemble de fichiers
|
31
|
+
copy 'test\src\*.test'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# copie d'un dossier entier
|
36
|
+
copy 'src\subdir2'
|
37
|
+
|
38
|
+
# copie d'un dossier entier en le renommant
|
39
|
+
copy 'src\subdir2', :rename => 'renamed'
|
40
|
+
|
41
|
+
# copie d'un ensemble de fichiers
|
42
|
+
copy 'test\src\reg_*.test'
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
data/example/src/subdir2/file7
CHANGED
@@ -1 +1 @@
|
|
1
|
-
aaaaaaaaaaaaaa
|
1
|
+
aaaaaaaaaaaaaa
|
data/lib/tesler.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "tesler", "ext")
|
2
|
-
require File.join(File.dirname(__FILE__), "tesler", "as")
|
3
|
-
require File.join(File.dirname(__FILE__), "tesler", "config")
|
4
|
-
require File.join(File.dirname(__FILE__), "tesler", "operators", "base")
|
5
|
-
require File.join(File.dirname(__FILE__), "tesler", "operators", "logger")
|
6
|
-
require File.join(File.dirname(__FILE__), "tesler", "operators", "run")
|
7
|
-
require File.join(File.dirname(__FILE__), "tesler", "copier")
|
8
|
-
require File.join(File.dirname(__FILE__), "tesler", "dsl")
|
9
|
-
|
1
|
+
require File.join(File.dirname(__FILE__), "tesler", "ext")
|
2
|
+
require File.join(File.dirname(__FILE__), "tesler", "as")
|
3
|
+
require File.join(File.dirname(__FILE__), "tesler", "config")
|
4
|
+
require File.join(File.dirname(__FILE__), "tesler", "operators", "base")
|
5
|
+
require File.join(File.dirname(__FILE__), "tesler", "operators", "logger")
|
6
|
+
require File.join(File.dirname(__FILE__), "tesler", "operators", "run")
|
7
|
+
require File.join(File.dirname(__FILE__), "tesler", "copier")
|
8
|
+
require File.join(File.dirname(__FILE__), "tesler", "dsl")
|
9
|
+
|
data/lib/tesler/as.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
module Kernel
|
2
|
-
|
3
|
-
# Stolen from Facets. Allows one two execute a specific ancestor's method
|
4
|
-
def as(ancestor, &blk)
|
5
|
-
@__as ||= {}
|
6
|
-
unless r = @__as[ancestor]
|
7
|
-
r = (@__as[ancestor] = As.new(self, ancestor))
|
8
|
-
end
|
9
|
-
r.instance_eval(&blk) if block_given?
|
10
|
-
r
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class As < BasicObject #:nodoc:
|
15
|
-
def initialize(subject, ancestor)
|
16
|
-
@subject = subject
|
17
|
-
@ancestor = ancestor
|
18
|
-
end
|
19
|
-
|
20
|
-
def method_missing(sym, *args, &blk)
|
21
|
-
@ancestor.instance_method(sym).bind(@subject).call(*args,&blk)
|
22
|
-
end
|
23
|
-
end
|
1
|
+
module Kernel
|
2
|
+
|
3
|
+
# Stolen from Facets. Allows one two execute a specific ancestor's method
|
4
|
+
def as(ancestor, &blk)
|
5
|
+
@__as ||= {}
|
6
|
+
unless r = @__as[ancestor]
|
7
|
+
r = (@__as[ancestor] = As.new(self, ancestor))
|
8
|
+
end
|
9
|
+
r.instance_eval(&blk) if block_given?
|
10
|
+
r
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class As < BasicObject #:nodoc:
|
15
|
+
def initialize(subject, ancestor)
|
16
|
+
@subject = subject
|
17
|
+
@ancestor = ancestor
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing(sym, *args, &blk)
|
21
|
+
@ancestor.instance_method(sym).bind(@subject).call(*args,&blk)
|
22
|
+
end
|
23
|
+
end
|
data/lib/tesler/config.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
module Tesler
|
2
|
-
# This module contains all the configuration variables used by tesler
|
3
|
-
module Config
|
4
|
-
|
5
|
-
# Get the standard output. The output is an object who must respond to the 'puts' method. By default it is set to STDOUT
|
6
|
-
def self.output
|
7
|
-
@output ||= STDOUT
|
8
|
-
end
|
9
|
-
|
10
|
-
# Set the standard output.
|
11
|
-
def self.output=(output)
|
12
|
-
@output = output
|
13
|
-
end
|
14
|
-
|
15
|
-
# Get the source directory. It is the directory where all the files that we are copying , are taken from.
|
16
|
-
def self.source_directory
|
17
|
-
@source_directory ||= ''
|
18
|
-
end
|
19
|
-
|
20
|
-
# Set the source directory
|
21
|
-
def self.source_directory=(directory_name)
|
22
|
-
@source_directory = directory_name.tesler
|
23
|
-
end
|
24
|
-
|
25
|
-
# get the module which performs the copy operations
|
26
|
-
def self.operator
|
27
|
-
@operator ||= Tesler::Operators::Run
|
28
|
-
end
|
29
|
-
|
30
|
-
# define the module which performs the copy operations
|
31
|
-
def self.operator=(op)
|
32
|
-
@operator = op
|
33
|
-
end
|
34
|
-
|
35
|
-
# Reinitializes the configuration
|
36
|
-
def self.reset
|
37
|
-
@output = nil
|
38
|
-
@source_directory = nil
|
39
|
-
@operator = nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
1
|
+
module Tesler
|
2
|
+
# This module contains all the configuration variables used by tesler
|
3
|
+
module Config
|
4
|
+
|
5
|
+
# Get the standard output. The output is an object who must respond to the 'puts' method. By default it is set to STDOUT
|
6
|
+
def self.output
|
7
|
+
@output ||= STDOUT
|
8
|
+
end
|
9
|
+
|
10
|
+
# Set the standard output.
|
11
|
+
def self.output=(output)
|
12
|
+
@output = output
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get the source directory. It is the directory where all the files that we are copying , are taken from.
|
16
|
+
def self.source_directory
|
17
|
+
@source_directory ||= ''
|
18
|
+
end
|
19
|
+
|
20
|
+
# Set the source directory
|
21
|
+
def self.source_directory=(directory_name)
|
22
|
+
@source_directory = directory_name.tesler
|
23
|
+
end
|
24
|
+
|
25
|
+
# get the module which performs the copy operations
|
26
|
+
def self.operator
|
27
|
+
@operator ||= Tesler::Operators::Run
|
28
|
+
end
|
29
|
+
|
30
|
+
# define the module which performs the copy operations
|
31
|
+
def self.operator=(op)
|
32
|
+
@operator = op
|
33
|
+
end
|
34
|
+
|
35
|
+
# Reinitializes the configuration
|
36
|
+
def self.reset
|
37
|
+
@output = nil
|
38
|
+
@source_directory = nil
|
39
|
+
@operator = nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|