Sha256: 09f968bddac30c3e8015c33da14774ff9f809ac590a92719b8ba973c578086c0

Contents?: true

Size: 1.41 KB

Versions: 52

Compression:

Stored size: 1.41 KB

Contents

# :stopdoc:
# WHY do I have to do this?!?
class Regexp
  ONCE = 0 unless defined? ONCE # FIX: remove this - it makes no sense

  unless defined? ENC_NONE then
    ENC_NONE = /x/n.options
    ENC_EUC  = /x/e.options
    ENC_SJIS = /x/s.options
    ENC_UTF8 = /x/u.options
  end
end
# :startdoc:

############################################################
# HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK

unless "".respond_to?(:grep) then
  class String
    def grep re
      lines.grep re
    end
  end
end

class String
  ##
  # This is a hack used by the lexer to sneak in line numbers at the
  # identifier level. This should be MUCH smaller than making
  # process_token return [value, lineno] and modifying EVERYTHING that
  # reduces tIDENTIFIER.

  attr_accessor :lineno

  def clean_caller
    self.sub(File.dirname(__FILE__), "./lib").sub(/:in.*/, "")
  end if $DEBUG
end

require "sexp"

class Sexp
  attr_writer :paren

  def paren
    @paren ||= false
  end

  def value
    raise "multi item sexp" if size > 2
    last
  end

  def to_sym
    raise "no: #{self.inspect}.to_sym is a bug"
    self.value.to_sym
  end

  alias :add :<<

  def add_all x
    self.concat x.sexp_body
  end

  def block_pass?
    any? { |s| Sexp === s && s.sexp_type == :block_pass }
  end

  alias :node_type :sexp_type
  alias :values :sexp_body # TODO: retire
end

# END HACK
############################################################

Version data entries

52 entries across 38 versions & 3 rubygems

Version Path
ruby_parser-3.17.0 lib/rp_extensions.rb
brakeman-5.1.1 bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_extensions.rb
brakeman-5.1.0 bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_extensions.rb
brakeman-5.0.4 bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_extensions.rb
brakeman-5.0.2 bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_extensions.rb
ruby_parser-3.16.0 lib/rp_extensions.rb
brakeman-5.0.1 bundle/ruby/2.7.0/gems/ruby_parser-3.15.1/lib/rp_extensions.rb
brakeman-5.0.0 bundle/ruby/2.7.0/gems/ruby_parser-3.15.1/lib/rp_extensions.rb
ruby_parser-3.15.1 lib/rp_extensions.rb
brakeman-4.10.1 bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/rp_extensions.rb
brakeman-5.0.0.pre1 bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/rp_extensions.rb
brakeman-4.10.0 bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/rp_extensions.rb
brakeman-4.9.1 bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/rp_extensions.rb
ruby_parser-3.15.0 lib/rp_extensions.rb
brakeman-4.9.0 bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/rp_extensions.rb
brakeman-4.8.2 bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/rp_extensions.rb
brakeman-4.8.1 bundle/ruby/2.4.0/gems/ruby_parser-3.14.2/lib/rp_extensions.rb
brakeman-4.8.0 bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/rp_extensions.rb
ruby_parser-3.14.2 lib/rp_extensions.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/brakeman-4.5.1/bundle/ruby/2.5.0/gems/ruby_parser-3.13.1/lib/rp_extensions.rb