Sha256: 9dd1e6a6d590dd97a06a7823459f7d86b81ffc81e4e05ede8d6af6ab88442c25

Contents?: true

Size: 1.36 KB

Versions: 34

Compression:

Stored size: 1.36 KB

Contents

require 'method_source'
require 'rspec'

def is_rbx?
  defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
end

def jruby?
  defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
end


module M
  def hello; :hello_module; end
end

$o = Object.new
def $o.hello; :hello_singleton; end

# A comment for hello

  # It spans two lines and is indented by 2 spaces
def hello; :hello; end

# a
# b
def comment_test1; end

 # a
 # b
def comment_test2; end

# a
#
# b
def comment_test3; end

# a

# b
def comment_test4; end


# a
  # b
    # c
# d
def comment_test5; end

# This is a comment for MyLambda
MyLambda = lambda { :lambda }
MyProc = Proc.new { :proc }


name = "name"

M.instance_eval <<-METHOD, __FILE__, __LINE__ + 1
  def hello_#{name}(*args)
    send_mesg(:#{name}, *args)
  end
METHOD

M.class_eval <<-METHOD, __FILE__, __LINE__ + 1
  def hello_#{name}(*args)
    send_mesg(:#{name}, *args)
  end
METHOD

# module_eval to DRY code up
#
M.module_eval <<-METHOD, __FILE__, __LINE__ + 1

  # module_eval is used here
  #
  def hi_#{name}
    @var = #{name}
  end
METHOD

# case where 2 methods are defined inside an _eval block
#
M.instance_eval <<EOF, __FILE__, __LINE__ + 1

  def #{name}_one()
    if 43
      44
    end
  end


  def #{name}_two()
    if 44
      45
    end
  end
EOF

# class_eval without filename and lineno + 1 parameter

M.class_eval "def #{name}_three; @tempfile.#{name}; end"

Version data entries

34 entries across 34 versions & 15 rubygems

Version Path
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/method_source-0.9.2/spec/spec_helper.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/method_source-0.9.2/spec/spec_helper.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/method_source-0.9.2/spec/spec_helper.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
spiral_form-0.1.1 vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb
spiral_form-0.1.0 vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/method_source-0.9.0/spec/spec_helper.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/method_source-0.9.2/spec/spec_helper.rb
chess_engine-0.0.2 vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb
chess_engine-0.0.1 vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb