dircat 0.1.12 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +1 -1
- data/README.md +31 -6
- data/bin/dircat +5 -1
- data/bin/scat +9 -0
- data/dircat.gemspec +48 -15
- data/examples/example.rb +2 -1
- data/lib/dircat.rb +29 -34
- data/lib/dircat/cat_on_sqlite/cat_on_sqlite.rb +177 -0
- data/lib/dircat/cat_on_sqlite/directory_visitor.rb +106 -0
- data/lib/dircat/cat_on_sqlite/migration/00_create_dircat_properties.rb +13 -0
- data/lib/dircat/cat_on_sqlite/migration/01_create_categories.rb +12 -0
- data/lib/dircat/cat_on_sqlite/migration/02_create_images.rb +16 -0
- data/lib/dircat/cat_on_sqlite/migration/03_create_items.rb +23 -0
- data/lib/dircat/cat_on_sqlite/migration/04_create_taggings.rb +13 -0
- data/lib/dircat/cat_on_sqlite/migration/05_create_tags.rb +13 -0
- data/lib/dircat/cat_on_sqlite/model/category.rb +16 -0
- data/lib/dircat/cat_on_sqlite/model/image.rb +24 -0
- data/lib/dircat/cat_on_sqlite/model/item.rb +19 -0
- data/lib/dircat/cat_on_sqlite/model/tag.rb +58 -0
- data/lib/dircat/cat_on_sqlite/model/tagging.rb +9 -0
- data/lib/dircat/cat_on_sqlite/simple_cataloger_error.rb +9 -0
- data/lib/dircat/cat_on_sqlite_cli/cli_cat.rb +25 -0
- data/lib/dircat/cat_on_sqlite_cli/cli_server.rb +65 -0
- data/lib/dircat/cat_on_sqlite_cli/cmd_create.rb +56 -0
- data/lib/dircat/cat_on_sqlite_cli/cmd_list.rb +72 -0
- data/lib/dircat/cat_on_sqlite_cli/cmd_server.rb +62 -0
- data/lib/dircat/cat_on_sqlite_cli/cmd_update.rb +49 -0
- data/lib/dircat/{cat.rb → cat_on_yaml/cat_on_yaml.rb} +22 -10
- data/lib/dircat/cat_on_yaml/entry.rb +64 -0
- data/lib/dircat/{cli → cat_on_yaml_cli}/cli_dircat.rb +0 -0
- data/lib/dircat/{cli → cat_on_yaml_cli}/command_build.rb +53 -12
- data/lib/dircat/{cli → cat_on_yaml_cli}/command_diff.rb +4 -4
- data/lib/dircat/{cli → cat_on_yaml_cli}/command_query.rb +16 -2
- data/lib/dircat/config.rb +25 -0
- data/lib/dircat/extensions.rb +26 -0
- data/lib/dircat/server/helpers.rb +60 -0
- data/lib/dircat/server/my_static.rb +40 -0
- data/lib/dircat/server/web_server.rb +176 -0
- data/lib/dircat/version.rb +2 -1
- data/lib/dircat_on_sqlite.rb +31 -0
- data/lib/dircat_on_sqlite_cli.rb +37 -0
- data/lib/simple_cataloger_dm/cli.rb +32 -0
- data/lib/simple_cataloger_dm/core.rb +43 -0
- data/lib/simple_cataloger_dm/core/catalog.rb +141 -0
- data/lib/simple_cataloger_dm/core/directory_visitor.rb +107 -0
- data/lib/simple_cataloger_dm/core/extensions.rb +26 -0
- data/lib/simple_cataloger_dm/core/simple_cataloger_error.rb +9 -0
- data/lib/simple_cataloger_dm/models/category.rb +21 -0
- data/lib/simple_cataloger_dm/models/image.rb +30 -0
- data/lib/simple_cataloger_dm/models/item.rb +24 -0
- data/lib/simple_cataloger_dm/models/tag.rb +62 -0
- data/lib/simple_cataloger_dm/models/tagging.rb +11 -0
- data/lib/simple_cataloger_dm/server/helpers.rb +60 -0
- data/lib/simple_cataloger_dm/server/my_static.rb +40 -0
- data/lib/simple_cataloger_dm/server/web_server.rb +171 -0
- data/spec/dircat/cat_on_sqlite/cat_on_sqlite_spec.rb +41 -0
- data/spec/dircat/cat_on_sqlite_web/web_server_spec.rb +30 -0
- data/spec/dircat/{cat_spec.rb → cat_on_yaml/cat_on_yaml_spec.rb} +20 -14
- data/spec/dircat/{cli → cat_on_yaml_cli}/cli_dircat_spec.rb +0 -0
- data/spec/dircat/{cli → cat_on_yaml_cli}/command_build_spec.rb +4 -4
- data/spec/dircat/{cli → cat_on_yaml_cli}/command_diff_spec.rb +0 -0
- data/spec/dircat/{cli → cat_on_yaml_cli}/command_query_spec.rb +1 -1
- data/spec/fixtures/certified_output/cat_dir1_20120811.yaml +25 -0
- data/spec/fixtures/certified_output/cat_dir2_20120811.yaml +34 -0
- data/spec/fixtures/certified_output/{dircat1.yaml → dircat1_version_0.1.yaml} +0 -0
- data/spec/fixtures/certified_output/{dircat2.yaml → dircat2_version_0.1.yaml} +0 -0
- data/spec/fixtures/dir4/file1.txt +1 -0
- data/spec/fixtures/dir4/file2.txt +1 -0
- data/spec/fixtures/dir4/subdir/file3.txt +1 -0
- data/spec/fixtures/films/A-Z/A/Arancia meccanica [Stanley Kubrick][1971]/folder.jpg +0 -0
- data/spec/fixtures/films/A-Z/P/Plan 9 [Edward Wood][1959]/folder.jpg +0 -0
- data/spec/fixtures/films/Directors/[Akira Kurosawa]/[1940] Dersu Uzala [5]/folder.jpg +0 -0
- data/spec/fixtures/films/Directors/[Akira Kurosawa]/[1965] Barbarossa [Toshiro Mifune][4]/folder.jpg +0 -0
- data/spec/fixtures/films/Directors/[Federico Fellini]/[1963] 8 e mezzo [Marcello Mastroianni][Claudia Cardinale][5]/folder.jpg +0 -0
- data/spec/fixtures/films/Directors/[Woody Allen]/[1977] Annie Hall [Diane Keaton][5]/folder.jpg +0 -0
- data/{.gemtest → spec/fixtures/readme.txt} +0 -0
- data/spec/fixtures/tmp/test_ar.sqlite3 +0 -0
- data/spec/fixtures/tmp/test_ar.yml +7 -0
- data/spec/generate_directories_to_catalog.rb +80 -0
- data/spec/generate_mysql_catalog.rb +124 -0
- data/spec/spec_helper.rb +29 -0
- data/tasks/rspec.rake +0 -2
- metadata +390 -112
- data/lib/dircat/entry.rb +0 -61
- data/lib/dircat/extension_md5.rb +0 -25
- data/lib/dircat/extension_numeric.rb +0 -15
- data/spec/dircat/md5_spec.rb +0 -8
- data/spec/dircat/numeric_spec.rb +0 -13
data/lib/dircat/entry.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
module DirCat
|
3
|
-
|
4
|
-
class EntrySer < OpenStruct
|
5
|
-
end
|
6
|
-
|
7
|
-
#
|
8
|
-
# Entry
|
9
|
-
#
|
10
|
-
class Entry
|
11
|
-
|
12
|
-
attr_reader :md5
|
13
|
-
attr_reader :name
|
14
|
-
attr_reader :path
|
15
|
-
attr_reader :size
|
16
|
-
attr_reader :mtime
|
17
|
-
|
18
|
-
def from_filename( filename )
|
19
|
-
@name = File.basename(filename)
|
20
|
-
@path = File.dirname(filename)
|
21
|
-
stat = File.stat(filename)
|
22
|
-
@size = stat.size
|
23
|
-
@mtime = stat.mtime
|
24
|
-
# self.md5 = Digest::MD5.hexdigest(File.read( f ))
|
25
|
-
@md5 = MD5.file( filename ).hexdigest
|
26
|
-
self
|
27
|
-
end
|
28
|
-
|
29
|
-
def from_ser( entry_ser )
|
30
|
-
@md5 = entry_ser.md5
|
31
|
-
@name = entry_ser.name
|
32
|
-
@path = entry_ser.path
|
33
|
-
@size = entry_ser.size
|
34
|
-
@mtime = entry_ser.mtime
|
35
|
-
self
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_ser
|
39
|
-
entry_ser = EntrySer.new
|
40
|
-
entry_ser.md5 = @md5
|
41
|
-
entry_ser.name = @name
|
42
|
-
entry_ser.path = @path
|
43
|
-
entry_ser.size = @size
|
44
|
-
entry_ser.mtime = @mtime
|
45
|
-
entry_ser
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_s
|
49
|
-
@md5 + " " + @name + "\t " + @path + "\n"
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
class DirCatSer < OpenStruct
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
class DirCatException < RuntimeError
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
data/lib/dircat/extension_md5.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# calculate md5 of big files, snipped found on usenet
|
4
|
-
#
|
5
|
-
|
6
|
-
if RUBY_VERSION =~ /1\.8/
|
7
|
-
# std lib
|
8
|
-
require 'md5'
|
9
|
-
else
|
10
|
-
# std lib
|
11
|
-
require 'digest/md5'
|
12
|
-
include Digest
|
13
|
-
end
|
14
|
-
|
15
|
-
class MD5
|
16
|
-
def self.file(file)
|
17
|
-
File.open(file, "rb") do |f|
|
18
|
-
res = self.new
|
19
|
-
while (data = f.read(4096))
|
20
|
-
res << data
|
21
|
-
end
|
22
|
-
res
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
class Numeric
|
3
|
-
#
|
4
|
-
# returns a string separated by the thousands <separator>
|
5
|
-
# es.: 100000 -> 1.000.000
|
6
|
-
#
|
7
|
-
def with_separator( separator = ',', length = 3 )
|
8
|
-
splitter = Regexp.compile "(\\d{#{length}})"
|
9
|
-
before, after = self.to_s.split('.')
|
10
|
-
before = before.reverse.gsub splitter, '\1' + separator
|
11
|
-
str = "#{ before.chomp( separator ).reverse }"
|
12
|
-
str += ".#{ after }" if after
|
13
|
-
str
|
14
|
-
end
|
15
|
-
end
|
data/spec/dircat/md5_spec.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require File.expand_path( File.join(File.dirname(__FILE__), "..", "spec_helper") )
|
3
|
-
describe "MD5" do
|
4
|
-
it "test_simple_md5" do
|
5
|
-
file_name = File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "lib", "dircat", "extension_md5.rb" ) )
|
6
|
-
MD5.file( file_name ).to_s.should == "ab4bc9cf679dede00672f2246e204b06"
|
7
|
-
end
|
8
|
-
end
|
data/spec/dircat/numeric_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.expand_path( File.join(File.dirname(__FILE__), "..", "spec_helper") )
|
4
|
-
|
5
|
-
describe "TCNumeric" do
|
6
|
-
|
7
|
-
it "test_simple" do
|
8
|
-
10.with_separator.should == "10"
|
9
|
-
10.0.with_separator.should == "10.0"
|
10
|
-
1000000.with_separator.should == "1,000,000"
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|