Sha256: 59cb8e3edff656f4209f31fefffa07e9c6eff988bc7afeed8f58d639b83d675a
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
namespace :album do desc "metadata handling for a given album" namespace :metadata do desc "generate metadata for an album in a given path" task :generate do puts "" print "Type the album path: " path = STDIN.gets.chomp if File.directory?(path) puts "Title:" title = STDIN.gets.chomp unless title.nil? puts "Description (optional):" description = STDIN.gets.chomp puts "Author (optional):" author = STDIN.gets.chomp info = {"album" => {"title" => title, "description" => description, "author" => author}} File.open("#{path}/.info.yml", 'w+') {|f| f.write(info.to_yaml) } else puts "Title cannot be empty. Run the task again" end else puts "Sorry but #{path.inspect} entered is not a folder. Run the task again" end end desc "retrieve metadata album based on path" task :check do puts "" print "Type the album path: " path = STDIN.gets.chomp info_file = "#{path}/.info.yml" if File.directory?(path) && File.exists?(info_file) data = YAML.load_file(info_file)['album'] puts "Title: #{data['title']}" puts "Description: #{data['description']}" puts "Author: #{data['author']}" else puts "Sorry but #{path.inspect} entered is not a folder. Run the task again" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
picturama-0.0.6 | lib/tasks/album.rake |
picturama-0.0.5 | lib/tasks/album.rake |