Class: Wonki::Storage
- Inherits:
-
Object
- Object
- Wonki::Storage
- Defined in:
- lib/wonki/storage.rb
Instance Method Summary collapse
- #build(route) ⇒ Object
- #find(name) ⇒ Object
- #get_mod_date(name) ⇒ Object
-
#initialize(repo_path) ⇒ Storage
constructor
A new instance of Storage.
Constructor Details
#initialize(repo_path) ⇒ Storage
Returns a new instance of Storage.
8 9 10 11 |
# File 'lib/wonki/storage.rb', line 8 def initialize(repo_path) @repo_path = repo_path @repository = Grit::Repo.new(@repo_path) end |
Instance Method Details
#build(route) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/wonki/storage.rb', line 13 def build(route) route_name = route[1..-1] # strip leading slash data = find(route_name) mod_date = get_mod_date(route_name) {:content => data, :last_modified => mod_date, :route_name => route_name} end |
#find(name) ⇒ Object
20 21 22 23 24 |
# File 'lib/wonki/storage.rb', line 20 def find(name) blob = (@repository.tree/name) raise Wonki::PageNotFound.new if blob.nil? blob.data end |
#get_mod_date(name) ⇒ Object
26 27 28 |
# File 'lib/wonki/storage.rb', line 26 def get_mod_date(name) @repository.commits.first.committed_date # date of the last commit to the repo. end |