media-organizer 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/media-organizer.rb +1 -7
- data/lib/renamer.rb +13 -17
- metadata +1 -1
data/lib/media-organizer.rb
CHANGED
@@ -9,13 +9,7 @@ require 'filescanner.rb'
|
|
9
9
|
# *Image
|
10
10
|
# *Music
|
11
11
|
module MediaOrganizer
|
12
|
-
VERSION = "0.1.
|
13
|
-
|
14
|
-
class FileNotValidError < StandardError ; end
|
15
|
-
class InvalidArgumentError < StandardError ; end
|
16
|
-
class UnsupportedFileTypeError < StandardError ; end
|
17
|
-
class RenameFailedError < StandardError ; end
|
18
|
-
class FileNotFoundError < StandardError ; end
|
12
|
+
VERSION = "0.1.4"
|
19
13
|
|
20
14
|
end
|
21
15
|
|
data/lib/renamer.rb
CHANGED
@@ -9,14 +9,13 @@ module MediaOrganizer
|
|
9
9
|
#Renamer: primary class to use for renaming files. Allows renaming of a given list of files to a user-defined scheme based on each file's metadata.
|
10
10
|
#
|
11
11
|
#===Key Methods
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
#* setNamingScheme()
|
13
|
+
#* generateRenameList()
|
14
|
+
#* overwrite()
|
15
15
|
#
|
16
16
|
#===Example Usage
|
17
17
|
#
|
18
18
|
# old_uris = ['./test/data/hs-2003-24-a-full_tif.tif']
|
19
|
-
#
|
20
19
|
# scheme = ["Test-", :date_time]
|
21
20
|
#
|
22
21
|
# r = Renamer.new()
|
@@ -44,29 +43,26 @@ module MediaOrganizer
|
|
44
43
|
@subchar = "_"
|
45
44
|
end
|
46
45
|
|
47
|
-
#Renamer.setNamingScheme(): sets the naming scheme for the generateRenameList method.
|
46
|
+
# Renamer.setNamingScheme(): sets the naming scheme for the generateRenameList method.
|
47
|
+
#
|
48
|
+
# @param [Array<String, Symbol>] arr contains strings and symbols representing the naming scheme.
|
48
49
|
#
|
49
|
-
|
50
|
-
# 1. Array containing strings and symbols.
|
50
|
+
# @return [void] instance variable @naming_scheme is set based upon input
|
51
51
|
#
|
52
|
-
|
53
|
-
#
|
52
|
+
# @example Set the naming scheme to a format like "Vacation_Photos_2014_05_22.png" based on the file's date_taken metadata field.
|
53
|
+
# setNamingScheme(["Vacation_Photos_", :date_taken]).
|
54
54
|
#
|
55
|
-
#===Example
|
56
|
-
#setNamingScheme(["Vacation_Photos_", :date_taken]).
|
57
|
-
#This will rename files into a format like "Vacation_Photos_2014_05_22.png" based on the file's date_taken metadata field.
|
58
55
|
def setNamingScheme(arr = [])
|
59
56
|
@naming_scheme = setScheme(arr)
|
60
57
|
end
|
61
58
|
|
62
59
|
#Renamer.generateRenameList(): Creates a hash mapping the original filenames to the new (renamed) filenames
|
63
60
|
#
|
64
|
-
|
65
|
-
#
|
66
|
-
#
|
67
|
-
# *:scheme - array of strings and symbols specifying file naming convention
|
61
|
+
# @param [Array<String>] uri_list contains list of URIs (as full AKA absolute paths)
|
62
|
+
# @param [Hash] args hash of options.
|
63
|
+
# @option args [Array<String, Symbol>] :scheme - array of strings and symbols specifying file naming convention
|
68
64
|
#
|
69
|
-
|
65
|
+
# @return [Hash] filename_pairs - mapping between old filenames and new filenames
|
70
66
|
#Hash of "file name pairs." old_file => new_file
|
71
67
|
def generateRenameList(uri_list = [], args = {})
|
72
68
|
if args[:scheme] != nil && args[:scheme].is_a?(Array) && !args[:scheme].empty?
|