Sha256: 034f6ba97383bbfa3b53874e4b603280d3bd7445b76a38b01d5313dd8ffe4210

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

require 'yaml'

require 'hound/tools/template'

module Hound
  module Tools
    class HoundYml
      include Template

      def initialize
        super('.hound.yml')
      end

      def rubocop_filename
        data = IO.read(filename)
        _validate(data)
        YAML.load(data)['ruby']['config_file']
      end

      private

      def _validate(data)
        config = YAML.load(data)
        ruby = config['ruby']
        fail InvalidTemplate, "No 'ruby' section" unless ruby
        fail InvalidTemplate, "Expected 'ruby' section to be a hash, got #{ruby.inspect}" unless ruby.is_a?(Hash)
        fail InvalidTemplate, "No 'config_file' section" unless ruby.key?('config_file')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hound-tools-0.0.6 lib/hound/tools/hound_yml.rb
hound-tools-0.0.5 lib/hound/tools/hound_yml.rb
hound-tools-0.0.4 lib/hound/tools/hound_yml.rb