gf-tree_visitor 0.0.2 → 0.0.4
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/bin/dirtree.rb +2 -2
- data/lib/gf_utility/file_utilities.rb +27 -0
- data/lib/gf_utility/kwartzhelper.rb +83 -0
- data/lib/{tree_visitor/utility → gf_utility}/md5.rb +0 -0
- data/lib/{tree_visitor/utility → gf_utility}/numeric.rb +0 -0
- data/test/gf_utility/tc_kwartz.rb +19 -0
- data/test/gf_utility/tc_md5.rb +18 -0
- data/test/gf_utility/tc_numeric.rb +19 -0
- data/test/tree_visitor/tc_dir_processor.rb +4 -4
- data/test/tree_visitor/tc_dir_tree_walker.rb +4 -4
- data/test/tree_visitor/tc_tree_node.rb +3 -3
- data/test/tree_visitor/tc_tree_node_visitor.rb +3 -3
- data/test/ts_tree_visitor.rb +4 -4
- data/test_data/gf_utility/kwartz_test_data/source/test1.html +5 -0
- data/test_data/tree_visitor/test_data/dir.1/dir.1.2/file.1.2.1 +0 -0
- data/test_data/tree_visitor/test_data/dir.1/file.1.1 +0 -0
- data/test_data/tree_visitor/test_data/dir.2/file.2.1 +0 -0
- metadata +14 -7
- data/test/tree_visitor/utility/tc_md5.rb +0 -20
- data/test/tree_visitor/utility/tc_numeric.rb +0 -21
data/bin/dirtree.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# clidirtree
|
5
5
|
#
|
6
6
|
|
7
|
-
$
|
8
|
-
$:.unshift( File.join($
|
7
|
+
$TREE_VISITOR_HOME = File.expand_path( File.join( File.dirname( __FILE__), ".." ) )
|
8
|
+
$:.unshift( File.join($TREE_VISITOR_HOME, "lib" ) )
|
9
9
|
|
10
10
|
require "tree_visitor/cli/cli_dir_tree"
|
11
11
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# substitute into a file
|
3
|
+
#
|
4
|
+
def subfile( filename, map )
|
5
|
+
lines = IO.readlines( filename)
|
6
|
+
if $options.backup
|
7
|
+
FileUtils.mv( filename, filename + ".bck" )
|
8
|
+
end
|
9
|
+
|
10
|
+
lines.each_with_index { |l,i|
|
11
|
+
map.each { |l1, l2|
|
12
|
+
#puts "#{l} #{l1} #{l.index(l1)}"
|
13
|
+
if l.index( l1 ) == 0
|
14
|
+
puts "subst #{l1}"
|
15
|
+
lines[i] = l2
|
16
|
+
end
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
File.open( filename, "w" ) { |f|
|
21
|
+
lines.each{ |l| f.puts l }
|
22
|
+
}
|
23
|
+
puts "patched #{filename}"
|
24
|
+
|
25
|
+
rescue Errno::ENOENT => e
|
26
|
+
puts "file not found '#{filename}'"
|
27
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# ruby gems
|
2
|
+
#
|
3
|
+
# Check dependecies
|
4
|
+
require 'rubygems'
|
5
|
+
begin
|
6
|
+
require "kwartz"
|
7
|
+
require "kwartz/main"
|
8
|
+
rescue LoadError
|
9
|
+
abort 'kwartz gem required!!'
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# kwartz utility
|
14
|
+
# template_dir: directory containing kwartz template
|
15
|
+
# template_include_dir: nil or a directory contained kwarz template referenced by template
|
16
|
+
# template_out_dir: where the output goes
|
17
|
+
#
|
18
|
+
def kwartz_compile( template_dir, template_include_dir, template_out_dir )
|
19
|
+
if not File.directory?(template_dir)
|
20
|
+
raise "template_dir: '#{template_dir}' is not a directory"
|
21
|
+
end
|
22
|
+
|
23
|
+
if not File.directory?(template_out_dir)
|
24
|
+
raise "template_out_dir: '#{template_out_dir}' is not a directory"
|
25
|
+
end
|
26
|
+
|
27
|
+
re_templatefile = /^[^\.](.+).html$/
|
28
|
+
|
29
|
+
maxtime_incs = Time.local( 1980 )
|
30
|
+
incs = []
|
31
|
+
if template_include_dir
|
32
|
+
if not File.directory?( template_include_dir )
|
33
|
+
raise "include_dir: '#{template_include_dir}' is not a directory"
|
34
|
+
end
|
35
|
+
incs = Dir.new( template_include_dir ).find_all { |f| f =~ re_templatefile }
|
36
|
+
incs = incs.map{ |f| File.join(template_include_dir, f) }
|
37
|
+
maxtime_incs = incs.inject(maxtime_incs) {|t,f|
|
38
|
+
t1 = File.mtime( f )
|
39
|
+
if t1 > t then t1 else t end
|
40
|
+
}
|
41
|
+
incs = incs.join(",")
|
42
|
+
end
|
43
|
+
|
44
|
+
Dir.foreach( template_dir ) { |f|
|
45
|
+
next unless f =~ re_templatefile
|
46
|
+
|
47
|
+
inpath = File.join(template_dir, f)
|
48
|
+
inpath_time = File.mtime( inpath )
|
49
|
+
|
50
|
+
plogicpath = template_dir + File::Separator + f.sub( /.html$/, ".plogic" )
|
51
|
+
plogicpath_time = Time.local( 1980 )
|
52
|
+
if File.exists?( plogicpath )
|
53
|
+
plogicpath_time = File.mtime( plogicpath )
|
54
|
+
end
|
55
|
+
|
56
|
+
outpath = File.join( template_out_dir, f.sub( /.html$/, ".rb" ) )
|
57
|
+
outpath_time = Time.local( 1980 )
|
58
|
+
if File.exist?( outpath )
|
59
|
+
outpath_time = File.mtime( outpath )
|
60
|
+
end
|
61
|
+
|
62
|
+
argv = %w[--delspan -a defun -l ruby]
|
63
|
+
if incs.length > 0
|
64
|
+
argv << "-i"
|
65
|
+
argv.push( incs )
|
66
|
+
end
|
67
|
+
|
68
|
+
if File.exist?( plogicpath )
|
69
|
+
argv.push( "-p", plogicpath )
|
70
|
+
end
|
71
|
+
argv.push( inpath )
|
72
|
+
|
73
|
+
if outpath_time < maxtime_incs or
|
74
|
+
outpath_time < inpath_time or
|
75
|
+
outpath_time < plogicpath_time
|
76
|
+
puts "kwartz " + argv.join(" ")
|
77
|
+
main = Kwartz::Main.new(argv)
|
78
|
+
output = main.execute()
|
79
|
+
File.open(outpath, 'w') { |f| f.write(output) }
|
80
|
+
end
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
File without changes
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test/unit'
|
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
|
+
require 'gf_utility/kwartzhelper'
|
8
|
+
|
9
|
+
class TCDirProcessor < Test::Unit::TestCase
|
10
|
+
|
11
|
+
KWARTZ_TEST_DATA = File.join( $TREE_VISITOR_HOME, "test_data", "gf_utility", "kwartz_test_data" )
|
12
|
+
|
13
|
+
def test_simple
|
14
|
+
template_dir = File.join( KWARTZ_TEST_DATA, "source" )
|
15
|
+
template_out = File.join( KWARTZ_TEST_DATA, "out" )
|
16
|
+
kwartz_compile( template_dir, nil, template_out )
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# stdlib
|
2
|
+
require 'test/unit'
|
3
|
+
|
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
|
+
|
9
|
+
require 'gf_utility/md5.rb'
|
10
|
+
|
11
|
+
class TCMD5 < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def test_simple_build
|
14
|
+
file_name = File.join( $TEST_FILE )
|
15
|
+
MD5.file( file_name )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# stdlib
|
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
|
+
|
9
|
+
require 'gf_utility/numeric.rb'
|
10
|
+
|
11
|
+
class TCNumeric < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def test_simple
|
14
|
+
assert_equal "10", 10.with_separator
|
15
|
+
assert_equal "10.0", 10.0.with_separator
|
16
|
+
assert_equal "1,000,000", 1000000.with_separator
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
|
-
$
|
4
|
-
$:.unshift( File.join($
|
5
|
-
$:.unshift( File.join($
|
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
6
|
|
7
|
-
$TEST_DATA = File.join( $
|
7
|
+
$TEST_DATA = File.join( $TREE_VISITOR_HOME, "test_data", "tree_visitor", "test_data" )
|
8
8
|
|
9
9
|
require 'tree_visitor/dir_processor'
|
10
10
|
|
@@ -2,10 +2,10 @@
|
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
4
|
# common
|
5
|
-
$
|
6
|
-
$:.unshift( File.join($
|
7
|
-
$:.unshift( File.join($
|
8
|
-
$TEST_DATA = File.join( $
|
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" )
|
9
9
|
|
10
10
|
require 'tree_visitor/dir_tree_walker.rb'
|
11
11
|
require 'tree_visitor/tree_node_visitor.rb'
|
@@ -2,9 +2,9 @@
|
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
4
|
# common
|
5
|
-
$
|
6
|
-
$:.unshift( File.join($
|
7
|
-
$:.unshift( File.join($
|
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
8
|
|
9
9
|
require 'tree_visitor/tree_node.rb'
|
10
10
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
|
-
$
|
4
|
-
$:.unshift( File.join($
|
5
|
-
$:.unshift( File.join($
|
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
6
|
|
7
7
|
require 'tree_visitor/tree_node.rb'
|
8
8
|
require 'tree_visitor/tree_node_visitor.rb'
|
data/test/ts_tree_visitor.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
require "test/unit"
|
3
3
|
|
4
4
|
# common
|
5
|
-
$
|
6
|
-
$:.unshift( File.join($
|
7
|
-
$:.unshift( File.join($
|
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
8
|
|
9
9
|
require "tree_visitor"
|
10
10
|
|
11
|
-
require "
|
11
|
+
require "gf_utility/tc_md5"
|
12
12
|
|
13
13
|
require "tree_visitor/tc_dir_processor"
|
14
14
|
require "tree_visitor/tc_dir_tree_walker"
|
File without changes
|
File without changes
|
File without changes
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gf
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-23 00:00:00 -07:00
|
13
13
|
default_executable: dirtree.rb
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -23,6 +23,10 @@ extra_rdoc_files:
|
|
23
23
|
- LICENSE
|
24
24
|
- README.rdoc
|
25
25
|
files:
|
26
|
+
- lib/gf_utility/file_utilities.rb
|
27
|
+
- lib/gf_utility/kwartzhelper.rb
|
28
|
+
- lib/gf_utility/md5.rb
|
29
|
+
- lib/gf_utility/numeric.rb
|
26
30
|
- lib/tree_visitor.rb
|
27
31
|
- lib/tree_visitor/abs_node.rb
|
28
32
|
- lib/tree_visitor/build_dir_tree_visitor.rb
|
@@ -32,9 +36,11 @@ files:
|
|
32
36
|
- lib/tree_visitor/leaf_node.rb
|
33
37
|
- lib/tree_visitor/tree_node.rb
|
34
38
|
- lib/tree_visitor/tree_node_visitor.rb
|
35
|
-
- lib/tree_visitor/utility/md5.rb
|
36
|
-
- lib/tree_visitor/utility/numeric.rb
|
37
39
|
- lib/tree_visitor/visitor/print_node_visitor2.rb
|
40
|
+
- test_data/gf_utility/kwartz_test_data/source/test1.html
|
41
|
+
- test_data/tree_visitor/test_data/dir.1/dir.1.2/file.1.2.1
|
42
|
+
- test_data/tree_visitor/test_data/dir.1/file.1.1
|
43
|
+
- test_data/tree_visitor/test_data/dir.2/file.2.1
|
38
44
|
- LICENSE
|
39
45
|
- README.rdoc
|
40
46
|
has_rdoc: true
|
@@ -58,16 +64,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
64
|
version:
|
59
65
|
requirements: []
|
60
66
|
|
61
|
-
rubyforge_project:
|
67
|
+
rubyforge_project: ralbum
|
62
68
|
rubygems_version: 1.2.0
|
63
69
|
signing_key:
|
64
70
|
specification_version: 2
|
65
71
|
summary: TODO
|
66
72
|
test_files:
|
73
|
+
- test/gf_utility/tc_md5.rb
|
74
|
+
- test/gf_utility/tc_kwartz.rb
|
75
|
+
- test/gf_utility/tc_numeric.rb
|
67
76
|
- test/ts_tree_visitor.rb
|
68
77
|
- test/tree_visitor/tc_dir_processor.rb
|
69
78
|
- test/tree_visitor/tc_dir_tree_walker.rb
|
70
79
|
- test/tree_visitor/tc_tree_node.rb
|
71
80
|
- test/tree_visitor/tc_tree_node_visitor.rb
|
72
|
-
- test/tree_visitor/utility/tc_md5.rb
|
73
|
-
- test/tree_visitor/utility/tc_numeric.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# stdlib
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
# common
|
5
|
-
$COMMON_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", "..", ".." ) )
|
6
|
-
$:.unshift( File.join($COMMON_HOME, "lib" ) )
|
7
|
-
$:.unshift( File.join($COMMON_HOME, "test" ) )
|
8
|
-
$TEST_FILE = File.join( $COMMON_HOME, "lib", "tree_visitor.rb" )
|
9
|
-
|
10
|
-
|
11
|
-
require 'tree_visitor/utility/md5.rb'
|
12
|
-
|
13
|
-
class TCMD5 < Test::Unit::TestCase
|
14
|
-
|
15
|
-
def test_simple_build
|
16
|
-
file_name = File.join( $TEST_FILE )
|
17
|
-
MD5.file( file_name )
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# stdlib
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
# common
|
5
|
-
$COMMON_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", "..", ".." ) )
|
6
|
-
$:.unshift( File.join($COMMON_HOME, "lib" ) )
|
7
|
-
$:.unshift( File.join($COMMON_HOME, "test" ) )
|
8
|
-
$TEST_FILE = File.join( $COMMON_HOME, "lib", "tree_visitor.rb" )
|
9
|
-
|
10
|
-
|
11
|
-
require 'tree_visitor/utility/numeric.rb'
|
12
|
-
|
13
|
-
class TCNumeric < Test::Unit::TestCase
|
14
|
-
|
15
|
-
def test_simple
|
16
|
-
assert_equal "10", 10.with_separator
|
17
|
-
assert_equal "10.0", 10.0.with_separator
|
18
|
-
assert_equal "1,000,000", 1000000.with_separator
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|