tlapse 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tlapse/capture.rb +5 -0
- data/lib/tlapse/cli/alpha.rb +5 -4
- data/lib/tlapse/logger.rb +18 -0
- data/lib/tlapse/util.rb +19 -8
- data/lib/tlapse/version.rb +1 -1
- data/lib/tlapse/video.rb +2 -5
- data/lib/tlapse.rb +1 -0
- data/tlapse.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f3adbb41bc2f796a89682bce9c9acc2f0ff157b64f76ecaab982bc8d45410c
|
4
|
+
data.tar.gz: f6a341d65c081eea20ea5c6308f5c480cfe30b9a479dfc8ba5393c4a23e63c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2718ee2c921fcf2aed699c76244989b50296f39fe187d057a7243c4933ad44c0e5295fef503749f4da194e3180f6bdf56d3b260de93d3825a97844d74be4c715
|
7
|
+
data.tar.gz: 633b08728398c25eb02c0e595b09ffcbafaff222beccc7d6abef730f0d92ab325a4c01ea542aa3506a5c75f9e9acb234b84f2c85df819261e703cd8606fba8f8
|
data/lib/tlapse/capture.rb
CHANGED
@@ -4,11 +4,16 @@ module Tlapse
|
|
4
4
|
module Capture
|
5
5
|
|
6
6
|
CAPTURE_FILENAME = "%Y-%m-%d_%H-%M-%S.jpg"
|
7
|
+
CAPTURE_DIRNAME = "%Y-%m-%d"
|
7
8
|
|
8
9
|
def self.capture_filename
|
9
10
|
CAPTURE_FILENAME
|
10
11
|
end
|
11
12
|
|
13
|
+
def self.capture_dirname
|
14
|
+
CAPTURE_DIRNAME
|
15
|
+
end
|
16
|
+
|
12
17
|
def self.capture_single
|
13
18
|
`gphoto2 --capture-image-and-download --filename '#{capture_filename}'`
|
14
19
|
end
|
data/lib/tlapse/cli/alpha.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "thor"
|
2
|
+
require "rainbow"
|
2
3
|
|
3
4
|
module Tlapse::CLI
|
4
5
|
class Alpha < Thor
|
@@ -41,7 +42,7 @@ module Tlapse::CLI
|
|
41
42
|
FileUtils.rm video.outfile
|
42
43
|
puts "Removed file #{video.outfile}"
|
43
44
|
else
|
44
|
-
|
45
|
+
Tlapse::Logger.error! "#{video.outfile} exists. Use -f to overwrite or " \
|
45
46
|
"-o to specify a different output file."
|
46
47
|
end
|
47
48
|
end
|
@@ -49,13 +50,13 @@ module Tlapse::CLI
|
|
49
50
|
video.create!
|
50
51
|
end
|
51
52
|
|
52
|
-
desc "
|
53
|
+
desc "organize", "Cannonically organize pictures in the current directory"
|
53
54
|
option :dry_run,
|
54
55
|
desc: "Print out what would change without actually changing anything",
|
55
56
|
type: :boolean,
|
56
57
|
default: false
|
57
|
-
def
|
58
|
-
Tlapse::Util.
|
58
|
+
def organize
|
59
|
+
Tlapse::Util.organize! dry_run: options[:dry_run]
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rainbow"
|
2
|
+
|
3
|
+
module Tlapse
|
4
|
+
class Logger
|
5
|
+
ERROR_COLOR = :red
|
6
|
+
|
7
|
+
def self.error(message)
|
8
|
+
puts Rainbow(message).fg ERROR_COLOR
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# Print the error message and then exit
|
13
|
+
def self.error!(message, exit_code: 1)
|
14
|
+
error message
|
15
|
+
exit exit_code
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/tlapse/util.rb
CHANGED
@@ -2,18 +2,29 @@ require "fileutils"
|
|
2
2
|
|
3
3
|
module Tlapse
|
4
4
|
class Util
|
5
|
-
def self.
|
5
|
+
def self.organize!(dry_run: false)
|
6
6
|
Dir["*.jpg"].each do |filename|
|
7
|
-
|
8
|
-
if filename != normalized
|
9
|
-
puts "Rename #{filename} to #{normalized}"
|
10
|
-
FileUtils.mv(filename, normalized) unless dry_run
|
11
|
-
end
|
7
|
+
normalize_path! filename, dry_run: dry_run
|
12
8
|
end
|
13
9
|
end
|
14
10
|
|
15
|
-
def self.
|
16
|
-
|
11
|
+
def self.normalize_path!(file, dry_run: false)
|
12
|
+
dirname = normalized_dirname(file)
|
13
|
+
FileUtils.mkdir dirname unless File.exist? dirname || dry_run
|
14
|
+
|
15
|
+
filename = normalized_filename(file)
|
16
|
+
path = File.join dirname, filename
|
17
|
+
|
18
|
+
puts "Rename #{file} to #{path}"
|
19
|
+
FileUtils.mv file, path unless dry_run
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.normalized_dirname(file)
|
23
|
+
File.mtime(file).strftime(Tlapse::Capture.capture_dirname)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.normalized_filename(file)
|
27
|
+
File.mtime(file).strftime(Tlapse::Capture.capture_filename)
|
17
28
|
end
|
18
29
|
end
|
19
30
|
end
|
data/lib/tlapse/version.rb
CHANGED
data/lib/tlapse/video.rb
CHANGED
data/lib/tlapse.rb
CHANGED
data/tlapse.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlapse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Toniazzo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,20 @@ dependencies:
|
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0.20'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rainbow
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3'
|
138
|
+
type: :runtime
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '3'
|
131
145
|
description:
|
132
146
|
email:
|
133
147
|
- jutonz42@gmail.com
|
@@ -154,6 +168,7 @@ files:
|
|
154
168
|
- lib/tlapse/cli/alpha.rb
|
155
169
|
- lib/tlapse/cli/cli.rb
|
156
170
|
- lib/tlapse/doctor.rb
|
171
|
+
- lib/tlapse/logger.rb
|
157
172
|
- lib/tlapse/server.rb
|
158
173
|
- lib/tlapse/solar_event.rb
|
159
174
|
- lib/tlapse/util.rb
|