Sha256: ba46a3af3cc714e7c6cad4324e4d14fcd5eff3ef97ab671b90c36f1f2634828e

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

# Create a .test.env and a .development.env for your different local
# environments
require 'dotenv'
require 'colored'
require 'readline'

paths = %W(.env .env.#{ENV['APP_ENV']}).map { |name| "#{Dir.pwd}/#{name}" }
Dotenv.load(*paths).each { |k, v| ENV[k] = v }

require 'movie_organizer/version'
require 'midwire_common/string'

module MovieOrganizer
  def self.root
    Pathname.new(File.dirname(__FILE__)).parent
  end

  def self.current_environment
    ENV.fetch('APP_ENV', 'development')
  end

  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

  def self.source_directories(settings = Settings.new, test_response = nil)
    settings[:new_media_directories] || begin
      strings = prompt_for('Media source directories (separated by a colon)', test_response)
      strings.split(':')
    end
  end

  #:nocov:
  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
  #:nocov:

  autoload :FileCopier, 'movie_organizer/file_copier'
  autoload :Logger,     'movie_organizer/logger'
  autoload :Media,      'movie_organizer/media'
  autoload :MediaList,  'movie_organizer/media_list'
  autoload :Movie,      'movie_organizer/movie'
  autoload :Organizer,  'movie_organizer/organizer'
  autoload :Settings,   'movie_organizer/settings'
  autoload :TvShow,     'movie_organizer/tv_show'
  autoload :Video,      'movie_organizer/video'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
movie_organizer-0.1.0 lib/movie_organizer.rb