Class: SceneToolkit::Release

Inherits:
Object
  • Object
show all
Includes:
AutoRename, Helpers, Validations, Validations::Checksum, Validations::Files, Validations::Name, Validations::Playlist
Defined in:
lib/scene_toolkit/release.rb,
lib/scene_toolkit/release/helpers.rb,
lib/scene_toolkit/release/auto_rename.rb,
lib/scene_toolkit/release/validations.rb,
lib/scene_toolkit/release/validations/name.rb,
lib/scene_toolkit/release/validations/files.rb,
lib/scene_toolkit/release/validations/checksum.rb,
lib/scene_toolkit/release/validations/playlist.rb

Defined Under Namespace

Modules: AutoRename, Helpers, Validations

Constant Summary

Constants included from Validations::Files

Validations::Files::REQUIRED_FILES_EXT

Constants included from Validations::Name

Validations::Name::REGEXP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validations::Checksum

included, #valid_checksum?

Methods included from Validations::Playlist

included, #valid_playlist?

Methods included from Validations::Files

included, #valid_files?

Methods included from Validations::Name

included, #valid_name?

Methods included from Helpers

#files

Methods included from AutoRename

#rename!

Methods included from Validations

#valid?

Constructor Details

#initialize(path) ⇒ Release

Returns a new instance of Release.



23
24
25
26
27
# File 'lib/scene_toolkit/release.rb', line 23

def initialize(path)
  @path = File.expand_path(path)
  @name = File.basename(path)
  @errors, @warnings = [], []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



12
13
14
# File 'lib/scene_toolkit/release.rb', line 12

def errors
  @errors
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/scene_toolkit/release.rb', line 11

def name
  @name
end

#pathObject

Returns the value of attribute path.



11
12
13
# File 'lib/scene_toolkit/release.rb', line 11

def path
  @path
end

#warningsObject

Returns the value of attribute warnings.



12
13
14
# File 'lib/scene_toolkit/release.rb', line 12

def warnings
  @warnings
end

Instance Method Details

#heuristic_filename(ext) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/scene_toolkit/release.rb', line 37

def heuristic_filename(ext)
  if candidates = common_filenames
    "#{candidates.first}.#{ext}"
  else
    "00-#{self.name.downcase}.#{ext}"
  end
end

#heuristic_nameObject



29
30
31
32
33
34
35
# File 'lib/scene_toolkit/release.rb', line 29

def heuristic_name
  if candidates = common_filenames
    candidates.first.gsub(/^\d+[-_]/, "")
  else
    self.name
  end
end