gf-tree_visitor 0.0.4 → 0.0.5
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/README.rdoc +9 -15
- data/lib/gf_utility/file_utilities.rb +43 -0
- data/lib/gf_utility/kwartzhelper.rb +1 -2
- data/test/gf_utility/tc_kwartz.rb +6 -5
- data/test/gf_utility/tc_md5.rb +4 -7
- data/test/gf_utility/tc_numeric.rb +1 -7
- data/test/gf_utility/test_helper.rb +5 -0
- data/test/tree_visitor/tc_dir_processor.rb +1 -7
- data/test/tree_visitor/tc_dir_tree_walker.rb +1 -8
- data/test/tree_visitor/tc_tree_node.rb +1 -7
- data/test/tree_visitor/tc_tree_node_visitor.rb +1 -5
- data/test/tree_visitor/test_helper.rb +10 -0
- metadata +16 -5
data/README.rdoc
CHANGED
@@ -1,27 +1,21 @@
|
|
1
|
-
=
|
1
|
+
= dirtree.rb / tree visitor lib
|
2
2
|
|
3
|
-
|
3
|
+
<pre>dirtree.rb</pre> is a 'clone' of tree unix command.
|
4
|
+
It is based on lib tree visitor.
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
FIX (describe your package)
|
8
|
-
|
9
|
-
== FEATURES/PROBLEMS:
|
10
|
-
|
11
|
-
* FIX (list of features or problems)
|
12
|
-
|
13
|
-
== SYNOPSIS:
|
14
|
-
|
15
|
-
FIX (code sample of usage)
|
6
|
+
Tree visitor is an implementation of visitor design pattern.
|
16
7
|
|
17
8
|
== REQUIREMENTS:
|
18
9
|
|
19
10
|
* utilizza la libreria abstract di kwartz
|
20
|
-
* gui: dipende da fxruby e/o wxruby
|
21
11
|
|
22
12
|
== INSTALL:
|
23
13
|
|
24
|
-
|
14
|
+
sudo gem install tree_visitor
|
15
|
+
|
16
|
+
or
|
17
|
+
|
18
|
+
sudo gem install gf-tree_visitor -s gems.github.com
|
25
19
|
|
26
20
|
== Copyright
|
27
21
|
|
@@ -1,3 +1,46 @@
|
|
1
|
+
# stdlib
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
def recursive_run( dir, &block )
|
5
|
+
block.call( dir )
|
6
|
+
Dir.entries( dir ).each { |entry|
|
7
|
+
next if entry == "." or entry == ".."
|
8
|
+
next if not FileTest.directory?( dir + File::Separator + entry )
|
9
|
+
next if $config.ignore_dir( entry )
|
10
|
+
recursive_run( dir + File::Separator + entry, block )
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_dir( indir, outdir, re )
|
15
|
+
if not File.directory?()
|
16
|
+
raise "#{indir} is not a directory"
|
17
|
+
end
|
18
|
+
if not File.directory?( outdir )
|
19
|
+
FileUtils.mkpath( outdir )
|
20
|
+
end
|
21
|
+
Dir.entries( indir ).each { |e|
|
22
|
+
if e.match( re )
|
23
|
+
from = File.join( indir, e )
|
24
|
+
to = File.join( outdir, e )
|
25
|
+
# puts "#{from} #{to}"
|
26
|
+
if File.exist?(to) and File.mtime(from) <= File.mtime(to)
|
27
|
+
next
|
28
|
+
end
|
29
|
+
FileUtils.cp from, to
|
30
|
+
end
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def copy_file( inpath, outdir )
|
35
|
+
from = inpath
|
36
|
+
to = File.join( outdir, File.basename( from ) )
|
37
|
+
# puts "#{from} #{to}"
|
38
|
+
if File.exist?(to) and File.mtime(from) <= File.mtime(to)
|
39
|
+
next
|
40
|
+
end
|
41
|
+
FileUtils.cp from, to
|
42
|
+
end
|
43
|
+
|
1
44
|
#
|
2
45
|
# substitute into a file
|
3
46
|
#
|
@@ -73,11 +73,10 @@ def kwartz_compile( template_dir, template_include_dir, template_out_dir )
|
|
73
73
|
if outpath_time < maxtime_incs or
|
74
74
|
outpath_time < inpath_time or
|
75
75
|
outpath_time < plogicpath_time
|
76
|
-
puts "kwartz " + argv.join(" ")
|
76
|
+
# puts "kwartz " + argv.join(" ")
|
77
77
|
main = Kwartz::Main.new(argv)
|
78
78
|
output = main.execute()
|
79
79
|
File.open(outpath, 'w') { |f| f.write(output) }
|
80
80
|
end
|
81
81
|
}
|
82
82
|
end
|
83
|
-
|
@@ -1,9 +1,6 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", ".." ) )
|
4
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
5
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "test" ) )
|
1
|
+
require File.join( File.dirname(__FILE__), "test_helper")
|
6
2
|
|
3
|
+
require 'fileutils'
|
7
4
|
require 'gf_utility/kwartzhelper'
|
8
5
|
|
9
6
|
class TCDirProcessor < Test::Unit::TestCase
|
@@ -14,6 +11,10 @@ class TCDirProcessor < Test::Unit::TestCase
|
|
14
11
|
template_dir = File.join( KWARTZ_TEST_DATA, "source" )
|
15
12
|
template_out = File.join( KWARTZ_TEST_DATA, "out" )
|
16
13
|
kwartz_compile( template_dir, nil, template_out )
|
14
|
+
|
15
|
+
out_filename = File.join( KWARTZ_TEST_DATA, "out", "test1.rb" )
|
16
|
+
assert File.exists?(out_filename)
|
17
|
+
FileUtils.rm out_filename
|
17
18
|
end
|
18
19
|
|
19
20
|
end
|
data/test/gf_utility/tc_md5.rb
CHANGED
@@ -1,17 +1,14 @@
|
|
1
|
-
|
2
|
-
require 'test/unit'
|
1
|
+
require File.join( File.dirname(__FILE__), "test_helper")
|
3
2
|
|
4
|
-
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", "..") )
|
5
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
6
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "test" ) )
|
7
|
-
$TEST_FILE = File.join( $TREE_VISITOR_HOME, "lib", "tree_visitor.rb" )
|
8
3
|
|
9
4
|
require 'gf_utility/md5.rb'
|
10
5
|
|
11
6
|
class TCMD5 < Test::Unit::TestCase
|
12
7
|
|
8
|
+
TEST_FILE = File.join( $TREE_VISITOR_HOME, "lib", "tree_visitor.rb" )
|
9
|
+
|
13
10
|
def test_simple_build
|
14
|
-
file_name = File.join(
|
11
|
+
file_name = File.join( TEST_FILE )
|
15
12
|
MD5.file( file_name )
|
16
13
|
end
|
17
14
|
|
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
# common
|
5
|
-
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", "..") )
|
6
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
7
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "test" ) )
|
1
|
+
require File.join( File.dirname(__FILE__), "test_helper")
|
8
2
|
|
9
3
|
require 'gf_utility/numeric.rb'
|
10
4
|
|
@@ -1,10 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", ".." ) )
|
4
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
5
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "test" ) )
|
6
|
-
|
7
|
-
$TEST_DATA = File.join( $TREE_VISITOR_HOME, "test_data", "tree_visitor", "test_data" )
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
8
2
|
|
9
3
|
require 'tree_visitor/dir_processor'
|
10
4
|
|
@@ -1,11 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
# common
|
5
|
-
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", ".." ) )
|
6
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
7
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "test" ) )
|
8
|
-
$TEST_DATA = File.join( $TREE_VISITOR_HOME, "test_data", "tree_visitor", "test_data" )
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
9
2
|
|
10
3
|
require 'tree_visitor/dir_tree_walker.rb'
|
11
4
|
require 'tree_visitor/tree_node_visitor.rb'
|
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
# common
|
5
|
-
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", ".." ) )
|
6
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
7
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "test" ) )
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
8
2
|
|
9
3
|
require 'tree_visitor/tree_node.rb'
|
10
4
|
|
@@ -1,8 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", ".." ) )
|
4
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
5
|
-
$:.unshift( File.join($TREE_VISITOR_HOME, "test" ) )
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
6
2
|
|
7
3
|
require 'tree_visitor/tree_node.rb'
|
8
4
|
require 'tree_visitor/tree_node_visitor.rb'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", ".." ) )
|
2
|
+
|
3
|
+
lib_dir = File.join($TREE_VISITOR_HOME, "lib" )
|
4
|
+
test_dir = File.join($TREE_VISITOR_HOME, "test" )
|
5
|
+
$:.unshift lib_dir unless $:.include?(lib_dir)
|
6
|
+
$:.unshift test_dir unless $:.include?(test_dir)
|
7
|
+
|
8
|
+
$TEST_DATA = File.join( $TREE_VISITOR_HOME, "test_data", "tree_visitor", "test_data" )
|
9
|
+
|
10
|
+
require 'test/unit'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gf-tree_visitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gf
|
@@ -9,10 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-25 00:00:00 -07:00
|
13
13
|
default_executable: dirtree.rb
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: abstract
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
16
25
|
description:
|
17
26
|
email: giovanni.ferro@gmail.com
|
18
27
|
executables:
|
@@ -68,13 +77,15 @@ rubyforge_project: ralbum
|
|
68
77
|
rubygems_version: 1.2.0
|
69
78
|
signing_key:
|
70
79
|
specification_version: 2
|
71
|
-
summary:
|
80
|
+
summary: implementation of visitor design pattern
|
72
81
|
test_files:
|
73
82
|
- test/gf_utility/tc_md5.rb
|
74
83
|
- test/gf_utility/tc_kwartz.rb
|
75
84
|
- test/gf_utility/tc_numeric.rb
|
85
|
+
- test/gf_utility/test_helper.rb
|
76
86
|
- test/ts_tree_visitor.rb
|
77
87
|
- test/tree_visitor/tc_dir_processor.rb
|
78
88
|
- test/tree_visitor/tc_dir_tree_walker.rb
|
79
89
|
- test/tree_visitor/tc_tree_node.rb
|
80
90
|
- test/tree_visitor/tc_tree_node_visitor.rb
|
91
|
+
- test/tree_visitor/test_helper.rb
|