dircat 0.1.10 → 0.1.11

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/dircat.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  # dependencies
21
21
  #
22
22
  gem.add_runtime_dependency(%q<treevisitor>, ["= 0.2.2"])
23
- gem.add_runtime_dependency(%q<optparse-command>, ["= 0.1.5"])
23
+ gem.add_runtime_dependency(%q<optparse-command>, ["= 0.1.6"])
24
24
  gem.add_development_dependency(%q<rake>, [">= 0"])
25
25
  gem.add_development_dependency(%q<yard>, [">= 0"])
26
26
  gem.add_development_dependency(%q<bundler>, [">= 0"])
@@ -54,4 +54,3 @@ Gem::Specification.new do |gem|
54
54
  # s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
55
55
 
56
56
  end
57
-
@@ -16,7 +16,7 @@ module DirCat
16
16
  DirCat::VERSION
17
17
  end
18
18
 
19
- def defaults
19
+ def defaults(options)
20
20
  OpenStruct.new(
21
21
  :verbose => true,
22
22
  :force => false
@@ -4,7 +4,9 @@ module DirCat
4
4
  #
5
5
  # Build a catalogue starting from a directory
6
6
  #
7
- class CommandBuild < OptParseCommand::CliCommand
7
+ class CommandBuild < OptParseCommand::Command
8
+
9
+ CliDirCat.register_command(self)
8
10
 
9
11
  def self.command
10
12
  "build"
@@ -94,4 +96,4 @@ module DirCat
94
96
  end
95
97
 
96
98
  end
97
- end
99
+ end
@@ -1,6 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module DirCat
3
- class CommandDiff < OptParseCommand::CliCommand
3
+ class CommandDiff < OptParseCommand::Command
4
+
5
+ CliDirCat.register_command(self)
4
6
 
5
7
  def self.command
6
8
  "diff"
@@ -83,4 +85,4 @@ and then print the difference with the format specified on output
83
85
  end
84
86
 
85
87
  end
86
- end
88
+ end
@@ -1,6 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module DirCat
3
- class CommandQuery < OptParseCommand::CliCommand
3
+ class CommandQuery < OptParseCommand::Command
4
+
5
+ CliDirCat.register_command(self)
4
6
 
5
7
  def self.command
6
8
  "query"
@@ -21,7 +23,7 @@ module DirCat
21
23
  return 0
22
24
  end
23
25
 
24
- cat_opts = {}
26
+ cat_opts = {}
25
27
  cat_filename = rest[0]
26
28
  if !File.exists?(cat_filename) or File.directory?(cat_filename)
27
29
  puts "first args must be a catalogue"
@@ -53,4 +55,4 @@ module DirCat
53
55
  end
54
56
 
55
57
  end
56
- end
58
+ end
@@ -1,11 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  module DirCat
2
- VERSION="0.1.10"
3
- # def self.version
4
- # filename = File.join(File.dirname(__FILE__), %w{.. VERSION.yml})
5
- # yaml = YAML.load_file(filename)
6
- # major = (yaml['major'] || yaml[:major]).to_i
7
- # minor = (yaml['minor'] || yaml[:minor]).to_i
8
- # patch = (yaml['patch'] || yaml[:patch]).to_i
9
- # "#{major}.#{minor}.#{patch}"
10
- # end
3
+ VERSION="0.1.11"
11
4
  end
data/lib/dircat.rb CHANGED
@@ -12,7 +12,7 @@ require 'pp'
12
12
  #
13
13
  # rubygems
14
14
  #
15
- gem "optparse-command", "0.1.5"
15
+ gem "optparse-command", "0.1.6"
16
16
  require 'optparse-command'
17
17
 
18
18
  gem "treevisitor", "0.2.2"
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.expand_path( File.join(File.dirname(__FILE__), "..", "spec_helper") )
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
4
4
 
5
5
  #
6
6
  # dir1 contains 2 files
@@ -13,61 +13,65 @@ describe Cat do
13
13
 
14
14
  before do
15
15
  @data_dir = TEST_DIR
16
- @tmp_dir = File.join( @data_dir, "tmp" )
17
16
  end
18
17
 
19
18
  it "should build catalog from dir1" do
20
- cat1 = Cat.from_dir( File.join(@data_dir, "dir1") )
19
+ cat1 = Cat.from_dir(File.join(@data_dir, "dir1"))
21
20
  cat1.size.should == 2
22
21
  cat1.bytes.size.should == 8
23
22
  end
24
23
 
25
24
  it "should load catalog from dir2" do
26
- cat2 = Cat.from_dir( File.join(@data_dir, "dir2") )
25
+ cat2 = Cat.from_dir(File.join(@data_dir, "dir2"))
27
26
  cat2.size.should == 3
28
27
  cat2.bytes.should == 6
29
28
  end
30
29
 
31
- it "(dir1 - dir2) the difference from dir1 and dir2 is empty" do
32
- cat1 = Cat.from_dir( File.join(@data_dir, "dir1") )
33
- cat2 = Cat.from_dir( File.join(@data_dir, "dir2") )
34
- # dir1 contiene tutti i file di dir2
30
+ it "(dir1 - dir2): the difference from dir1 and dir2 is empty" do
31
+ cat1 = Cat.from_dir(File.join(@data_dir, "dir1"))
32
+ cat2 = Cat.from_dir(File.join(@data_dir, "dir2"))
33
+ # dir1 contains all the files in dir2
35
34
  cat_diff = cat1 - cat2
36
35
  cat_diff.size.should == 0
37
36
  end
38
37
 
39
- it "(dir2 - dir1) the difference from dir2 and dir1 is a file" do
40
- cat1 = Cat.from_dir( File.join(@data_dir, "dir1") )
41
- cat2 = Cat.from_dir( File.join(@data_dir, "dir2") )
38
+ it "(dir2 - dir1): the difference from dir2 and dir1 is a file" do
39
+ cat1 = Cat.from_dir(File.join(@data_dir, "dir1"))
40
+ cat2 = Cat.from_dir(File.join(@data_dir, "dir2"))
42
41
 
43
- # dir2 contiene un file in piu' di dir1
42
+ # dir2 contains one file more than dir1
44
43
  cat_diff = cat2 - cat1
45
44
  cat_diff.size.should == 1
46
45
  end
47
46
 
48
- it "saving to an inexistents file shoud raise an exception" do
49
- cat1 = Cat.from_dir( File.join(@data_dir, "dir1") )
50
-
51
- not_existent_file = File.join(@tmp_dir, "not_existent", "dircat1.yaml")
52
- lambda {cat1.save_to( not_existent_file )}.should raise_exception(DirCatException)
53
- end
54
-
55
- it "saving to a file" do
56
- cat1 = Cat.from_dir( File.join(@data_dir, "dir1") )
57
- tmp_file = File.join(@tmp_dir, "dircat1.yaml")
58
- cat1.save_to( tmp_file )
59
-
60
- dircat1_bis = Cat.from_file( tmp_file )
61
- (cat1 - dircat1_bis).size.should == 0
62
- (dircat1_bis - cat1).size.should == 0
63
-
64
- FileUtils.rm( tmp_file )
65
- end
66
-
67
47
 
68
48
  it "should detect duplicates" do
69
- cat1 = Cat.from_dir( File.join(@data_dir, "dir3") )
49
+ cat1 = Cat.from_dir(File.join(@data_dir, "dir3"))
70
50
  cat1.duplicates.should have(1).files
71
51
  end
72
52
 
53
+ context "save to a file" do
54
+ before do
55
+ @tmp_file = File.join(Dir.tmpdir, "dircat1.yaml")
56
+ end
57
+
58
+ after do
59
+ FileUtils.rm(@tmp_file) if File.exist? @tmp_file
60
+ end
61
+
62
+ it "saving to a file" do
63
+ cat1 = Cat.from_dir(File.join(@data_dir, "dir1"))
64
+ cat1.save_to(@tmp_file)
65
+
66
+ dircat1_bis = Cat.from_file(@tmp_file)
67
+ (cat1 - dircat1_bis).size.should == 0
68
+ (dircat1_bis - cat1).size.should == 0
69
+ end
70
+
71
+ it "saving to an non-existent file should raise an exception" do
72
+ cat1 = Cat.from_dir(File.join(@data_dir, "dir1"))
73
+ not_existent_file = File.join(Dir.tmpdir, "not_existent", "dircat1.yaml")
74
+ lambda { cat1.save_to(not_existent_file) }.should raise_exception(DirCatException)
75
+ end
76
+ end
73
77
  end
@@ -4,10 +4,10 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_hel
4
4
  describe CommandBuild do
5
5
 
6
6
  before do
7
- @dir1_dirname = File.join(TEST_DIR, "dir1")
8
- @dir2_dirname = File.join(TEST_DIR, "dir2")
7
+ @dir1_dirname = File.join(TEST_DIR, "dir1")
8
+ @dir2_dirname = File.join(TEST_DIR, "dir2")
9
9
  @certified_output_dirname = File.join(TEST_DIR, "certified_output")
10
- @tmp_output_dirname = File.join(TEST_DIR, "tmp")
10
+ @tmp_output_dirname = Dir.tmpdir
11
11
  end
12
12
 
13
13
  it "should accept -h (-help) option" do
@@ -27,8 +27,8 @@ describe CommandBuild do
27
27
 
28
28
  capture_out { CliDirCat.run("build -f -o #{result_filename} #{@dir1_dirname}".split) }
29
29
 
30
- cat_expect = Cat.from_file(expect_filename)
31
- cat_result = Cat.from_file(result_filename)
30
+ cat_expect = Cat.from_file(expect_filename)
31
+ cat_result = Cat.from_file(result_filename)
32
32
 
33
33
  (cat_result - cat_result).size.should == 0
34
34
 
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
-
3
2
  require "stringio"
4
3
  require 'ostruct'
4
+ require 'tmpdir'
5
5
 
6
6
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  require 'dircat'
@@ -20,15 +20,3 @@ def capture_out
20
20
  end
21
21
  OpenStruct.new(:out => out.string, :err => err.string)
22
22
  end
23
-
24
- #def with_stdout_captured
25
- # old_stdout = $stdout
26
- # out = StringIO.new
27
- # $stdout = out
28
- # begin
29
- # yield
30
- # ensure
31
- # $stdout = old_stdout
32
- # end
33
- # out.string
34
- #end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dircat
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.10
5
+ version: 0.1.11
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tokiro
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-18 00:00:00 +01:00
13
+ date: 2011-02-23 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirements:
33
33
  - - "="
34
34
  - !ruby/object:Gem::Version
35
- version: 0.1.5
35
+ version: 0.1.6
36
36
  type: :runtime
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
@@ -106,7 +106,6 @@ files:
106
106
  - lib/dircat/version.rb
107
107
  - lib/dircat.rb
108
108
  - examples/example.rb
109
- - tasks/jeweler.rake
110
109
  - tasks/rspec.rake
111
110
  - tasks/yard.rake
112
111
  - spec/dircat/cat_spec.rb
@@ -126,7 +125,6 @@ files:
126
125
  - spec/fixtures/dir2/subdir/file3.txt
127
126
  - spec/fixtures/dir3/file1.txt
128
127
  - spec/fixtures/dir3/subdir/file1.txt
129
- - spec/fixtures/tmp/dummy.txt
130
128
  has_rdoc: true
131
129
  homepage: http://github.com/tokiro/dircat
132
130
  licenses: []
@@ -173,4 +171,3 @@ test_files:
173
171
  - spec/fixtures/dir2/subdir/file3.txt
174
172
  - spec/fixtures/dir3/file1.txt
175
173
  - spec/fixtures/dir3/subdir/file1.txt
176
- - spec/fixtures/tmp/dummy.txt
@@ -1 +0,0 @@
1
- This file exists so git create this directory
data/tasks/jeweler.rake DELETED
@@ -1,44 +0,0 @@
1
- ## -*- coding: utf-8 -*-
2
- #begin
3
- # require 'jeweler'
4
- # Jeweler::Tasks.new do |gem|
5
- #
6
- # # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
7
- # gem.name = "dircat"
8
- # gem.summary = "command line utilites to manage catalogs of directory"
9
- # gem.description = %Q{
10
- # command line utilites to manage catalogs of directory
11
- # }
12
- # gem.authors = ["Tokiro"]
13
- # gem.email = "tokiro.oyama@gmail.com"
14
- # gem.homepage = "http://github.com/tokiro/dircat"
15
- #
16
- # #
17
- # # dependencies, automatically loaded from Gemfile
18
- # #
19
- #
20
- # #
21
- # # bin
22
- # #
23
- # gem.executables = %w{ dircat }
24
- #
25
- # #
26
- # # files
27
- # #
28
- # gem.files = %w{LICENSE.txt README.md Rakefile dircat.gemspec .gemtest}
29
- # gem.files.concat Dir['lib/**/*.rb']
30
- # gem.files.concat Dir['examples/*.rb']
31
- # gem.files.concat Dir['tasks/*.rake']
32
- #
33
- # #
34
- # # test files
35
- # #
36
- # gem.test_files = Dir['spec/**/*.rb']
37
- # gem.test_files.concat Dir['spec/fixtures/**/*']
38
- #
39
- # end
40
- #
41
- # Jeweler::GemcutterTasks.new
42
- #rescue LoadError
43
- # puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
44
- #end