codependency 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Guardfile +4 -4
- data/README.md +7 -4
- data/codependency.gemspec +6 -4
- data/lib/codependency.rb +1 -0
- data/lib/codependency/graph.rb +27 -34
- data/lib/codependency/parser.rb +11 -15
- data/lib/codependency/path.rb +53 -0
- data/lib/codependency/version.rb +1 -1
- data/spec/codependency/graph_spec.rb +89 -51
- data/spec/codependency/graph_spec/codependency_graph/files/assets/application.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/files/assets/templates_account.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/files/assets/templates_history.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/files/assets/templates_user.txt +5 -0
- data/spec/codependency/graph_spec/codependency_graph/files/breakfast/butter.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/files/breakfast/egg.txt +4 -0
- data/spec/codependency/graph_spec/codependency_graph/files/breakfast/sandwich.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/files/breakfast/toast.txt +4 -0
- data/spec/codependency/graph_spec/codependency_graph/files/solar_system/body.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/files/solar_system/earth.txt +5 -0
- data/spec/codependency/graph_spec/codependency_graph/files/solar_system/mars.txt +5 -0
- data/spec/codependency/graph_spec/codependency_graph/files/solar_system/phobos.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/files/solar_system/planet.txt +4 -0
- data/spec/codependency/graph_spec/codependency_graph/require/assets/application.txt +11 -0
- data/spec/codependency/graph_spec/codependency_graph/require/assets/templates_account.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/require/assets/templates_history.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/require/assets/templates_user.txt +8 -0
- data/spec/codependency/graph_spec/codependency_graph/require/breakfast/butter.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/require/breakfast/egg.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/require/breakfast/sandwich.txt +13 -0
- data/spec/codependency/graph_spec/codependency_graph/require/breakfast/toast.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/require/lox/money.txt +11 -0
- data/spec/codependency/graph_spec/codependency_graph/require/lox/power.txt +11 -0
- data/spec/codependency/graph_spec/codependency_graph/require/lox/respect.txt +11 -0
- data/spec/codependency/graph_spec/codependency_graph/require/solar_system/body.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/require/solar_system/earth.txt +9 -0
- data/spec/codependency/graph_spec/codependency_graph/require/solar_system/mars.txt +9 -0
- data/spec/codependency/graph_spec/codependency_graph/require/solar_system/phobos.txt +13 -0
- data/spec/codependency/graph_spec/codependency_graph/require/solar_system/planet.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/assets/application.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/assets/templates_account.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/assets/templates_history.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/assets/templates_user.txt +5 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/breakfast/butter.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/breakfast/egg.txt +4 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/breakfast/sandwich.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/breakfast/toast.txt +4 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/solar_system/body.txt +3 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/solar_system/earth.txt +5 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/solar_system/mars.txt +5 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/solar_system/phobos.txt +6 -0
- data/spec/codependency/graph_spec/codependency_graph/tsort/solar_system/planet.txt +4 -0
- data/spec/codependency/parser_spec.rb +48 -40
- data/spec/codependency/path_spec.rb +55 -0
- data/spec/fixtures/assets/application.js +1 -0
- data/spec/fixtures/assets/templates/account.js +1 -0
- data/spec/fixtures/assets/templates/history.js +1 -0
- data/spec/fixtures/assets/templates/user.js +4 -0
- data/spec/fixtures/breakfast/butter.js +1 -0
- data/spec/fixtures/breakfast/egg.js +3 -0
- data/spec/fixtures/breakfast/sandwich.js +4 -0
- data/spec/fixtures/breakfast/toast.js +3 -0
- data/spec/fixtures/lox/money.rb +4 -0
- data/spec/fixtures/lox/power.rb +4 -0
- data/spec/fixtures/lox/respect.rb +4 -0
- data/spec/fixtures/solar_system/body.rb +2 -0
- data/spec/fixtures/solar_system/earth.rb +4 -0
- data/spec/fixtures/solar_system/mars.rb +4 -0
- data/spec/fixtures/solar_system/phobos.rb +5 -0
- data/spec/fixtures/solar_system/planet.rb +4 -0
- data/spec/spec_helper.rb +5 -2
- data/spec/support/approvals.rb +1 -0
- metadata +146 -17
- data/spec/support/breakfasts_context.rb +0 -24
- data/spec/support/circular_context.rb +0 -25
- data/spec/support/file_system_stubs.rb +0 -10
- data/spec/support/planets_context.rb +0 -38
- data/spec/support/subdirectories_context.rb +0 -21
@@ -1,49 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Codependency::Parser do
|
4
|
-
|
5
|
-
|
4
|
+
let( :dirname ){ example.example_group.description }
|
5
|
+
let( :basename ){ example.description }
|
6
|
+
let( :filename ){ "./spec/fixtures/#{dirname}/#{basename}" }
|
7
|
+
let( :file ){ Pathname( filename ) }
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
# TODO convert these to approvals?
|
10
|
+
context 'solar_system' do
|
11
|
+
example 'body.rb' do
|
12
|
+
subject.parse( file ).should == [ ]
|
13
|
+
end
|
14
|
+
example 'earth.rb' do
|
15
|
+
subject.parse( file ).should == [
|
16
|
+
'solar_system/planet'
|
17
|
+
]
|
18
|
+
end
|
19
|
+
example 'mars.rb' do
|
20
|
+
subject.parse( file ).should == [
|
21
|
+
'solar_system/planet'
|
22
|
+
]
|
23
|
+
end
|
24
|
+
example 'phobos.rb' do
|
25
|
+
subject.parse( file ).should == [
|
26
|
+
'solar_system/body',
|
27
|
+
'solar_system/mars'
|
28
|
+
]
|
29
|
+
end
|
30
|
+
example 'planet.rb' do
|
31
|
+
subject.parse( file ).should == [
|
32
|
+
'solar_system/body'
|
33
|
+
]
|
26
34
|
end
|
27
35
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
subject
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
context 'breakfast' do
|
37
|
+
example 'butter.js' do
|
38
|
+
subject.parse( file ).should == [ ]
|
39
|
+
end
|
40
|
+
example 'egg.js' do
|
41
|
+
subject.parse( file ).should == [
|
42
|
+
'breakfast/butter'
|
43
|
+
]
|
44
|
+
end
|
45
|
+
example 'toast.js' do
|
46
|
+
subject.parse( file ).should == [
|
47
|
+
'breakfast/butter'
|
48
|
+
]
|
49
|
+
end
|
50
|
+
example 'sandwich.js' do
|
51
|
+
subject.parse( file ).should == [
|
52
|
+
'breakfast/egg',
|
53
|
+
'breakfast/toast'
|
54
|
+
]
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Codependency::Path do
|
4
|
+
it { should be_an( Array ) }
|
5
|
+
|
6
|
+
describe '#extensions' do
|
7
|
+
it 'contains ".rb" by default' do
|
8
|
+
subject.extensions.should == [ '.rb' ]
|
9
|
+
end
|
10
|
+
it 'accepts an array' do
|
11
|
+
subject = described_class.new [ '.rb', '.js' ]
|
12
|
+
subject.extensions.should == [ '.rb', '.js' ]
|
13
|
+
end
|
14
|
+
it 'accepts a string and turns it into an array' do
|
15
|
+
subject = described_class.new '.js'
|
16
|
+
subject.extensions.should == [ '.js' ]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#<<' do
|
21
|
+
it 'turns paths into pathnames' do
|
22
|
+
subject << './spec/fixtures'
|
23
|
+
subject[ 0 ].should be_a( Pathname )
|
24
|
+
end
|
25
|
+
it 'expands paths as they are added' do
|
26
|
+
subject << './spec/fixtures'
|
27
|
+
subject[ 0 ].to_path.should == File.expand_path( './spec/fixtures' )
|
28
|
+
end
|
29
|
+
it 'raises an exception if the path does not exist' do
|
30
|
+
expect { subject << './spec/mixtures' }.to raise_error( Errno::ENOENT )
|
31
|
+
end
|
32
|
+
it 'raises an exception if the path is not a directory' do
|
33
|
+
expect { subject << __FILE__ }.to raise_error( Errno::ENOTDIR )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#[]' do
|
38
|
+
subject { described_class.new %w| .rb | }
|
39
|
+
before { subject << './spec/fixtures' }
|
40
|
+
|
41
|
+
it 'behaves normally if given an integer' do
|
42
|
+
subject[ 0 ].should_not be_nil
|
43
|
+
subject[ 1 ].should be_nil
|
44
|
+
end
|
45
|
+
it 'returns a pathname if given a string' do
|
46
|
+
subject[ 'solar_system/body' ].should be_a( Pathname )
|
47
|
+
end
|
48
|
+
it 'raises an exception of the file does not exist' do
|
49
|
+
expect { subject[ 'solar_system/pluto' ] }.to raise_error( Errno::ENOENT )
|
50
|
+
end
|
51
|
+
it 'raises an exception of the extension does not match' do
|
52
|
+
expect { subject[ 'breakfast/butter' ] }.to raise_error( Errno::ENOENT )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require assets/templates/user
|