New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Picture set refactoring #16
Conversation
app/models/picture_set.rb
Outdated
class << self | ||
|
||
def all | ||
dirs = Dir.glob(File.join(PICTURE_PATH, "*/*#{ANIMATION_SUFFIX}")).map do |animation| | ||
File.basename(File.dirname(animation)) | ||
end | ||
dirs.sort.reverse.map { |dir| new(dir) } | ||
Rails.logger.warn "No picture sets found at: #{PICTURE_PATH}" if dirs.empty? | ||
dirs.sort.reverse.map { |dir| PictureSet.new(date: dir) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
should be enough then you also don't have the dependency to the class name.
|
||
# Create collage of all images | ||
def combine_images(overwrite: false) | ||
if File.exist?(File.join(dir, combined)) && !overwrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can also introduce a flag for create_combine_images
which we can set in the options. Then we don't need to comment it on the raspberry ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> #19
app/models/picture_set.rb
Outdated
end | ||
|
||
def destroy | ||
Syscall.execute("rm -r #{date}", dir: PICTURE_PATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why you don't use FileUtils.rm_rf?
https://ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-rm_f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should move all file operations to FileUtils, will do.
No description provided.