pre_push 0.0.3 → 0.0.4

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.
data/.gitignore CHANGED
@@ -16,7 +16,8 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  *TestResult.xml
19
- bin/
19
+ spec/TestProj/TestProj/bin/
20
+ spec/TestProj/TestProj2/bin/
20
21
  obj/
21
22
  _ReSharper*
22
23
  *ReSharper*
data/bin/prepush CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "pre_push"
4
4
  require "prepush_validator"
5
+ require "sln_finder"
5
6
  require "fileutils"
6
7
 
7
8
 
@@ -9,11 +10,12 @@ runner = ARGV[0] || 'nunit262'
9
10
 
10
11
  if PrePush::Validator.validate(runner)
11
12
  bin = File.dirname(__FILE__)
12
- FileUtils.cp("#{bin}/pre-push", ".git/hooks")
13
+ FileUtils.cp("#{bin}/../lib/template/pre-push", ".git/hooks")
13
14
 
14
15
  pre_push_hook = ".git/hooks/pre-push"
15
16
  file_text = File.read(pre_push_hook)
16
- content = file_text.gsub(/\{runner\}/, "\"#{runner}\"")
17
+ sln_path = PrePush::SlnFinder.find || "path/to/your.sln"
18
+ content = file_text.gsub(/\{runner\}/, "\"#{runner}\"").gsub(/\{sln_path\}/, "\"#{sln_path}\"")
17
19
  File.open(pre_push_hook, "w") {|file| file.puts content}
18
20
  puts "the pre-push hook has been dropped into your hooks dir; please modify it to build your assembly & run your tests."
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module PrePush
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/sln_finder.rb ADDED
@@ -0,0 +1,20 @@
1
+ module PrePush
2
+ class SlnFinder
3
+ def self.find
4
+ try_find_sln('.')
5
+ end
6
+
7
+ private
8
+ def self.try_find_sln location
9
+ sln = Dir.entries(location).find {|f| File.file?("#{location}/#{f}") && f.end_with?('.sln')}
10
+ return "#{location}/#{sln}" if sln != nil
11
+
12
+ dirs = Dir.entries(location).select {|e| !File.file?("#{location}/#{e}") && File.directory?("#{location}/#{e}") && !(/^\.{1,2}$/ =~ e)}
13
+ dirs.each do |dir|
14
+ sln = try_find_sln("#{location}/#{dir}")
15
+ return sln if sln != nil
16
+ end
17
+ sln
18
+ end
19
+ end
20
+ end
@@ -7,7 +7,7 @@ class Executor
7
7
  @test_runner = {runner}
8
8
  ###
9
9
 
10
- @solution = "path/to/your.sln" # the path to the solution to build
10
+ @solution = {sln_path} # the path to the solution to build
11
11
  # @assemblies = ['path/to/first/test.dll','path/to/second/test.dll'] #uncomment & insert dlls to test if different to the solution.
12
12
  include PrePush
13
13
  end
@@ -59,4 +59,4 @@
59
59
  <Target Name="AfterBuild">
60
60
  </Target>
61
61
  -->
62
- </Project>
62
+ </Project>
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module PrePush
4
+ describe SlnFinder do
5
+ describe 'find' do
6
+ it "should return first sln file found" do
7
+ Dir.stub('entries').and_return(['second.sln','first.sln'])
8
+ File.stub('file?').with(anything()).and_return(true)
9
+ PrePush::SlnFinder.find().should == './second.sln'
10
+ end
11
+ it "should return nested sln when none found at top level" do
12
+ Dir.stub('entries').with('.').and_return(['second.sn','first.sl', 'nested'])
13
+ Dir.stub('entries').with('./nested').and_return(['third.sn', 'first.sln', 'second.sln','fourth.sl', 'inner'])
14
+ File.stub('file?').with('./nested').and_return(false)
15
+ File.stub('file?').with('./nested/third.sn').and_return(false)
16
+ File.stub('file?').with('./nested/first.sln').and_return(true)
17
+ File.stub('file?').with('./second.sn').and_return(true)
18
+ File.stub('file?').with('./first.sl').and_return(true)
19
+ File.stub('file?').with('./first.sln').and_return(true)
20
+ File.stub('file?').with('./second.sln').and_return(true)
21
+ File.stub('directory?').with('./nested').and_return(true)
22
+ PrePush::SlnFinder.find().should == './nested/first.sln'
23
+ end
24
+ it "should disregard . and .. directories" do
25
+ Dir.stub('entries').with('.').and_return(['second.sn','.', '..'])
26
+ File.stub('file?').with('./second.sn').and_return(true)
27
+ File.stub('file?').with('./.').and_return(false)
28
+ File.stub('file?').with('./..').and_return(false)
29
+ File.stub('directory?').with('./.').and_return(true)
30
+ File.stub('directory?').with('./..').and_return(true)
31
+ Dir.should_not_receive(:entries).with('./.')
32
+ Dir.should_not_receive(:entries).with('./..')
33
+ PrePush::SlnFinder.find().should be_nil
34
+ end
35
+ end
36
+ end
37
+ end
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,7 @@ require 'rspec/expectations'
5
5
  require 'nokogiri'
6
6
  require 'pre_push'
7
7
  require 'prepush_validator'
8
+ require 'sln_finder'
8
9
 
9
10
  #uncomment the following line to use spork with the debugger
10
11
  #require 'spork/ext/ruby-debug'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pre_push
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2013-06-18 00:00:00.000000000 Z
12
+ date: 2013-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &21522876 !ruby/object:Gem::Requirement
16
+ requirement: &23324772 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *21522876
24
+ version_requirements: *23324772
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &21522276 !ruby/object:Gem::Requirement
27
+ requirement: &23324460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,12 +32,11 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *21522276
35
+ version_requirements: *23324460
36
36
  description: adding a pre-push hook for git to compile & run tests
37
37
  email:
38
38
  - nievegoor@gmail.com
39
39
  executables:
40
- - pre-push
41
40
  - prepush
42
41
  extensions: []
43
42
  extra_rdoc_files: []
@@ -47,7 +46,6 @@ files:
47
46
  - LICENSE.txt
48
47
  - README.md
49
48
  - Rakefile
50
- - bin/pre-push
51
49
  - bin/prepush
52
50
  - lib/pre_push.rb
53
51
  - lib/pre_push/version.rb
@@ -106,6 +104,8 @@ files:
106
104
  - lib/runners_config/mspec.rb
107
105
  - lib/runners_config/nunit262.rb
108
106
  - lib/runners_config/xunit191.rb
107
+ - lib/sln_finder.rb
108
+ - lib/template/pre-push
109
109
  - pre_push.gemspec
110
110
  - spec/TestProj/TestProj.sln
111
111
  - spec/TestProj/TestProj/AllTests.cs
@@ -185,6 +185,7 @@ files:
185
185
  - spec/nunit_integration_spec.rb
186
186
  - spec/pre_push_spec.rb
187
187
  - spec/prepush_validator_spec.rb
188
+ - spec/sln_finder_spec.rb
188
189
  - spec/spec_helper.rb
189
190
  - spec/xunit_integration_spec.rb
190
191
  homepage: https://github.com/nieve/prepush
@@ -292,5 +293,6 @@ test_files:
292
293
  - spec/nunit_integration_spec.rb
293
294
  - spec/pre_push_spec.rb
294
295
  - spec/prepush_validator_spec.rb
296
+ - spec/sln_finder_spec.rb
295
297
  - spec/spec_helper.rb
296
298
  - spec/xunit_integration_spec.rb