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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05c79cb1ebafb8041b0bec716670c93a3338f7bd9c7eefdede3bced629797aee
4
- data.tar.gz: 5ac5492c545731497b09c717db5a71cf43b902f97d920a34fa9c9fe99de38111
3
+ metadata.gz: 95f3adbb41bc2f796a89682bce9c9acc2f0ff157b64f76ecaab982bc8d45410c
4
+ data.tar.gz: f6a341d65c081eea20ea5c6308f5c480cfe30b9a479dfc8ba5393c4a23e63c78
5
5
  SHA512:
6
- metadata.gz: dbc3c2f6bfc6f6a1581e6c2a4f17e3ef6d9de3f42f017b4c42cbd6ab03236849bbe151c576b5a018c398c5d6b5600e743388ea3a05bfb54d6cdc669e8b9a2c81
7
- data.tar.gz: 50630cc133c3b139bb01054817f1f18979ad93211c3545a77d033d02d170eb1e54ebf691c86e85d69c9ccbd19f736b97c824ee841ca4f4d0d6139448d44aa4aa
6
+ metadata.gz: 2718ee2c921fcf2aed699c76244989b50296f39fe187d057a7243c4933ad44c0e5295fef503749f4da194e3180f6bdf56d3b260de93d3825a97844d74be4c715
7
+ data.tar.gz: 633b08728398c25eb02c0e595b09ffcbafaff222beccc7d6abef730f0d92ab325a4c01ea542aa3506a5c75f9e9acb234b84f2c85df819261e703cd8606fba8f8
@@ -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
@@ -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
- raise "#{video.outfile} exists. Use -f to overwrite or " \
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 "normalize", "Cannonically organize pictures in the current directory"
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 normalize
58
- Tlapse::Util.normalize! dry_run: options[:dry_run]
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.normalize!(dry_run: false)
5
+ def self.organize!(dry_run: false)
6
6
  Dir["*.jpg"].each do |filename|
7
- normalized = normalize_filename(filename)
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.normalize_filename(file)
16
- File.mtime(file).strftime(Tlapse::Capture::CAPTURE_FILENAME)
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
@@ -1,3 +1,3 @@
1
1
  module Tlapse
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
data/lib/tlapse/video.rb CHANGED
@@ -21,11 +21,8 @@ module Tlapse
21
21
  exec command
22
22
  end
23
23
 
24
- ##
25
- # @return whether the output file already exists
26
24
  def outfile_exists?
27
25
  File.exist? @outfile
28
26
  end
29
-
30
- end # Video
31
- end # Tlapse
27
+ end
28
+ end
data/lib/tlapse.rb CHANGED
@@ -5,6 +5,7 @@ require_relative "tlapse/video"
5
5
  require_relative "tlapse/server"
6
6
  require_relative "tlapse/solar_event"
7
7
  require_relative "tlapse/util"
8
+ require_relative "tlapse/logger"
8
9
 
9
10
  include Tlapse::Doctor
10
11
  include Tlapse::Capture
data/tlapse.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "activesupport", ">= 5.0.0.beta3", "< 5.1"
28
28
  spec.add_dependency "RubySunrise", "~> 0.3"
29
29
  spec.add_dependency "thor", "~> 0.20"
30
+ spec.add_dependency "rainbow", "~> 3"
30
31
  end
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.2
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-20 00:00:00.000000000 Z
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