dircat 0.0.5 → 0.1.4

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 +1 -1
  2. data/README.rdoc +1 -1
  3. data/Rakefile +9 -0
  4. data/VERSION.yml +5 -0
  5. data/bin/dircat-build +6 -0
  6. data/bin/dircat-diff +6 -0
  7. data/bin/dircat-query +6 -0
  8. data/dircat.gemspec +88 -0
  9. data/examples/example.rb +10 -0
  10. data/lib/dircat/cat.rb +192 -0
  11. data/lib/dircat/cli/dircat_build.rb +92 -83
  12. data/lib/dircat/cli/dircat_diff.rb +85 -0
  13. data/lib/dircat/cli/dircat_query.rb +53 -43
  14. data/lib/dircat/entry.rb +60 -0
  15. data/lib/dircat/extension_md5.rb +24 -0
  16. data/lib/dircat/extension_numeric.rb +17 -0
  17. data/lib/dircat/report.rb +61 -0
  18. data/lib/dircat.rb +29 -2
  19. data/spec/dircat/cat_spec.rb +71 -0
  20. data/spec/dircat/cli/dircat_build_spec.rb +59 -0
  21. data/spec/dircat/cli/dircat_query_diff_spec.rb +26 -0
  22. data/spec/dircat/cli/dircat_query_spec.rb +35 -0
  23. data/spec/dircat/md5_spec.rb +12 -0
  24. data/spec/dircat/numeric_spec.rb +11 -0
  25. data/spec/spec_helper.rb +25 -0
  26. metadata +136 -40
  27. data/bin/dircat-build.rb +0 -8
  28. data/bin/dircat-cfr.rb +0 -8
  29. data/bin/dircat-cmp.rb +0 -8
  30. data/bin/dircat-query.rb +0 -8
  31. data/lib/dircat/cli/dircat_cfr.rb +0 -69
  32. data/lib/dircat/cli/dircat_cmp.rb +0 -65
  33. data/lib/dircat/dircat.rb +0 -263
  34. data/test/dircat/tc_dircat.rb +0 -83
  35. data/test/dircat/tc_dircat_build.rb +0 -43
  36. data/test/test_dircat.rb +0 -6
  37. /data/{test_data/dircat/data → spec/fixtures}/certified_output/dircat1.yaml +0 -0
  38. /data/{test_data/dircat/data → spec/fixtures}/certified_output/dircat2.yaml +0 -0
  39. /data/{test_data/dircat/data → spec/fixtures}/dir1/file1.txt +0 -0
  40. /data/{test_data/dircat/data → spec/fixtures}/dir1/subdir/file3.txt +0 -0
  41. /data/{test_data/dircat/data → spec/fixtures}/dir2/file1.txt +0 -0
  42. /data/{test_data/dircat/data → spec/fixtures}/dir2/file2.txt +0 -0
  43. /data/{test_data/dircat/data → spec/fixtures}/dir2/subdir/file3.txt +0 -0
  44. /data/{test_data/dircat/data → spec/fixtures}/dir3/file1.txt +0 -0
  45. /data/{test_data/dircat/data → spec/fixtures}/dir3/subdir/file1.txt +0 -0
  46. /data/{test_data/dircat/data → spec/fixtures}/tmp/dummy.txt +0 -0
@@ -1,83 +0,0 @@
1
- $DIRCAT_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", "..") )
2
- $:.unshift( File.join($DIRCAT_HOME, "lib" ) )
3
-
4
- require 'test/unit'
5
- require 'dircat/dircat.rb'
6
-
7
- # dir1 contiene 2 file
8
- # aggiunto un file a dir1
9
- # dir2 contiene 3 file (uno in piu' di dir2)
10
-
11
- # dir 3 contiene file duplicati
12
-
13
- #
14
- # data/
15
- # |-- dir1
16
- # | |-- file1.txt
17
- # | |-- file2.txt
18
- # | `-- subdir
19
- # | `-- file3.txt
20
- # `-- dir2
21
- # |-- file1.txt
22
- # `-- subdir
23
- # `-- file3.txt
24
-
25
-
26
- class TC_DirCat < Test::Unit::TestCase
27
-
28
- def setup
29
- @data_dir = File.join($DIRCAT_HOME, "test_data", "dircat", "data")
30
- @tmp_dir = File.join( @data_dir, "tmp" )
31
- end
32
-
33
- def teardown
34
- end
35
-
36
- def test_dircat1
37
- dircat1 = DirCat.loadfromdir( File.join(@data_dir, "dir1") )
38
- assert_equal(2, dircat1.size )
39
- assert_equal(4, dircat1.bytes )
40
- end
41
-
42
- def test_dircat2
43
- dircat2 = DirCat.loadfromdir( File.join(@data_dir, "dir2") )
44
- assert_equal(3, dircat2.size )
45
- assert_equal(6, dircat2.bytes )
46
- end
47
-
48
- def test_diff_dir1_dir2
49
- dircat1 = DirCat.loadfromdir( File.join(@data_dir, "dir1") )
50
- dircat2 = DirCat.loadfromdir( File.join(@data_dir, "dir2") )
51
- # dir1 contiene tutti i file di dir2
52
- cat_diff = dircat1 - dircat2
53
- assert_equal(0, cat_diff.size)
54
- end
55
-
56
- def test_diff_dir2_dir1
57
- dircat1 = DirCat.loadfromdir( File.join(@data_dir, "dir1") )
58
- dircat2 = DirCat.loadfromdir( File.join(@data_dir, "dir2") )
59
-
60
- # dir2 contiene un file in piu' di dir1
61
- cat_diff = dircat2 - dircat1
62
- assert_equal(1, cat_diff.size)
63
- end
64
-
65
- def test_dir1_ser
66
- dircat1 = DirCat.loadfromdir( File.join(@data_dir, "dir1") )
67
- not_existent_file = File.join(@tmp_dir, "not_existent", "dircat1.yaml")
68
- tmp_file = File.join(@tmp_dir, "dircat1.yaml")
69
-
70
- assert_raise DirCatException do
71
- dircat1.savetofile( not_existent_file )
72
- end
73
-
74
- dircat1.savetofile( tmp_file )
75
-
76
- dircat1_bis = DirCat.loadfromfile( tmp_file )
77
- assert_equal( 0, (dircat1 - dircat1_bis).size )
78
- assert_equal( 0, (dircat1_bis - dircat1).size )
79
-
80
- FileUtils.rm( tmp_file )
81
- end
82
-
83
- end
@@ -1,43 +0,0 @@
1
- $DIRCAT_HOME = File.expand_path( File.join( File.dirname( __FILE__), "..", "..") )
2
- $:.unshift( File.join($DIRCAT_HOME, "lib" ) )
3
-
4
- # stdlib
5
- require 'test/unit'
6
-
7
- # dircat
8
- require 'dircat/dircat.rb'
9
- require 'dircat/cli/dircat_build.rb'
10
-
11
- class TC_DirCatBuild < Test::Unit::TestCase
12
-
13
- def setup
14
- @testdata_dirname = File.join( $DIRCAT_HOME, "test_data", "dircat", "data")
15
- @dir1_dirname = File.join( @testdata_dirname, "dir1" )
16
- @dir2_dirname = File.join( @testdata_dirname, "dir2" )
17
- @certified_output_dirname = File.join( @testdata_dirname, "certified_output" )
18
- @tmp_output_dirname = File.join( @testdata_dirname, "tmp" )
19
- end
20
-
21
- def test_help
22
- args = "-h"
23
- DirCatBuild.new.parse_args( args.split )
24
- end
25
-
26
- def test_dir1
27
- expect_filename = File.join( @certified_output_dirname, "dircat1.yaml" )
28
- result_filename = File.join( @tmp_output_dirname, "dircat1.yaml")
29
- args = "-f -o #{result_filename} #{@dir1_dirname}"
30
- DirCatBuild.new.parse_args( args.split )
31
-
32
- cat_expect = DirCat.loadfromfile( expect_filename )
33
- cat_result = DirCat.loadfromfile( result_filename )
34
-
35
- assert_equal( 0, (cat_result - cat_result).size )
36
-
37
- assert_equal( 0, (cat_result - cat_expect).size )
38
- assert_equal( 0, (cat_expect - cat_result).size )
39
-
40
- FileUtils.rm(result_filename)
41
- end
42
-
43
- end
data/test/test_dircat.rb DELETED
@@ -1,6 +0,0 @@
1
- $DIRCAT_HOME = File.expand_path( File.join( File.dirname( __FILE__), ".." ) )
2
- $:.unshift( File.join($DIRCAT_HOME, "lib" ) )
3
- $:.unshift( File.join($DIRCAT_HOME, "test" ) )
4
-
5
- require 'dircat/tc_dircat.rb'
6
- require 'dircat/tc_dircat_build.rb'