Class: Bob::Test::SvnRepo

Inherits:
AbstractSCMRepo show all
Defined in:
lib/bob/test/scm/svn.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractSCMRepo

#name, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractSCMRepo

#add_commit, #add_failing_commit, #add_successful_commit, #head

Constructor Details

#initialize(name, base_dir = Bob.directory) ⇒ SvnRepo

Returns a new instance of SvnRepo.



12
13
14
15
16
17
# File 'lib/bob/test/scm/svn.rb', line 12

def initialize(name, base_dir=Bob.directory)
  super

  @path   = base_dir.join("svn-#{name}")
  @remote = SvnRepo.server_root.join(name.to_s)
end

Instance Attribute Details

#remoteObject (readonly)

Returns the value of attribute remote.



10
11
12
# File 'lib/bob/test/scm/svn.rb', line 10

def remote
  @remote
end

Class Method Details

.server_rootObject



6
7
8
# File 'lib/bob/test/scm/svn.rb', line 6

def self.server_root
  @root ||= Bob.directory.join("svn")
end

Instance Method Details

#commitsObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bob/test/scm/svn.rb', line 30

def commits
  Dir.chdir(path) do
    doc = Hpricot::XML(`svn log --xml`)

    (doc/:log/:logentry).inject([]) { |commits, commit|
      commits << { "identifier" => commit["revision"],
        "message"      => commit.at("msg").inner_html,
        "committed_at" => Time.parse(commit.at("date").inner_html) }
    }.reverse
  end
end

#createObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/bob/test/scm/svn.rb', line 19

def create
  create_remote

  run "svn checkout file://#{remote} #{path}"

  add_commit("First commit") do
    run "echo 'just a test repo' >> README"
    add "README"
  end
end