melon 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/features/add.feature +10 -0
- data/features/check.feature +13 -0
- data/lib/melon/commands.rb +10 -6
- data/lib/melon/commands/add.rb +6 -0
- data/lib/melon/commands/check.rb +14 -0
- data/lib/melon/version.rb +1 -1
- metadata +4 -4
data/History.txt
CHANGED
data/features/add.feature
CHANGED
@@ -60,3 +60,13 @@ Feature: Adding files to the database
|
|
60
60
|
And the output should contain "dir/test2"
|
61
61
|
And the output should contain "dir/test/test3"
|
62
62
|
And the output should contain "test_file"
|
63
|
+
|
64
|
+
Scenario: Adding as an update
|
65
|
+
Given a file named "test2" with:
|
66
|
+
"""
|
67
|
+
Also a test file
|
68
|
+
"""
|
69
|
+
And I run "melon -d test.db add -q test_file"
|
70
|
+
When I run "melon -d test.db add -u test_file test2"
|
71
|
+
Then the output should contain "test2"
|
72
|
+
And the output should not contain "test_file"
|
data/features/check.feature
CHANGED
@@ -25,3 +25,16 @@ Feature: Check
|
|
25
25
|
"""
|
26
26
|
melon: no such file: nonexistant_file
|
27
27
|
"""
|
28
|
+
|
29
|
+
Scenario: Checking recursively
|
30
|
+
Given a file named "dir/test2" with:
|
31
|
+
"""
|
32
|
+
Another test file
|
33
|
+
"""
|
34
|
+
And a file named "dir/sub/test3" with:
|
35
|
+
"""
|
36
|
+
Nothing to see here, folks
|
37
|
+
"""
|
38
|
+
When I run "melon -d test.db check -r dir"
|
39
|
+
Then the output should contain "dir/test2"
|
40
|
+
And the output should contain "dir/sub/test3"
|
data/lib/melon/commands.rb
CHANGED
@@ -21,17 +21,21 @@ module Melon
|
|
21
21
|
|
22
22
|
|
23
23
|
# 1.0 list
|
24
|
-
# TODO:
|
25
|
-
# both internal 2-hash consistency (consistency) and db<->filesystem
|
26
|
-
# matching up (integrity) [file exists, hashes match]
|
24
|
+
# TODO: check needs -r
|
27
25
|
# TODO: needs a 'remove' command, or some way to deal with deletes/renames
|
28
26
|
# remove: given a tracked file, removes it
|
29
27
|
# given an untracked file, it hashes it
|
30
|
-
# and
|
28
|
+
# and attempts to remove it by hash
|
31
29
|
# TODO: list needs --paths(only) and --hashes(only)
|
32
|
-
# --count
|
33
|
-
# TODO: check needs -r
|
34
30
|
# TODO: update- a function of add, ignore files that are already present in the db
|
35
31
|
# TODO: handle moving a file somehow -- hopefully a function of update
|
32
|
+
# could be:
|
33
|
+
# 1. move file
|
34
|
+
# 2. add new path to db
|
35
|
+
# 3. some sort of cull cmd that removes untracked paths
|
36
|
+
# post-1.0
|
37
|
+
# TODO: needs a 'verify' command to check integrity of database
|
38
|
+
# both internal 2-hash consistency (consistency) and db<->filesystem
|
39
|
+
# matching up (integrity) [file exists, hashes match]
|
36
40
|
end
|
37
41
|
end
|
data/lib/melon/commands/add.rb
CHANGED
@@ -16,6 +16,11 @@ module Melon
|
|
16
16
|
parser.on("-r", "--recursive", "Recursively add directory contents") do
|
17
17
|
options.recursive = true
|
18
18
|
end
|
19
|
+
|
20
|
+
parser.on("-u" "--update",
|
21
|
+
"Skip paths already present in the database") do
|
22
|
+
options.update = true
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
def run
|
@@ -34,6 +39,7 @@ module Melon
|
|
34
39
|
end
|
35
40
|
|
36
41
|
if options.database[:by_path][filename]
|
42
|
+
next if options.update
|
37
43
|
error "path already present in database: #{arg}"
|
38
44
|
end
|
39
45
|
|
data/lib/melon/commands/check.rb
CHANGED
@@ -18,11 +18,25 @@ EOS
|
|
18
18
|
"file [file [file ...]"
|
19
19
|
end
|
20
20
|
|
21
|
+
def parser_options(parser)
|
22
|
+
parser.on("-r", "--recursive", "Recursively check directory contents") do
|
23
|
+
options.recursive = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
21
27
|
def run
|
22
28
|
parse_options!
|
23
29
|
|
30
|
+
if options.recursive
|
31
|
+
self.args = recursively_expand(args)
|
32
|
+
end
|
33
|
+
|
24
34
|
options.database.transaction do
|
25
35
|
args.each do |filename|
|
36
|
+
if File.directory?(filename)
|
37
|
+
error "argument is a directory: #{arg}"
|
38
|
+
end
|
39
|
+
|
26
40
|
hash = Hasher.digest(filename)
|
27
41
|
unless options.database[:by_hash][hash]
|
28
42
|
puts File.expand_path(filename)
|
data/lib/melon/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: melon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Roberts
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-09 00:00:00 -05:00
|
19
19
|
default_executable: melon
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|