codependency 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -1
- data/lib/codependency/node.rb +1 -17
- data/lib/codependency/version.rb +1 -1
- data/spec/codependency/graph_spec.rb +9 -0
- data/spec/support/subdirectories_context.rb +21 -0
- metadata +3 -1
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Codependency
|
2
2
|
|
3
|
-
Codependency is a simple comment-based dependency graph that you can use on arbitrary files.
|
3
|
+
Codependency is a simple comment-based dependency graph that you can use on arbitrary files.
|
4
|
+
|
5
|
+
It uses the program `tsort` under the hood, so sorry windoze I guess?
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
data/lib/codependency/node.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
|
3
1
|
module Codependency
|
4
2
|
class Node
|
5
3
|
def initialize( filename, parser )
|
@@ -14,7 +12,7 @@ module Codependency
|
|
14
12
|
def edges
|
15
13
|
@edges ||= begin
|
16
14
|
parser.parse( filename ).map do |f|
|
17
|
-
|
15
|
+
"#{f}#{File.extname( filename )}"
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
@@ -24,19 +22,5 @@ module Codependency
|
|
24
22
|
def dependencies
|
25
23
|
edges.map { |edge| [ filename, edge ] }.flatten.join ' '
|
26
24
|
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
def dirname
|
31
|
-
path.dirname
|
32
|
-
end
|
33
|
-
|
34
|
-
def extname
|
35
|
-
path.extname
|
36
|
-
end
|
37
|
-
|
38
|
-
def path
|
39
|
-
@path ||= Pathname.new filename
|
40
|
-
end
|
41
25
|
end
|
42
26
|
end
|
data/lib/codependency/version.rb
CHANGED
@@ -33,4 +33,13 @@ describe Codependency::Graph do
|
|
33
33
|
expect { subject.files }.to raise_error( CircularDependencyError )
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
context 'subdirectories', :files => :subdirectories do
|
38
|
+
subject { Codependency::Graph.new graph, :comment => '//' }
|
39
|
+
|
40
|
+
context 'application.js' do
|
41
|
+
let( :graph ){ 'application.js' }
|
42
|
+
its( :files ){ should eq( %w| templates/user/history.js templates/user/account.js templates/user.js application.js | ) }
|
43
|
+
end
|
44
|
+
end
|
36
45
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
shared_context 'subdirectories', :files => :subdirectories do
|
2
|
+
|
3
|
+
before do
|
4
|
+
file 'application.js', <<-EOS
|
5
|
+
// require templates/user
|
6
|
+
EOS
|
7
|
+
|
8
|
+
file 'templates/user.js', <<-EOS
|
9
|
+
// require templates/user/history
|
10
|
+
// require templates/user/account
|
11
|
+
EOS
|
12
|
+
|
13
|
+
file 'templates/user/history.js', <<-EOS
|
14
|
+
var History = { }
|
15
|
+
EOS
|
16
|
+
|
17
|
+
file 'templates/user/account.js', <<-EOS
|
18
|
+
var Account = { }
|
19
|
+
EOS
|
20
|
+
end
|
21
|
+
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: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- spec/support/circular_context.rb
|
87
87
|
- spec/support/file_system_stubs.rb
|
88
88
|
- spec/support/planets_context.rb
|
89
|
+
- spec/support/subdirectories_context.rb
|
89
90
|
homepage: ''
|
90
91
|
licenses: []
|
91
92
|
post_install_message:
|
@@ -119,3 +120,4 @@ test_files:
|
|
119
120
|
- spec/support/circular_context.rb
|
120
121
|
- spec/support/file_system_stubs.rb
|
121
122
|
- spec/support/planets_context.rb
|
123
|
+
- spec/support/subdirectories_context.rb
|