include_all 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46036ad3c81b9f418be85c626de15859bc0a2e83c71c099ae9a243dcc3f0ae29
4
- data.tar.gz: 467306c0bd8d1a8a6d3aadc3070aa68a148b3eb31f1058f3d5425593202ad59d
3
+ metadata.gz: f1998f5fa8a2ff35ee7bc685f8bda4bf27713d97f6626387e4c6527fcbede18a
4
+ data.tar.gz: 80b4cfc142c4c613d7d42e5ace879436a907a5f9340168b4b2765bf591e05457
5
5
  SHA512:
6
- metadata.gz: e9dc9b5b43fd3cfdc585dceba844982c6df91d0118326364c6968586834362d672bdeb13dfab122b48dc9d29cf4faac90425e3e833bc0c37659b1f42c4e3227b
7
- data.tar.gz: 179cb94ca59a31083592fd7d1c3fbce14efaaedcf6d30d025df7341c5036d95fc8e3293eb20f2a5f8f4d3cc4a5a6d9cf0924df2231193266086b5bdfe1ab98a7
6
+ metadata.gz: 06cd0207b09f3a9ec8142e49cee00acd05287da925cace67090d410bbaf16bac1b20e9dc1d912b4e0614632747796aa23e13c341122e9ec62f6832668f6030d4
7
+ data.tar.gz: 8289477d2a974545911844ce4417520ac6ef740915e248c88c4179dd22d466bdf0e10ed4dda809f2b0a12d8309a9b0038b416703e87b5ba56efb804dcbfb15eb
data/README.md CHANGED
@@ -1 +1,22 @@
1
1
  # `include_all`
2
+
3
+ You've heard of [`require_all`](https://github.com/jarmo/require_all), now meet `include_all`! Written
4
+ for the purpose of including functions from a `require`'d module without typing them all out, this niche,
5
+ but personally useful, gem shines brightest when used in conjunction with a Ruby monolith.
6
+
7
+ ## Installation
8
+
9
+ `gem install 'include_all'` or include in your `Gemfile`: `gem 'include_all'`
10
+
11
+ ## Usage
12
+
13
+ It's best used after something that has a lot of items you'd like to include but not do so individually.
14
+ Let's assume that the `methods` module has a bunch of stuff we'd like to bring in.
15
+ ```ruby
16
+ require 'require_all`
17
+ require 'include_all`
18
+
19
+ require 'methods'
20
+ include_all
21
+ ```
22
+ The `include_all` gem will automatically _diff_ the list of `require`d objects and figure out what's missing.
data/include_all.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "include_all"
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
  s.authors = ["Douglas Luman"]
5
5
  s.email = "dluman@allegheny.edu"
6
6
  s.summary = "A wonderfully simple way to include modules from your code"
data/lib/include_all.rb CHANGED
@@ -1,13 +1,29 @@
1
1
  # Implmentation of approach described by this SO article:
2
2
  # https://stackoverflow.com/questions/3084325/getting-contents-classes-modules-of-required-files-in-ruby
3
3
 
4
+ # Module declaration
4
5
  module IncludeAll
6
+ # Include all (in the future, a subset) of functionality or
7
+ # classes in a newly-required module
8
+ #
9
+ # Example
10
+ # require_all 'module'
11
+ # include_all
5
12
 
6
13
  def include_all(*args)
7
14
  added = list_objects()
8
- (added - $startup).each { |m| include m }
15
+ (added - $startup).each {
16
+ |m|
17
+ begin
18
+ include m
19
+ rescue TypeError => e
20
+ # Do nothing
21
+ end
22
+ }
23
+ $startup = added
9
24
  end
10
25
 
26
+ # Lists objects in the ObjectSpace on demand
11
27
  def list_objects
12
28
  ObjectSpace.each_object(Module).to_a
13
29
  end
@@ -15,4 +31,6 @@ module IncludeAll
15
31
  end
16
32
 
17
33
  include IncludeAll
34
+
35
+ # Create initial conditions at import
18
36
  $startup = IncludeAll.list_objects()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: include_all
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Luman