photobox 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +21 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/bin/photobox +4 -0
- data/lib/photobox/cli.rb +18 -0
- data/lib/photobox/version.rb +3 -0
- data/lib/photobox.rb +92 -0
- data/photobox.gemspec +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 49f4a033b62611b38c80b3707570a35d5390a150
|
4
|
+
data.tar.gz: 2ff4e0918c4630b3aeaf687902c1784e2ceda8bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b88d54934a2de0f2ef2d09414abeeab26a7bc3353674f8d5132c502adf8ed1a8e6b617c6a17d3000db7f9aaa8be6542968e28d9b78e59e9cf84801e3ec734b17
|
7
|
+
data.tar.gz: 363861befbdf4ad72ac5522c972cdf14f095f472283cb7ec6d6717a866d5629e071372857fe7a2c387ad4a64a5ef40487cce51078c71a4f79ffa61e001647b77
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
photobox (0.0.1)
|
5
|
+
rainbow (~> 2.0)
|
6
|
+
thor (~> 0.19)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
rainbow (2.0.0)
|
12
|
+
rake (10.3.2)
|
13
|
+
thor (0.19.1)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.7)
|
20
|
+
photobox!
|
21
|
+
rake (~> 10.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Devin Wadsworth
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
photobox
|
2
|
+
========
|
3
|
+
|
4
|
+
Simple Dropbox photo management.
|
5
|
+
|
6
|
+
## Assumptions
|
7
|
+
* `~/Dropbox/Camera Uploads` contains photos, screenshots, and videos
|
8
|
+
* Photos are in the following format: `yyyy-mm-dd hh.mm.ss.jpg`
|
9
|
+
* Photos have tne `.jpg` extension
|
10
|
+
* Screenshots have the `.png` extension
|
11
|
+
* Videos have the `.mov` and `.mp4` extensions
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'photobox'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install photobox
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
View a summary of photo folders and their contents:
|
30
|
+
|
31
|
+
$ photobox
|
32
|
+
|
33
|
+
Group photos into folders by month:
|
34
|
+
|
35
|
+
$ photobox cluster
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
1. Fork it ( https://github.com/daymun/photobox/fork )
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/photobox
ADDED
data/lib/photobox/cli.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "photobox"
|
3
|
+
|
4
|
+
module Photobox
|
5
|
+
class CLI < Thor
|
6
|
+
default_task :info
|
7
|
+
|
8
|
+
desc "cluster", "Group photos into folders by month"
|
9
|
+
def cluster
|
10
|
+
Photobox::Photo.cluster
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "info", "View a summary of photo folders and their contents"
|
14
|
+
def info
|
15
|
+
Photobox::Photo.info
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/photobox.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require "photobox/version"
|
2
|
+
require "date"
|
3
|
+
require "fileutils"
|
4
|
+
require "rainbow"
|
5
|
+
|
6
|
+
module Photobox
|
7
|
+
class Photo
|
8
|
+
PHOTOS_DIR = File.expand_path("~/Dropbox/Camera Uploads")
|
9
|
+
SCREENSHOTS_DIR = "#{PHOTOS_DIR}/Screenshots"
|
10
|
+
VIDEOS_DIR = "#{PHOTOS_DIR}/Videos"
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def cluster
|
14
|
+
files = Dir.glob("#{PHOTOS_DIR}/*.*")
|
15
|
+
photos = Dir.glob("#{PHOTOS_DIR}/*.jpg")
|
16
|
+
screenshots = Dir.glob("#{PHOTOS_DIR}/*.png")
|
17
|
+
videos = Dir.glob("#{PHOTOS_DIR}/*.{mov,mp4}")
|
18
|
+
|
19
|
+
if files.count.zero?
|
20
|
+
puts "No unclustered files."
|
21
|
+
else
|
22
|
+
cluster_photos(photos)
|
23
|
+
cluster_screenshots(screenshots)
|
24
|
+
cluster_videos(videos)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def info
|
29
|
+
dirs = Dir.glob("#{PHOTOS_DIR}/*").select { |f| File.directory?(f) }
|
30
|
+
dirs.map! { |f| f.split("/").last }
|
31
|
+
headers = dirs.map { |f| f.split("-").first }.uniq
|
32
|
+
|
33
|
+
headers.each do |header|
|
34
|
+
puts Rainbow(header).blue.bright
|
35
|
+
dirs.select { |f| f.include?(header) }.each do |f|
|
36
|
+
file_count = Dir.glob("#{PHOTOS_DIR}/#{f}/*.*").count
|
37
|
+
puts " #{Date::MONTHNAMES[f.split("-").last.to_i]} #{Rainbow(file_count).green}"
|
38
|
+
end
|
39
|
+
puts ""
|
40
|
+
end
|
41
|
+
|
42
|
+
year = Time.now.year
|
43
|
+
month = Time.now.month
|
44
|
+
last_month_photos = Dir.glob("#{PHOTOS_DIR}/#{year}-#{month - 1}/*.*")
|
45
|
+
this_month_photos = Dir.glob("#{PHOTOS_DIR}/#{year}-#{month}/*.*")
|
46
|
+
photos_difference = this_month_photos.count - last_month_photos.count
|
47
|
+
|
48
|
+
status = "You took #{Rainbow(this_month_photos.count).green} photos this month "
|
49
|
+
status += if photos_difference > 0
|
50
|
+
"(#{Rainbow("#{photos_difference} more").green} than last month)."
|
51
|
+
else
|
52
|
+
"(#{photos_difference.abs} less than last month)."
|
53
|
+
end
|
54
|
+
|
55
|
+
puts status
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def cluster_photos(photos)
|
61
|
+
unless photos.count.zero?
|
62
|
+
month_dirs = photos.map do |photo|
|
63
|
+
"#{PHOTOS_DIR}/#{photo.split("/").last[0..6]}"
|
64
|
+
end
|
65
|
+
|
66
|
+
month_dirs.uniq.each do |month_dir|
|
67
|
+
month_photos = Dir.glob("#{month_dir}*.jpg")
|
68
|
+
puts "Moving #{month_photos.count} photos to `#{month_dir}`"
|
69
|
+
FileUtils::mkdir_p(month_dir)
|
70
|
+
FileUtils.mv(month_photos, month_dir)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def cluster_screenshots(screenshots)
|
76
|
+
unless screenshots.count.zero?
|
77
|
+
puts "Moving #{screenshots.count} screenshots to `#{SCREENSHOTS_DIR}`"
|
78
|
+
FileUtils.mkdir_p(SCREENSHOTS_DIR)
|
79
|
+
FileUtils.mv(screenshots, SCREENSHOTS_DIR)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def cluster_videos(videos)
|
84
|
+
unless videos.count.zero?
|
85
|
+
puts "Moving #{videos.count} videos to `#{VIDEOS_DIR}`"
|
86
|
+
FileUtils.mkdir_p(VIDEOS_DIR)
|
87
|
+
FileUtils.mv(videos, VIDEOS_DIR)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/photobox.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'photobox/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "photobox"
|
8
|
+
spec.version = Photobox::VERSION
|
9
|
+
spec.authors = ["Devin Wadsworth"]
|
10
|
+
spec.email = ["devinwadsworth@gmail.com"]
|
11
|
+
spec.summary = "Simple Dropbox photo management."
|
12
|
+
spec.description = "Group photos into folders by month."
|
13
|
+
spec.homepage = "https://github.com/daymun/photobox"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_runtime_dependency "rainbow", "~> 2.0"
|
24
|
+
spec.add_runtime_dependency "thor", "~> 0.19"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: photobox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Devin Wadsworth
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-02 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rainbow
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.19'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.19'
|
69
|
+
description: Group photos into folders by month.
|
70
|
+
email:
|
71
|
+
- devinwadsworth@gmail.com
|
72
|
+
executables:
|
73
|
+
- photobox
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/photobox
|
84
|
+
- lib/photobox.rb
|
85
|
+
- lib/photobox/cli.rb
|
86
|
+
- lib/photobox/version.rb
|
87
|
+
- photobox.gemspec
|
88
|
+
homepage: https://github.com/daymun/photobox
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.2
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Simple Dropbox photo management.
|
112
|
+
test_files: []
|