dependable 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.
@@ -1,5 +1,5 @@
1
1
  module Dependable
2
2
 
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
 
5
5
  end
data/lib/dependable.rb CHANGED
@@ -1,3 +1,35 @@
1
1
  module Dependable
2
-
2
+
3
+ module Dependency
4
+
5
+ def dependencies=(dependencies)
6
+ raise ArgumentError.new('Dependencies must be enumerable') unless dependencies.kind_of?(Enumerable) # TODO debatable whether this should be here
7
+ @dependencies = dependencies
8
+ end
9
+
10
+ def dependencies
11
+ @dependencies || []
12
+ end
13
+
14
+ def load_path(include_self = true)
15
+ load = []
16
+ @dependencies.each do |dependency|
17
+ load.concat dependency.load_path
18
+ end if @dependencies
19
+ load << self if include_self
20
+ load.uniq!
21
+ load
22
+ end
23
+
24
+ def print_load_path(include_self = true)
25
+ load = self.load_path(include_self)
26
+ load.each_with_index do |thing, index|
27
+ print "#{index + 1}) #{thing}"
28
+ print " (requires: #{thing.dependencies.join(',')})" unless thing.dependencies.empty?
29
+ puts
30
+ end
31
+ end
32
+
33
+ end
34
+
3
35
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Crepezzi