roopap 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a61908602da7eae05e3d71d149683edfd7482bb2
4
- data.tar.gz: bd09fb3ebcd89dd64fe4d4446c666dd52b7a7b7a
3
+ metadata.gz: d7d417193b5eacb7b84b4939e06f2d49d1b3a7cc
4
+ data.tar.gz: 9341510c5db4f4b29e42889339f46bb0e8a4eaa2
5
5
  SHA512:
6
- metadata.gz: 85f956d646db9f0bafa034b21ab862cf1f0a7c2d24a655e232b33d4392a9f61631733c4963763919978a02b0fe0c78f90350d20b739aefb105e544f432007d3e
7
- data.tar.gz: e9da5775f2970ae7c4662bcadf9ad7e180af61f675ee2580e8d5781c528da291b643e1255ef9a6ca281f1cee0a6dfd651ba458d63728cd10a004b20d5976f185
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
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: 'rake test'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Roopap
1
+ # Roopap [![Build Status](https://travis-ci.org/visibletrap/roopap.png?branch=master)](https://travis-ci.org/visibletrap/roopap) [![Code Climate](https://codeclimate.com/github/visibletrap/roopap.png)](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
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- require 'minitest/pride'
3
+ ENV['RUBYOPT'] = "#{ENV['RUBYOPT']} -rminitest/pride"
4
4
  require 'rake/testtask'
5
5
 
6
6
  Rake::TestTask.new do |t|
@@ -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
- path = dest_for(c.realpath.to_s, dest)
8
- prepare_dir(path)
9
- copy(c.to_s, path)
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')
@@ -1,3 +1,3 @@
1
1
  module Roopap
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
Binary file
@@ -0,0 +1 @@
1
+ No jpg file
@@ -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}`
@@ -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.1
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-25 00:00:00.000000000 Z
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