Sha256: 405a262df49ba645febe9dc635487c1311c8e527d748bf85f1b1b7620abb91c1

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'hound/tools/template'
require 'hound/tools/hound_yml'
require 'hound/tools/hound_overrides'

module Hound
  module Tools
    class MergedYml
      include Template

      def initialize
        @todo_file = '.rubocop_todo.yml'

        # NOTE: should be named. .rubocop.yml to prevent RuboCop from traversing
        super('.rubocop_merged_for_hound.yml')
      end

      def generate
        s = StringIO.new
        s.write(<<EOS)
# This is a file generated by `hound-tools`
#
# We don't include .hound/defaults.yml, because Hound has internally
# loaded them at this point
#
EOS
        [HoundOverrides.new.filename, @todo_file].each do |filename|
          s.puts '# ---------------------------------'
          s.puts "# #{filename}"
          s.puts '# ---------------------------------'
          s.puts IO.read(filename)
        end
        Pathname.new(filename).dirname.mkpath
        output_file = HoundYml.new.rubocop_filename
        IO.write(output_file, s.string)

        $stdout.puts "#{output_file} (regenerated)"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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