Sha256: 91af8df4f5a2d1cecfbb4f36bd01069fc954d01b5c75bb589f594e97c4ad8ef9

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'ehbrs_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Music
    class LyricsBook
      require_sub __FILE__

      DEFAULT_PROVIDER_NAME = 'lyrics.com'
      DEFAULT_TITLE = 'Letras de músicas'

      enable_listable
      lists.add_symbol :option, :provider_name, :title
      enable_simple_cache
      common_constructor :source_dir, :options, default: [{}] do
        self.source_dir = source_dir.to_pathname
        self.options = self.class.lists.option.hash_keys_validate!(options)
      end

      def first_previous
        nil
      end

      def header_index
        1
      end

      def output
        erb_template('main.html.erb')
      end

      def path
        source_dir
      end

      def title
        options[OPTION_TITLE].if_present(DEFAULT_TITLE)
      end

      private

      def albums_directories_uncached
        r = []
        t = ::EacRubyUtils::Fs::Traverser.new
        t.recursive = true
        t.check_directory = ->(directory) { r << directory }
        t.check_path(source_dir)
        r
      end

      def albums_uncached
        ::EhbrsRubyUtils::Music::LyricsBook::Album.create_list(self, albums_directories)
      end

      def provider_uncached
        ::UltimateLyrics::Provider.by_name(provider_name)
      end

      def provider_name
        options[OPTION_PROVIDER_NAME].if_present(DEFAULT_PROVIDER_NAME)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ehbrs_ruby_utils-0.12.1 lib/ehbrs_ruby_utils/music/lyrics_book.rb
ehbrs-tools-0.28.2 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book.rb
ehbrs-tools-0.28.1 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book.rb
ehbrs_ruby_utils-0.12.0 lib/ehbrs_ruby_utils/music/lyrics_book.rb
ehbrs-tools-0.28.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book.rb