lib/danger/danger_core/dangerfile.rb
# Parses the file at a path, optionally takes the content of the file for DI
#
Parses the file at a path, optionally takes the content of the file for DI
Parses the file at a path optionally takes the content of the file for DI
def parse(path, contents = nil)
      print_known_info if verbose
      contents ||= File.open(path, "r:utf-8", &:read)
      if contents.respond_to?(:encoding) && contents.encoding.name != "UTF-8"
        contents.encode!("UTF-8")
      end
      if contents.tr!("“”‘’‛", %(""'''))
        ui.puts "Your #{path.basename} has had smart quotes sanitised. " \
          "To avoid issues in the future, you should not use " \
          "TextEdit for editing it. If you are not using TextEdit, " \
          "you should turn off smart quotes in your editor of choice.".red
      end
      if contents.include?("puts")
        ui.puts "You used `puts` in your Dangerfile. To print out text to GitHub use `message` instead"
      end
      self.defined_in_file = path
      instance_eval do
        begin
          eval_file(contents, path)
        rescue Exception => e
          message = "Invalid `#{path.basename}` file: #{e.message}"
          raise DSLError.new(message, path, e.backtrace, contents)
        end
      end
    end
def parse ( path , contents = nil ) print_known_info if verbose contents ||= File . open ( path , "r:utf-8" , & :read ) if contents . respond_to? ( :encoding ) && contents . encoding . name != "UTF-8" contents . encode! ( "UTF-8" ) end if contents . tr! ( "“”‘’‛", %(""''') ) ui . puts "Your #{path.basename} has had smart quotes sanitised. " "To avoid issues in the future, you should not use " "TextEdit for editing it. If you are not using TextEdit, " "you should turn off smart quotes in your editor of choice." . red end if contents . include? ( "puts" ) ui . puts "You used `puts` in your Dangerfile. To print out text to GitHub use `message` instead" end self . defined_in_file = path instance_eval do begin eval_file ( contents , path ) rescue Exception => e message = "Invalid `#{path.basename}` file: #{e.message}" raise DSLError . new ( message , path , e . backtrace , contents ) end end end
Parses the file at a path, optionally takes the content of the file for DI
Parses the file at a path optionally takes the content of the file for DI
# Work around for Rubinius incomplete encoding in 1.9 mode # Changes have been made # rubocop:disable Lint/RescueException # rubocop:enable Lint/RescueException
path
<not_specific>
contents
<not_specific>