tree.rb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/LICENSE.txt +1 -1
  2. data/README.md +1 -0
  3. data/Rakefile +5 -5
  4. data/bin/tree.rb +3 -2
  5. data/examples/directory_walker/directory_without_subdirectory.rb +2 -2
  6. data/examples/directory_walker/find_files.rb +1 -1
  7. data/examples/directory_walker/print_files.rb +1 -1
  8. data/examples/protovis/directory_to_json_visitor.rb +2 -2
  9. data/lib/{treevisitor → tree_rb}/abs_node.rb +2 -2
  10. data/lib/{treevisitor → tree_rb}/basic_tree_node_visitor.rb +1 -1
  11. data/lib/{treevisitor → tree_rb}/cli/cli_tree.rb +35 -18
  12. data/lib/{treevisitor → tree_rb}/directory_walker.rb +1 -1
  13. data/lib/{treevisitor → tree_rb}/leaf_node.rb +1 -1
  14. data/lib/{treevisitor → tree_rb}/tree_node.rb +16 -8
  15. data/lib/{treevisitor → tree_rb}/tree_node_visitor.rb +1 -1
  16. data/lib/{treevisitor → tree_rb}/util/dir_processor.rb +2 -2
  17. data/lib/tree_rb/version.rb +4 -0
  18. data/lib/{treevisitor → tree_rb}/visitors/block_tree_node_visitor.rb +1 -1
  19. data/lib/{treevisitor → tree_rb}/visitors/build_dir_tree_visitor.rb +1 -2
  20. data/lib/{treevisitor → tree_rb}/visitors/callback_tree_node_visitor2.rb +7 -1
  21. data/lib/{treevisitor → tree_rb}/visitors/clone_tree_node_visitor.rb +7 -1
  22. data/lib/{treevisitor → tree_rb}/visitors/depth_tree_node_visitor.rb +7 -1
  23. data/lib/{treevisitor → tree_rb}/visitors/directory_to_hash_visitor.rb +7 -1
  24. data/lib/{treevisitor → tree_rb}/visitors/flat_print_tree_node_visitors.rb +7 -1
  25. data/lib/{treevisitor → tree_rb}/visitors/print_dir_tree_visitor.rb +7 -1
  26. data/lib/{treevisitor → tree_rb}/visitors/print_tree_node_visitor.rb +7 -1
  27. data/lib/treevisitor.rb +15 -15
  28. data/lib/treevisitor_cli.rb +12 -1
  29. data/spec/spec_helper.rb +1 -1
  30. data/spec/{treevisitor → tree_rb}/cli/cli_tree_spec.rb +1 -1
  31. data/spec/{treevisitor → tree_rb}/directory_walker_spec.rb +0 -0
  32. data/spec/{treevisitor → tree_rb}/tree_dsl_spec.rb +0 -0
  33. data/spec/{treevisitor → tree_rb}/tree_dsl_with_derived_class1_spec.rb +0 -0
  34. data/spec/{treevisitor → tree_rb}/tree_dsl_with_derived_class_spec.rb +0 -0
  35. data/spec/{treevisitor → tree_rb}/tree_node_paths_spec.rb +0 -0
  36. data/spec/{treevisitor → tree_rb}/tree_node_spec.rb +0 -0
  37. data/spec/{treevisitor → tree_rb}/tree_node_visitor_delegate_spec.rb +0 -0
  38. data/spec/{treevisitor → tree_rb}/tree_node_visitor_dsl_spec.rb +0 -0
  39. data/spec/{treevisitor → tree_rb}/util/dir_processor_spec.rb +0 -0
  40. data/spec/{treevisitor → tree_rb}/visitors/block_tree_node_visitor_spec.rb +0 -0
  41. data/spec/{treevisitor → tree_rb}/visitors/callback_tree_node_visitor2_spec.rb +0 -0
  42. data/spec/{treevisitor → tree_rb}/visitors/depth_tree_node_visitor_spec.rb +0 -0
  43. data/spec/{treevisitor → tree_rb}/visitors/tree_node_visitors_spec.rb +0 -0
  44. data/tree.rb.gemspec +14 -10
  45. metadata +59 -65
  46. data/lib/treevisitor/version.rb +0 -4
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2010 tokiro.oyama@gmail.com
1
+ Copyright (c) 2009-2012 tokiro.oyama@gmail.com
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -98,6 +98,7 @@ $ ruby bin/tree.rb --format json lib
98
98
  </pre>
99
99
 
100
100
  The json structure can be transformed into image:
101
+
101
102
  <img src='https://github.com/tokiro/tree.rb/raw/master/examples/protovis/treevisitor.png'/>
102
103
 
103
104
  ## Usage as library
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
+ #!/usr/bin/env rake
1
2
  # -*- encoding: utf-8; mode: ruby -*-
2
- require 'rubygems'
3
- require 'rake'
4
-
5
- require 'bundler'
6
- Bundler::GemHelper.install_tasks
3
+ require 'bundler/gem_tasks'
4
+ #Bundler::GemHelper.install_tasks
5
+ #require 'rubygems'
6
+ #require 'rake'
7
7
 
8
8
  # Load tasks
9
9
  Dir.glob('tasks/**/*.rake').each { |r| Rake.application.add_import r }
data/bin/tree.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
2
+ # -*- coding: utf-8 -*-
3
+ #require 'rubygems'
3
4
 
4
5
  cwd = File.expand_path( File.join( File.dirname(__FILE__), "..", "lib" ) )
5
6
  $:.unshift(cwd) unless $:.include?(cwd)
6
7
  require 'treevisitor_cli'
7
8
 
8
- include TreeVisitor
9
+ include TreeRb
9
10
  exit CliTree.run
@@ -8,7 +8,7 @@ require 'treevisitor'
8
8
  #
9
9
  # Find directories without subdirectories
10
10
  #
11
- class DirWithoutSubDir < TreeVisitor::BasicTreeNodeVisitor
11
+ class DirWithoutSubDir < TreeRb::BasicTreeNodeVisitor
12
12
 
13
13
  def initialize
14
14
  super
@@ -31,7 +31,7 @@ class DirWithoutSubDir < TreeVisitor::BasicTreeNodeVisitor
31
31
 
32
32
  end
33
33
 
34
- dtw = TreeVisitor::DirTreeWalker.new( ".." )
34
+ dtw = TreeRb::DirTreeWalker.new( ".." )
35
35
  dtw.ignore /^\./
36
36
  dtw.visit_file=false
37
37
  dtw.run( DirWithoutSubDir.new )
@@ -3,7 +3,7 @@
3
3
  cwd = File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "lib" ) )
4
4
  $:.unshift(cwd) unless $:.include?(cwd)
5
5
  require 'treevisitor'
6
- include TreeVisitor
6
+ include TreeRb
7
7
 
8
8
  class MyVisitor < BasicTreeNodeVisitor
9
9
  def visit_leaf( pathname )
@@ -2,7 +2,7 @@
2
2
  cwd = File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "lib" ) )
3
3
  $:.unshift(cwd) unless $:.include?(cwd)
4
4
  require 'treevisitor'
5
- include TreeVisitor
5
+ include TreeRb
6
6
 
7
7
  dtw = DirTreeWalker.new( :ignore => ".git" )
8
8
  dtw.run ".." do
@@ -5,11 +5,11 @@ require 'rubygems'
5
5
  cwd = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib"))
6
6
  $:.unshift(cwd) unless $:.include?(cwd)
7
7
  require 'treevisitor'
8
- include TreeVisitor
8
+ include TreeRb
9
9
 
10
10
  dir = File.expand_path( File.join("..", "..", "lib") )
11
11
 
12
- dtw = TreeVisitor::DirTreeWalker.new( :ignore => [/^\./, "doc", "pkg"] )
12
+ dtw = TreeRb::DirTreeWalker.new( :ignore => [/^\./, "doc", "pkg"] )
13
13
  root = dtw.run(dir, DirectoryToHashVisitor.new(dir)).root
14
14
  str = "var treevisitor = #{JSON.pretty_generate(root)};"
15
15
  File.open( File.dirname(__FILE__) + "/treevisitor.js", "w"){ |f| f.write str }
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
 
4
4
  #
5
5
  # @abstract Subclass to implement a concrete Node (Leaf or Tree).
@@ -141,4 +141,4 @@ module TreeVisitor
141
141
  end
142
142
 
143
143
  end
144
- end
144
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Callback methods used to visit a tree
5
5
  # Are empty so it is possible to define only a subset when deriving subclass
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  #
5
5
  #
@@ -11,7 +11,7 @@ module TreeVisitor
11
11
 
12
12
  def parse_args(argv)
13
13
 
14
- options = {:verbose => true, :force => false, :algo => 'build-dir'}
14
+ options = { :verbose => true, :force => false, :algo => 'build-dir' }
15
15
 
16
16
  opts = OptionParser.new
17
17
  opts.banner = "Usage: tree.rb [options] [directory]"
@@ -28,15 +28,15 @@ module TreeVisitor
28
28
  end
29
29
 
30
30
  opts.on("--version", "Show the version") do
31
- puts "tree.rb version #{TreeVisitor::VERSION}"
31
+ puts "tree.rb version #{TreeRb::VERSION}"
32
32
  return 0
33
33
  end
34
34
 
35
- opts.on("-a", "All file are listed") do |v|
35
+ opts.on("-a", "All file are listed") do
36
36
  options[:all_files] = true
37
37
  end
38
38
 
39
- opts.on("-d", "List directories only") do |v|
39
+ opts.on("-d", "List directories only") do
40
40
  options[:only_directories] = true
41
41
  end
42
42
 
@@ -44,24 +44,46 @@ module TreeVisitor
44
44
  options[:verbose] = v
45
45
  end
46
46
 
47
- opts.on("-q", "--quiet", "quiet mode as --no-verbose") do |v|
47
+ opts.on("-q", "--quiet", "quiet mode as --no-verbose") do
48
48
  options[:verbose] = false
49
49
  end
50
50
 
51
51
  algos = %w[build-dir print-dir json yaml]
52
- algo_aliases = {"b" => "build-dir", "v" => "print-dir", "j" => "json", "y" => "yaml"}
52
+ algo_aliases = { "b" => "build-dir", "v" => "print-dir", "j" => "json", "y" => "yaml" }
53
53
 
54
- algo_list = (algo_aliases.keys + algos).join(',')
54
+ algo_list = (algo_aliases.keys + algos).join(',')
55
55
  opts.on("-f", "--format ALGO", algos, algo_aliases, "select an algo", " (#{algo_list})") do |algo|
56
56
  options[:algo] = algo
57
57
  end
58
58
 
59
+ #
60
+ # begin colorize
61
+ #
62
+ # copied from tree man page
63
+ opts.on("-n", "Turn colorization off always, over-ridden by the -C option.") do
64
+ options[:colorize] = false
65
+ end
66
+
67
+ # copied from tree man page
68
+ opts.on("-C", "Turn colorization on always, using built-in color defaults if the LS_COLORS environment variable is not set. Useful to colorize output to a pipe.") do
69
+ options[:colorize] = true
70
+ end
71
+ options[:colorize] ||= $stdout.isatty
72
+
73
+ #
74
+ # end colorize
75
+ #
76
+
59
77
  begin
60
78
  rest = opts.parse(argv)
61
79
  rescue OptionParser::InvalidOption => e
62
80
  $stderr.puts e.to_s
63
81
  $stderr.puts "try -h for help"
64
82
  return false
83
+ rescue OptionParser::MissingArgument => e
84
+ $stderr.puts e.to_s
85
+ $stderr.puts "try -h for help"
86
+ return false
65
87
  end
66
88
 
67
89
  if rest.length < 1
@@ -72,7 +94,7 @@ module TreeVisitor
72
94
 
73
95
  dirname = File.expand_path(dirname)
74
96
 
75
- dtw = DirTreeWalker.new(dirname)
97
+ dtw = DirTreeWalker.new(dirname)
76
98
  unless options[:all_files]
77
99
  dtw.ignore(/^\.[^.]+/) # ignore all file starting with "."
78
100
  end
@@ -84,17 +106,12 @@ module TreeVisitor
84
106
  when 'build-dir'
85
107
  # TODO: capture CTRL^C
86
108
  # http://ruby-doc.org/core-1.9.3/Kernel.html#method-i-trap
87
- Kernel.trap('INT') { put "User interrupted exit"; exit; }
88
-
109
+ Kernel.trap('INT') { put "User interrupted exit"; exit }
110
+
89
111
  visitor = BuildDirTreeVisitor.new
90
112
  dtw.run(visitor)
91
-
92
- # colors also in windows
93
- if $stdout.isatty
94
- puts visitor.root.to_str('', true) #use color
95
- else
96
- puts visitor.root.to_str
97
- end
113
+
114
+ puts visitor.root.to_str('', options[:colorize])
98
115
  puts
99
116
  puts "#{visitor.nr_directories} directories, #{visitor.nr_files} files"
100
117
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
 
4
4
  #
5
5
  # Visit a file system directory
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
 
4
4
  #
5
5
  # Represent a LeafNode
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # TreeNode can contains other TreeNode (children)
5
5
  # and can contains LeafNode (leaves)
@@ -8,7 +8,7 @@ module TreeVisitor
8
8
  # @leaves -1---n-> LeafNode
9
9
  #
10
10
  # define dsl to create Tree
11
- #
11
+ #
12
12
  # @example
13
13
  # tree = TreeNode.create do
14
14
  # node "root" do
@@ -49,8 +49,8 @@ module TreeVisitor
49
49
  private
50
50
 
51
51
  # DSL node add a child to the surrounding node
52
- # TreeNode.create do
53
- # node "..."
52
+ # TreeNode.create do
53
+ # node "..."
54
54
  # end
55
55
  def node(*args, &block)
56
56
  parent_node = @scope_stack.length > 0 ? @scope_stack[-1] : nil
@@ -71,8 +71,8 @@ module TreeVisitor
71
71
  end
72
72
 
73
73
  # DSL node add a leaf to the surround node
74
- # TreeNode.create do
75
- # leaf "..."
74
+ # TreeNode.create do
75
+ # leaf "..."
76
76
  # end
77
77
  def leaf(*args, &block)
78
78
  tree_node = @scope_stack[-1]
@@ -245,6 +245,14 @@ module TreeVisitor
245
245
  #
246
246
  # Format the content of tree
247
247
  #
248
+
249
+ # TODO: integrate with ansi color
250
+ # TODO: see dircolors command
251
+ # http://isthe.com/chongo/tech/comp/ansi_escapes.html
252
+ # puts "\033[2J" # clear screen
253
+ # puts "aaaa \033[7;31;40m ciao \033[0m"
254
+ # ESC[K Clear to end of line
255
+
248
256
  def to_str(prefix= "", tty_color = false)
249
257
  str = ""
250
258
 
@@ -279,9 +287,9 @@ module TreeVisitor
279
287
  str << '`-- '
280
288
  end
281
289
  if tty_color
282
- str << ANSI.green{ leaf.to_s } << "\n"
290
+ str << ANSI.green{ leaf.to_s } << "\n"
283
291
  else
284
- str << leaf.to_s << "\n"
292
+ str << leaf.to_s << "\n"
285
293
  end
286
294
  end
287
295
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
 
4
4
  #
5
5
  # More complex TreeNodeVisitor, define a simple dsl
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
 
4
4
  #
5
5
  # Visit a directory tree
@@ -31,7 +31,7 @@ module TreeVisitor
31
31
  end
32
32
 
33
33
  private
34
-
34
+
35
35
  def process_file( pn )
36
36
  # puts "file: #{f}"
37
37
  pair = @processors.find { |re,action| re =~ pn.to_s }
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+ module TreeRb
3
+ VERSION="0.3.1"
4
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # It calls a block when visit a tree_node or leaf_node
5
5
  #
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Builds a TreeNode from a filesystem directory
5
5
  # It similar to CloneTreeNodeVisitor
@@ -40,7 +40,6 @@ module TreeVisitor
40
40
  end
41
41
 
42
42
  def cannot_enter_node(pathname, error)
43
-
44
43
  end
45
44
 
46
45
  def exit_node( pathname )
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Executes a block when enter in a node
5
5
  # The block are defined from on_enter_X methods
@@ -38,6 +38,12 @@ module TreeVisitor
38
38
  @stack.pop
39
39
  end
40
40
 
41
+ #
42
+ # called when the tree node is not accessible or an exception is raise when the node is accessed
43
+ #
44
+ def cannot_enter_node( tree_node, error)
45
+ end
46
+
41
47
  def visit_leaf(src_leaf_node)
42
48
  parent_node = @stack.last
43
49
  @action_visit_leaf_node.call(src_leaf_node, parent_node) if @action_visit_leaf_node
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Clone a tree_node, nodes are duplicated.
5
5
  # Node content are not duplicated!
@@ -31,6 +31,12 @@ module TreeVisitor
31
31
  @stack.pop
32
32
  end
33
33
 
34
+ #
35
+ # called when the tree node is not accessible or an exception is raise when the node is accessed
36
+ #
37
+ def cannot_enter_node( tree_node, error)
38
+ end
39
+
34
40
  def visit_leaf( leaf_node )
35
41
  LeafNode.new( leaf_node.content, @stack.last )
36
42
  end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Simple visitor: show how calculate the depth of a tree
5
5
  #
@@ -20,6 +20,12 @@ module TreeVisitor
20
20
  @depth -= 1
21
21
  end
22
22
 
23
+ #
24
+ # called when the tree node is not accessible or an exception is raise when the node is accessed
25
+ #
26
+ def cannot_enter_node( tree_node, error)
27
+ end
28
+
23
29
  def visit_leaf( leaf_node )
24
30
  end
25
31
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- module TreeVisitor
3
+ module TreeRb
4
4
  #
5
5
  # Build hash with directory structure
6
6
  #
@@ -25,6 +25,12 @@ module TreeVisitor
25
25
  @node = @stack.pop
26
26
  end
27
27
 
28
+ #
29
+ # called when the tree node is not accessible or an exception is raise when the node is accessed
30
+ #
31
+ def cannot_enter_node( tree_node, error)
32
+ end
33
+
28
34
  def visit_leaf(pathname)
29
35
  @node[File.basename(pathname)] = File.stat(pathname).size
30
36
  end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Print for every node the name
5
5
  #
@@ -12,6 +12,12 @@ module TreeVisitor
12
12
  def exit_node( tree_node )
13
13
  end
14
14
 
15
+ #
16
+ # called when the tree node is not accessible or an exception is raise when the node is accessed
17
+ #
18
+ def cannot_enter_node( tree_node, error)
19
+ end
20
+
15
21
  def visit_leaf( leaf_node )
16
22
  puts leaf_node.name
17
23
  end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Visitor for DirTreeWalker
5
5
  # Prints the node at enter
@@ -13,6 +13,12 @@ module TreeVisitor
13
13
  def exit_node( pathname )
14
14
  end
15
15
 
16
+ #
17
+ # called when the tree node is not accessible or an exception is raise when the node is accessed
18
+ #
19
+ def cannot_enter_node( tree_node, error)
20
+ end
21
+
16
22
  def visit_leaf( pathname )
17
23
  puts pathname
18
24
  end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- module TreeVisitor
2
+ module TreeRb
3
3
  #
4
4
  # Prints TreeNode names indenting according to depth
5
5
  #
@@ -27,6 +27,12 @@ module TreeVisitor
27
27
  @depth -= 1
28
28
  end
29
29
 
30
+ #
31
+ # called when the tree node is not accessible or an exception is raise when the node is accessed
32
+ #
33
+ def cannot_enter_node( tree_node, error)
34
+ end
35
+
30
36
  def visit_leaf( leaf_node )
31
37
  str = ""
32
38
  (0...@depth-1).step {
data/lib/treevisitor.rb CHANGED
@@ -17,24 +17,24 @@ require 'ansi/code'
17
17
  # treevisitor
18
18
  #
19
19
 
20
- require "treevisitor/version"
21
- require "treevisitor/abs_node"
22
- require 'treevisitor/leaf_node'
23
- require 'treevisitor/tree_node'
24
- require 'treevisitor/basic_tree_node_visitor'
25
- require 'treevisitor/tree_node_visitor'
20
+ require "tree_rb/version"
21
+ require "tree_rb/abs_node"
22
+ require 'tree_rb/leaf_node'
23
+ require 'tree_rb/tree_node'
24
+ require 'tree_rb/basic_tree_node_visitor'
25
+ require 'tree_rb/tree_node_visitor'
26
26
 
27
- require 'treevisitor/directory_walker'
27
+ require 'tree_rb/directory_walker'
28
28
 
29
29
  #
30
30
  # visitors
31
31
  #
32
- require 'treevisitor/visitors/block_tree_node_visitor'
33
- require 'treevisitor/visitors/build_dir_tree_visitor'
34
- require 'treevisitor/visitors/callback_tree_node_visitor2'
35
- require 'treevisitor/visitors/clone_tree_node_visitor'
36
- require 'treevisitor/visitors/depth_tree_node_visitor'
37
- require 'treevisitor/visitors/print_dir_tree_visitor'
38
- require 'treevisitor/visitors/directory_to_hash_visitor'
32
+ require 'tree_rb/visitors/block_tree_node_visitor'
33
+ require 'tree_rb/visitors/build_dir_tree_visitor'
34
+ require 'tree_rb/visitors/callback_tree_node_visitor2'
35
+ require 'tree_rb/visitors/clone_tree_node_visitor'
36
+ require 'tree_rb/visitors/depth_tree_node_visitor'
37
+ require 'tree_rb/visitors/print_dir_tree_visitor'
38
+ require 'tree_rb/visitors/directory_to_hash_visitor'
39
39
 
40
- require 'treevisitor/util/dir_processor'
40
+ require 'tree_rb/util/dir_processor'
@@ -1,7 +1,18 @@
1
+ # -*- coding: utf-8 -*-
1
2
  #
2
3
  # cli
3
4
  #
4
5
 
5
6
  require 'optparse'
6
7
  require 'treevisitor'
7
- require "treevisitor/cli/cli_tree"
8
+
9
+ begin
10
+ require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
11
+ rescue LoadError
12
+ puts 'You must gem install win32console to use color on Windows'
13
+ end
14
+
15
+ #
16
+ # gem
17
+ #
18
+ require "tree_rb/cli/cli_tree"
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,7 @@ require "stringio"
7
7
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
8
  require 'treevisitor'
9
9
  require 'treevisitor_cli'
10
- include TreeVisitor
10
+ include TreeRb
11
11
 
12
12
  FIXTURES = File.expand_path( File.join( File.dirname(__FILE__), "fixtures" ) )
13
13
 
@@ -16,7 +16,7 @@ describe CliTree do
16
16
  args = %w{--version}
17
17
  CliTree.new.parse_args(args)
18
18
  end
19
- version = TreeVisitor::VERSION
19
+ version = TreeRb::VERSION
20
20
  out[:stdout].should match version
21
21
  end
22
22
 
File without changes
File without changes
data/tree.rb.gemspec CHANGED
@@ -1,17 +1,17 @@
1
1
  # -*- encoding: utf-8; mode: ruby -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "treevisitor/version"
3
+ require "tree_rb/version"
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "tree.rb"
7
- gem.version = TreeVisitor::VERSION
7
+ gem.version = TreeRb::VERSION
8
8
  gem.platform = Gem::Platform::RUBY
9
9
  gem.summary = "tree.rb is a 'clone' of tree unix command. The gem implements a library to mange tree structures."
10
10
 
11
11
  gem.description = <<-EOF
12
12
  (This gem was named as treevisitor)
13
13
  tree.rb is a 'clone' of tree unix command. The gem implements a library to mange tree structures.
14
- The gem contains also a library to build tree with a dsl (domain specific language), and
14
+ The gem contains also a library to build tree with a dsl (domain specific language), and
15
15
  an implementation of visitor design pattern.
16
16
  An example of DSL to build tree:
17
17
  <pre>
@@ -29,6 +29,7 @@ An example of DSL to build tree:
29
29
  gem.authors = ["Tokiro"]
30
30
  gem.email = "tokiro.oyama@gmail.com"
31
31
  gem.homepage = "http://github.com/tokiro/tree.rb"
32
+ gem.require_paths = ["lib"]
32
33
 
33
34
  #
34
35
  # dependencies
@@ -42,29 +43,32 @@ An example of DSL to build tree:
42
43
  gem.add_development_dependency(%q<bundler>, [">= 0"])
43
44
  gem.add_development_dependency(%q<rspec>, [">= 0"])
44
45
 
45
- #
46
- # bin
47
- #
48
- # s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
49
- gem.executables = %w{ tree.rb }
50
-
51
46
  #
52
47
  # files
53
48
  #
54
49
  # s.files = `git ls-files`.split("\n")
50
+ # gem.files = `git ls-files`.split($\)
55
51
  gem.files = %w{LICENSE.txt README.md Rakefile tree.rb.gemspec .gemtest}
56
52
  gem.files.concat Dir['lib/**/*.rb']
57
53
  gem.files.concat Dir['tasks/**/*.rake']
58
54
  gem.files.concat Dir['examples/**/*']
59
55
 
56
+ #
57
+ # bin
58
+ #
59
+ # s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
60
+ # gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
61
+ gem.executables = %w{ tree.rb }
62
+
63
+
60
64
  #
61
65
  # test files
62
66
  #
63
67
  # s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
68
+ # gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
64
69
  gem.test_files = Dir['spec/**/*.rb']
65
70
  gem.test_files.concat Dir['spec/fixtures/**/*']
66
71
  gem.test_files.concat Dir['spec/fixtures/**/.gitkeep']
67
72
  gem.test_files.concat Dir['spec/fixtures/**/.dir_with_dot/*']
68
73
 
69
- gem.require_paths = ["lib"]
70
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-14 00:00:00.000000000 Z
12
+ date: 2012-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  description: ! "(This gem was named as treevisitor)\ntree.rb is a 'clone' of tree
111
111
  unix command. The gem implements a library to mange tree structures.\nThe gem contains
112
- also a library to build tree with a dsl (domain specific language), and \nan implementation
112
+ also a library to build tree with a dsl (domain specific language), and\nan implementation
113
113
  of visitor design pattern.\nAn example of DSL to build tree:\n<pre>\n tree = TreeNode.create
114
114
  do\n node \"root\" do\n leaf \"l1\"\n node \"sub\" do\n leaf
115
115
  \"l3\"\n end\n node \"wo leaves\"\n end\n</pre>\n"
@@ -124,58 +124,58 @@ files:
124
124
  - Rakefile
125
125
  - tree.rb.gemspec
126
126
  - .gemtest
127
- - bin/tree.rb
128
- - lib/treevisitor.rb
129
- - lib/tree_visitor.rb
130
127
  - lib/treevisitor_cli.rb
131
- - lib/treevisitor/util/dir_processor.rb
132
- - lib/treevisitor/abs_node.rb
133
- - lib/treevisitor/version.rb
134
- - lib/treevisitor/directory_walker.rb
135
- - lib/treevisitor/tree_node.rb
136
- - lib/treevisitor/basic_tree_node_visitor.rb
137
- - lib/treevisitor/tree_node_visitor.rb
138
- - lib/treevisitor/cli/cli_tree.rb
139
- - lib/treevisitor/visitors/block_tree_node_visitor.rb
140
- - lib/treevisitor/visitors/flat_print_tree_node_visitors.rb
141
- - lib/treevisitor/visitors/clone_tree_node_visitor.rb
142
- - lib/treevisitor/visitors/build_dir_tree_visitor.rb
143
- - lib/treevisitor/visitors/directory_to_hash_visitor.rb
144
- - lib/treevisitor/visitors/depth_tree_node_visitor.rb
145
- - lib/treevisitor/visitors/callback_tree_node_visitor2.rb
146
- - lib/treevisitor/visitors/print_tree_node_visitor.rb
147
- - lib/treevisitor/visitors/print_dir_tree_visitor.rb
148
- - lib/treevisitor/leaf_node.rb
128
+ - lib/tree_visitor.rb
129
+ - lib/tree_rb/cli/cli_tree.rb
130
+ - lib/tree_rb/util/dir_processor.rb
131
+ - lib/tree_rb/directory_walker.rb
132
+ - lib/tree_rb/visitors/print_dir_tree_visitor.rb
133
+ - lib/tree_rb/visitors/build_dir_tree_visitor.rb
134
+ - lib/tree_rb/visitors/depth_tree_node_visitor.rb
135
+ - lib/tree_rb/visitors/print_tree_node_visitor.rb
136
+ - lib/tree_rb/visitors/callback_tree_node_visitor2.rb
137
+ - lib/tree_rb/visitors/directory_to_hash_visitor.rb
138
+ - lib/tree_rb/visitors/flat_print_tree_node_visitors.rb
139
+ - lib/tree_rb/visitors/block_tree_node_visitor.rb
140
+ - lib/tree_rb/visitors/clone_tree_node_visitor.rb
141
+ - lib/tree_rb/abs_node.rb
142
+ - lib/tree_rb/leaf_node.rb
143
+ - lib/tree_rb/tree_node_visitor.rb
144
+ - lib/tree_rb/tree_node.rb
145
+ - lib/tree_rb/basic_tree_node_visitor.rb
146
+ - lib/tree_rb/version.rb
147
+ - lib/treevisitor.rb
149
148
  - tasks/rspec.rake
150
149
  - tasks/yard.rake
150
+ - examples/directory_walker/print_files.rb
151
151
  - examples/directory_walker/directory_without_subdirectory.rb
152
152
  - examples/directory_walker/find_files.rb
153
- - examples/directory_walker/print_files.rb
154
- - examples/protovis/treevisitor.js
153
+ - examples/protovis/treevisitor.png
155
154
  - examples/protovis/protovis-r3.2.js
156
155
  - examples/protovis/index.html
157
- - examples/protovis/treevisitor.png
156
+ - examples/protovis/treevisitor.js
158
157
  - examples/protovis/directory_to_json_visitor.rb
159
158
  - spec/spec_helper.rb
160
- - spec/treevisitor/tree_node_paths_spec.rb
161
- - spec/treevisitor/util/dir_processor_spec.rb
162
- - spec/treevisitor/tree_node_spec.rb
163
- - spec/treevisitor/directory_walker_spec.rb
164
- - spec/treevisitor/tree_dsl_spec.rb
165
- - spec/treevisitor/tree_dsl_with_derived_class1_spec.rb
166
- - spec/treevisitor/cli/cli_tree_spec.rb
167
- - spec/treevisitor/visitors/depth_tree_node_visitor_spec.rb
168
- - spec/treevisitor/visitors/tree_node_visitors_spec.rb
169
- - spec/treevisitor/visitors/block_tree_node_visitor_spec.rb
170
- - spec/treevisitor/visitors/callback_tree_node_visitor2_spec.rb
171
- - spec/treevisitor/tree_dsl_with_derived_class_spec.rb
172
- - spec/treevisitor/tree_node_visitor_delegate_spec.rb
173
- - spec/treevisitor/tree_node_visitor_dsl_spec.rb
174
- - spec/fixtures/test_dir_1/dir.2/file.2.1
175
- - spec/fixtures/test_dir_1/dir.1/file.1.1
159
+ - spec/tree_rb/cli/cli_tree_spec.rb
160
+ - spec/tree_rb/util/dir_processor_spec.rb
161
+ - spec/tree_rb/visitors/depth_tree_node_visitor_spec.rb
162
+ - spec/tree_rb/visitors/callback_tree_node_visitor2_spec.rb
163
+ - spec/tree_rb/visitors/block_tree_node_visitor_spec.rb
164
+ - spec/tree_rb/visitors/tree_node_visitors_spec.rb
165
+ - spec/tree_rb/tree_dsl_with_derived_class_spec.rb
166
+ - spec/tree_rb/directory_walker_spec.rb
167
+ - spec/tree_rb/tree_dsl_spec.rb
168
+ - spec/tree_rb/tree_node_paths_spec.rb
169
+ - spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
170
+ - spec/tree_rb/tree_node_visitor_delegate_spec.rb
171
+ - spec/tree_rb/tree_node_spec.rb
172
+ - spec/tree_rb/tree_node_visitor_dsl_spec.rb
176
173
  - spec/fixtures/test_dir_1/dir.1/dir.1.2/file.1.2.1
174
+ - spec/fixtures/test_dir_1/dir.1/file.1.1
175
+ - spec/fixtures/test_dir_1/dir.2/file.2.1
177
176
  - spec/fixtures/test_dir_2/[Dsube]/sub/.gitkeep
178
177
  - spec/fixtures/test_dir_1/.dir_with_dot/dummy.txt
178
+ - bin/tree.rb
179
179
  homepage: http://github.com/tokiro/tree.rb
180
180
  licenses: []
181
181
  post_install_message:
@@ -188,18 +188,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
188
  - - ! '>='
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
- segments:
192
- - 0
193
- hash: -2920884827506678874
194
191
  required_rubygems_version: !ruby/object:Gem::Requirement
195
192
  none: false
196
193
  requirements:
197
194
  - - ! '>='
198
195
  - !ruby/object:Gem::Version
199
196
  version: '0'
200
- segments:
201
- - 0
202
- hash: -2920884827506678874
203
197
  requirements: []
204
198
  rubyforge_project:
205
199
  rubygems_version: 1.8.24
@@ -209,23 +203,23 @@ summary: tree.rb is a 'clone' of tree unix command. The gem implements a library
209
203
  mange tree structures.
210
204
  test_files:
211
205
  - spec/spec_helper.rb
212
- - spec/treevisitor/tree_node_paths_spec.rb
213
- - spec/treevisitor/util/dir_processor_spec.rb
214
- - spec/treevisitor/tree_node_spec.rb
215
- - spec/treevisitor/directory_walker_spec.rb
216
- - spec/treevisitor/tree_dsl_spec.rb
217
- - spec/treevisitor/tree_dsl_with_derived_class1_spec.rb
218
- - spec/treevisitor/cli/cli_tree_spec.rb
219
- - spec/treevisitor/visitors/depth_tree_node_visitor_spec.rb
220
- - spec/treevisitor/visitors/tree_node_visitors_spec.rb
221
- - spec/treevisitor/visitors/block_tree_node_visitor_spec.rb
222
- - spec/treevisitor/visitors/callback_tree_node_visitor2_spec.rb
223
- - spec/treevisitor/tree_dsl_with_derived_class_spec.rb
224
- - spec/treevisitor/tree_node_visitor_delegate_spec.rb
225
- - spec/treevisitor/tree_node_visitor_dsl_spec.rb
226
- - spec/fixtures/test_dir_1/dir.2/file.2.1
227
- - spec/fixtures/test_dir_1/dir.1/file.1.1
206
+ - spec/tree_rb/cli/cli_tree_spec.rb
207
+ - spec/tree_rb/util/dir_processor_spec.rb
208
+ - spec/tree_rb/visitors/depth_tree_node_visitor_spec.rb
209
+ - spec/tree_rb/visitors/callback_tree_node_visitor2_spec.rb
210
+ - spec/tree_rb/visitors/block_tree_node_visitor_spec.rb
211
+ - spec/tree_rb/visitors/tree_node_visitors_spec.rb
212
+ - spec/tree_rb/tree_dsl_with_derived_class_spec.rb
213
+ - spec/tree_rb/directory_walker_spec.rb
214
+ - spec/tree_rb/tree_dsl_spec.rb
215
+ - spec/tree_rb/tree_node_paths_spec.rb
216
+ - spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
217
+ - spec/tree_rb/tree_node_visitor_delegate_spec.rb
218
+ - spec/tree_rb/tree_node_spec.rb
219
+ - spec/tree_rb/tree_node_visitor_dsl_spec.rb
228
220
  - spec/fixtures/test_dir_1/dir.1/dir.1.2/file.1.2.1
221
+ - spec/fixtures/test_dir_1/dir.1/file.1.1
222
+ - spec/fixtures/test_dir_1/dir.2/file.2.1
229
223
  - spec/fixtures/test_dir_2/[Dsube]/sub/.gitkeep
230
224
  - spec/fixtures/test_dir_1/.dir_with_dot/dummy.txt
231
225
  has_rdoc:
@@ -1,4 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- module TreeVisitor
3
- VERSION="0.3.0"
4
- end