grandprix 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +14 -0
  5. data/Guardfile +24 -0
  6. data/LICENSE +22 -0
  7. data/README.md +118 -0
  8. data/Rakefile +2 -0
  9. data/bin/grandprix +31 -0
  10. data/doc/sample/alongside_elements/elements +4 -0
  11. data/doc/sample/alongside_elements/sample_output +6 -0
  12. data/doc/sample/alongside_elements/topology.yml +11 -0
  13. data/doc/sample/alongside_elements_2/elements +4 -0
  14. data/doc/sample/alongside_elements_2/sample_output +6 -0
  15. data/doc/sample/alongside_elements_2/topology.yml +11 -0
  16. data/doc/sample/annotated_topology/elements +4 -0
  17. data/doc/sample/annotated_topology/sample_output +3 -0
  18. data/doc/sample/annotated_topology/topology.yml +14 -0
  19. data/doc/sample/as_a_library/Gemfile +1 -0
  20. data/doc/sample/as_a_library/sample.rb +29 -0
  21. data/doc/sample/elements_with_extra_info/elements +4 -0
  22. data/doc/sample/elements_with_extra_info/sample_output +3 -0
  23. data/doc/sample/elements_with_extra_info/topology.yml +8 -0
  24. data/doc/sample/simple/elements +4 -0
  25. data/doc/sample/simple/sample_output +4 -0
  26. data/doc/sample/simple/topology.yml +9 -0
  27. data/grandprix.gemspec +17 -0
  28. data/lib/grandprix.rb +9 -0
  29. data/lib/grandprix/elements.rb +98 -0
  30. data/lib/grandprix/graph.rb +105 -0
  31. data/lib/grandprix/planner.rb +62 -0
  32. data/lib/grandprix/runner.rb +6 -0
  33. data/lib/grandprix/version.rb +3 -0
  34. data/spec/lib/grandprix/elements_spec.rb +71 -0
  35. data/spec/lib/grandprix/graph_spec.rb +93 -0
  36. data/spec/lib/grandprix/planner_spec.rb +158 -0
  37. data/spec/lib/grandprix/runner_spec.rb +75 -0
  38. data/spec/matchers_spec.rb +32 -0
  39. data/spec/spec_helper.rb +88 -0
  40. data/version +1 -0
  41. metadata +92 -0
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ # This is an integration test
4
+ describe Grandprix::Runner do
5
+ it "should understand dependencies" do
6
+ topology = {
7
+ "frontend" => {
8
+ "after" => ["backend"]
9
+ },
10
+ "backend" => {
11
+ "after" => ["db", "mq"]
12
+ },
13
+ "client" => {
14
+ "after" => ["frontend"]
15
+ }
16
+ }
17
+
18
+ elements = ["frontend", "db", "client"]
19
+
20
+ subject.run!(topology, elements).names.should == ["db", "frontend", "client"]
21
+ end
22
+
23
+ it "a complex case" do
24
+ topology = {
25
+ "frontend" => {
26
+ "after" => ["backend", "assets"], # frontend depends on assets in addxition to
27
+ "alongside" => ["assets", "images"] # having it declared alongside
28
+ },
29
+ "backend" => {
30
+ "alongside" => ["external_backend"]
31
+ },
32
+ "images" => {
33
+ "after" => ["client"] #images that is an alongside dep of frontend depends on client
34
+ }
35
+ }
36
+
37
+ elements = ["frontend", "client", "backend", "extra"] #extra is not mentioned on the topology
38
+ result = subject.run!(topology, elements)
39
+
40
+ result.names.should =~ ["client", "backend", "external_backend", "frontend", "assets", "images", "extra"]
41
+ result.should beOrderedHaving("backend", "assets").before("frontend")
42
+ result.should beOrderedHaving("backend", "assets").before("frontend", "assets", "images")
43
+ result.should beOrderedHaving("client").before("images")
44
+ end
45
+
46
+ it "REGRESSION" do
47
+ topology = {
48
+ "schumi" => {
49
+ "after" => ["prost", "assets"],
50
+ "alongside" => ["assets"],
51
+ "annotation" => "r7-schumi"
52
+ },
53
+
54
+ "prost" => {
55
+ "alongside" => ["prost_externo"],
56
+ "annotation" => "r7-prost"
57
+ },
58
+
59
+ "assets" => {
60
+ "annotation" => "r7-cms-assets"
61
+ }
62
+ }
63
+
64
+ elements = ["prost=1.2.3"]
65
+ result = subject.run!(topology, elements)
66
+
67
+ expected = [
68
+ "prost_externo=1.2.3",
69
+ "prost=1.2.3=r7-prost"
70
+ ]
71
+
72
+ result.strings.should =~ expected
73
+ end
74
+
75
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Custom rspec matchers" do
4
+ describe :beOrderedHaving do
5
+ context "passing" do
6
+ it { [1,2,3].should beOrderedHaving(1).before(1) }
7
+ it { [1,2,3].should beOrderedHaving(1).before(2) }
8
+ it { [1,2,3].should beOrderedHaving(1).before(3) }
9
+
10
+ it { [1,2,3].should beOrderedHaving(1).before(2,3) }
11
+ it { [1,2,3].should beOrderedHaving(2).before(3) }
12
+
13
+ it { [1,2,3].should beOrderedHaving(1,2).before(3) }
14
+ it { [1,2,3].should beOrderedHaving(2,1).before(3) }
15
+ end
16
+
17
+ context "failing" do
18
+ it { [1,2,3].should_not beOrderedHaving(2).before(1) }
19
+ it { [1,2,3].should_not beOrderedHaving(3).before(1) }
20
+ it { [1,2,3].should_not beOrderedHaving(2,3).before(1) }
21
+
22
+ it { [1,2,3].should_not beOrderedHaving(3).before(2) }
23
+ it { [1,2,3].should_not beOrderedHaving(1,3).before(2) }
24
+
25
+ it { [1,2,3].should_not beOrderedHaving(3).before(1,2) }
26
+ it { [1,2,3].should_not beOrderedHaving(2).before(3,1) }
27
+
28
+ it { [1,2,3].should_not beOrderedHaving(42).before(3) }
29
+ it { [1,2,3].should_not beOrderedHaving(1).before(42) }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,88 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require './lib/grandprix'
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
20
+
21
+ RSpec::Matchers.define :be_an_ordering_of do |edges|
22
+ def mismatches(edges, actual_seq)
23
+ edges.select do |e|
24
+ j, k = e
25
+ actual_seq.find_index(j) > actual_seq.find_index(k)
26
+ end
27
+ end
28
+
29
+ def missing_vertices(edges, actual_seq)
30
+ edges.flatten.uniq - actual_seq
31
+ end
32
+
33
+ match do |actual_seq|
34
+ missing_vertices(edges, actual_seq).empty? && mismatches(edges, actual_seq).empty?
35
+ end
36
+ failure_message_for_should do |actual_seq|
37
+ if missing_vertices(edges, actual_seq)
38
+ "#{actual_seq} is missing these edges: #{missing_vertices(edges, actual_seq)}"
39
+ else
40
+ <<-END
41
+ "#{actual_seq}" is not an ordering, as these pairs are inverted:
42
+ \t#{mismatches(edges, actual_seq).map(&:inspect).join("\n\t")}
43
+ END
44
+ end
45
+ end
46
+ end
47
+
48
+
49
+ RSpec::Matchers.define :beOrderedHaving do |*initial_segment|
50
+ def inverted(before, after, actual_array)
51
+ before.flat_map do |initial_el|
52
+ errors = after.select {|after_el|
53
+ actual_array.find_index(initial_el) > actual_array.find_index(after_el)
54
+ }
55
+ errors.empty? ? [] : [[initial_el, errors]]
56
+ end
57
+ end
58
+
59
+ match do |actual_array_object|
60
+ actual_array = actual_array_object.to_a
61
+ missing_init = initial_segment - actual_array
62
+ missing_after = @after_segment - actual_array
63
+
64
+ missing_init.empty? &&
65
+ missing_after.empty? &&
66
+ inverted(initial_segment, @after_segment, actual_array).empty?
67
+ end
68
+
69
+ chain :before do |*after|
70
+ @after_segment = after
71
+ end
72
+
73
+ failure_message_for_should do |actual_array_object|
74
+ actual_array = actual_array_object.to_a
75
+
76
+ missing_init = initial_segment - actual_array
77
+ missing_after = @after_segment - actual_array
78
+
79
+ if (not missing_init.empty?) || (not missing_after.empty?)
80
+ message = ""
81
+ message += "Elements #{missing_init.inspect} missing in #{actual_array.inspect}\n" unless missing_init.empty?
82
+ message += "Elements #{missing_after.inspect} missing in #{actual_array.inspect}\n" unless missing_after.empty?
83
+ message
84
+ else
85
+ "Elements #{inverted(initial_segment, @after_segment, actual_array).map {|x,y| "#{x} -> #{y}"}} are in inverse order in #{actual_array.inspect}"
86
+ end
87
+ end
88
+ end
data/version ADDED
@@ -0,0 +1 @@
1
+ 0.0.4
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grandprix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rafael de F. Ferreira
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-15 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Deploy assistant.
15
+ email:
16
+ - public@rafaelferreira.net
17
+ executables:
18
+ - grandprix
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - .rspec
24
+ - .rvmrc
25
+ - Gemfile
26
+ - Guardfile
27
+ - LICENSE
28
+ - README.md
29
+ - Rakefile
30
+ - bin/grandprix
31
+ - doc/sample/alongside_elements/elements
32
+ - doc/sample/alongside_elements/sample_output
33
+ - doc/sample/alongside_elements/topology.yml
34
+ - doc/sample/alongside_elements_2/elements
35
+ - doc/sample/alongside_elements_2/sample_output
36
+ - doc/sample/alongside_elements_2/topology.yml
37
+ - doc/sample/annotated_topology/elements
38
+ - doc/sample/annotated_topology/sample_output
39
+ - doc/sample/annotated_topology/topology.yml
40
+ - doc/sample/as_a_library/Gemfile
41
+ - doc/sample/as_a_library/sample.rb
42
+ - doc/sample/elements_with_extra_info/elements
43
+ - doc/sample/elements_with_extra_info/sample_output
44
+ - doc/sample/elements_with_extra_info/topology.yml
45
+ - doc/sample/simple/elements
46
+ - doc/sample/simple/sample_output
47
+ - doc/sample/simple/topology.yml
48
+ - grandprix.gemspec
49
+ - lib/grandprix.rb
50
+ - lib/grandprix/elements.rb
51
+ - lib/grandprix/graph.rb
52
+ - lib/grandprix/planner.rb
53
+ - lib/grandprix/runner.rb
54
+ - lib/grandprix/version.rb
55
+ - spec/lib/grandprix/elements_spec.rb
56
+ - spec/lib/grandprix/graph_spec.rb
57
+ - spec/lib/grandprix/planner_spec.rb
58
+ - spec/lib/grandprix/runner_spec.rb
59
+ - spec/matchers_spec.rb
60
+ - spec/spec_helper.rb
61
+ - version
62
+ homepage: ''
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.24
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Deploy assistant
86
+ test_files:
87
+ - spec/lib/grandprix/elements_spec.rb
88
+ - spec/lib/grandprix/graph_spec.rb
89
+ - spec/lib/grandprix/planner_spec.rb
90
+ - spec/lib/grandprix/runner_spec.rb
91
+ - spec/matchers_spec.rb
92
+ - spec/spec_helper.rb