urirequire 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/urirequire.rb +24 -0
  2. data/lib/urirequire.rb~ +18 -0
  3. metadata +38 -0
data/lib/urirequire.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'open-uri'
2
+
3
+ module UriRequire
4
+ Version = '0.1.0'
5
+
6
+ @@orig_require = Kernel.method :require
7
+
8
+ def self.orig_require; @@orig_require; end
9
+ end
10
+
11
+ def require( library_name )
12
+ if library_name =~ /^(http|https|ftp):\/\//
13
+ begin
14
+ contents = open( library_name ) do |f| f.gets( nil ); end
15
+ rescue OpenURI::HTTPError
16
+ library_name += '.rb'
17
+ contents = open( library_name ) do |f| f.gets( nil ); end
18
+ end
19
+ eval contents
20
+ else
21
+ UriRequire.orig_require.call library_name
22
+ end
23
+ end
24
+
@@ -0,0 +1,18 @@
1
+ require 'open-uri'
2
+
3
+ module UriRequire
4
+ @@orig_require = Kernel.method :require
5
+
6
+ def self.orig_require; @@orig_require; end
7
+ end
8
+
9
+ def require( library_name )
10
+ if library_name =~ /^(http|https|ftp):\/\//
11
+ library_name += '.rb' unless library_name =~ /\.rb$/
12
+ contents = open( library_name ) do |f| f.gets( nil ); end
13
+ eval contents
14
+ else
15
+ UriRequire.orig_require.call library_name
16
+ end
17
+ end
18
+
metadata ADDED
@@ -0,0 +1,38 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.6
3
+ specification_version: 1
4
+ name: urirequire
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2005-11-01
8
+ summary: urirequire hijacks Kernel.require to download and eval Ruby code somewhere else on the internets.
9
+ require_paths:
10
+ - lib
11
+ email: sera@fhwang.net
12
+ homepage: http://rubyforge.org/projects/urirequire/
13
+ rubyforge_project:
14
+ description: urirequire hijacks Kernel.require to download and eval Ruby code somewhere else on the internets.
15
+ autorequire: urirequire
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
25
+ version:
26
+ platform: ruby
27
+ authors:
28
+ - Francis Hwang
29
+ files:
30
+ - lib/urirequire.rb
31
+ - lib/urirequire.rb~
32
+ test_files: []
33
+ rdoc_options: []
34
+ extra_rdoc_files: []
35
+ executables: []
36
+ extensions: []
37
+ requirements: []
38
+ dependencies: []