class Massa::Tool

Attributes

command[R]
description[R]
gem[R]
gem?[R]
name[R]
required[R]
required?[R]

Public Class Methods

list() click to toggle source
# File lib/massa/tool.rb, line 19
def list
  tools = custom_tools.any? ? custom_tools : default_tools

  tools.map { |name, attributes| new(name, attributes) }
end
new(name, attributes) click to toggle source
# File lib/massa/tool.rb, line 7
def initialize(name, attributes)
  @name        = name
  @description = attributes['description']
  @gem         = attributes['gem'].nil? ? true : attributes['gem']
  @command     = attributes['command']
  @required    = attributes['required'].nil? ? true : attributes['required']
end

Private Class Methods

config_file_from_gem() click to toggle source
# File lib/massa/tool.rb, line 40
def config_file_from_gem
  File.expand_path('../../config/default_tools.yml', __dir__)
end
config_file_from_project() click to toggle source
# File lib/massa/tool.rb, line 44
def config_file_from_project
  "#{Dir.pwd}/config/massa.yml"
end
custom_tools() click to toggle source
# File lib/massa/tool.rb, line 31
def custom_tools
  # Returns an empty hash if config file is empty
  @custom_tools ||= YAML.load_file(config_file_from_project) || {}

# When there is no config file in the project
rescue Errno::ENOENT
  {}
end
default_tools() click to toggle source
# File lib/massa/tool.rb, line 27
def default_tools
  @default_tools ||= YAML.load_file(config_file_from_gem)
end