roopap 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/roopap/organizer.rb +14 -3
- data/lib/roopap/version.rb +1 -1
- data/spec/fixtures/2/a.jpg +0 -0
- data/spec/fixtures/2/t.txt +1 -0
- data/spec/integration_spec.rb +1 -1
- data/spec/lib/organizer_spec.rb +10 -1
- metadata +13 -6
- /data/spec/fixtures/{a.jpg → 1/a.jpg} +0 -0
- /data/spec/fixtures/{b.jpg → 1/b.jpg} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d417193b5eacb7b84b4939e06f2d49d1b3a7cc
|
4
|
+
data.tar.gz: 9341510c5db4f4b29e42889339f46bb0e8a4eaa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92cc7f08b0b97a60cb905b31a76c855ba2e1531e07508348d288485a4d36c96240966498f4f97b544f3dd463589ed0b24dbc7a704896ecdc1fa6709bd0bddb0d
|
7
|
+
data.tar.gz: b259b600db393c5b28ffb083d632be0f5612a5e9529838b92c374ebdf9c1d5bbd49a8ae5570c3f3ea42299ba57c96e3891eac8bd23e6b722f752ad9f93f17b69
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
roopap
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Roopap
|
1
|
+
# Roopap [](https://travis-ci.org/visibletrap/roopap) [](https://codeclimate.com/github/visibletrap/roopap)
|
2
2
|
|
3
3
|
If you like me, have photo files spread all around. Some of them my friends, some from your old handphone, some in you backup harddrives and you want to organize them in to directories separate by creation time of each photo. This gem file is what you looking for.
|
4
4
|
|
data/Rakefile
CHANGED
data/lib/roopap/organizer.rb
CHANGED
@@ -4,13 +4,24 @@ module Roopap
|
|
4
4
|
class Organizer
|
5
5
|
def perform(source, dest)
|
6
6
|
Pathname.new(source).each_child do |c|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
src_file_path = c.to_s
|
8
|
+
next unless jpg_file?(src_file_path)
|
9
|
+
target_path = dest_for(src_file_path, dest)
|
10
|
+
prepare_dir(target_path)
|
11
|
+
copy(src_file_path, target_path)
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
15
|
private
|
16
|
+
def jpg_file?(path)
|
17
|
+
begin
|
18
|
+
EXIFR::JPEG.new(path)
|
19
|
+
true
|
20
|
+
rescue EXIFR::MalformedJPEG
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
14
25
|
def dest_for(filepath, root)
|
15
26
|
time = EXIFR::JPEG.new(filepath).date_time
|
16
27
|
dir_name = time.utc.strftime('%Y-%m')
|
data/lib/roopap/version.rb
CHANGED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
No jpg file
|
data/spec/integration_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe "Calling Roopap via shell command" do
|
|
14
14
|
|
15
15
|
it "copies all images under FROM directory to month directories under TARGET directory
|
16
16
|
according to the image created date" do
|
17
|
-
from = 'spec/fixtures'
|
17
|
+
from = 'spec/fixtures/1'
|
18
18
|
target = output_dir
|
19
19
|
|
20
20
|
`bin/roopap #{from} #{target}`
|
data/spec/lib/organizer_spec.rb
CHANGED
@@ -16,7 +16,7 @@ module Roopap
|
|
16
16
|
|
17
17
|
it "copies all images under SOURCE directory to month directories under DEST directory
|
18
18
|
according to the image created date" do
|
19
|
-
source = 'spec/fixtures'
|
19
|
+
source = 'spec/fixtures/1'
|
20
20
|
target = output_dir
|
21
21
|
|
22
22
|
Organizer.new.perform(source, target)
|
@@ -24,5 +24,14 @@ module Roopap
|
|
24
24
|
assert FileTest.exists?("#{target}/2006-01/a.jpg"), "No file in the target directory"
|
25
25
|
assert FileTest.exists?("#{target}/2011-04/b.jpg"), "No file in the target directory"
|
26
26
|
end
|
27
|
+
|
28
|
+
it "ignores non jpg file" do
|
29
|
+
source = 'spec/fixtures/2'
|
30
|
+
target = output_dir
|
31
|
+
|
32
|
+
Organizer.new.perform(source, target)
|
33
|
+
|
34
|
+
assert FileTest.exists?("#{target}/2006-01/a.jpg"), "No file in the target directory"
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roopap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nuttanart Pornprasitsakul
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,6 +61,9 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- .gitignore
|
64
|
+
- .ruby-gemset
|
65
|
+
- .ruby-version
|
66
|
+
- .travis.yml
|
64
67
|
- ATTRIBUTIONS.txt
|
65
68
|
- Gemfile
|
66
69
|
- LICENSE.txt
|
@@ -71,8 +74,10 @@ files:
|
|
71
74
|
- lib/roopap/organizer.rb
|
72
75
|
- lib/roopap/version.rb
|
73
76
|
- roopap.gemspec
|
74
|
-
- spec/fixtures/a.jpg
|
75
|
-
- spec/fixtures/b.jpg
|
77
|
+
- spec/fixtures/1/a.jpg
|
78
|
+
- spec/fixtures/1/b.jpg
|
79
|
+
- spec/fixtures/2/a.jpg
|
80
|
+
- spec/fixtures/2/t.txt
|
76
81
|
- spec/integration_spec.rb
|
77
82
|
- spec/lib/organizer_spec.rb
|
78
83
|
homepage:
|
@@ -100,7 +105,9 @@ signing_key:
|
|
100
105
|
specification_version: 4
|
101
106
|
summary: Organize photo files into directories base on creation date in EXIF
|
102
107
|
test_files:
|
103
|
-
- spec/fixtures/a.jpg
|
104
|
-
- spec/fixtures/b.jpg
|
108
|
+
- spec/fixtures/1/a.jpg
|
109
|
+
- spec/fixtures/1/b.jpg
|
110
|
+
- spec/fixtures/2/a.jpg
|
111
|
+
- spec/fixtures/2/t.txt
|
105
112
|
- spec/integration_spec.rb
|
106
113
|
- spec/lib/organizer_spec.rb
|
File without changes
|
File without changes
|