gorgon 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGExZTQwNzZlNWEwNDY4YTc0MmUxMDhhYWY4N2MwOTUxMjgyMDg2Mw==
4
+ MjQ4NWZhNTMzMjIzZWQ4NTMwNzAxYzMzMDQ0NDhiMWJjMjg1Y2NmZQ==
5
5
  data.tar.gz: !binary |-
6
- ZWQyNTdlYmQ2MDBjMGU0ZWY0MmMwZWRkYzg2NjJlYjQxNDZlMzc4Yg==
6
+ YmRiMDAzYmU3M2Y3ZGFiNWQzOGU3NWZiYWUyM2QwZDAzNTQ4N2EwYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2RiYjRjNjYyOTY2ODM5MmQ1MjJiMGRiNGVlMWNkY2E2NWE4YTk3ZTE5N2I2
10
- MWFkNWIxNWU0ZDQ3MDY5M2IyN2Y4NzNhYjgyZTBhODVjN2U0NTU0ZmZiYTUz
11
- MGNmZDUyZWQ1YWI4YjdiZDU0MDhhZTc3ZmMyZWRjYjc3ZjdmMTc=
9
+ ZWY2YTZmYjY5OGVhMjNlYjEwZWQ0ZWM2MDBmYjNiMWUzNjBmYTY5NWQ1MzBi
10
+ NDJiYTA0ZTA0NGQyM2ZkMmQ5YWMzZmFjYWIxMmJkOWEwYjJhZjE1Mzc0YWJj
11
+ YmE4NzA2ZmJhOGNlMWMyNjEyMTUwNTEwMGE0YWI0MmYwMjE2YjQ=
12
12
  data.tar.gz: !binary |-
13
- MjY5ZjUxYTMyNDA4Yjg1OGMwOGZjODA5MDE1NGUxYjg0NGJjY2M1Mzk0ZTYw
14
- ZmQxZDhlZTQwMjUzM2JhMzdhYjAzZDIyYzFmMWI2MGUwYmM1N2RlYjhhYjc4
15
- YzhkZWEzYjIxZTg5NWI4OTYwNDJkYWRjY2IwZjczNjZjOGE1ZjU=
13
+ Mjk4YTUwYzNmMWJiNmZmYzU1NzY1YTc4ZWQxYzdhZDgyYjExODk2Y2M0ZmFm
14
+ MDI0YTljODRkNjVjNTUyMjc5YjU3MDhmMTJhMDJjNGYyOTk3YmU4ZWRlNGZk
15
+ ZGQ3NDFmNmRiZjgxMjdjZWRkNmI4YzFmZDk4NjJjYmRmNWJjOTc=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gorgon (0.8.2)
4
+ gorgon (0.8.3)
5
5
  amqp (~> 1.1.0)
6
6
  awesome_print
7
7
  colorize (~> 0.5.8)
@@ -20,7 +20,7 @@ GEM
20
20
  awesome_print (1.2.0)
21
21
  colorize (0.5.8)
22
22
  diff-lcs (1.1.3)
23
- eventmachine (1.0.3)
23
+ eventmachine (1.0.4)
24
24
  open4 (1.3.4)
25
25
  rake (0.9.2.2)
26
26
  rspec (2.11.0)
@@ -152,12 +152,7 @@ class Originator
152
152
  end
153
153
 
154
154
  def files
155
- return @files unless @files.nil?
156
- current_files = configuration[:files].reduce([]) do |memo, obj|
157
- memo.concat(Dir[obj])
158
- end.uniq
159
- runtime_file_reader = RuntimeFileReader.new configuration[:runtime_file]
160
- @files = runtime_file_reader.sorted_files(current_files)
155
+ @files ||= RuntimeFileReader.new(configuration).sorted_files
161
156
  end
162
157
 
163
158
  def job_definition
@@ -2,8 +2,9 @@ require 'yajl'
2
2
 
3
3
  class RuntimeFileReader
4
4
 
5
- def initialize(runtime_filename)
6
- @runtime_filename = runtime_filename || ""
5
+ def initialize(configuration)
6
+ @runtime_filename = configuration[:runtime_file] || ""
7
+ @globs_of_files = configuration[:files] || [] # e.g. ["spec/file1_spec.rb", "spec/**/*_spec.rb"]
7
8
  end
8
9
 
9
10
  def old_files
@@ -18,9 +19,19 @@ class RuntimeFileReader
18
19
  end
19
20
  end
20
21
 
21
- def sorted_files(current_files = [])
22
+ def sorted_files # sorts by 1.) globs, 2.) runtime
23
+ @globs_of_files.reduce([]) do |memo, glob|
24
+ memo.concat( sorted_files_by_runtime(Dir[glob]) )
25
+ end.uniq
26
+ end
27
+
28
+ private
29
+
30
+ def sorted_files_by_runtime(current_files = [])
22
31
  (self.old_files+current_files).uniq - (self.old_files-current_files)
23
32
  end
24
33
 
34
+
35
+
25
36
  end
26
37
 
@@ -1,3 +1,3 @@
1
1
  module Gorgon
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
@@ -3,47 +3,75 @@ require 'yajl'
3
3
 
4
4
  describe RuntimeFileReader do
5
5
 
6
+ let(:old_files){ ["old_a.rb", "old_b.rb", "old_c.rb", "old_d.rb"] }
7
+
6
8
  describe "#old_files" do
7
- let(:runtime_filename){ "runtime_file.json" }
9
+ let(:configuration){ {runtime_file: "runtime_file.json"} }
8
10
 
9
11
  it "should read runtime_file" do
10
12
  File.stub(:file?).and_return(true)
11
- runtime_file_reader = RuntimeFileReader.new(runtime_filename)
12
- File.should_receive(:open).with(runtime_filename, 'r')
13
+ runtime_file_reader = RuntimeFileReader.new(configuration)
14
+ File.should_receive(:open).with(configuration[:runtime_file], 'r')
13
15
  runtime_file_reader.old_files
14
16
  end
15
17
 
16
18
  it "should return empty array if runtime_file is invalid" do
17
19
  File.should_receive(:file?).and_return(false)
18
- runtime_file_reader = RuntimeFileReader.new(runtime_filename)
20
+ runtime_file_reader = RuntimeFileReader.new(configuration)
19
21
  File.should_not_receive(:open)
20
22
  runtime_file_reader.old_files
21
23
  end
22
24
  end
23
25
 
24
26
 
25
- describe "#sorted_files" do
26
- let (:old_files){ [ "old_a.rb", "old_b.rb", "old_c.rb"] }
27
+ describe "#sorted_files_by_runtime" do
28
+ let(:configuration){ {runtime_file: "runtime_file.json"} }
27
29
 
28
30
  before do
29
- @runtime_file_reader = RuntimeFileReader.new "runtime_file.json"
31
+ @runtime_file_reader = RuntimeFileReader.new(configuration)
30
32
  @runtime_file_reader.stub(:old_files).and_return old_files
31
33
  end
32
34
 
33
35
  it "should include new files at the end" do
34
- current_spec_files = ["new_a.rb", "old_b.rb", "old_a.rb", "new_b.rb", "old_c.rb"]
35
- sorted_files = @runtime_file_reader.sorted_files(current_spec_files)
36
- expect(sorted_files.first(sorted_files.size-2)).to eq(old_files)
37
- expect(sorted_files.last(2)).to eq(["new_a.rb", "new_b.rb"])
36
+ current_spec_files = ["new_a.rb", "old_b.rb", "old_a.rb", "new_b.rb", "old_c.rb", "old_d.rb"]
37
+ sorted_files_by_runtime = @runtime_file_reader.send(:sorted_files_by_runtime, current_spec_files)
38
+ expect(sorted_files_by_runtime.first(sorted_files_by_runtime.size-2)).to eq(old_files)
39
+ expect(sorted_files_by_runtime.last(2)).to eq(["new_a.rb", "new_b.rb"])
38
40
  end
39
41
 
40
42
  it "should remove old files that are not in current files" do
41
43
  current_spec_files = ["new_a.rb", "old_a.rb", "old_c.rb"]
42
- sorted_files = @runtime_file_reader.sorted_files(current_spec_files)
43
- expect(sorted_files.first(2)).to eq(["old_a.rb", "old_c.rb"])
44
- expect(sorted_files.last(1)).to eq(["new_a.rb"])
44
+ sorted_files_by_runtime = @runtime_file_reader.send(:sorted_files_by_runtime, current_spec_files)
45
+ expect(sorted_files_by_runtime.first(2)).to eq(["old_a.rb", "old_c.rb"])
46
+ expect(sorted_files_by_runtime.last(1)).to eq(["new_a.rb"])
45
47
  end
46
48
  end
47
49
 
50
+
51
+ describe "#sorted_files" do
52
+ let(:configuration){ {files: ["glob_1", "glob_2", "glob_3"]} }
53
+
54
+ before do
55
+ @runtime_file_reader = RuntimeFileReader.new(configuration)
56
+ @runtime_file_reader.stub(:old_files).and_return old_files
57
+ end
58
+
59
+ it "sort by globs then by runtime" do
60
+ globs = {
61
+ "glob_1" => ["old_b.rb"],
62
+ "glob_2" => ["new_c.rb", "old_a.rb"],
63
+ "glob_3" => ["old_d.rb", "old_c.rb", "new_a.rb", "new_b.rb", "new_c.rb", "old_a.rb", "old_b.rb"]
64
+ }
65
+ Dir.stub(:[]) do |glob|
66
+ globs[glob]
67
+ end
68
+ sorted_files = @runtime_file_reader.sorted_files
69
+ expect(sorted_files).to eq(
70
+ ["old_b.rb", "old_a.rb", "new_c.rb", "old_c.rb", "old_d.rb", "new_a.rb", "new_b.rb"]
71
+ )
72
+ end
73
+ end
74
+
75
+
48
76
  end
49
77
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorgon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Fitzsimmons
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-12-28 00:00:00.000000000 Z
15
+ date: 2015-02-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake