xtrn 0.1.0 → 0.1.1

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.
@@ -8,16 +8,18 @@ module Xtrn
8
8
 
9
9
  def update!
10
10
  @config.each do |entry|
11
-
12
- x = @executor.exec("svn info #{entry['url']}")
11
+ username = entry['username'] ? "--username '#{entry['username']}' " : ''
12
+ password = entry['password'] ? "--password '#{entry['password']}' " : ''
13
+ # username = ''
14
+
15
+ x = @executor.exec("svn info #{username}#{password}#{entry['url']}")
13
16
  rev = YAML.load(x)["Last Changed Rev"]
14
17
  cmd = if File.directory?(entry['path'])
15
18
  'update'
16
19
  else
17
20
  'checkout'
18
21
  end
19
-
20
- @executor.exec("svn #{cmd} -r#{rev} #{entry['url']} #{entry['path']}")
22
+ @executor.exec("svn #{cmd} #{username}#{password}-r#{rev} #{entry['url']} #{entry['path']}")
21
23
  end
22
24
 
23
25
  def updated_gitignore(original_gitignore)
data/lib/xtrn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xtrn
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -0,0 +1,35 @@
1
+ module Xtrn
2
+ module SpecHelpers
3
+ class SVNCommand
4
+ def initialize()
5
+ @username_and_password = ''
6
+ end
7
+
8
+ def cmd(c)
9
+ @cmd = c
10
+ self
11
+ end
12
+
13
+ def args(a)
14
+ @args = a
15
+ self
16
+ end
17
+
18
+ def credentials(u, p)
19
+ unless u.nil?
20
+ @username_and_password = "--username '#{u}' --password '#{p}' "
21
+ end
22
+ self
23
+ end
24
+
25
+ def to_s
26
+ "svn #{@cmd} #{@username_and_password}#{@args}"
27
+ end
28
+
29
+ def match(actual)
30
+ actual == to_s
31
+ end
32
+ end
33
+ end
34
+ end
35
+
data/spec/xtrn_spec.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rspec'
2
2
  require 'xtrn'
3
+ require File.dirname(__FILE__) + '/spec_helpers'
3
4
  describe Xtrn::Directory do
4
5
 
5
6
  let(:config) do
@@ -16,36 +17,63 @@ describe Xtrn::Directory do
16
17
 
17
18
  subject { Xtrn::Directory.new(config, executor) }
18
19
 
20
+ let(:svn) { Xtrn::SpecHelpers::SVNCommand.new }
21
+ let(:credentials) {nil}
22
+
19
23
  context 'updating' do
20
24
  before do
21
- executor.should_receive(:exec).with("svn info #{config[0]['url']}") {
25
+ executor.should_receive(:exec) do |actual_svn_cmd|
26
+ actual_svn_cmd.should == svn.cmd('info').args(config[0]['url']).to_s
22
27
  <<EOF
23
28
  Ignore this one: Some value
24
29
  Last Changed Rev: 12345
25
30
  Some other stuff: Bobby
26
31
  EOF
27
- }
32
+ end
28
33
  end
29
34
 
35
+ shared_examples_for('svn with command') do |c|
36
+ it "should #{c} the given svn directory path" do
37
+ executor.should_receive(:exec) do |actual_svn_cmd|
38
+ actual_svn_cmd.should == svn.cmd(command).args("-r12345 #{config[0]['url']} #{config[0]['path']}").to_s
39
+ end
40
+
41
+ subject.update!
42
+ end
43
+
44
+ context 'with username and password' do
45
+ let(:credentials) {%w(testuser testpass).tap{|i|svn.credentials(*i)}}
46
+ it 'should pass username and password to svn if given' do
47
+ config[0]['username'] = credentials[0]
48
+ config[0]['password'] = credentials[1]
49
+ executor.should_receive(:exec) do |actual_svn_cmd|
50
+ actual_svn_cmd.should == svn.cmd(command).args("-r12345 #{config[0]['url']} #{config[0]['path']}").to_s
51
+ end
52
+ subject.update!
53
+ end
54
+ end
55
+ end
56
+
57
+
30
58
  context 'when checkout path does not exist' do
31
59
 
32
- it 'should check out the given svn directory path' do
60
+ before do
33
61
  File.should_receive(:"directory?").with(config[0]['path']).and_return(false)
34
- executor.should_receive(:exec).with("svn checkout -r12345 #{config[0]['url']} #{config[0]['path']}")
35
-
36
- subject.update!
37
62
  end
63
+ let(:command) {'checkout'}
64
+ include_examples('svn with command', 'checkout')
38
65
 
39
66
  end
40
67
 
41
68
  context 'when checkout path already exists' do
42
69
 
43
- it 'should update the given svn directory path' do
70
+ before do
44
71
  File.should_receive(:"directory?").with(config[0]['path']).and_return(true)
45
- executor.should_receive(:exec).with("svn update -r12345 #{config[0]['url']} #{config[0]['path']}")
46
-
47
- subject.update!
48
72
  end
73
+
74
+ let(:command) {'update'}
75
+ include_examples('svn with command', 'update')
76
+
49
77
  end
50
78
  end
51
79
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xtrn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-18 00:00:00.000000000 Z
13
+ date: 2012-01-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &20265220 !ruby/object:Gem::Requirement
17
+ requirement: &70097058424700 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '2.8'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *20265220
25
+ version_requirements: *70097058424700
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: autotest
28
- requirement: &20264720 !ruby/object:Gem::Requirement
28
+ requirement: &70097058424040 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '4.4'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *20264720
36
+ version_requirements: *70097058424040
37
37
  description:
38
38
  email:
39
39
  - james@mediamolecule.com
@@ -53,6 +53,7 @@ files:
53
53
  - lib/xtrn/directory.rb
54
54
  - lib/xtrn/executor.rb
55
55
  - lib/xtrn/version.rb
56
+ - spec/spec_helpers.rb
56
57
  - spec/xtrn_spec.rb
57
58
  - xtrn.gemspec
58
59
  homepage:
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  version: '0'
76
77
  requirements: []
77
78
  rubyforge_project:
78
- rubygems_version: 1.8.11
79
+ rubygems_version: 1.8.10
79
80
  signing_key:
80
81
  specification_version: 3
81
82
  summary: Manage your externals without locking yourself into a single source control