Sha256: 5c8643f2047cd48b7fd6c8fc377032dfe113da069a13ab0b30469913e214f04e

Contents?: true

Size: 807 Bytes

Versions: 3

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

module Massa
  class Tool
    class << self
      def list
        default_tools.each_with_object({}) do |(tool, options), hash|
          hash[tool] = options.merge(custom_tools[tool] || {})
          hash
        end
      end

      private

      def default_tools
        YAML.load_file(config_file_from_gem)
      end

      def custom_tools
        # Returns an empty hash if config file is empty
        YAML.load_file(config_file_from_project) || {}

      # When there is no config file in the project
      rescue Errno::ENOENT
        {}
      end

      def config_file_from_gem
        File.expand_path('../../../config/default_tools.yml', __FILE__)
      end

      def config_file_from_project
        "#{Dir.pwd}/config/massa.yml"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
massa-0.1.5 lib/massa/tool.rb
massa-0.1.4 lib/massa/tool.rb
massa-0.1.3 lib/massa/tool.rb