Class: Cover
- Inherits:
-
Object
- Object
- Cover
- Includes:
- SanitizePlugin
- Defined in:
- lib/what_cd/sanitize_plugins/cover.rb
Instance Method Summary collapse
-
#initialize ⇒ Cover
constructor
A new instance of Cover.
- #sanitize(context) ⇒ Object
Constructor Details
#initialize ⇒ Cover
Returns a new instance of Cover.
9 10 11 12 13 14 15 16 17 |
# File 'lib/what_cd/sanitize_plugins/cover.rb', line 9 def initialize @log = Logging.logger[self] @log.appenders = Logging.appenders.stdout if $verbose @log.level = :debug else @log.level = :info end end |
Instance Method Details
#sanitize(context) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/what_cd/sanitize_plugins/cover.rb', line 19 def sanitize(context) path = context[:path] images = Dir.chdir(path) { Dir["*.jpg"] } if images.count == 1 file_name = images[0] file_path = path + file_name new_file_path = path + '00. cover.jpg' File.rename(file_path, new_file_path) elsif images.count > 1 @log.info "Several .jpg files in release directory. Unable to determine cover art." else @log.debug "No .jpg files found in release directory." end return context end |