media-organizer 0.1.2 → 0.1.3

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.
@@ -8,11 +8,18 @@ require 'scrapers/music.rb'
8
8
 
9
9
  module MediaOrganizer
10
10
 
11
- class FileNotValidError < StandardError ; end
12
11
 
12
+ #FileScanner: scans a file system for images and/or music files, providing a list of file URIs.
13
+ #Output of FileScanner.open() returns a list of paths that can then be consumed by MediaOrganizer::Renamer.
14
+ #
15
+ #===Example
16
+ #
17
+ #Filescanner.open("/path/to/files/", {:image => true, :music => true})
18
+ #
19
+ #This will return a list of all music and image files contained in /path/to/files/ and it's
13
20
  class Filescanner
14
- include Image
15
- include Music
21
+ class FileNotValidError < StandardError ; end
22
+
16
23
 
17
24
  attr_reader :root_nodes
18
25
  attr_accessor :source_list
@@ -26,21 +33,19 @@ module MediaOrganizer
26
33
  #
27
34
  #Filescanner.open(String, {}): scans directory tree for media files, starting at String specified in first argument.
28
35
  #
29
- #==Inputs
30
- #===Required
31
- #(1) String: String containing the URI of the top of the directory tree to scan
36
+ #===Inputs
37
+ # *(1) String: String containing the URI of the top of the directory tree to scan
32
38
  #
33
- #===Optional
34
- #(2) Arguments Hash:
35
- #*:mode => (:single) -- if set to :single, only the given URI will be scanned. Subdirectories will be ignored.
36
- #*:music => (true, false) -- if true, music files will be included in the scan. Set to false to exclude music files. Defaults to true
37
- #*:image => (true, false) -- if true, image files will be included in the scan. Set to false to exclude image files. Defaults to true
39
+ # *2: Optional Arguments Hash:
40
+ # *:mode => (:single) -- if set to :single, only the given URI will be scanned. Subdirectories will be ignored.
41
+ # *:music => (true, false) -- if true, music files will be included in the scan. Set to false to exclude music files. Defaults to true
42
+ # *:image => (true, false) -- if true, image files will be included in the scan. Set to false to exclude image files. Defaults to true
38
43
  #
39
- #==Outputs
44
+ #===Outputs
40
45
  #Returns array of strings, where each string is a file URI for a music or image file.
41
46
  #
42
47
  #
43
- #==Usage Example
48
+ #===Example
44
49
  #Filescanner.open("/absolute/path/for/top/of/directory/tree")
45
50
  #
46
51
  def open(uri = "", args = {})
@@ -72,7 +77,7 @@ module MediaOrganizer
72
77
  return false
73
78
  end
74
79
 
75
- #alternative run mode. Add multiple "root" directories to scan at once
80
+ #Alternative run mode. Add multiple "root" directories to scan at once
76
81
  def addRoot(dir_uri)
77
82
  unless !dir_uri.nil? && dir_uri.is_a?(String) && File.directory?(dir_uri)
78
83
  raise FileNotFoundError, "Directory given (#{dir_uri}) could not be accessed."
@@ -84,23 +89,16 @@ module MediaOrganizer
84
89
  return false
85
90
  end
86
91
 
87
- #<<(): synonym for addRoot(). Also a deformed emoticon.
88
- # def << (dir_uri) addRoot(dir_uri) end
89
-
90
- #
91
- #multiscan(): scans multiple directories added to @root_nodes using the addRoot() method.
92
+ #Filescanner:multiscan(): scans multiple directories added to @root_nodes using the addRoot() method.
92
93
  #
93
- #==Inputs
94
- #===Required
95
- #none
94
+ #===Inputs
96
95
  #
97
- #===Optional
98
- #(1) Arguments Hash:
99
- #*:mode => (:single, :multiple)
100
- #*:music => (true, false) -- if true, music files will be included in the scan. Set to false to exclude music files. Defaults to true
101
- #*:image => (true, false) -- if true, image files will be included in the scan. Set to false to exclude image files. Defaults to true
96
+ # *Optional Arguments Hash:
97
+ # *:mode => (:single, :multiple)
98
+ # *:music => (true, false) -- if true, music files will be included in the scan. Set to false to exclude music files. Defaults to true
99
+ # *:image => (true, false) -- if true, image files will be included in the scan. Set to false to exclude image files. Defaults to true
102
100
  #
103
- #==Outputs
101
+ #===Outputs
104
102
  #Array of strings, where each string is a file URI for a music or image file.
105
103
  #
106
104
  def multiscan(args = {})
@@ -3,8 +3,19 @@
3
3
  require 'renamer.rb'
4
4
  require 'filescanner.rb'
5
5
 
6
+ #MediaOrganizer: namespace container for MediaOrganizer sub-classes:
7
+ # *Renamer
8
+ # *Filescanner
9
+ # *Image
10
+ # *Music
6
11
  module MediaOrganizer
7
12
  VERSION = "0.1.2"
8
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
19
+
9
20
  end
10
21
 
@@ -5,11 +5,6 @@ require 'scrapers/image.rb'
5
5
  require 'scrapers/music.rb'
6
6
 
7
7
  module MediaOrganizer
8
-
9
- class FileNotValidError < StandardError ; end
10
- class InvalidArgumentError < StandardError ; end
11
- class UnsupportedFileTypeError < StandardError ; end
12
- class RenameFailedError < StandardError ; end
13
8
 
14
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.
15
10
  #
@@ -34,6 +29,12 @@ module MediaOrganizer
34
29
  #
35
30
  class Renamer
36
31
  DISALLOWED_CHARACTERS = /[\\:\?\*<>\|"\/]/ #Characters that are not allowed in file names by many file systems. Replaced with @subchar character.
32
+ class RenameFailedError < StandardError ; end
33
+ class FileNotValidError < StandardError ; end
34
+ class InvalidArgumentError < StandardError ; end
35
+ class UnsupportedFileTypeError < StandardError ; end
36
+ class FileNotFoundError < StandardError ; end
37
+
37
38
 
38
39
  attr_accessor :naming_scheme #Array of strings and literals used to construct filenames. Set thruough setNamingScheme as opposed to typical/default accessor.
39
40
  attr_accessor :subchar #Character with which to substitute disallowed characters
@@ -1,11 +1,10 @@
1
1
  require 'exifr'
2
2
 
3
- class FileNotFoundError < StandardError ; end
4
-
5
3
  module MediaOrganizer
6
4
 
7
5
  module Image
8
6
  SUPPORTED_FILETYPES = %w{.jpg .tif}
7
+ class FileNotFoundError < StandardError ; end
9
8
 
10
9
  def Image.getJpegData(file)
11
10
  meta = EXIFR::JPEG.new(file)
@@ -2,9 +2,8 @@ require 'taglib'
2
2
 
3
3
  module MediaOrganizer
4
4
 
5
- class FileNotFoundError < StandardError ; end
6
-
7
5
  module Music
6
+ class FileNotFoundError < StandardError ; end
8
7
 
9
8
  SUPPORTED_FILETYPES = %w{.mp3 .m4a .mp4 .flac .m4a .ogg .aiff .asf .wav}
10
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: media-organizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,55 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-14 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: taglib-ruby
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: exifr
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- description: ! 'Provides a set of functions for scanning directory trees and dynamically
47
- renaming files using their metadata, according to a customizable taxonomy. For example,
48
- use media-organizer to set filenames for a directory of photos to a standard such
49
- as: "<date-taken> - Ski Vacation.jpg". Currently supports only JPEG and TIFF files,
50
- and various music formats.'
12
+ date: 2015-03-24 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! 'Provides a set of functions to scan file systems for media files,
15
+ and dynamically rename them using their metadata. Files are renamed according to
16
+ a customizable taxonomy. For example, use MediaOrganizer::Renamer to set filenames
17
+ for a directory of photos to a standard such as: "<date-taken> - Ski Vacation.jpg".
18
+ Currently supports only JPEG and TIFF files. Future releases will include support
19
+ for music and additional image files.'
51
20
  email: djeserkare@gmail.com
52
21
  executables: []
53
22
  extensions: []
54
23
  extra_rdoc_files: []
55
24
  files:
56
- - lib/media-organizer.rb
57
25
  - lib/renamer.rb
26
+ - lib/media-organizer.rb
58
27
  - lib/filescanner.rb
59
- - lib/scrapers/image.rb
60
28
  - lib/scrapers/music.rb
29
+ - lib/scrapers/image.rb
61
30
  homepage: http://rubygems.org/gems/media-organizer
62
31
  licenses:
63
32
  - MIT
@@ -82,5 +51,5 @@ rubyforge_project:
82
51
  rubygems_version: 1.8.23
83
52
  signing_key:
84
53
  specification_version: 3
85
- summary: Organize & rename files in bulk based on file metadata.
54
+ summary: Rename media files in bulk based on file metadata.
86
55
  test_files: []