Sha256: 0329b7dd4edf22b2c58b57f9b0a1073d0a8d9c09103c16578e7e66bff1be80c9
Contents?: true
Size: 993 Bytes
Versions: 4
Compression:
Stored size: 993 Bytes
Contents
# frozen_string_literal: true module ConvenientService module Examples module Rails module V1 class Gemfile module Services class AssertValidRubySyntax include RailsService::Config attribute :content, :string def result ## # NOTE: `> /dev/null 2>&1` is used to hide output. # https://unix.stackexchange.com/a/119650/394253 # check_ruby_syntax_result = Services::RunShellCommand.result(command: "ruby -c #{file.path} > /dev/null 2>&1") return error("`#{content}` contains invalid Ruby syntax") unless check_ruby_syntax_result.success? success end private def file @file ||= ::Tempfile.new.tap { |tempfile| tempfile.write(content) }.tap(&:close) end end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems