bowler 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,18 +13,19 @@ module Bowler
13
13
  @definition = definition
14
14
  end
15
15
 
16
- def dependencies_for(processes)
17
- processes.inject([]) do |array, p|
18
- array += [ (@definition.tree[p] || []), p ].flatten
19
- end.uniq
16
+ def dependencies_for(processes, visited = [])
17
+ return [] unless processes
18
+ (processes - visited).map { |p|
19
+ [dependencies_for(@definition.tree[p], visited + [p]), p]
20
+ }.flatten.compact.uniq
20
21
  end
21
22
 
22
23
  def process_list_for(processes)
23
24
  on = dependencies_for(processes)
24
- off = @definition.processes.reject {|i| on.include? i }
25
+ off = @definition.processes - on
25
26
 
26
27
  [ on.map {|x| "#{x}=1" }, off.map {|x| "#{x}=0" } ].flatten.sort.join(',')
27
28
  end
28
29
 
29
30
  end
30
- end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module Bowler
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -15,6 +15,18 @@ module Bowler
15
15
  tree.dependencies_for([:foo]).should =~ [:bar, :foo, :required]
16
16
  tree.dependencies_for([:nyan]).should =~ [:bar, :foo, :nyan, :required]
17
17
  end
18
+
19
+ it "should find the dependencies of dependencies" do
20
+ tree = DependencyTree.load File.join( File.dirname(__FILE__), 'fixtures', 'dependency_tree_pinfile' )
21
+
22
+ tree.dependencies_for([:cat]).should =~ [:cat, :nyan, :bar, :foo, :required]
23
+ end
24
+
25
+ it "should correctly handle recursive dependencies" do
26
+ tree = DependencyTree.load File.join( File.dirname(__FILE__), 'fixtures', 'dependency_tree_pinfile' )
27
+
28
+ tree.dependencies_for([:loop1]).should =~ [:loop1, :loop2, :required]
29
+ end
18
30
  end
19
31
 
20
32
  context "given an array of one process" do
data/spec/dsl_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'bowler'
2
+ require_relative 'helpers/definition_helper'
2
3
 
3
4
  module Bowler
4
5
 
@@ -2,4 +2,7 @@ dependency :required
2
2
 
3
3
  process :foo => :bar
4
4
  process :nyan => [:foo, :bar]
5
- process :rick
5
+ process :cat => :nyan
6
+ process :loop1 => :loop2
7
+ process :loop2 => :loop1
8
+ process :rick
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bowler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-17 00:00:00.000000000Z
12
+ date: 2012-04-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: foreman
16
- requirement: &70109390703300 !ruby/object:Gem::Requirement
16
+ requirement: &70208968322280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70109390703300
24
+ version_requirements: *70208968322280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70109390702060 !ruby/object:Gem::Requirement
27
+ requirement: &70208968321020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.2.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70109390702060
35
+ version_requirements: *70208968321020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70109390694280 !ruby/object:Gem::Requirement
38
+ requirement: &70208968319640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 2.8.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70109390694280
46
+ version_requirements: *70208968319640
47
47
  description:
48
48
  email:
49
49
  - jordan@jordanh.net
@@ -80,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  segments:
82
82
  - 0
83
- hash: -3332018436335453637
83
+ hash: -4084858017591319005
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: -3332018436335453637
92
+ hash: -4084858017591319005
93
93
  requirements: []
94
94
  rubyforge_project:
95
95
  rubygems_version: 1.8.12