def inject_into_file(relative_path, *args, **options, &block)
      check_path(relative_path)
      replacement = block_given? ? block[] : args.join

      flag, match = if options.key?(:after)
                      [:after, options.delete(:after)]
                    else
                      [:before, options.delete(:before)]
                    end

      match = match.is_a?(Regexp) ? match : Regexp.escape(match)
      content = if flag == :after
                  '\0' + replacement
                else
                  replacement + '\0'
                end

      log_status(:inject, relative_path, options.fetch(:verbose, true),
                                         options.fetch(:color, :green))
      replace_in_file(relative_path, /#{match}/, content,
                      options.merge(verbose: false))
    end
def inject_into_file(relative_path, *args, **options, &block)
      check_path(relative_path)
      replacement = block_given? ? block[] : args.join

      flag, match = if options.key?(:after)
                      [:after, options.delete(:after)]
                    else
                      [:before, options.delete(:before)]
                    end

      match = match.is_a?(Regexp) ? match : Regexp.escape(match)
      content = if flag == :after
                  '\0' + replacement
                else
                  replacement + '\0'
                end

      log_status(:inject, relative_path, options.fetch(:verbose, true),
                                         options.fetch(:color, :green))
      replace_in_file(relative_path, /#{match}/, content,
                      options.merge(verbose: false))
    end
Inject content into file at a given location

 @param [String, Pathname] relative_path

 @param [Hash] options
 @option options [Symbol] :before
   the matching line to insert content before
 @option options [Symbol] :after
   the matching line to insert content after
 @option options [Symbol] :force
   insert content more than once
 @option options [Symbol] :verbose
   log status

 @example
   inject_into_file('Gemfile', "gem 'tty'", after: "gem 'rack'\n")

 @example
   inject_into_file('Gemfile', "gem 'tty'\n", "gem 'loaf'", after: "gem 'rack'\n")

 @example
   inject_into_file('Gemfile', after: "gem 'rack'\n") do
     "gem 'tty'\n"
   end

 @api public