tesler 0.1.0 → 0.1.1

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/.document CHANGED
@@ -1,5 +1,5 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore CHANGED
@@ -1,23 +1,23 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- test/dest
23
- *.gemspec
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ test/dest
23
+ *.gemspec
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.1.0
1
+ 0.1.1
@@ -1 +1 @@
1
- aaaaaaaaaaaaaa
1
+ aaaaaaaaaaaaaa
@@ -1 +1 @@
1
- aaaaaaaaaaaaaa
1
+ aaaaaaaaaaaaaa
data/example/main.rb CHANGED
@@ -1,41 +1,41 @@
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
- end
30
- end
31
-
32
- # copie d'un dossier entier
33
- copy 'src\subdir2'
34
-
35
- # copie d'un dossier entier en le renommant
36
- copy 'src\subdir2', :rename => 'renamed'
37
-
38
- end
39
-
40
-
41
-
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
+ end
30
+ end
31
+
32
+ # copie d'un dossier entier
33
+ copy 'src\subdir2'
34
+
35
+ # copie d'un dossier entier en le renommant
36
+ copy 'src\subdir2', :rename => 'renamed'
37
+
38
+ end
39
+
40
+
41
+
@@ -1 +1 @@
1
- aaaaaaaaaaaaaa
1
+ aaaaaaaaaaaaaa
@@ -1,11 +1,11 @@
1
- module Tesler
2
- module Commands
3
- module Base
4
- def self.get_name(file_name, options)
5
- option_rename = options.delete(:rename)
6
- return file_name if option_rename.nil?
7
- "#{File.dirname(file_name)}/#{option_rename}"
8
- end
9
- end
10
- end
11
- end
1
+ module Tesler
2
+ module Commands
3
+ module Base
4
+ def self.get_name(file_name, options)
5
+ option_rename = options.delete(:rename)
6
+ return file_name if option_rename.nil?
7
+ "#{File.dirname(file_name)}/#{option_rename}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,38 +1,38 @@
1
- module Tesler
2
- module Commands
3
- module Logger
4
- extend Tesler::Commands::Base
5
- extend self
6
-
7
- def set_directory(directory_name)
8
- if File.exists? directory_name
9
- Tesler::Config.output.puts "\texists\t#{directory_name}"
10
- else
11
- Tesler::Config.output.puts "\tcreate\t#{directory_name}"
12
- end
13
- end
14
-
15
- def copy_file(file_name, options)
16
- if @directory_name
17
- # When included itself in the copier
18
- base_name = options[:rename]
19
- base_name = File.basename(file_name) if base_name.nil?
20
- Tesler::Config.output.puts "\tcopy\t#{@directory_name}/#{base_name}"
21
- else
22
- # When used by another module included in the copier
23
- output = file_name
24
- if options[:rename]
25
- output = "#{File.dirname(file_name)}/#{options[:rename]}"
26
- end
27
-
28
- Tesler::Config.output.puts "\tcopy\t#{output}"
29
- end
30
- end
31
-
32
- def copy_dir(file_name, options)
33
- copy_file(file_name, options)
34
- end
35
- end
36
- end
37
- end
38
-
1
+ module Tesler
2
+ module Commands
3
+ module Logger
4
+ extend Tesler::Commands::Base
5
+ extend self
6
+
7
+ def set_directory(directory_name)
8
+ if File.exists? directory_name
9
+ Tesler::Config.output.puts "\texists\t#{directory_name}"
10
+ else
11
+ Tesler::Config.output.puts "\tcreate\t#{directory_name}"
12
+ end
13
+ end
14
+
15
+ def copy_file(file_name, options)
16
+ if @directory_name
17
+ # When included itself in the copier
18
+ base_name = options[:rename]
19
+ base_name = File.basename(file_name) if base_name.nil?
20
+ Tesler::Config.output.puts "\tcopy\t#{@directory_name}/#{base_name}"
21
+ else
22
+ # When used by another module included in the copier
23
+ output = file_name
24
+ if options[:rename]
25
+ output = "#{File.dirname(file_name)}/#{options[:rename]}"
26
+ end
27
+
28
+ Tesler::Config.output.puts "\tcopy\t#{output}"
29
+ end
30
+ end
31
+
32
+ def copy_dir(file_name, options)
33
+ copy_file(file_name, options)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
@@ -1,35 +1,35 @@
1
- require 'fileutils'
2
-
3
- module Tesler
4
- module Commands
5
- module Run
6
- extend Tesler::Commands::Base
7
-
8
- def set_directory(directory_name)
9
- Tesler::Commands::Logger.set_directory(directory_name)
10
-
11
- # create the directory if it doesn't exist
12
- FileUtils.mkdir_p @directory_name
13
- end
14
-
15
- def copy_file(file_name, options)
16
- copy_dir(file_name, options)
17
- end
18
-
19
- def copy_dir(file_name, options)
20
- # even if the rename option is set, we send the old filename and the rename option to the logger. It will rename the file itself.
21
- dest_file_name = "#{@directory_name}/#{File.basename(file_name)}"
22
- Tesler::Commands::Logger.copy_dir(dest_file_name, options)
23
-
24
- # change the destination filename if needed
25
- if options[:rename]
26
- dest_file_name = "#{@directory_name}/#{options[:rename]}"
27
- end
28
-
29
- # recursive copy
30
- FileUtils.cp_r file_name, dest_file_name
31
- end
32
- end
33
- end
34
- end
35
-
1
+ require 'fileutils'
2
+
3
+ module Tesler
4
+ module Commands
5
+ module Run
6
+ extend Tesler::Commands::Base
7
+
8
+ def set_directory(directory_name)
9
+ Tesler::Commands::Logger.set_directory(directory_name)
10
+
11
+ # create the directory if it doesn't exist
12
+ FileUtils.mkdir_p @directory_name
13
+ end
14
+
15
+ def copy_file(file_name, options)
16
+ copy_dir(file_name, options)
17
+ end
18
+
19
+ def copy_dir(file_name, options)
20
+ # even if the rename option is set, we send the old filename and the rename option to the logger. It will rename the file itself.
21
+ dest_file_name = "#{@directory_name}/#{File.basename(file_name)}"
22
+ Tesler::Commands::Logger.copy_dir(dest_file_name, options)
23
+
24
+ # change the destination filename if needed
25
+ if options[:rename]
26
+ dest_file_name = "#{@directory_name}/#{options[:rename]}"
27
+ end
28
+
29
+ # recursive copy
30
+ FileUtils.cp_r file_name, dest_file_name
31
+ end
32
+ end
33
+ end
34
+ end
35
+
data/lib/tesler/config.rb CHANGED
@@ -1,11 +1,11 @@
1
- module Tesler
2
- module Config
3
- def self.output
4
- @output ||= STDOUT
5
- end
6
-
7
- def self.output=(output)
8
- @output = output
9
- end
10
- end
11
- end
1
+ module Tesler
2
+ module Config
3
+ def self.output
4
+ @output ||= STDOUT
5
+ end
6
+
7
+ def self.output=(output)
8
+ @output = output
9
+ end
10
+ end
11
+ end
data/lib/tesler/copier.rb CHANGED
@@ -1,29 +1,29 @@
1
- module Tesler
2
- class Copier
3
- include Tesler::Commands::Run
4
-
5
- def initialize(directory_name)
6
- @directory_name = directory_name
7
- set_directory(@directory_name)
8
- end
9
-
10
- def copy(file_name, options={})
11
- if File.directory? file_name.to_unix
12
- copy_dir(file_name.to_unix, options)
13
- else
14
- copy_file(file_name.to_unix, options)
15
- end
16
- end
17
-
18
- def directory(directory_name, &block)
19
- copier = Copier.new("#{@directory_name}/#{directory_name}")
20
- copier.instance_eval(&block)
21
- end
22
-
23
- def self.directory(directory_name, &block)
24
- copier = Copier.new(directory_name)
25
- copier.instance_eval(&block)
26
- end
27
- end
28
- end
29
-
1
+ module Tesler
2
+ class Copier
3
+ include Tesler::Commands::Run
4
+
5
+ def initialize(directory_name)
6
+ @directory_name = directory_name
7
+ set_directory(@directory_name)
8
+ end
9
+
10
+ def copy(file_name, options={})
11
+ if File.directory? file_name.to_unix
12
+ copy_dir(file_name.to_unix, options)
13
+ else
14
+ copy_file(file_name.to_unix, options)
15
+ end
16
+ end
17
+
18
+ def directory(directory_name, &block)
19
+ copier = Copier.new("#{@directory_name}/#{directory_name}")
20
+ copier.instance_eval(&block)
21
+ end
22
+
23
+ def self.directory(directory_name, &block)
24
+ copier = Copier.new(directory_name)
25
+ copier.instance_eval(&block)
26
+ end
27
+ end
28
+ end
29
+
data/lib/tesler/dsl.rb CHANGED
@@ -1,14 +1,14 @@
1
- def directory(directory_name, &block)
2
- Tesler::Copier.directory(directory_name.to_unix, &block)
3
- end
4
-
5
- def run_in_test_mode
6
- eval <<-EOV
7
- module Tesler
8
- class Copier
9
- include Tesler::Commands::Logger
10
- end
11
- end
12
- EOV
13
- end
14
-
1
+ def directory(directory_name, &block)
2
+ Tesler::Copier.directory(directory_name.to_unix, &block)
3
+ end
4
+
5
+ def run_in_test_mode
6
+ eval <<-EOV
7
+ module Tesler
8
+ class Copier
9
+ include Tesler::Commands::Logger
10
+ end
11
+ end
12
+ EOV
13
+ end
14
+
data/lib/tesler/ext.rb CHANGED
@@ -1,6 +1,6 @@
1
- class String
2
- def to_unix
3
- File.join self.split("\\")
4
- end
5
- end
6
-
1
+ class String
2
+ def to_unix
3
+ File.join self.split("\\")
4
+ end
5
+ end
6
+
data/lib/tesler.rb CHANGED
@@ -1,8 +1,8 @@
1
- require File.join(File.dirname(__FILE__), "tesler", "ext")
2
- require File.join(File.dirname(__FILE__), "tesler", "config")
3
- require File.join(File.dirname(__FILE__), "tesler", "commands", "base")
4
- require File.join(File.dirname(__FILE__), "tesler", "commands", "logger")
5
- require File.join(File.dirname(__FILE__), "tesler", "commands", "run")
6
- require File.join(File.dirname(__FILE__), "tesler", "copier")
7
- require File.join(File.dirname(__FILE__), "tesler", "dsl")
8
-
1
+ require File.join(File.dirname(__FILE__), "tesler", "ext")
2
+ require File.join(File.dirname(__FILE__), "tesler", "config")
3
+ require File.join(File.dirname(__FILE__), "tesler", "commands", "base")
4
+ require File.join(File.dirname(__FILE__), "tesler", "commands", "logger")
5
+ require File.join(File.dirname(__FILE__), "tesler", "commands", "run")
6
+ require File.join(File.dirname(__FILE__), "tesler", "copier")
7
+ require File.join(File.dirname(__FILE__), "tesler", "dsl")
8
+
data/test/helper.rb CHANGED
@@ -1,10 +1,10 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'tesler'
8
-
9
- class Test::Unit::TestCase
10
- end
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'tesler'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -1 +1 @@
1
- aaaaaaaaaaaaaa
1
+ aaaaaaaaaaaaaa
data/test/test_tesler.rb CHANGED
@@ -1,71 +1,68 @@
1
- require 'helper'
2
-
3
- class Output
4
- def messages
5
- @messages ||= []
6
- end
7
-
8
- def puts(message)
9
- messages << message
10
- end
11
- end
12
-
13
- class TestTesler < Test::Unit::TestCase
14
- def setup
15
- FileUtils.rm_r("dest") if File.exists?("dest")
16
-
17
- @output = Output.new
18
- Tesler::Config.output = @output
19
-
20
- directory 'test\dest' do
21
- copy 'test\src\file1'
22
- copy 'test\src\file2'
23
- copy 'test\src\subdir1\file4'
24
-
25
- directory 'subdir1' do
26
- copy 'test\src\file3'
27
- copy 'test\src\subdir1\file5'
28
- copy 'c:\temp'
29
-
30
- directory 'subdir3' do
31
- copy 'test\src\file8'
32
- copy 'test\src\file9', :rename => 'renamed'
33
- end
34
- end
35
-
36
- copy 'test\src\subdir2'
37
- copy 'test\src\subdir2', :rename => 'renamed'
38
- end
39
- end
40
-
41
- should "copy files" do
42
- assert File.exists?("test/dest")
43
- assert File.exists?("test/dest/file1")
44
- assert File.exists?("test/dest/file2")
45
- assert File.exists?("test/dest/file4")
46
- assert File.exists?("test/dest/subdir1")
47
- assert File.exists?("test/dest/subdir1/file3")
48
- assert File.exists?("test/dest/subdir1/file5")
49
- assert File.exists?("test/dest/subdir1/temp")
50
- assert File.exists?("test/dest/subdir1/subdir3")
51
- assert File.exists?("test/dest/subdir1/subdir3/file8")
52
- assert File.exists?("test/dest/subdir1/subdir3/renamed")
53
- assert File.exists?("test/dest/subdir2")
54
- assert File.exists?("test/dest/renamed")
55
-
56
- messages = @output.messages.map { |m| m.strip }
57
- assert_match messages[0], /(create|exists)\ttest\/dest/
58
- assert_equal messages[1], "copy\ttest/dest/file1"
59
- assert_equal messages[2], "copy\ttest/dest/file2"
60
- assert_equal messages[3], "copy\ttest/dest/file4"
61
- assert_match messages[4], /(create|exists)\ttest\/dest\/subdir1/
62
- assert_equal messages[5], "copy\ttest/dest/subdir1/file3"
63
- assert_equal messages[6], "copy\ttest/dest/subdir1/file5"
64
- assert_equal messages[7], "copy\ttest/dest/subdir1/temp"
65
- assert_match messages[8], /(create|exists)\ttest\/dest\/subdir1\/subdir3/
66
- assert_equal messages[9], "copy\ttest/dest/subdir1/subdir3/file8"
67
- assert_equal messages[10], "copy\ttest/dest/subdir1/subdir3/renamed"
68
- assert_equal messages[11], "copy\ttest/dest/subdir2"
69
- assert_equal messages[12], "copy\ttest/dest/renamed"
70
- end
71
- end
1
+ require 'helper'
2
+
3
+ class Output
4
+ def messages
5
+ @messages ||= []
6
+ end
7
+
8
+ def puts(message)
9
+ messages << message
10
+ end
11
+ end
12
+
13
+ class TestTesler < Test::Unit::TestCase
14
+ def setup
15
+ FileUtils.rm_r("dest") if File.exists?("dest")
16
+
17
+ @output = Output.new
18
+ Tesler::Config.output = @output
19
+
20
+ directory 'test\dest' do
21
+ copy 'test\src\file1'
22
+ copy 'test\src\file2'
23
+ copy 'test\src\subdir1\file4'
24
+
25
+ directory 'subdir1' do
26
+ copy 'test\src\file3'
27
+ copy 'test\src\subdir1\file5'
28
+
29
+ directory 'subdir3' do
30
+ copy 'test\src\file8'
31
+ copy 'test\src\file9', :rename => 'renamed'
32
+ end
33
+ end
34
+
35
+ copy 'test\src\subdir2'
36
+ copy 'test\src\subdir2', :rename => 'renamed'
37
+ end
38
+ end
39
+
40
+ should "copy files" do
41
+ assert File.exists?("test/dest")
42
+ assert File.exists?("test/dest/file1")
43
+ assert File.exists?("test/dest/file2")
44
+ assert File.exists?("test/dest/file4")
45
+ assert File.exists?("test/dest/subdir1")
46
+ assert File.exists?("test/dest/subdir1/file3")
47
+ assert File.exists?("test/dest/subdir1/file5")
48
+ assert File.exists?("test/dest/subdir1/subdir3")
49
+ assert File.exists?("test/dest/subdir1/subdir3/file8")
50
+ assert File.exists?("test/dest/subdir1/subdir3/renamed")
51
+ assert File.exists?("test/dest/subdir2")
52
+ assert File.exists?("test/dest/renamed")
53
+
54
+ messages = @output.messages.map { |m| m.strip }
55
+ assert_match messages[0], /(create|exists)\ttest\/dest/
56
+ assert_equal messages[1], "copy\ttest/dest/file1"
57
+ assert_equal messages[2], "copy\ttest/dest/file2"
58
+ assert_equal messages[3], "copy\ttest/dest/file4"
59
+ assert_match messages[4], /(create|exists)\ttest\/dest\/subdir1/
60
+ assert_equal messages[5], "copy\ttest/dest/subdir1/file3"
61
+ assert_equal messages[6], "copy\ttest/dest/subdir1/file5"
62
+ assert_match messages[7], /(create|exists)\ttest\/dest\/subdir1\/subdir3/
63
+ assert_equal messages[8], "copy\ttest/dest/subdir1/subdir3/file8"
64
+ assert_equal messages[9], "copy\ttest/dest/subdir1/subdir3/renamed"
65
+ assert_equal messages[10], "copy\ttest/dest/subdir2"
66
+ assert_equal messages[11], "copy\ttest/dest/renamed"
67
+ end
68
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tesler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rawane ZOSSOU
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-25 00:00:00 +02:00
18
+ date: 2010-06-26 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency