Class: Achoo::VCS::Subversion

Inherits:
Object
  • Object
show all
Defined in:
lib/achoo/vcs/subversion.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Subversion

Returns a new instance of Subversion.



12
13
14
# File 'lib/achoo/vcs/subversion.rb', line 12

def initialize(dir)
  @dir = dir
end

Class Method Details

.repository?(dir) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/achoo/vcs/subversion.rb', line 8

def self.repository?(dir)
  File.exist?("#{dir}/.svn")
end

Instance Method Details

#log_for(date) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/achoo/vcs/subversion.rb', line 16

def log_for(date)
  date = date.strftime("%F")
  xml = Nokogiri::XML(`cd #@dir; svn log --xml`)
  logentries = xml.xpath("/log/logentry/author[contains(., \"#{ENV['USER']}\")]/parent::*")
  
  # FIX are the dates in the xml local time, or do they need to be
  # converted?
  log = ""
  logentries.each do |e|
    if e.css('date').text.start_with?(date)
      log << e.css('msg').text.strip << "\n"
    end
  end
  log
end