Module: Kernel

Defined in:
lib/uri/common.rb,
lib/syntax_suggest/core_ext.rb,
lib/rubygems/core_ext/kernel_gem.rb,
lib/rubygems/core_ext/kernel_warn.rb,
lib/rubygems/core_ext/kernel_require.rb,
ext/psych/lib/psych/y.rb,
ext/json/lib/json/common.rb,
ext/objspace/lib/objspace/trace.rb,
lib/pp.rb

Overview

– Monkey patch kernel to ensure that all ‘require` calls call the same method ++

Constant Summary collapse

RUBYGEMS_ACTIVATION_MONITOR =

:nodoc:

Monitor.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.3.1Object

.<internal:Object

.l!Object

.load(file, wrap = false) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/syntax_suggest/core_ext.rb', line 84

def load(file, wrap = false)
  syntax_suggest_original_load(file)
rescue SyntaxError => e
  require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)

  SyntaxSuggest.handle_error(e)
end

.pp(*objs) ⇒ Object

prints arguments in pretty form.

pp returns argument(s).



646
647
648
649
650
651
# File 'lib/pp.rb', line 646

def pp(*objs)
  objs.each {|obj|
    PP.pp(obj)
  }
  objs.size <= 1 ? objs.first : objs
end

.require(file) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/rubygems/core_ext/kernel_require.rb', line 36

def require(file)
  syntax_suggest_original_require(file)
rescue SyntaxError => e
  require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)

  SyntaxSuggest.handle_error(e)
end

.require_relative(file) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/syntax_suggest/core_ext.rb', line 100

def require_relative(file)
  if Pathname.new(file).absolute?
    syntax_suggest_original_require file
  else
    relative_from = caller_locations(1..1).first
    relative_from_path = relative_from.absolute_path || relative_from.path
    syntax_suggest_original_require File.expand_path("../#{file}", relative_from_path)
  end
rescue SyntaxError => e
  require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)

  SyntaxSuggest.handle_error(e)
end

.syntax_suggest_original_loadObject



82
# File 'lib/syntax_suggest/core_ext.rb', line 82

alias_method :syntax_suggest_original_load, :load

.syntax_suggest_original_requireObject



80
# File 'lib/syntax_suggest/core_ext.rb', line 80

alias_method :syntax_suggest_original_require, :require

.syntax_suggest_original_require_relativeObject



81
# File 'lib/syntax_suggest/core_ext.rb', line 81

alias_method :syntax_suggest_original_require_relative, :require_relative

.uplevelObject

.URI(uri) ⇒ Object

Returns a URI object derived from the given uri, which may be a URI string or an existing URI object:

# Returns a new URI.
uri = URI('http://github.com/ruby/ruby')
# => #<URI::HTTP http://github.com/ruby/ruby>
# Returns the given URI.
URI(uri)
# => #<URI::HTTP http://github.com/ruby/ruby>


842
843
844
845
846
847
848
849
850
851
# File 'lib/uri/common.rb', line 842

def URI(uri)
  if uri.is_a?(URI::Generic)
    uri
  elsif uri = String.try_convert(uri)
    URI.parse(uri)
  else
    raise ArgumentError,
      "bad argument (expected URI object or URI string)"
  end
end

.warnObject

Instance Method Details

#Pathname(str) ⇒ Object

:call-seq:

Pathname(path)  -> pathname

Creates a new Pathname object from the given string, path, and returns pathname object.

In order to use this constructor, you must first require the Pathname standard library extension.

require ‘pathname’ Pathname(“/home/zzak”) #=> #<Pathname:/home/zzak>

See also Pathname::new for more information.



1311
1312
1313
1314
1315
1316
1317
# File 'ext/pathname/pathname.c', line 1311

static VALUE
path_f_pathname(VALUE self, VALUE str)
{
    if (CLASS_OF(str) == rb_cPathname)
        return str;
    return rb_class_new_instance(1, &str, rb_cPathname);
}

#pretty_inspectObject

Returns a pretty printed object as a string.

See the PP module for more information.



639
640
641
# File 'lib/pp.rb', line 639

def pretty_inspect
  PP.pp(self, ''.dup)
end

#rb_eval_string(str) ⇒ Object



3
4
5
6
7
# File 'ext/-test-/eval/eval.c', line 3

static VALUE
eval_string(VALUE self, VALUE str)
{
    return rb_eval_string(StringValueCStr(str));
}

#register_sample_bug_reporter(obj) ⇒ Object



13
14
15
16
17
18
# File 'ext/-test-/bug_reporter/bug_reporter.c', line 13

static VALUE
register_sample_bug_reporter(VALUE self, VALUE obj)
{
    rb_bug_reporter_add(sample_bug_reporter, (void *)(uintptr_t)NUM2INT(obj));
    return Qnil;
}