filentory-cli 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ This is file A
@@ -0,0 +1 @@
1
+ This is file B
Binary file
@@ -0,0 +1,62 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'filentory/collector'
4
+
5
+ class TestCollector < Test::Unit::TestCase
6
+
7
+ def test_collector_finds_files
8
+ col = Collector.new
9
+ result = col.collect(File.dirname(__FILE__)+"/integration/data/")
10
+
11
+ assert_equal(4, result.length)
12
+ assert_equal("bf65dac6b214f362fc6a8b151c9f44668fed8460bbe8204f215e82332a295939", result[0].checksum)
13
+ assert_equal(".", result[0].path)
14
+ end
15
+
16
+ def test_metadata_only_for_jpg
17
+ col = Collector.new
18
+ result = col.collect(File.dirname(__FILE__)+"/integration/data/")
19
+ fileA = result[0]
20
+ jpg = result[2]
21
+
22
+ assert_equal("fileA.txt", fileA.name)
23
+ assert_nil fileA.metadata
24
+
25
+ assert_equal("image_with_exif_and_xmp_infos.jpg", jpg.name)
26
+ assert_equal("Canon PowerShot S110", jpg.metadata["exif.model"])
27
+ end
28
+
29
+ def test_relative_path
30
+ pn = Pathname.new("/test/integration/data/fileA")
31
+ porig = Pathname.new("/test/integration/data")
32
+
33
+ assert_equal(".", pn.relative_path_from(porig).dirname.to_s)
34
+ assert_equal("fileA", pn.relative_path_from(porig).basename.to_s)
35
+ end
36
+
37
+ def test_file_extension_for_files_without_extension
38
+ extension = File.extname("/test/integration/data/fileA")
39
+ assert_equal("", extension)
40
+ end
41
+
42
+ def test_file_extension_for_a_directory_path
43
+ extension = File.extname("/test/integration/data/fileA/")
44
+ assert_equal("", extension)
45
+ end
46
+
47
+ def test_file_extension_for_files_in_uppercase
48
+ extension = File.extname("FILE.TXT")
49
+ assert_equal(".TXT", extension)
50
+ end
51
+
52
+ def test_file_extension_for_files_in_lowercase
53
+ extension = File.extname("file.txt")
54
+ assert_equal(".txt", extension)
55
+ end
56
+
57
+ def test_file_extension_for_files_in_mixedcase
58
+ extension = File.extname("fIlE.tXt")
59
+ assert_equal(".tXt", extension)
60
+ end
61
+
62
+ end
@@ -0,0 +1,34 @@
1
+ require 'test/unit'
2
+ require 'filentory/datastore'
3
+
4
+ class TestDatastore < Test::Unit::TestCase
5
+ def test_initialisation_with_a_name
6
+ ds = Datastore.new("a name")
7
+
8
+ assert_equal("a name", ds.name)
9
+ end
10
+
11
+ def test_can_set_a_type
12
+ ds = Datastore.new("")
13
+ ds.type= "DVD"
14
+
15
+ assert_equal("DVD", ds.type)
16
+ end
17
+
18
+ def test_can_add_array_of_files
19
+ ds = Datastore.new("File")
20
+ names = ["a", "b"]
21
+ ds.files= Array.new (names)
22
+
23
+ assert_equal(names, ds.files)
24
+ end
25
+
26
+ def test_can_add__files
27
+ ds = Datastore.new("File")
28
+ names = ["a", "b"]
29
+ ds.files << "a"
30
+ ds.files << "b"
31
+
32
+ assert_equal(names, ds.files)
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'filentory/exifextractor'
4
+
5
+ class TestExifExtractor < Test::Unit::TestCase
6
+
7
+ def test_can_extract_metadata
8
+ extractor = ExifExtractor.new
9
+ metadata = extractor.metadata_for_file(File.dirname(__FILE__)+"/integration/data/image_with_exif_and_xmp_infos.jpg")
10
+
11
+ assert_equal("Canon PowerShot S110", metadata["exif.model"])
12
+ assert_equal("Johnny Graber", metadata["exif.artist"])
13
+ assert_nil metadata["rdf.about"]
14
+ end
15
+
16
+ def test_can_handle_jpg
17
+ assert(ExifExtractor.handles?(".jpg"), "ExifExtractor should handle .jpg")
18
+ end
19
+
20
+ def test_can_not_handle_avi
21
+ assert(!ExifExtractor.handles?(".avi"), "ExifExtractor should responde false for .avi")
22
+ end
23
+
24
+ end
@@ -0,0 +1,62 @@
1
+ require 'test/unit'
2
+ require 'date'
3
+ require 'oj'
4
+ require 'filentory/fileentry'
5
+
6
+
7
+ class TestFileEntry < Test::Unit::TestCase
8
+
9
+ def test_initialisation_with_a_path_and_a_name
10
+ fe = FileEntry.new("/media/","a name")
11
+
12
+ assert_equal("a name", fe.name)
13
+ assert_equal("/media/", fe.path)
14
+ end
15
+
16
+ def test_checksum_can_be_set
17
+ fe = FileEntry.new("/media/","a name")
18
+ fe.checksum = "1234"
19
+
20
+ assert_equal("1234", fe.checksum)
21
+ end
22
+
23
+ def test_last_modification_can_be_set
24
+ fe = FileEntry.new("/media/","a name")
25
+ last = DateTime.iso8601("2014-01-04T21:06:04+01:00")
26
+
27
+ fe.last_modified = last
28
+
29
+ assert_equal("2014-01-04T21:06:04+01:00", fe.last_modified.strftime("%FT%T%:z"))
30
+ end
31
+
32
+ def test_json_stores_datestring
33
+ fe = FileEntry.new("/media/","a name")
34
+ fe.last_modified = DateTime.iso8601("2014-01-04T21:06:04+01:00")
35
+
36
+ json = Oj::dump fe, :indent => 2
37
+
38
+ assert_equal(json_compact.strip, json)
39
+ end
40
+
41
+ def test_to_s_is_readable
42
+ fe = FileEntry.new("/media/","a name")
43
+ fe.last_modified = DateTime.iso8601("2014-01-04T21:06:04+01:00")
44
+ fe.size = 100
45
+
46
+ assert_equal("/media/a name (100) - 2014-01-04T21:06:04+01:00",fe.to_s)
47
+ end
48
+
49
+
50
+ private
51
+ def json_compact
52
+ <<-eos
53
+ {
54
+ "^o":"FileEntry",
55
+ "path":"/media/",
56
+ "name":"a name",
57
+ "last_modified":"2014-01-04T21:06:04+01:00"
58
+ }
59
+ eos
60
+ end
61
+
62
+ end
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+
3
+ class TestSomething < Test::Unit::TestCase
4
+ def test_truth
5
+ assert true
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'filentory/videoextractor'
4
+
5
+ class TestVideoExtractor < Test::Unit::TestCase
6
+
7
+ def test_can_extract_metadata
8
+ extractor = VideoExtractor.new
9
+ metadata = extractor.metadata_for_file(File.dirname(__FILE__)+"/integration/data/video.mov")
10
+
11
+ assert_equal(2.18, metadata["duration"])
12
+ assert_equal("568x320", metadata["resolution"])
13
+ end
14
+
15
+ def test_can_handle_avi
16
+ assert(VideoExtractor.handles?(".avi"), "VideoExtractor should handle .avi")
17
+ end
18
+
19
+ def test_can_not_handle_jpg
20
+ assert(!VideoExtractor.handles?(".jpg"), "VideoExtractor should responde false for .jpg")
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,235 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: filentory-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Johnny Graber
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: aruba
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 10.1.1
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 10.1.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: methadone
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.1
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.3.1
78
+ - !ruby/object:Gem::Dependency
79
+ name: oj
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 2.5.3
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.5.3
94
+ - !ruby/object:Gem::Dependency
95
+ name: json_spec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.1.1
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.1
110
+ - !ruby/object:Gem::Dependency
111
+ name: exifr
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.1.3
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.1.3
126
+ - !ruby/object:Gem::Dependency
127
+ name: xmp
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.2.0
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.2.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: streamio-ffmpeg
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 1.0.0
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.0.0
158
+ description: A tool to create an filentory-cli of a storage medium
159
+ email:
160
+ - jg@jgraber.ch
161
+ executables:
162
+ - filentory-cli
163
+ extensions: []
164
+ extra_rdoc_files: []
165
+ files:
166
+ - .gitignore
167
+ - .travis.yml
168
+ - Gemfile
169
+ - Gemfile.lock
170
+ - LICENSE
171
+ - README.md
172
+ - README.rdoc
173
+ - Rakefile
174
+ - bin/filentory-cli
175
+ - features/filentory-cli.feature
176
+ - features/step_definitions/filentory-cli_steps.rb
177
+ - features/support/env.rb
178
+ - filentory-cli.gemspec
179
+ - lib/filentory.rb
180
+ - lib/filentory/collector.rb
181
+ - lib/filentory/datastore.rb
182
+ - lib/filentory/exifextractor.rb
183
+ - lib/filentory/fileentry.rb
184
+ - lib/filentory/version.rb
185
+ - lib/filentory/videoextractor.rb
186
+ - results.html
187
+ - test/integration/data/fileA.txt
188
+ - test/integration/data/folder/fileB.txt
189
+ - test/integration/data/image_with_exif_and_xmp_infos.jpg
190
+ - test/integration/data/video.mov
191
+ - test/tc_collector.rb
192
+ - test/tc_datastore.rb
193
+ - test/tc_exifextractor.rb
194
+ - test/tc_fileentry.rb
195
+ - test/tc_something.rb
196
+ - test/tc_videoextractor.rb
197
+ homepage: https://github.com/jgraber/filentory-cli
198
+ licenses: []
199
+ post_install_message:
200
+ rdoc_options: []
201
+ require_paths:
202
+ - lib
203
+ required_ruby_version: !ruby/object:Gem::Requirement
204
+ none: false
205
+ requirements:
206
+ - - ! '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ required_rubygems_version: !ruby/object:Gem::Requirement
210
+ none: false
211
+ requirements:
212
+ - - ! '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ requirements: []
216
+ rubyforge_project:
217
+ rubygems_version: 1.8.23
218
+ signing_key:
219
+ specification_version: 3
220
+ summary: Filentory-cli is a first step to get order in a chaotic collection of storage
221
+ medias.
222
+ test_files:
223
+ - features/filentory-cli.feature
224
+ - features/step_definitions/filentory-cli_steps.rb
225
+ - features/support/env.rb
226
+ - test/integration/data/fileA.txt
227
+ - test/integration/data/folder/fileB.txt
228
+ - test/integration/data/image_with_exif_and_xmp_infos.jpg
229
+ - test/integration/data/video.mov
230
+ - test/tc_collector.rb
231
+ - test/tc_datastore.rb
232
+ - test/tc_exifextractor.rb
233
+ - test/tc_fileentry.rb
234
+ - test/tc_something.rb
235
+ - test/tc_videoextractor.rb