Sha256: d62195be6c6ff4b94ffff6b0003de38cb25cb5a5ec97d8ce0c07f544191dd8cb

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

require_relative "../base"

module Rsg
  module Gemfile
    class CleanupGenerator < Rsg::Generators::Base
      def banner
        say "Cleaning up Gemfile"
      end

      def remove_comments
        gsub_file "Gemfile", /^ *#\s*[^#\n]+\n/, ""
      end

      def remove_tzinfo
        # Remove tzinfo-data since we don't have a need for it in dev / prod env
        gsub_file "Gemfile", /\ngem 'tzinfo-data'[^\n]+\n/, ""
      end

      def remove_extra_whitespace
        gsub_file "Gemfile", /^( *gem[^\n]+)\n\n\n/, "\\1\n\n"
      end

      def isolate_rails_gem
        gsub_file "Gemfile", /^( *)(gem ["']rails["'][^\n]+)\n(?: *)(gem ['"]puma['"][^\n]+)\n$/, "\\1\\2\n\n\\3"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rsg-0.0.1 lib/rsg/generators/gemfile/cleanup_generator.rb