module MovieOrganizer

:nocov:

A cached movie lookup instance

A cached TV show lookup instance

Constants

VERSION

Public Class Methods

config_file(filename = '.movie_organizer.yml') click to toggle source
# File lib/movie_organizer.rb, line 20
def self.config_file(filename = '.movie_organizer.yml')
  return root.join('spec', 'fixtures', filename) if current_environment == 'test'
  #:nocov:
  home = ENV.fetch('HOME')
  file = ENV.fetch('MO_CONFIG_FILE', File.join(home, '.movie_organizer.yml'))
  FileUtils.touch(file)
  file
  #:nocov:
end
current_environment() click to toggle source
# File lib/movie_organizer.rb, line 16
def self.current_environment
  ENV.fetch('APP_ENV', 'development')
end
movie_directory(settings = Settings.instance, test_response = nil) click to toggle source
# File lib/movie_organizer.rb, line 64
def self.movie_directory(settings = Settings.instance, test_response = nil)
  return settings[:movies][:directory] if settings[:movies] && settings[:movies][:directory]
  settings[:movies] ||= {}
  settings[:movies][:directory] =
    prompt_for('Movie destination directory', test_response)
  settings.save
  settings[:movies][:directory]
end
options() click to toggle source
# File lib/movie_organizer.rb, line 30
def self.options
  MovieOrganizer::Options.instance
end
os() click to toggle source
# File lib/movie_organizer.rb, line 38
def self.os
  if RUBY_PLATFORM.match?(/cygwin|mswin|mingw|bccwin|wince|emx/)
    :retarded
  else
    :normal
  end
end
prompt_for(message = '', test_response = nil) click to toggle source

:nocov:

# File lib/movie_organizer.rb, line 92
def self.prompt_for(message = '', test_response = nil)
  prompt = "#{message.dup}\n? "
  return test_response if test_response
  Readline.readline(prompt, true).squeeze(' ').strip
end
root() click to toggle source
# File lib/movie_organizer.rb, line 12
def self.root
  Pathname.new(File.dirname(__FILE__)).parent
end
source_directories(settings = Settings.instance, test_response = nil) click to toggle source
# File lib/movie_organizer.rb, line 46
def self.source_directories(settings = Settings.instance, test_response = nil)
  settings[:new_media_directories] || begin
    strings = prompt_for('Media source directories (separated by a colon)', test_response)
    settings[:new_media_directories] = strings.split(':')
    settings.save
    settings[:new_media_directories]
  end
end
tmdb_key(settings = Settings.instance, test_response = nil) click to toggle source
# File lib/movie_organizer.rb, line 55
def self.tmdb_key(settings = Settings.instance, test_response = nil)
  return settings[:movies][:tmdb_key] if settings[:movies] && settings[:movies][:tmdb_key]
  settings[:movies] ||= {}
  settings[:movies][:tmdb_key] =
    prompt_for('TMDB API key (https://www.themoviedb.org/)', test_response)
  settings.save
  settings[:movies][:tmdb_key]
end
tv_shows_directory(settings = Settings.instance, test_response = nil) click to toggle source
# File lib/movie_organizer.rb, line 73
def self.tv_shows_directory(settings = Settings.instance, test_response = nil)
  return settings[:tv_shows][:directory] if settings[:tv_shows] && settings[:tv_shows][:directory]
  settings[:tv_shows] ||= {}
  settings[:tv_shows][:directory] =
    prompt_for('TV show destination directory', test_response)
  settings.save
  settings[:tv_shows][:directory]
end
verbose_puts(string) click to toggle source
# File lib/movie_organizer.rb, line 34
def self.verbose_puts(string)
  Logger.instance.info(" #{string}") if options[:verbose]
end
video_directory(settings = Settings.instance, test_response = nil) click to toggle source
# File lib/movie_organizer.rb, line 82
def self.video_directory(settings = Settings.instance, test_response = nil)
  return settings[:videos][:directory] if settings[:videos] && settings[:videos][:directory]
  settings[:videos] ||= {}
  settings[:videos][:directory] =
    prompt_for('Video destination directory', test_response)
  settings.save
  settings[:videos][:directory]
end