Class: Svn::Log::Index
- Inherits:
-
Object
- Object
- Svn::Log::Index
- Defined in:
- lib/svnlog/index.rb
Overview
An index of svn log entries
Instance Method Summary collapse
-
#close ⇒ Object
Close the index when you’re done with it.
-
#initialize(path = nil, repository_url = nil) ⇒ Index
constructor
A new instance of Index.
-
#last_revision ⇒ Object
Returns the revision number of the last entry indexed.
-
#path ⇒ Object
Returns the path to the index.
-
#repository_url ⇒ Object
Returns the url of the repository that is indexed.
-
#search(query) ⇒ Object
Returns all entries that match the query.
-
#size ⇒ Object
Returns the number of entries in the index.
-
#update ⇒ Object
Updates the index with the latest entries.
Constructor Details
#initialize(path = nil, repository_url = nil) ⇒ Index
Returns a new instance of Index.
14 15 16 17 18 19 20 21 |
# File 'lib/svnlog/index.rb', line 14 def initialize(path = nil, repository_url = nil) @path = path @index = Ferret::Index::Index.new(:path => @path, :key => :revision) # load the properties properties_path = @path && File.join(@path, "properties.yml") @props = Properties.new(properties_path) @props[:repository_url] ||= repository_url end |
Instance Method Details
#close ⇒ Object
Close the index when you’re done with it
66 67 68 |
# File 'lib/svnlog/index.rb', line 66 def close @index.close end |
#last_revision ⇒ Object
Returns the revision number of the last entry indexed
34 35 36 |
# File 'lib/svnlog/index.rb', line 34 def last_revision @props[:last_revision] end |
#path ⇒ Object
Returns the path to the index
24 25 26 |
# File 'lib/svnlog/index.rb', line 24 def path @path end |
#repository_url ⇒ Object
Returns the url of the repository that is indexed
29 30 31 |
# File 'lib/svnlog/index.rb', line 29 def repository_url @props[:repository_url] end |
#search(query) ⇒ Object
Returns all entries that match the query
56 57 58 59 60 61 62 63 |
# File 'lib/svnlog/index.rb', line 56 def search(query) entries = [] = {:num_docs => @index.size, :sort => SortField::FIELD_DOC } for doc_id, score in @index.search(query, ) entries << @index[doc_id] end entries end |
#size ⇒ Object
Returns the number of entries in the index
39 40 41 |
# File 'lib/svnlog/index.rb', line 39 def size @index.size end |
#update ⇒ Object
Updates the index with the latest entries
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/svnlog/index.rb', line 44 def update revision = "#{last_revision.to_i}:HEAD" entries = Log.new(repository_url).find(revision) return if entries.size == 0 for entry in entries add_entry(entry) end @index.flush @props[:last_revision] = entries.last[:revision] end |