roopap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a61908602da7eae05e3d71d149683edfd7482bb2
4
+ data.tar.gz: bd09fb3ebcd89dd64fe4d4446c666dd52b7a7b7a
5
+ SHA512:
6
+ metadata.gz: 85f956d646db9f0bafa034b21ab862cf1f0a7c2d24a655e232b33d4392a9f61631733c4963763919978a02b0fe0c78f90350d20b739aefb105e544f432007d3e
7
+ data.tar.gz: e9da5775f2970ae7c4662bcadf9ad7e180af61f675ee2580e8d5781c528da291b643e1255ef9a6ca281f1cee0a6dfd651ba458d63728cd10a004b20d5976f185
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/ATTRIBUTIONS.txt ADDED
@@ -0,0 +1,5 @@
1
+ I want to thank you to owners of the images that allow me (through CC BY) to use as fixtures for testing this gem
2
+
3
+ a.jpg => [Délirante bestiole](http://www.flickr.com/photos/86778817@N00/)
4
+ b.jpg => [Sébastien Launay](http://www.flickr.com/photos/slaunay/)
5
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in roopap.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Nuttanart Pornprasitsakul
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Roopap
2
+
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
+
5
+ ## Installation
6
+
7
+ $ gem install roopap
8
+
9
+ ## Usage
10
+
11
+ $ roopap SOURCE DEST
12
+
13
+ * SOURCE is a directory where the photos you want to organize are located
14
+ * DEST is a root directory of the by-time directoreis that you want your photo to be copied to
15
+
16
+ ## Example
17
+
18
+ $ ls ~/Pictures
19
+ a.jpg
20
+
21
+ $ roopap ~/Pictures /Volumes/pictures
22
+ $ ls /Volumes/pictures
23
+ 2013-08
24
+ $ ls /Volumes/picutres/2013-08
25
+ a.jpg
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'minitest/pride'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "spec"
8
+ t.test_files = FileList['spec/**/*_spec.rb']
9
+ end
data/bin/roopap ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'roopap'
4
+
5
+ Roopap.process(ARGV)
@@ -0,0 +1,28 @@
1
+ require 'exifr'
2
+
3
+ module Roopap
4
+ class Organizer
5
+ def perform(source, dest)
6
+ Pathname.new(source).each_child do |c|
7
+ path = dest_for(c.realpath.to_s, dest)
8
+ prepare_dir(path)
9
+ copy(c.to_s, path)
10
+ end
11
+ end
12
+
13
+ private
14
+ def dest_for(filepath, root)
15
+ time = EXIFR::JPEG.new(filepath).date_time
16
+ dir_name = time.utc.strftime('%Y-%m')
17
+ File.join(root, dir_name)
18
+ end
19
+
20
+ def prepare_dir(path)
21
+ FileUtils.mkdir(path)
22
+ end
23
+
24
+ def copy(filepath, dest)
25
+ FileUtils.cp(filepath, dest)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Roopap
2
+ VERSION = "0.0.1"
3
+ end
data/lib/roopap.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "roopap/version"
2
+ require "roopap/organizer"
3
+
4
+ module Roopap
5
+ def self.process(args)
6
+ source, dest = *args
7
+ Organizer.new.perform(source, dest)
8
+ end
9
+ end
data/roopap.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'roopap/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "roopap"
8
+ spec.version = Roopap::VERSION
9
+ spec.authors = ["Nuttanart Pornprasitsakul"]
10
+ spec.email = ["visibletrap@gmail.com"]
11
+ spec.description = %q{Bulk photo organizer}
12
+ spec.summary = %q{Organize photo files into directories base on creation date in EXIF}
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+
23
+ spec.add_dependency "exifr"
24
+ end
Binary file
Binary file
@@ -0,0 +1,26 @@
1
+ require 'minitest/autorun'
2
+ require 'fileutils'
3
+
4
+ describe "Calling Roopap via shell command" do
5
+ let(:output_dir) { 'tmp/out' }
6
+
7
+ before do
8
+ FileUtils.mkdir_p(output_dir)
9
+ end
10
+
11
+ after do
12
+ FileUtils.rm_r(output_dir)
13
+ end
14
+
15
+ it "copies all images under FROM directory to month directories under TARGET directory
16
+ according to the image created date" do
17
+ from = 'spec/fixtures'
18
+ target = output_dir
19
+
20
+ `bin/roopap #{from} #{target}`
21
+
22
+ assert FileTest.exists?("#{target}/2006-01/a.jpg"), "No file in the target directory"
23
+ assert FileTest.exists?("#{target}/2011-04/b.jpg"), "No file in the target directory"
24
+ end
25
+
26
+ end
@@ -0,0 +1,28 @@
1
+ require 'minitest/autorun'
2
+ require 'fileutils'
3
+ require 'roopap/organizer'
4
+
5
+ module Roopap
6
+ describe "Organizer" do
7
+ let(:output_dir) { 'tmp/out' }
8
+
9
+ before do
10
+ FileUtils.mkdir_p(output_dir)
11
+ end
12
+
13
+ after do
14
+ FileUtils.rm_r(output_dir)
15
+ end
16
+
17
+ it "copies all images under SOURCE directory to month directories under DEST directory
18
+ according to the image created date" do
19
+ source = 'spec/fixtures'
20
+ target = output_dir
21
+
22
+ Organizer.new.perform(source, target)
23
+
24
+ assert FileTest.exists?("#{target}/2006-01/a.jpg"), "No file in the target directory"
25
+ assert FileTest.exists?("#{target}/2011-04/b.jpg"), "No file in the target directory"
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roopap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nuttanart Pornprasitsakul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: exifr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Bulk photo organizer
56
+ email:
57
+ - visibletrap@gmail.com
58
+ executables:
59
+ - roopap
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - ATTRIBUTIONS.txt
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/roopap
70
+ - lib/roopap.rb
71
+ - lib/roopap/organizer.rb
72
+ - lib/roopap/version.rb
73
+ - roopap.gemspec
74
+ - spec/fixtures/a.jpg
75
+ - spec/fixtures/b.jpg
76
+ - spec/integration_spec.rb
77
+ - spec/lib/organizer_spec.rb
78
+ homepage:
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.0.5
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Organize photo files into directories base on creation date in EXIF
102
+ test_files:
103
+ - spec/fixtures/a.jpg
104
+ - spec/fixtures/b.jpg
105
+ - spec/integration_spec.rb
106
+ - spec/lib/organizer_spec.rb