Class: SVNDataCollector
- Inherits:
-
Object
- Object
- SVNDataCollector
- Defined in:
- lib/codespicuous/svn_data_collector.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #collect_commit_history(repositories) ⇒ Object
- #collect_commits_for_repository(repository) ⇒ Object
-
#initialize(config, commit_history = CommitHistory.new) ⇒ SVNDataCollector
constructor
A new instance of SVNDataCollector.
- #retrieve_commits_from_log(xmllog) ⇒ Object
- #retrieve_svn_log_from(repository) ⇒ Object
- #save_svn_log(repository, xmllog) ⇒ Object
Constructor Details
#initialize(config, commit_history = CommitHistory.new) ⇒ SVNDataCollector
Returns a new instance of SVNDataCollector.
7 8 9 10 |
# File 'lib/codespicuous/svn_data_collector.rb', line 7 def initialize(config, commit_history = CommitHistory.new) @commit_history = commit_history @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/codespicuous/svn_data_collector.rb', line 5 def config @config end |
Instance Method Details
#collect_commit_history(repositories) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/codespicuous/svn_data_collector.rb', line 42 def collect_commit_history(repositories) repositories.each { | repository| @commit_history.add_commits(collect_commits_for_repository(repository)) } @commit_history end |
#collect_commits_for_repository(repository) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/codespicuous/svn_data_collector.rb', line 33 def collect_commits_for_repository(repository) puts "Getting svn log from repository: " + repository.name xmllog = retrieve_svn_log_from(repository) save_svn_log(repository, xmllog) commits_in_repository = retrieve_commits_from_log(xmllog) commits_in_repository.set_repository(repository) commits_in_repository end |
#retrieve_commits_from_log(xmllog) ⇒ Object
22 23 24 25 26 |
# File 'lib/codespicuous/svn_data_collector.rb', line 22 def retrieve_commits_from_log(xmllog) parser = SVNLogParser.new parser.parse(xmllog) parser.commits end |
#retrieve_svn_log_from(repository) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/codespicuous/svn_data_collector.rb', line 12 def retrieve_svn_log_from(repository) if config.offline File.read(config.path_to_cached_svn_log(repository.name)) else svn = SVNClient.new svn.repository(repository.url) svn.log_xml end end |
#save_svn_log(repository, xmllog) ⇒ Object
28 29 30 31 |
# File 'lib/codespicuous/svn_data_collector.rb', line 28 def save_svn_log(repository, xmllog) Dir.mkdir(config.path_to_cached_svn_log_dir) unless Dir.exists?(config.path_to_cached_svn_log_dir) File.write(config.path_to_cached_svn_log(repository.name), xmllog) end |