Skip to content

Instantly share code, notes, and snippets.

@edipofederle
Last active June 18, 2018 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edipofederle/ec143e3fdcd0da482eee7157da84fe21 to your computer and use it in GitHub Desktop.
Save edipofederle/ec143e3fdcd0da482eee7157da84fe21 to your computer and use it in GitHub Desktop.
sdfsdf

$LOAD_PATH

$LOAD_PATH.push('/Users/edipofederle/work/requires')

load('load.rb')

require

$LOAD_PATH.push('/Users/edipofederle/work/requires')

require('load') # first time will executed

require('load') # second time will NOT executed

falar sobre"

$LOADED_FEATURES - ruby keep tracked the fiiles already loaded here

NO NEED extension - THIS IS SHOW RUBY LOAD THE C Code

REQUIRE_RELATIVE

In ~/work

 load('/Users/edipofederle/work/requires/foo.rb')

depois mudar require de foo.rb no bar.rb para require_relative

who do we require gems

This Rubygems code actually replaces the default require method with its own version. That version will look through your installed gems in addition to the directories in $LOAD_PATH. If Rubygems finds the file in your gems, it will add that gem to your $LOAD_PATH:

puts $LOAD_PATH.grep(/json/)

JSO

puts $LOADED_FEATURES.grep(/json/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment