codependency 2.3.1 → 2.3.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.
- data/lib/codependency/graph.rb +12 -10
- data/lib/codependency/version.rb +1 -1
- metadata +2 -2
data/lib/codependency/graph.rb
CHANGED
@@ -9,14 +9,10 @@ module Codependency
|
|
9
9
|
# the value is the array of relative paths to its dependencies.
|
10
10
|
# Any dependent files will also be recursively added to this
|
11
11
|
# graph.
|
12
|
-
def require(
|
13
|
-
file = path_to string
|
14
|
-
|
12
|
+
def require( file )
|
15
13
|
return if key?( file )
|
16
14
|
|
17
|
-
self[ file ]
|
18
|
-
path_to path[ short ]
|
19
|
-
end
|
15
|
+
self[ file ] = deps( file )
|
20
16
|
self[ file ].each do |dependency|
|
21
17
|
self.require dependency
|
22
18
|
end
|
@@ -28,8 +24,8 @@ module Codependency
|
|
28
24
|
# dependencies to the graph. A file in this glob is not added
|
29
25
|
# to the graph unless another file in the glob depends on it.
|
30
26
|
def scan( glob )
|
31
|
-
Dir[ glob ].
|
32
|
-
self.require
|
27
|
+
Dir[ glob ].flat_map { |f| deps( f ) }.uniq.each do |dependency|
|
28
|
+
self.require dependency
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
@@ -75,13 +71,19 @@ module Codependency
|
|
75
71
|
|
76
72
|
##
|
77
73
|
# Returns the given path, relative to the `#root` path.
|
78
|
-
def path_to(
|
79
|
-
path = Pathname(
|
74
|
+
def path_to( file )
|
75
|
+
path = Pathname( file )
|
80
76
|
.expand_path
|
81
77
|
.relative_path_from( root )
|
82
78
|
.to_path
|
83
79
|
|
84
80
|
path.start_with?( '.' ) ? path : File.join( '.', path )
|
85
81
|
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Parses the file and returns the relative paths to its dependencies.
|
85
|
+
def deps( file )
|
86
|
+
parser.parse( file ).map { |f| path_to path[ f ] }
|
87
|
+
end
|
86
88
|
end
|
87
89
|
end
|
data/lib/codependency/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codependency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|