backload 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6eec43b6ba7ca6e7e25802ed27c2261990fc1e2acfb3b59d5b23dbe0baa716a4
4
+ data.tar.gz: eac21f66471c21fb39aa11525ad20cd082770181fd171a9849344d2993267813
5
+ SHA512:
6
+ metadata.gz: 1ece03104c9c63514f0b9bfe57ec6258e69ba740d52d45bf0d0c544b17fd6a45fac274c2d92d2fa3032192b35c7771085aa428de36b3e8eea5c1740d718bcf34
7
+ data.tar.gz: f5e5b12a6c35740dfeb2c2e4e05af02622769b888c9969015019ea8d4e3d810043b623a6b025452f98ee9beefa458cf13351ab9861b930a6ae3750949a26505c
data/HISTORY.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## 0.3.0 / 2026-11-26
4
+
5
+ Backload is revived, for Ruby 3.1 and up.
6
+
7
+ Changes:
8
+
9
+ * Add `Kernel.backloading`, called before every load. Until now there
10
+ were only callbacks for afterwards. (#4)
11
+ * Add the `:depth` option, which says how many loads a load is inside
12
+ of, so that what required what can be shown as a tree. (#2)
13
+ * Add `backload/trace`, which prints that tree:
14
+ `ruby -rbackload/trace script.rb`.
15
+ * The `require_relative` callback is always on. It no longer has to be
16
+ asked for with `backload/require_relative`. That file, and
17
+ `backload/require` and `backload/load`, now just load Backload.
18
+ * `Kernel.required_relative` is given the directory as a second
19
+ argument. A callback that takes only the feature still works. (#5)
20
+ * The hooks are put in place with `Module#prepend` instead of aliases.
21
+ * The callbacks are no longer defined as empty methods, so defining one
22
+ doesn't warn of a method redefined.
23
+ * Tests run on Spectrum.
24
+
25
+ Fixes:
26
+
27
+ * `require_relative` raised "Can't parse" on current Ruby, whose
28
+ backtrace lines have changed. The directory now comes from
29
+ `caller_locations`.
30
+
31
+
3
32
  ## 0.2.0 / 2012-12-22
4
33
 
5
34
  Change the name of the project from Loaded to Backload, and
data/README.md CHANGED
@@ -1,74 +1,111 @@
1
- [Homepage](http://rubygems.org/gems/backload) |
2
- [Report Issue](http://github.com/rubyworks/backload/issues) |
3
- [Source Code](http://github.com/rubyworks/backload)
4
- ( [![Build Status](https://secure.travis-ci.org/rubyworks/backload.png)](http://travis-ci.org/rubyworks/backload) )
1
+ # Backload
5
2
 
3
+ [Source Code](https://github.com/rubyworks/backload) /
4
+ [Report Issue](https://github.com/rubyworks/backload/issues)    
5
+ [![CI](https://github.com/rubyworks/backload/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyworks/backload/actions/workflows/ci.yml)
6
6
 
7
- # Backload
7
+ **Shouldn't loading have a callback?**
8
8
 
9
- Shouldn't loading have a callback?
9
+ Backload gives Ruby's `require`, `require_relative` and `load` callbacks,
10
+ before and after, so a program can see what is loaded, when, and from
11
+ inside what. It needs Ruby 3.1 or newer.
10
12
 
13
+ $ gem install backload
11
14
 
12
- ## Installation
13
15
 
14
- Using RubyGems type on a command line:
16
+ ## Seeing what a program loads
15
17
 
16
- $ gem install backload
18
+ To print every load as a tree, without writing anything:
19
+
20
+ $ ruby -rbackload/trace script.rb
17
21
 
22
+ require json
23
+ require json/common
24
+ require json/version
25
+ require_relative lib/thing
26
+ require set
18
27
 
19
- ## Instruction
28
+ The tree goes to standard error. Each line is printed as the load starts,
29
+ and is indented by how many loads it is inside of. A feature that was
30
+ already loaded is still listed, since it was asked for.
20
31
 
21
- To use Backload simply override the `Kernel.backloaded` method.
32
+
33
+ ## The callbacks
34
+
35
+ For anything else, require `backload` and define the callbacks you want
36
+ as methods of `Kernel`. None of them exists until you define it.
22
37
 
23
38
  ```ruby
24
- require 'backload'
25
- require 'backload/require_relative'
26
-
27
- def Kernel.backloaded(feature, options={})
28
- if options[:require]
29
- if rel = options[:relative]
30
- puts "#{feature} has been required relative to #{rel}!"
31
- else
32
- puts "#{feature} has been required!"
33
- end
39
+ require 'backload'
40
+
41
+ def Kernel.backloading(feature, options={})
42
+ puts "#{' ' * options[:depth]}loading #{feature}"
43
+ end
44
+
45
+ def Kernel.backloaded(feature, options={})
46
+ if options[:require]
47
+ if dir = options[:relative]
48
+ puts "#{feature} has been required relative to #{dir}"
34
49
  else
35
- if wrap = options[:wrap]
36
- puts "#{feature} has been loaded with wrap, it's #{wrap}!"
37
- else
38
- puts "#{feature} has been loaded!"
39
- end
50
+ puts "#{feature} has been required"
40
51
  end
52
+ else
53
+ puts "#{feature} has been loaded"
41
54
  end
55
+ end
42
56
  ```
43
57
 
44
- Becuase of implementation details, `#require_relative` has to be reimplemented completely
45
- to make the callback work. To be on the safe side, at least for now, it therefore has to
46
- be required separately, as the example above demonstrates.
58
+ `Kernel.backloading` is called before every `require`, `require_relative`
59
+ and `load`. `Kernel.backloaded` is called after each one that loaded
60
+ something: not when `require` returns false because the feature was
61
+ loaded before, and not when the load raises.
47
62
 
48
- Backload also provides callbacks for each type of loading. Just use the past tense
49
- of the term for any of `#load`, `#require` and `#require_relative`. For example, to
50
- see all features as they have been required.
63
+ The options say what happened:
64
+
65
+ | Option | Value |
66
+ |-------------|--------------------------------------------------------------|
67
+ | `:require` | true for `require` and `require_relative` |
68
+ | `:load` | true for `load` |
69
+ | `:relative` | for `require_relative`, the directory it is relative to |
70
+ | `:wrap` | for `load`, its second argument |
71
+ | `:depth` | how many loads this one is inside of; 0 at the top |
72
+
73
+ There is also a plain callback for each method, called after it, named by
74
+ its past tense:
51
75
 
52
76
  ```ruby
53
- def Kernel.required(feature)
54
- puts "#{feature} required!"
55
- end
56
- ```
77
+ def Kernel.required(feature)
78
+ puts "#{feature} required"
79
+ end
57
80
 
58
- ## Feedback
81
+ def Kernel.loaded(path, wrap)
82
+ puts "#{path} loaded"
83
+ end
59
84
 
60
- Please report issues or suggestions to
61
- [GitHub Issues](http://github.com/rubyworks/backload/issues).
62
- Or if you wish to discuss in real-time try [IRC #rubyworks](irc://chat.us.freenet.org/rubyworks) on freenode.net.
85
+ def Kernel.required_relative(feature, directory)
86
+ puts "#{feature} required relative to #{directory}"
87
+ end
88
+ ```
63
89
 
64
90
 
65
- ## Copying
91
+ ## Notes
66
92
 
67
- Backload is copyrighted open source software.
93
+ * An `autoload` is seen as the `require` it makes when the constant is
94
+ first used.
95
+ * `require_relative` can't be wrapped like the others, because Ruby works
96
+ out the directory from the file that called it. Backload finds the
97
+ directory itself and requires the file by its full path, which is what
98
+ `require_relative` does. Before 0.3 this had to be asked for with
99
+ `require 'backload/require_relative'`; it is now always on.
100
+ * The hooks are put in front of Kernel's methods with `Module#prepend`,
101
+ so they work alongside RubyGems, Bundler and others that redefine
102
+ `require`.
103
+ * The nesting depth is counted for each thread.
68
104
 
69
- Copyright 2012 Rubyworks.
70
105
 
71
- it is modifiable and redistributable in accordance with the
72
- **BSD-2-Clause** license.
106
+ ## Copying
107
+
108
+ Copyright (c) 2012 Rubyworks
73
109
 
110
+ Backload is distributed under the terms of the **BSD-2-Clause** license.
74
111
  See LICENSE.txt for details.
data/lib/backload/load.rb CHANGED
@@ -1,52 +1,2 @@
1
- module Kernel
2
-
3
- #
4
- # We create a noop method b/c it simplifes implementation.
5
- # Just override this method to use.
6
- #
7
- def self.loaded(path, wrap=nil)
8
- end
9
-
10
- private
11
-
12
- #
13
- # Alias original Kernel#load method.
14
- #
15
- alias_method :load_without_callback, :load
16
-
17
- #
18
- # Redefine Kernel#load with callback.
19
- #
20
- def load(path, wrap=nil)
21
- result = load_without_callback(path, wrap)
22
-
23
- if result
24
- Kernel.loaded(path, wrap)
25
- Kernel.backloaded(path, :load=>true, :require=>false, :wrap=>wrap)
26
- end
27
-
28
- result
29
- end
30
-
31
- class << self
32
- #
33
- # Alias original Kernel.load method.
34
- #
35
- alias_method :load_without_callback, :load
36
-
37
- #
38
- # Redefine Kernel.load with callback.
39
- #
40
- def load(path, wrap=nil)
41
- result = load_without_callback(path, wrap)
42
-
43
- if result
44
- Kernel.loaded(path, wrap)
45
- Kernel.backloaded(path, :load=>true, :require=>false, :wrap=>wrap)
46
- end
47
-
48
- result
49
- end
50
- end
51
-
52
- end
1
+ # Kept so that requiring this file still works. Backload is one file now.
2
+ require 'backload'
@@ -1,52 +1,2 @@
1
- module Kernel
2
-
3
- #
4
- # We create a noop method b/c it simplifes implementation.
5
- # Just override this method to use.
6
- #
7
- def self.required(path)
8
- end
9
-
10
- private
11
-
12
- #
13
- # Alias original Kernel#require method.
14
- #
15
- alias_method :require_without_callback, :require
16
-
17
- #
18
- # Redefine Kernel#require with callback.
19
- #
20
- def require(feature, options=nil)
21
- result = require_without_callback(feature)
22
-
23
- if result
24
- Kernel.required(feature)
25
- Kernel.backloaded(feature, :require=>true, :load=>false)
26
- end
27
-
28
- result
29
- end
30
-
31
- class << self
32
- #
33
- # Alias original Kernel.require method.
34
- #
35
- alias_method :require_without_callback, :require
36
-
37
- #
38
- # Redefine Kernel.require with callback.
39
- #
40
- def require(feature)
41
- result = require_without_callback(feature)
42
-
43
- if result
44
- Kernel.required(feature)
45
- Kernel.backloaded(feature, :require=>true, :load=>false)
46
- end
47
-
48
- result
49
- end
50
- end
51
-
52
- end
1
+ # Kept so that requiring this file still works. Backload is one file now.
2
+ require 'backload'
@@ -1,89 +1,4 @@
1
- module Kernel
2
-
3
- #
4
- # We create a noop method b/c it simplifes implementation.
5
- # Just override this method to use.
6
- #
7
- # Presently this is an optional feature and must be required
8
- # separately via `backload/require_relative`.
9
- #
10
- def self.required_relative(path)
11
- end
12
-
13
- private
14
-
15
- #
16
- # Alias original Kernel#require_relative method.
17
- #
18
- alias_method :require_relative_without_callback, :require_relative
19
-
20
- #
21
- # Redefine Kernel#require_relative with callback.
22
- #
23
- # @todo It would nice if the `:relative` option were set to the
24
- # realtive path, but that would require `Binding.of_caller`.
25
- #
26
- def require_relative(feature)
27
- #result = require_relative_without_callback(feature)
28
-
29
- ## We have to reimplement #require_relative instead of calling
30
- ## the alias to ensure the proper path is used. (*sad*)
31
- result = (
32
- c = caller.first
33
- fail "Can't parse #{c}" unless c.rindex(/:\d+(:in `.*')?$/)
34
- file = $` # File.dirname(c)
35
- if /\A\((.*)\)/ =~ file # eval, etc.
36
- raise LoadError, "require_relative is called in #{$1}"
37
- end
38
- #options[:relative] = File.dirname(file)
39
- absolute = File.expand_path(feature, File.dirname(file))
40
- require_without_callback(absolute)
41
- )
42
-
43
- if result
44
- Kernel.required_relative(feature)
45
- Kernel.backloaded(feature, :require=>true, :load=>false, :relative=>File.dirname(file))
46
- end
47
-
48
- result
49
- end
50
-
51
- class << self
52
- #
53
- # Alias original Kernel.require_relative method.
54
- #
55
- alias_method :require_relative_without_callback, :require_relative
56
-
57
- #
58
- # Redefine Kernel.require_relative with callback.
59
- #
60
- # @todo It would nice if the `:relative` option were set to the
61
- # realtive path, but that would require `Binding.of_caller`.
62
- #
63
- def require_relative(feature)
64
- #result = require_relative_without_callback(feature)
65
-
66
- ## We have to reimplement #require_relative instead of calling
67
- ## the alias to ensure the proper path is used. (*sad*)
68
- result = (
69
- c = caller.first
70
- fail "Can't parse #{c}" unless c.rindex(/:\d+(:in `.*')?$/)
71
- file = $` # File.dirname(c)
72
- if /\A\((.*)\)/ =~ file # eval, etc.
73
- raise LoadError, "require_relative is called in #{$1}"
74
- end
75
- #options[:relative] = File.dirname(file)
76
- absolute = File.expand_path(feature, File.dirname(file))
77
- require_without_callback absolute
78
- )
79
-
80
- if result
81
- Kernel.required_relative(feature)
82
- Kernel.backloaded(feature, :require=>true, :load=>false, :relative=>File.dirname(file))
83
- end
84
-
85
- result
86
- end
87
- end
88
-
89
- end
1
+ # Before 0.3, the #require_relative callback had to be asked for with
2
+ # this file. It is now part of Backload itself, and this file is kept
3
+ # so that requiring it still works.
4
+ require 'backload'
@@ -0,0 +1,17 @@
1
+ # Print every load as it starts, to standard error, indented by how deep
2
+ # it is, so the output reads as a tree of what required what.
3
+ #
4
+ # $ ruby -rbackload/trace script.rb
5
+ #
6
+ # require json
7
+ # require json/common
8
+ # require json/version
9
+ # require_relative lib/thing
10
+ #
11
+ # A feature that was already loaded is still listed, as it was asked for.
12
+ require 'backload'
13
+
14
+ def Kernel.backloading(feature, options={})
15
+ word = options[:load] ? 'load' : (options[:relative] ? 'require_relative' : 'require')
16
+ $stderr.puts "#{' ' * options[:depth]}#{word} #{feature}"
17
+ end
@@ -0,0 +1,3 @@
1
+ module Backload
2
+ VERSION = '0.3.0'
3
+ end
data/lib/backload.rb CHANGED
@@ -1,29 +1,136 @@
1
- require 'backload/load'
2
- require 'backload/require'
3
- #require 'backload/require_relative'
1
+ require 'backload/version'
4
2
 
5
- module Kernel
3
+ # Backload gives Ruby's loading methods callbacks.
4
+ #
5
+ # To use it, define any of these methods of Kernel (none of them exists
6
+ # until you do):
7
+ #
8
+ # Kernel.backloading(feature, options) # before a load or require
9
+ # Kernel.backloaded(feature, options) # after one that loaded something
10
+ #
11
+ # The options say what happened:
12
+ #
13
+ # :require true for #require and #require_relative
14
+ # :load true for #load
15
+ # :relative for #require_relative, the directory it is relative to
16
+ # :wrap for #load, its second argument
17
+ # :depth how many loads this one is inside of (0 at the top)
18
+ #
19
+ # There are also plain callbacks for each method, called after it:
20
+ # Kernel.required(feature), Kernel.loaded(path, wrap) and
21
+ # Kernel.required_relative(feature, directory).
22
+ #
23
+ # The "after" callbacks are called only when something was loaded: not
24
+ # when #require returns false because the feature was loaded before, and
25
+ # not when it raises. The "before" callback is called every time.
26
+ #
27
+ module Backload
28
+
29
+ # The methods put in front of Kernel's own.
30
+ HOOKS = proc do
31
+
32
+ #
33
+ def require(feature)
34
+ Backload.around(feature, :require=>true, :load=>false) do
35
+ super
36
+ end
37
+ end
38
+
39
+ #
40
+ def load(path, wrap=false)
41
+ Backload.around(path, :load=>true, :require=>false, :wrap=>wrap) do
42
+ super
43
+ end
44
+ end
45
+
46
+ # Ruby's #require_relative works out the directory from the file that
47
+ # called it, so it can't be called from here on that file's behalf.
48
+ # Instead the directory is found here and the feature required by
49
+ # its full path, which is what #require_relative does.
50
+ def require_relative(feature)
51
+ feature = feature.to_path if feature.respond_to?(:to_path)
52
+ location = caller_locations(1, 1).first
53
+ base = location && (location.absolute_path || location.path)
54
+ if base.nil? || !File.file?(base)
55
+ raise LoadError, "cannot infer basepath"
56
+ end
57
+ dir = File.dirname(File.realpath(base))
58
+ path = File.expand_path(feature, dir)
59
+ Backload.around(feature, :require=>true, :load=>false, :relative=>dir) do
60
+ Backload.without_callbacks{ require(path) }
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ # The hooks for Kernel's module methods, which are public.
67
+ module Hooks
68
+ module_eval(&HOOKS)
69
+ end
70
+
71
+ # The hooks for Kernel's instance methods, which are private.
72
+ module PrivateHooks
73
+ module_eval(&HOOKS)
74
+ private :require, :load, :require_relative
75
+ end
6
76
 
7
- # Common callback for all loading methods: #load, #require
8
- # and #require_relative.
9
- #
10
- # @param [Hash] options
11
- # The load callback options.
12
- #
13
- # @option options [Boolean] :load
14
- # True if #load was used.
15
- #
16
- # @option options [Boolean] :require
17
- # True is #require or #require_relative was used.
18
- #
19
- # @option options [Boolean] :relative
20
- # True is #require_relative was used.
21
- #
22
- # @option options [Boolean] :wrap
23
- # The wrap argument passed to #load.
24
- #
25
- def self.backloaded(path, options={})
77
+ # Run a load between the callbacks. The block does the loading.
78
+ def self.around(feature, options)
79
+ # A load made on another's behalf (see #without_callbacks) is passed
80
+ # over, once: the loads made inside it are reported as usual.
81
+ if Thread.current[:backload_off]
82
+ Thread.current[:backload_off] = false
83
+ return yield
84
+ end
85
+
86
+ depth = (Thread.current[:backload_depth] ||= 0)
87
+ options = options.merge(:depth=>depth)
88
+
89
+ Kernel.backloading(feature, options) if Kernel.respond_to?(:backloading)
90
+
91
+ Thread.current[:backload_depth] = depth + 1
92
+ begin
93
+ result = yield
94
+ ensure
95
+ Thread.current[:backload_depth] = depth
96
+ end
97
+
98
+ if result
99
+ if options[:load]
100
+ Kernel.loaded(feature, options[:wrap]) if Kernel.respond_to?(:loaded)
101
+ elsif options[:relative]
102
+ if Kernel.respond_to?(:required_relative)
103
+ if Kernel.method(:required_relative).arity == 1
104
+ Kernel.required_relative(feature)
105
+ else
106
+ Kernel.required_relative(feature, options[:relative])
107
+ end
108
+ end
109
+ else
110
+ Kernel.required(feature) if Kernel.respond_to?(:required)
111
+ end
112
+ Kernel.backloaded(feature, options) if Kernel.respond_to?(:backloaded)
113
+ end
114
+
115
+ result
116
+ end
117
+
118
+ # Run a block in which the outermost load isn't reported. Loads made
119
+ # by the file being loaded are.
120
+ def self.without_callbacks
121
+ old = Thread.current[:backload_off]
122
+ Thread.current[:backload_off] = true
123
+ yield
124
+ ensure
125
+ Thread.current[:backload_off] = old
26
126
  end
27
127
 
28
128
  end
29
129
 
130
+ module Kernel
131
+ prepend Backload::PrivateHooks
132
+
133
+ class << self
134
+ prepend Backload::Hooks
135
+ end
136
+ end
metadata CHANGED
@@ -1,120 +1,110 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
- - Thomas Sawyer
9
- autorequire:
7
+ - Trans
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2012-12-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
- name: microtest
13
+ name: rake
16
14
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
15
  requirements:
19
- - - ! '>='
16
+ - - ">="
20
17
  - !ruby/object:Gem::Version
21
- version: '0'
18
+ version: '13'
22
19
  type: :development
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
22
  requirements:
27
- - - ! '>='
23
+ - - ">="
28
24
  - !ruby/object:Gem::Version
29
- version: '0'
25
+ version: '13'
30
26
  - !ruby/object:Gem::Dependency
31
- name: detroit
27
+ name: rubytest
32
28
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
29
  requirements:
35
- - - ! '>='
30
+ - - ">="
36
31
  - !ruby/object:Gem::Version
37
- version: '0'
32
+ version: 0.11.1
38
33
  type: :development
39
34
  prerelease: false
40
35
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
36
  requirements:
43
- - - ! '>='
37
+ - - ">="
44
38
  - !ruby/object:Gem::Version
45
- version: '0'
39
+ version: 0.11.1
46
40
  - !ruby/object:Gem::Dependency
47
- name: rake
41
+ name: spectrum
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0.2'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0.2'
54
+ - !ruby/object:Gem::Dependency
55
+ name: assay
48
56
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
57
  requirements:
51
- - - ! '>='
58
+ - - ">="
52
59
  - !ruby/object:Gem::Version
53
- version: '0'
60
+ version: 0.5.1
54
61
  type: :development
55
62
  prerelease: false
56
63
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
64
  requirements:
59
- - - ! '>='
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
62
- description: ! 'Backload provides callbacks for Ruby''s #require and #load methods.'
67
+ version: 0.5.1
68
+ description: 'Backload gives Ruby''s #require, #require_relative and #load callbacks,
69
+ before and after, so a program can see what is loaded, when, and from inside what.'
63
70
  email:
64
71
  - transfire@gmail.com
65
72
  executables: []
66
73
  extensions: []
67
- extra_rdoc_files:
68
- - LICENSE.txt
74
+ extra_rdoc_files: []
75
+ files:
69
76
  - HISTORY.md
77
+ - LICENSE.txt
70
78
  - README.md
71
- files:
72
- - .index
73
- - lib/backload/autoload.rb
79
+ - lib/backload.rb
74
80
  - lib/backload/load.rb
75
81
  - lib/backload/require.rb
76
82
  - lib/backload/require_relative.rb
77
- - lib/backload.rb
78
- - test/fixtures/example_load.rb
79
- - test/fixtures/example_relative.rb
80
- - test/fixtures/example_require.rb
81
- - test/helper.rb
82
- - test/test_load.rb
83
- - test/test_require.rb
84
- - test/test_require_relative.rb
85
- - LICENSE.txt
86
- - HISTORY.md
87
- - README.md
88
- homepage: http://rubyworks.github.com/backload
83
+ - lib/backload/trace.rb
84
+ - lib/backload/version.rb
85
+ homepage: https://github.com/rubyworks/backload
89
86
  licenses:
90
87
  - BSD-2-Clause
91
- post_install_message:
88
+ metadata:
89
+ source_code_uri: https://github.com/rubyworks/backload
90
+ bug_tracker_uri: https://github.com/rubyworks/backload/issues
91
+ changelog_uri: https://github.com/rubyworks/backload/blob/master/HISTORY.md
92
+ documentation_uri: https://rubydoc.info/gems/backload
92
93
  rdoc_options: []
93
94
  require_paths:
94
95
  - lib
95
96
  required_ruby_version: !ruby/object:Gem::Requirement
96
- none: false
97
97
  requirements:
98
- - - ! '>='
98
+ - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: '0'
100
+ version: '3.1'
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
- none: false
103
102
  requirements:
104
- - - ! '>='
103
+ - - ">="
105
104
  - !ruby/object:Gem::Version
106
105
  version: '0'
107
106
  requirements: []
108
- rubyforge_project:
109
- rubygems_version: 1.8.23
110
- signing_key:
111
- specification_version: 3
112
- summary: ! 'Callbacks for #require and #load.'
113
- test_files:
114
- - test/test_require.rb
115
- - test/helper.rb
116
- - test/test_require_relative.rb
117
- - test/test_load.rb
118
- - test/fixtures/example_require.rb
119
- - test/fixtures/example_load.rb
120
- - test/fixtures/example_relative.rb
107
+ rubygems_version: 3.6.9
108
+ specification_version: 4
109
+ summary: 'Callbacks for Ruby''s #require and #load'
110
+ test_files: []
data/.index DELETED
@@ -1,53 +0,0 @@
1
- ---
2
- type: ruby
3
- revision: 2013
4
- sources:
5
- - var
6
- authors:
7
- - name: Thomas Sawyer
8
- email: transfire@gmail.com
9
- organizations: []
10
- requirements:
11
- - groups:
12
- - test
13
- development: true
14
- name: microtest
15
- - groups:
16
- - build
17
- development: true
18
- name: detroit
19
- - groups:
20
- - build
21
- development: true
22
- name: rake
23
- conflicts: []
24
- alternatives: []
25
- resources:
26
- - type: home
27
- uri: http://rubyworks.github.com/backload
28
- label: Homepage
29
- - type: code
30
- uri: http://github.com/rubyworks/backload
31
- label: Source Code
32
- - type: bugs
33
- uri: http://github.com/rubyworks/backload/issues
34
- label: Issue Tracker
35
- repositories:
36
- - name: upstream
37
- scm: git
38
- uri: git://github.com/rubyworks/backload.git
39
- categories: []
40
- paths:
41
- load:
42
- - lib
43
- copyrights:
44
- - holder: Rubyworks
45
- year: '2012'
46
- license: BSD-2-Clause
47
- created: '2012-04-29'
48
- summary: ! 'Callbacks for #require and #load.'
49
- title: Backload
50
- version: 0.2.0
51
- name: backload
52
- description: ! 'Backload provides callbacks for Ruby''s #require and #load methods.'
53
- date: '2012-12-23'
@@ -1,12 +0,0 @@
1
- # This does not look doable in pure Ruby.
2
-
3
- #module Kernel
4
- #
5
- # #
6
- # # We create a noop method b/c it simplifes implementation.
7
- # # Just override this method to use.
8
- # #
9
- # def self.autoloaded(path, options={})
10
- # end
11
- #
12
- #end
@@ -1,2 +0,0 @@
1
- # example ruby file
2
- 1 + 1
@@ -1,2 +0,0 @@
1
- # example ruby file
2
- 1 + 1
@@ -1,2 +0,0 @@
1
- # example ruby file
2
- 1 + 1
data/test/helper.rb DELETED
@@ -1,25 +0,0 @@
1
- # Load our test framework.
2
- require 'microtest'
3
- require 'microtest/assertions'
4
-
5
- # Load the library to be tested.
6
- require 'backload'
7
-
8
- # Put our load fixtures on the load path.
9
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/fixtures')
10
-
11
- # We use this setup to test each possible load configuration.
12
- def Kernel.backloaded(name, opts)
13
- $load_name = name
14
- $load_opts = opts
15
- end
16
-
17
- # Old version of Microtest lacks #refute.
18
- module MicroTest::Assertions
19
- unless method_defined?(:refute)
20
- def refute(fact, msg=nil)
21
- __assert__(!fact, msg)
22
- end
23
- end
24
- end
25
-
data/test/test_load.rb DELETED
@@ -1,17 +0,0 @@
1
- require File.expand_path('helper', File.dirname(__FILE__))
2
-
3
- class RequiredTestCase < MicroTest::TestCase
4
-
5
- def test_load
6
- load 'example_load.rb'
7
-
8
- assert_equal 'example_load.rb', $load_name
9
-
10
- refute $load_opts[:require]
11
- refute $load_opts[:relative]
12
- assert $load_opts[:load]
13
- refute $load_opts[:wrap]
14
- end
15
-
16
- end
17
-
data/test/test_require.rb DELETED
@@ -1,17 +0,0 @@
1
- require File.expand_path('helper', File.dirname(__FILE__))
2
-
3
- class RequiredTestCase < MicroTest::TestCase
4
-
5
- def test_require
6
- require 'example_require'
7
-
8
- assert_equal 'example_require', $load_name
9
-
10
- assert $load_opts[:require]
11
- refute $load_opts[:relative]
12
- refute $load_opts[:load]
13
- refute $load_opts[:wrap]
14
- end
15
-
16
- end
17
-
@@ -1,21 +0,0 @@
1
- require File.expand_path('helper', File.dirname(__FILE__))
2
-
3
- require 'backload/require_relative' # optional feature
4
-
5
- class RequiredTestCase < MicroTest::TestCase
6
-
7
- def test_require_relative
8
- require_relative 'fixtures/example_relative'
9
-
10
- assert_equal 'fixtures/example_relative', $load_name
11
-
12
- assert $load_opts[:require]
13
- assert $load_opts[:relative]
14
- refute $load_opts[:load]
15
- refute $load_opts[:wrap]
16
-
17
- assert_equal File.dirname(__FILE__), $load_opts[:relative]
18
- end
19
-
20
- end
21
-