findrr 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +10 -0
- data/lib/findrr/command.rb +8 -0
- data/lib/findrr/config.rb +40 -0
- data/lib/findrr/database.rb +11 -6
- data/lib/findrr/version.rb +1 -1
- data/test/test-config.rb +24 -0
- data/test/test-database.rb +14 -3
- metadata +24 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2cb6a4afbb32672bb8839699faa0b34df06a6fc
|
4
|
+
data.tar.gz: b784af3d8c7d48e43abfd7029827c905cf8220b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 050142118bba1a8bec3b8729f0ed1f3eb1ec011eea9e3df8cfd89fe85674d8d7004a3acf67102489d36dcfb1f64479530c8151099fd1bf8419b8815861d73b46
|
7
|
+
data.tar.gz: ced6a3e9deaa11df5f8e4c7f9eab89d94d6a1e0ccc8723e4aa4dec52b02cb7ccd42f40a0ffd301b4c2aa90b35a23f6ba3fbddf62aace87259da539ef62827900
|
data/NEWS.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# NEWS
|
2
2
|
|
3
|
+
## 0.0.4: 2013-12-15
|
4
|
+
|
5
|
+
### Changes
|
6
|
+
|
7
|
+
* Improvements
|
8
|
+
* Added version command.
|
9
|
+
* Skip collecting of a path when an error occurred.
|
10
|
+
* Use plane-text for history manager.
|
11
|
+
* Make update when already having the key.
|
12
|
+
|
3
13
|
## 0.0.3: 2013-12-13
|
4
14
|
|
5
15
|
### Changes
|
data/lib/findrr/command.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
require "thor"
|
2
|
+
require "findrr/version"
|
2
3
|
require "findrr/database"
|
4
|
+
require "findrr/config"
|
3
5
|
|
4
6
|
module Findrr
|
5
7
|
class Command < Thor
|
8
|
+
desc "version", "Show version number"
|
9
|
+
def version
|
10
|
+
puts VERSION
|
11
|
+
end
|
12
|
+
|
6
13
|
desc "collect PATH", "Collect filenames (take a few minutes)"
|
7
14
|
def collect(path)
|
15
|
+
Config.new.save(path)
|
8
16
|
begin
|
9
17
|
Database.new.collect(path)
|
10
18
|
rescue => e
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Findrr
|
4
|
+
class Config
|
5
|
+
attr_accessor :base_dir
|
6
|
+
def initialize(base_dir=default_base_dir)
|
7
|
+
@base_dir = base_dir
|
8
|
+
@config = read
|
9
|
+
end
|
10
|
+
|
11
|
+
def save(target)
|
12
|
+
FileUtils.mkdir_p(@base_dir)
|
13
|
+
@config["history"] << target
|
14
|
+
write
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def default_base_dir
|
19
|
+
File.join(File.expand_path("~"), ".findrr")
|
20
|
+
end
|
21
|
+
|
22
|
+
def config_path
|
23
|
+
File.join(@base_dir, "config.yml")
|
24
|
+
end
|
25
|
+
|
26
|
+
def read
|
27
|
+
if File.exist?(config_path)
|
28
|
+
YAML.load(File.read(config_path))
|
29
|
+
else
|
30
|
+
{"history" => []}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def write
|
35
|
+
File.open(config_path, "w") do |file|
|
36
|
+
YAML.dump(@config, file)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/findrr/database.rb
CHANGED
@@ -14,14 +14,20 @@ module Findrr
|
|
14
14
|
create_database_dir
|
15
15
|
create_database
|
16
16
|
Groonga::Database.open(database_path) do
|
17
|
-
Groonga["Registers"].add(File.expand_path(target))
|
18
17
|
files = Groonga["Files"]
|
19
18
|
Find.find(File.expand_path(target)) do |path|
|
20
19
|
begin
|
21
|
-
files.
|
22
|
-
|
20
|
+
if files.has_key?(path)
|
21
|
+
files[path] = {:mtime => File.mtime(path)}
|
22
|
+
else
|
23
|
+
files.add(path, :basename => File.basename(path),
|
24
|
+
:mtime => File.mtime(path))
|
25
|
+
end
|
23
26
|
rescue Errno::ENOENT
|
24
27
|
next
|
28
|
+
rescue => e
|
29
|
+
$stderr.puts("Skip: #{e.class}: #{e.message} (#{path})")
|
30
|
+
next
|
25
31
|
end
|
26
32
|
end
|
27
33
|
files.size
|
@@ -42,7 +48,8 @@ module Findrr
|
|
42
48
|
end
|
43
49
|
|
44
50
|
def destroy
|
45
|
-
FileUtils.
|
51
|
+
FileUtils.rm(Dir.glob(File.join(database_dir, "findrr.db*")))
|
52
|
+
FileUtils.rmdir(database_dir)
|
46
53
|
end
|
47
54
|
|
48
55
|
private
|
@@ -68,8 +75,6 @@ module Findrr
|
|
68
75
|
|
69
76
|
Groonga::Database.create(:path => database_path)
|
70
77
|
|
71
|
-
Groonga::Schema.create_table("Registers", :type => :patricia_trie)
|
72
|
-
|
73
78
|
Groonga::Schema.create_table("Files", :type => :patricia_trie) do |table|
|
74
79
|
table.short_text("basename")
|
75
80
|
table.time("mtime")
|
data/lib/findrr/version.rb
CHANGED
data/test/test-config.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "findrr/config"
|
3
|
+
|
4
|
+
class ConfigTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@tmp_dir = File.join(File.dirname(__FILE__), "tmp")
|
7
|
+
@config_path = File.join(@tmp_dir, "config.yml")
|
8
|
+
FileUtils.rm_f(@config_path)
|
9
|
+
@config = Findrr::Config.new(@tmp_dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
FileUtils.rm_f(@config_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_save
|
17
|
+
@config.save("foo")
|
18
|
+
assert_equal({"history" => ["foo"]},
|
19
|
+
YAML.load(File.read(@config_path)))
|
20
|
+
@config.save("bar")
|
21
|
+
assert_equal({"history" => ["foo", "bar"]},
|
22
|
+
YAML.load(File.read(@config_path)))
|
23
|
+
end
|
24
|
+
end
|
data/test/test-database.rb
CHANGED
@@ -5,16 +5,27 @@ class DatabaseTest < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@tmp_dir = File.join(File.dirname(__FILE__), "tmp")
|
7
7
|
@tmp_db_dir = File.join(@tmp_dir, "db")
|
8
|
-
FileUtils.
|
8
|
+
FileUtils.rm(Dir.glob(File.join(@tmp_db_dir, "findrr.db*")))
|
9
|
+
FileUtils.rmdir(@tmp_db_dir)
|
9
10
|
@database = Findrr::Database.new(@tmp_dir)
|
10
11
|
end
|
11
12
|
|
12
13
|
def teardown
|
13
|
-
FileUtils.
|
14
|
+
FileUtils.rm(Dir.glob(File.join(@tmp_db_dir, "findrr.db*")))
|
15
|
+
FileUtils.rmdir(@tmp_db_dir)
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
18
|
+
def test_collect
|
17
19
|
assert_true(0 < @database.collect(File.dirname(__FILE__)))
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_collect_update
|
23
|
+
size = @database.collect(File.dirname(__FILE__))
|
24
|
+
assert_equal(size, @database.collect(File.dirname(__FILE__)))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_search
|
28
|
+
@database.collect(File.dirname(__FILE__))
|
18
29
|
assert_true(0 < @database.search("test"))
|
19
30
|
end
|
20
31
|
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: findrr
|
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
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rroonga
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: test-unit
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: test-unit-notify
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: test-unit-rr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '1.3'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.3'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: A search tool for filenames in your directories.
|
@@ -116,8 +116,8 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
-
-
|
120
|
-
-
|
119
|
+
- .gitignore
|
120
|
+
- .travis.yml
|
121
121
|
- Gemfile
|
122
122
|
- NEWS.md
|
123
123
|
- README.md
|
@@ -126,11 +126,13 @@ files:
|
|
126
126
|
- findrr.gemspec
|
127
127
|
- lib/findrr.rb
|
128
128
|
- lib/findrr/command.rb
|
129
|
+
- lib/findrr/config.rb
|
129
130
|
- lib/findrr/database.rb
|
130
131
|
- lib/findrr/version.rb
|
131
132
|
- license/lgpl-3.0.txt
|
132
133
|
- test/run-test.rb
|
133
134
|
- test/test-command.rb
|
135
|
+
- test/test-config.rb
|
134
136
|
- test/test-database.rb
|
135
137
|
homepage: https://github.com/myokoym/findrr
|
136
138
|
licenses:
|
@@ -142,21 +144,22 @@ require_paths:
|
|
142
144
|
- lib
|
143
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
144
146
|
requirements:
|
145
|
-
- -
|
147
|
+
- - '>='
|
146
148
|
- !ruby/object:Gem::Version
|
147
149
|
version: '0'
|
148
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
151
|
requirements:
|
150
|
-
- -
|
152
|
+
- - '>='
|
151
153
|
- !ruby/object:Gem::Version
|
152
154
|
version: '0'
|
153
155
|
requirements: []
|
154
156
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.0.14
|
156
158
|
signing_key:
|
157
159
|
specification_version: 4
|
158
160
|
summary: A filenames search tool
|
159
161
|
test_files:
|
160
162
|
- test/run-test.rb
|
161
163
|
- test/test-command.rb
|
164
|
+
- test/test-config.rb
|
162
165
|
- test/test-database.rb
|