file_indexing 0.0.9 → 1.0.0

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.
@@ -7,171 +7,170 @@ require 'content_data'
7
7
  require 'file_indexing/indexer_patterns'
8
8
  require 'log'
9
9
 
10
- module BBFS
11
- module FileIndexing
12
10
 
11
+ module FileIndexing
13
12
  ####################
14
13
  # Index Agent
15
14
  ####################
16
15
 
17
- class IndexAgent
18
- attr_reader :indexed_content, :failed_files
16
+ class IndexAgent
17
+ attr_reader :indexed_content, :failed_files
19
18
 
20
- # Why are those lines needed?
21
- LOCALTZ = Time.now.zone
22
- ENV['TZ'] = 'UTC'
19
+ # Why are those lines needed?
20
+ LOCALTZ = Time.now.zone
21
+ ENV['TZ'] = 'UTC'
23
22
 
24
- def initialize
25
- @indexed_content = ContentData::ContentData.new
26
- @failed_files = Set.new
27
- end
28
-
29
- # Calculate file checksum (SHA1)
30
- def self.get_checksum(filename)
31
- digest = Digest::SHA1.new
32
- begin
33
- File.open(filename, 'rb') { |f|
34
- while buffer = f.read(65536) do
35
- digest << buffer
36
- end
37
- }
38
- Log.debug1("#{filename} sha1 #{digest.hexdigest.downcase}")
39
- digest.hexdigest.downcase
40
- rescue Errno::EACCES, Errno::ETXTBSY => exp
41
- Log.warning("#{exp.message}")
42
- false
43
- end
44
- end
23
+ def initialize
24
+ @indexed_content = ContentData::ContentData.new
25
+ @failed_files = Set.new
26
+ end
45
27
 
46
- def IndexAgent.get_content_checksum(content)
47
- # Calculate checksum.
48
- digest = Digest::SHA1.new
49
- digest << content
28
+ # Calculate file checksum (SHA1)
29
+ def self.get_checksum(filename)
30
+ digest = Digest::SHA1.new
31
+ begin
32
+ File.open(filename, 'rb') { |f|
33
+ while buffer = f.read(65536) do
34
+ digest << buffer
35
+ end
36
+ }
37
+ Log.debug1("#{filename} sha1 #{digest.hexdigest.downcase}")
50
38
  digest.hexdigest.downcase
39
+ rescue Errno::EACCES, Errno::ETXTBSY => exp
40
+ Log.warning("#{exp.message}")
41
+ false
51
42
  end
43
+ end
52
44
 
53
- # get all files
54
- # satisfying the pattern
55
- def collect(pattern)
56
- Dir.glob(pattern.to_s)
57
- end
45
+ def IndexAgent.get_content_checksum(content)
46
+ # Calculate checksum.
47
+ digest = Digest::SHA1.new
48
+ digest << content
49
+ digest.hexdigest.downcase
50
+ end
58
51
 
59
- # TODO(kolman): Replace this with File.lstat(file).mtime when new version of Ruby comes out.
60
- # http://bugs.ruby-lang.org/issues/6385
61
- def IndexAgent.get_correct_mtime(file)
62
- begin
52
+ # get all files
53
+ # satisfying the pattern
54
+ def collect(pattern)
55
+ Dir.glob(pattern.to_s)
56
+ end
57
+
58
+ # TODO(kolman): Replace this with File.lstat(file).mtime when new version of Ruby comes out.
59
+ # http://bugs.ruby-lang.org/issues/6385
60
+ def IndexAgent.get_correct_mtime(file)
61
+ begin
63
62
  File.open(file, 'r') { |f| f.mtime }
64
- rescue Errno::EACCES => e
65
- Log.warning("Could not open file #{file} to get mtime. #{e}")
66
- return 0
67
- end
63
+ rescue Errno::EACCES => e
64
+ Log.warning("Could not open file #{file} to get mtime. #{e}")
65
+ return 0
68
66
  end
67
+ end
69
68
 
70
- # index device according to the pattern
71
- # store the result
72
- # does not adds automatically otherDB to stored result
73
- # TODO device support
74
- def index(patterns, otherDB = nil)
75
- abort "#{self.class}: DB not empty. Current implementation permits only one running of index" \
69
+ # index device according to the pattern
70
+ # store the result
71
+ # does not adds automatically otherDB to stored result
72
+ # TODO device support
73
+ def index(patterns, otherDB = nil)
74
+ abort "#{self.class}: DB not empty. Current implementation permits only one running of index" \
76
75
  unless @indexed_content.contents.empty?
77
76
 
78
- server_name = `hostname`.strip
79
- permit_patterns = Array.new
80
- forbid_patterns = Array.new
81
- otherDB_table = Hash.new # contains instances from given DB while full path name is a key and instance is a value
82
- otherDB_contents = Hash.new # given DB contents
83
-
84
- # if there is a given DB then populate table with files
85
- # that was already indexed on this server/device
86
- if (otherDB != nil)
87
- otherDB_contents.update(otherDB.contents)
88
- otherDB.instances.each_value do |i|
89
- next unless i.server_name == server_name #and i.device == @device
90
- otherDB_table[i.full_path] = i
91
- end
77
+ server_name = `hostname`.strip
78
+ permit_patterns = Array.new
79
+ forbid_patterns = Array.new
80
+ otherDB_table = Hash.new # contains instances from given DB while full path name is a key and instance is a value
81
+ otherDB_contents = Hash.new # given DB contents
82
+
83
+ # if there is a given DB then populate table with files
84
+ # that was already indexed on this server/device
85
+ if (otherDB != nil)
86
+ otherDB_contents.update(otherDB.contents)
87
+ otherDB.instances.each_value do |i|
88
+ next unless i.server_name == server_name #and i.device == @device
89
+ otherDB_table[i.full_path] = i
92
90
  end
91
+ end
93
92
 
94
- permit_patterns = patterns.positive_patterns
95
- forbid_patterns = patterns.negative_patterns
93
+ permit_patterns = patterns.positive_patterns
94
+ forbid_patterns = patterns.negative_patterns
96
95
 
97
- # add files found by positive patterns
98
- files = Array.new
99
- permit_patterns.each_index do |i|
100
- files = files | (collect(permit_patterns[i]));
101
- end
96
+ # add files found by positive patterns
97
+ files = Array.new
98
+ permit_patterns.each_index do |i|
99
+ files = files | (collect(permit_patterns[i]));
100
+ end
102
101
 
103
- Log.info "Files: #{files}."
102
+ Log.info "Files: #{files}."
104
103
 
105
- # expand to absolute pathes
106
- files.map! {|f| File.expand_path(f)}
104
+ # expand to absolute pathes
105
+ files.map! {|f| File.expand_path(f)}
107
106
 
108
- # remove files found by negative patterns
109
- forbid_patterns.each_index do |i|
110
- forbid_files = Array.new(collect(forbid_patterns[i]));
111
- forbid_files.each do |f|
112
- files.delete(File.expand_path(f))
113
- end
107
+ # remove files found by negative patterns
108
+ forbid_patterns.each_index do |i|
109
+ forbid_files = Array.new(collect(forbid_patterns[i]));
110
+ forbid_files.each do |f|
111
+ files.delete(File.expand_path(f))
114
112
  end
113
+ end
115
114
 
116
- # create and add contents and instances
117
- files.each do |file|
118
- file_stats = File.lstat(file)
119
- file_mtime = IndexAgent.get_correct_mtime(file)
120
-
121
- # index only files
122
- next if file_stats.directory?
115
+ # create and add contents and instances
116
+ files.each do |file|
117
+ file_stats = File.lstat(file)
118
+ file_mtime = IndexAgent.get_correct_mtime(file)
123
119
 
124
- # keep only files with names in UTF-8
125
- unless file.force_encoding("UTF-8").valid_encoding?
126
- Log.warning("Non UTF-8 file name \"#{file}\", skipping.")
127
- next
128
- end
120
+ # index only files
121
+ next if file_stats.directory?
129
122
 
130
- # add files present in the given DB to the DB and remove these files
131
- # from further processing (save checksum calculation)
132
- if otherDB_table.has_key?(file)
133
- instance = otherDB_table[file]
134
- if instance.size == file_stats.size and instance.modification_time == file_mtime
135
- @indexed_content.add_content(otherDB_contents[instance.checksum])
136
- @indexed_content.add_instance(instance)
137
- next
138
- else
139
- Log.warning("File (#{file}) size or modification file is different.")
140
- end
141
- end
123
+ # keep only files with names in UTF-8
124
+ unless file.force_encoding("UTF-8").valid_encoding?
125
+ Log.warning("Non UTF-8 file name \"#{file}\", skipping.")
126
+ next
127
+ end
142
128
 
143
- # calculate a checksum
144
- unless (checksum = self.class.get_checksum(file))
145
- Log.warning("Cheksum failure: " + file)
146
- @failed_files.add(file)
129
+ # add files present in the given DB to the DB and remove these files
130
+ # from further processing (save checksum calculation)
131
+ if otherDB_table.has_key?(file)
132
+ instance = otherDB_table[file]
133
+ if instance.size == file_stats.size and instance.modification_time == file_mtime
134
+ @indexed_content.add_content(otherDB_contents[instance.checksum])
135
+ @indexed_content.add_instance(instance)
147
136
  next
137
+ else
138
+ Log.warning("File (#{file}) size or modification file is different.")
148
139
  end
140
+ end
149
141
 
150
- if !@indexed_content.content_exists(checksum)
151
- @indexed_content.add_content ContentData::Content.new(checksum, file_stats.size,
152
- Time.now.utc)
153
- end
142
+ # calculate a checksum
143
+ unless (checksum = self.class.get_checksum(file))
144
+ Log.warning("Cheksum failure: " + file)
145
+ @failed_files.add(file)
146
+ next
147
+ end
154
148
 
155
- instance = ContentData::ContentInstance.new(
156
- checksum, file_stats.size, server_name, file_stats.dev.to_s,
157
- File.expand_path(file), file_mtime)
158
- @indexed_content.add_instance(instance)
149
+ if !@indexed_content.content_exists(checksum)
150
+ @indexed_content.add_content ContentData::Content.new(checksum, file_stats.size,
151
+ Time.now.utc)
159
152
  end
160
- end
161
153
 
162
- def IndexAgent.create_shallow_instance(filename)
163
- return nil unless File.exists?(filename)
164
- file_stats = File.lstat(filename)
165
- file_mtime = IndexAgent.get_correct_mtime(filename)
166
- ContentData::ContentInstance.new(nil, file_stats.size, nil, file_stats.dev.to_s,
167
- File.expand_path(filename), file_mtime)
154
+ instance = ContentData::ContentInstance.new(
155
+ checksum, file_stats.size, server_name, file_stats.dev.to_s,
156
+ File.expand_path(file), file_mtime)
157
+ @indexed_content.add_instance(instance)
168
158
  end
159
+ end
169
160
 
170
- def IndexAgent.global_path(filename)
171
- server_name = `hostname`.strip
172
- return ContentData::ContentInstance.instance_global_path(server_name, filename)
173
- end
161
+ def IndexAgent.create_shallow_instance(filename)
162
+ return nil unless File.exists?(filename)
163
+ file_stats = File.lstat(filename)
164
+ file_mtime = IndexAgent.get_correct_mtime(filename)
165
+ ContentData::ContentInstance.new(nil, file_stats.size, nil, file_stats.dev.to_s,
166
+ File.expand_path(filename), file_mtime)
174
167
  end
175
168
 
169
+ def IndexAgent.global_path(filename)
170
+ server_name = `hostname`.strip
171
+ return ContentData::ContentInstance.instance_global_path(server_name, filename)
172
+ end
176
173
  end
174
+
177
175
  end
176
+
@@ -1,73 +1,72 @@
1
1
  require 'log'
2
2
  require 'params'
3
3
 
4
- module BBFS
5
- module FileIndexing
4
+ module FileIndexing
6
5
 
7
- class IndexerPatterns
8
- attr_reader :positive_patterns, :negative_patterns
6
+ class IndexerPatterns
7
+ attr_reader :positive_patterns, :negative_patterns
9
8
 
10
- # @param indexer_patterns_str [String]
11
- def initialize (indexer_patterns = nil)
12
- Log.info "Initialize index patterns #{indexer_patterns}."
13
- @positive_patterns = Array.new
14
- @negative_patterns = Array.new
15
- # TODO add a test (including empty collections)
16
- if indexer_patterns
17
- indexer_patterns.positive_patterns.each do |pattern|
18
- add_pattern(pattern)
19
- end
20
- indexer_patterns.negative_patterns.each do |pattern|
21
- add_pattern(pattern, false)
22
- end
9
+ # @param indexer_patterns_str [String]
10
+ def initialize (indexer_patterns = nil)
11
+ Log.info "Initialize index patterns #{indexer_patterns}."
12
+ @positive_patterns = Array.new
13
+ @negative_patterns = Array.new
14
+ # TODO add a test (including empty collections)
15
+ if indexer_patterns
16
+ indexer_patterns.positive_patterns.each do |pattern|
17
+ add_pattern(pattern)
18
+ end
19
+ indexer_patterns.negative_patterns.each do |pattern|
20
+ add_pattern(pattern, false)
23
21
  end
24
22
  end
23
+ end
25
24
 
26
- def serialize
27
- # TODO add a test (including empty collections)
28
- indexer_patterns = IndexerPatternsMessage.new
29
- positive_patterns.each do |pattern|
30
- indexer_patterns.positive_patterns << pattern
31
- end
32
- negative_patterns.each do |pattern|
33
- indexer_patterns.negative_patterns << pattern
34
- end
35
- indexer_patterns
25
+ def serialize
26
+ # TODO add a test (including empty collections)
27
+ indexer_patterns = IndexerPatternsMessage.new
28
+ positive_patterns.each do |pattern|
29
+ indexer_patterns.positive_patterns << pattern
36
30
  end
31
+ negative_patterns.each do |pattern|
32
+ indexer_patterns.negative_patterns << pattern
33
+ end
34
+ indexer_patterns
35
+ end
37
36
 
38
- # @param pattern [String]
39
- # @param is_positive [true]
40
- # @param is_positive [false]
41
- def add_pattern(pattern, is_positive = true)
42
- pattern.gsub!(/\\/,'/')
43
- if (is_positive)
44
- @positive_patterns << pattern
45
- else
46
- @negative_patterns << pattern
47
- end
37
+ # @param pattern [String]
38
+ # @param is_positive [true]
39
+ # @param is_positive [false]
40
+ def add_pattern(pattern, is_positive = true)
41
+ pattern.gsub!(/\\/,'/')
42
+ if (is_positive)
43
+ @positive_patterns << pattern
44
+ else
45
+ @negative_patterns << pattern
48
46
  end
47
+ end
49
48
 
50
- def parse_from_file(file)
51
- input_patterns = IO.readlines(file)
52
- begin
53
- Log.info "Error loading patterns=%s" % file
54
- raise IOError("Error loading patterns=%s" % file)
55
- end unless not input_patterns.nil?
49
+ def parse_from_file(file)
50
+ input_patterns = IO.readlines(file)
51
+ begin
52
+ Log.info "Error loading patterns=%s" % file
53
+ raise IOError("Error loading patterns=%s" % file)
54
+ end unless not input_patterns.nil?
56
55
 
57
- input_patterns.each do |pattern|
58
- if (m = /^\s*([+-]):(.*)/.match(pattern))
59
- add_pattern(m[2], m[1].eql?('+') ? true : false)
60
- elsif (not /^\s*[\/\/|#]/.match(pattern)) # not a comment
61
- Log.info "pattern in incorrect format: #{pattern}"
62
- raise RuntimeError("pattern in incorrect format: #{pattern}")
63
- end
56
+ input_patterns.each do |pattern|
57
+ if (m = /^\s*([+-]):(.*)/.match(pattern))
58
+ add_pattern(m[2], m[1].eql?('+') ? true : false)
59
+ elsif (not /^\s*[\/\/|#]/.match(pattern)) # not a comment
60
+ Log.info "pattern in incorrect format: #{pattern}"
61
+ raise RuntimeError("pattern in incorrect format: #{pattern}")
64
62
  end
65
63
  end
66
-
67
- def size
68
- return @positive_patterns.size
69
- end
70
64
  end
71
65
 
66
+ def size
67
+ return @positive_patterns.size
68
+ end
72
69
  end
70
+
73
71
  end
72
+
@@ -1,5 +1,3 @@
1
- module BBFS
2
- module FileIndexing
3
- VERSION = "0.0.9"
4
- end
1
+ module FileIndexing
2
+ VERSION = "1.0.0"
5
3
  end
data/lib/file_indexing.rb CHANGED
@@ -5,7 +5,5 @@ require 'file_indexing/indexer_patterns'
5
5
 
6
6
  # Data structure for an abstract layer over files.
7
7
  # Each binary sequence is a content, each file is content instance.
8
- module BBFS
9
- module FileIndexing
10
- end
8
+ module FileIndexing
11
9
  end
@@ -3,52 +3,51 @@ require 'tempfile'
3
3
 
4
4
  require_relative '../../lib/file_indexing/index_agent.rb'
5
5
 
6
- module BBFS
7
- module FileCopy
8
- module Spec
9
-
10
- describe 'checksum' do
11
- it 'should generate correct checksum' do
12
- # The test does not checks the problem the problem is when reading from File
13
- # class which handles read(num) different from read()
14
- content = ''
15
- 100000.times { content << 'abagadavazahatikalamansapazkareshet' }
16
- content_checksum = FileIndexing::IndexAgent.get_content_checksum(content)
17
-
18
- stream = StringIO.new(content)
19
- File.stub(:open).and_yield(stream)
20
- file_checksum = FileIndexing::IndexAgent.get_checksum('kuku')
21
-
22
- content_checksum.should == file_checksum
23
- content_checksum.should == '381e99eb0e2dfcaf45c9a367a04a4197ef3039a6'
24
- end
25
-
26
- it 'should generate correct checksum for temp file' do
27
- # A hack to get tmp file name
28
- tmp_file = Tempfile.new('foo')
29
- path = tmp_file .path
30
- tmp_file .close()
6
+ module FileCopy
7
+ module Spec
8
+
9
+ describe 'checksum' do
10
+ it 'should generate correct checksum' do
11
+ # The test does not checks the problem the problem is when reading from File
12
+ # class which handles read(num) different from read()
13
+ content = ''
14
+ 100000.times { content << 'abagadavazahatikalamansapazkareshet' }
15
+ content_checksum = FileIndexing::IndexAgent.get_content_checksum(content)
16
+
17
+ stream = StringIO.new(content)
18
+ File.stub(:open).and_yield(stream)
19
+ file_checksum = FileIndexing::IndexAgent.get_checksum('kuku')
20
+
21
+ content_checksum.should == file_checksum
22
+ content_checksum.should == '381e99eb0e2dfcaf45c9a367a04a4197ef3039a6'
23
+ end
31
24
 
32
- # Open file in binary mode.
33
- file = File.open(path, 'wb')
34
- 100000.times { file.write('abagadavazahatikalamansapazkareshet') }
35
- file.close()
25
+ it 'should generate correct checksum for temp file' do
26
+ # A hack to get tmp file name
27
+ tmp_file = Tempfile.new('foo')
28
+ path = tmp_file .path
29
+ tmp_file .close()
36
30
 
37
- file_checksum = FileIndexing::IndexAgent.get_checksum(path)
38
- file_checksum.should == '381e99eb0e2dfcaf45c9a367a04a4197ef3039a6'
31
+ # Open file in binary mode.
32
+ file = File.open(path, 'wb')
33
+ 100000.times { file.write('abagadavazahatikalamansapazkareshet') }
34
+ file.close()
39
35
 
40
- File.open(path, 'rb') { |f|
41
- content = f.read()
42
- content_checksum = FileIndexing::IndexAgent.get_content_checksum(content)
43
- content_checksum.should == '381e99eb0e2dfcaf45c9a367a04a4197ef3039a6'
44
- file_checksum.should == content_checksum
45
- }
36
+ file_checksum = FileIndexing::IndexAgent.get_checksum(path)
37
+ file_checksum.should == '381e99eb0e2dfcaf45c9a367a04a4197ef3039a6'
46
38
 
47
- # Delete tmp file.
48
- tmp_file.unlink
49
- end
39
+ File.open(path, 'rb') { |f|
40
+ content = f.read()
41
+ content_checksum = FileIndexing::IndexAgent.get_content_checksum(content)
42
+ content_checksum.should == '381e99eb0e2dfcaf45c9a367a04a4197ef3039a6'
43
+ file_checksum.should == content_checksum
44
+ }
50
45
 
46
+ # Delete tmp file.
47
+ tmp_file.unlink
51
48
  end
49
+
52
50
  end
53
51
  end
54
52
  end
53
+
@@ -4,49 +4,47 @@ require_relative '../../lib/file_indexing/index_agent'
4
4
  require 'log'
5
5
  require 'params'
6
6
 
7
- module BBFS
8
- module FileIndexing
9
- module Test
10
- class IndexAgentTest < ::Test::Unit::TestCase
11
- def test_index
12
- indexer = IndexAgent.new
13
- patterns = IndexerPatterns.new
14
- patterns.add_pattern File.join(File.dirname(__FILE__), 'index_agent_test\**\*')
15
- patterns.add_pattern File.join(File.dirname(__FILE__), 'index_agent_test\**\*.h'), false
7
+ module FileIndexing
8
+ module Test
9
+ class IndexAgentTest < ::Test::Unit::TestCase
10
+ def test_index
11
+ indexer = IndexAgent.new
12
+ patterns = IndexerPatterns.new
13
+ patterns.add_pattern File.join(File.dirname(__FILE__), 'index_agent_test\**\*')
14
+ patterns.add_pattern File.join(File.dirname(__FILE__), 'index_agent_test\**\*.h'), false
16
15
 
17
- indexer.index(patterns)
18
- # ./index_agent_test/lib/libexslt.lib
19
- Log.info "Contents: #{indexer.indexed_content.contents}."
20
- assert(indexer.indexed_content.content_exists('c6d9d837659e38d906a4bbdcc6703bc37e9ac7e8'))
21
- # .index_agent_test/include/libexslt/exsltexports.h
22
- assert_equal(false, indexer.indexed_content.content_exists('5c87a31b0106b3c4bb1768e43f5b8c41139882c2'))
23
- # ./index_agent_test/bin/xsltproc.exe
24
- assert(indexer.indexed_content.content_exists('d0d57ff4834a517a52004f59ee5cdb63f2f0427b'))
16
+ indexer.index(patterns)
17
+ # ./index_agent_test/lib/libexslt.lib
18
+ Log.info "Contents: #{indexer.indexed_content.contents}."
19
+ assert(indexer.indexed_content.content_exists('c6d9d837659e38d906a4bbdcc6703bc37e9ac7e8'))
20
+ # .index_agent_test/include/libexslt/exsltexports.h
21
+ assert_equal(false, indexer.indexed_content.content_exists('5c87a31b0106b3c4bb1768e43f5b8c41139882c2'))
22
+ # ./index_agent_test/bin/xsltproc.exe
23
+ assert(indexer.indexed_content.content_exists('d0d57ff4834a517a52004f59ee5cdb63f2f0427b'))
25
24
 
26
- patterns.add_pattern('./resources/index_agent_test/lib/**/*', false)
27
- indexer = IndexAgent.new
25
+ patterns.add_pattern('./resources/index_agent_test/lib/**/*', false)
26
+ indexer = IndexAgent.new
28
27
 
29
- indexer.index(patterns)
30
- # ./index_agent_test/lib/libexslt.lib
31
- assert_equal(false, indexer.indexed_content.content_exists('9e409338c0d8e0bbdbf5316cb569a0afcdb321db'))
28
+ indexer.index(patterns)
29
+ # ./index_agent_test/lib/libexslt.lib
30
+ assert_equal(false, indexer.indexed_content.content_exists('9e409338c0d8e0bbdbf5316cb569a0afcdb321db'))
32
31
 
33
- # checking that existing db as a prameter for indexer is really working
34
- # i.e. no checksum calculation performs for files that were indexed but weren't changed
35
- new_indexer = IndexAgent.new
36
- event_regex = /^(call)/
37
- id_regex = /get_checksum/
38
- get_checksum_num = 0
39
- set_trace_func Proc.new { |event, file, line, id, binding, classname|
40
- if event =~ event_regex and id.to_s =~ id_regex
41
- Log.info sprintf "[%8s] %30s %30s (%s:%-2d)\n", event, id, classname, file, line
42
- get_checksum_num +=1
43
- end
44
- }
45
- new_indexer.index(patterns, indexer.indexed_content)
46
- set_trace_func nil
47
- assert_equal(new_indexer.indexed_content, indexer.indexed_content)
48
- assert_equal(0, get_checksum_num)
49
- end
32
+ # checking that existing db as a prameter for indexer is really working
33
+ # i.e. no checksum calculation performs for files that were indexed but weren't changed
34
+ new_indexer = IndexAgent.new
35
+ event_regex = /^(call)/
36
+ id_regex = /get_checksum/
37
+ get_checksum_num = 0
38
+ set_trace_func Proc.new { |event, file, line, id, binding, classname|
39
+ if event =~ event_regex and id.to_s =~ id_regex
40
+ Log.info sprintf "[%8s] %30s %30s (%s:%-2d)\n", event, id, classname, file, line
41
+ get_checksum_num +=1
42
+ end
43
+ }
44
+ new_indexer.index(patterns, indexer.indexed_content)
45
+ set_trace_func nil
46
+ assert_equal(new_indexer.indexed_content, indexer.indexed_content)
47
+ assert_equal(0, get_checksum_num)
50
48
  end
51
49
  end
52
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_indexing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 1.0.0
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-09-13 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: content_data
@@ -60,7 +60,7 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  description: Indexes files, treats files with same binary sequence as one content.
63
- email: kolmanv@gmail.com
63
+ email: bbfsdev@gmail.com
64
64
  executables: []
65
65
  extensions: []
66
66
  extra_rdoc_files: []
@@ -70,48 +70,48 @@ files:
70
70
  - lib/file_indexing/index_agent.rb
71
71
  - lib/file_indexing/version.rb
72
72
  - spec/file_indexing/index_agent_spec.rb
73
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libexslt.dll
73
+ - test/file_indexing/index_agent_test.rb
74
74
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libxslt.dll
75
75
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/xsltproc.exe
76
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libexslt.dll
77
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/readme.txt
78
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt_a.lib
79
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt.lib
80
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt_a.lib
81
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt.lib
82
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/libexslt.h
83
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltexports.h
76
84
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exslt.h
77
85
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltconfig.h
78
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltexports.h
79
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/libexslt.h
86
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltwin32config.h
87
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltexports.h
88
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/win32config.h
89
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltconfig.h
90
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xslt.h
91
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/functions.h
80
92
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/attributes.h
81
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/documents.h
82
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extensions.h
93
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/security.h
94
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/templates.h
95
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltutils.h
96
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/variables.h
83
97
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extra.h
84
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/functions.h
98
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/pattern.h
99
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/documents.h
100
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/trio.h
101
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/preproc.h
102
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltInternals.h
85
103
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/imports.h
86
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/keys.h
104
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extensions.h
87
105
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/libxslt.h
106
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltlocale.h
88
107
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/namespaces.h
89
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/numbersInternals.h
90
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/pattern.h
91
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/preproc.h
92
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/security.h
93
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/templates.h
108
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/keys.h
94
109
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/transform.h
95
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/trio.h
110
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/numbersInternals.h
96
111
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/triodef.h
97
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/variables.h
98
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/win32config.h
99
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xslt.h
100
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltconfig.h
101
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltexports.h
102
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltInternals.h
103
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltlocale.h
104
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltutils.h
105
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltwin32config.h
106
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt.lib
107
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt_a.lib
108
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt.lib
109
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt_a.lib
110
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/readme.txt
111
112
  - test/file_indexing/index_agent_test/New.txt
112
113
  - test/file_indexing/index_agent_test/patterns.input
113
- - test/file_indexing/index_agent_test.rb
114
- homepage: http://github.com/kolmanv/bbfs
114
+ homepage: http://github.com/bbfsdev/bbfs
115
115
  licenses: []
116
116
  post_install_message:
117
117
  rdoc_options: []
@@ -137,44 +137,44 @@ specification_version: 3
137
137
  summary: Indexes files.
138
138
  test_files:
139
139
  - spec/file_indexing/index_agent_spec.rb
140
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libexslt.dll
140
+ - test/file_indexing/index_agent_test.rb
141
141
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libxslt.dll
142
142
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/xsltproc.exe
143
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libexslt.dll
144
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/readme.txt
145
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt_a.lib
146
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt.lib
147
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt_a.lib
148
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt.lib
149
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/libexslt.h
150
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltexports.h
143
151
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exslt.h
144
152
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltconfig.h
145
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltexports.h
146
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/libexslt.h
153
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltwin32config.h
154
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltexports.h
155
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/win32config.h
156
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltconfig.h
157
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xslt.h
158
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/functions.h
147
159
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/attributes.h
148
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/documents.h
149
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extensions.h
160
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/security.h
161
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/templates.h
162
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltutils.h
163
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/variables.h
150
164
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extra.h
151
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/functions.h
165
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/pattern.h
166
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/documents.h
167
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/trio.h
168
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/preproc.h
169
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltInternals.h
152
170
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/imports.h
153
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/keys.h
171
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extensions.h
154
172
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/libxslt.h
173
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltlocale.h
155
174
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/namespaces.h
156
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/numbersInternals.h
157
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/pattern.h
158
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/preproc.h
159
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/security.h
160
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/templates.h
175
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/keys.h
161
176
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/transform.h
162
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/trio.h
177
+ - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/numbersInternals.h
163
178
  - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/triodef.h
164
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/variables.h
165
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/win32config.h
166
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xslt.h
167
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltconfig.h
168
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltexports.h
169
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltInternals.h
170
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltlocale.h
171
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltutils.h
172
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltwin32config.h
173
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt.lib
174
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt_a.lib
175
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt.lib
176
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt_a.lib
177
- - test/file_indexing/index_agent_test/libxslt-1.1.26.win32/readme.txt
178
179
  - test/file_indexing/index_agent_test/New.txt
179
180
  - test/file_indexing/index_agent_test/patterns.input
180
- - test/file_indexing/index_agent_test.rb