codependency 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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( string )
13
- file = path_to string
14
-
12
+ def require( file )
15
13
  return if key?( file )
16
14
 
17
- self[ file ] ||= parser.parse( file ).map do |short|
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 ].map { |file| parser.parse( file ) }.flatten.uniq.each do |short|
32
- self.require path[ short ]
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( string )
79
- path = Pathname( string )
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
@@ -1,3 +1,3 @@
1
1
  module Codependency
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.2'
3
3
  end
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.1
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-02 00:00:00.000000000 Z
12
+ date: 2013-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec