Sha256: 059341315e67dd5618b1b863710b4c5687054d4bff88096da5c52787d58c5f3a

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

module Churn

  #analizes SVN SCM to find recently changed files, and what lines have been altered
  class SvnAnalyzer < SourceControl

    def self.supported?
      File.exist?(".svn")
    end

    def get_logs
      `svn log --verbose#{date_range}#{svn_credentials}`.split(/\n/).map { |line| clean_up_svn_line(line) }.compact
    end

    private
    def svn_credentials
      " --username #{ENV['SVN_USR']} --password #{ENV['SVN_PWD']}" if ENV['SVN_PWD'] && ENV['SVN_USR']
    end

    def date_range
      if @start_date
        date = Chronic.parse(@start_date)
        " --revision {#{date.strftime('%Y-%m-%d')}}:{#{Time.now.strftime('%Y-%m-%d')}}"
      end
    end

    def clean_up_svn_line(line)
      match = line.match(/\W*[A,M]\W+(\/.*)\b/)
      match ? match[1] : nil
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
churn-0.0.35 lib/churn/scm/svn_analyzer.rb