Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of http://github.com/robashton/TwitterFS
- Loading branch information
Showing
4 changed files
with
106 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require 'twitterfs' | ||
require 'twitterfspersistance' | ||
|
||
class MockPersister | ||
def initialize | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'twitterfs' | ||
|
||
class FileSystem | ||
|
||
attr :root | ||
|
||
def initialize(persister) | ||
@persister = persister | ||
@root = Directory.new(nil, "root") | ||
end | ||
end | ||
|
||
class Persister | ||
|
||
def initialize() | ||
@tweets = Array.new | ||
end | ||
|
||
def add_tweet(tweet, annotation) | ||
newtweet = Tweet.new(nil, tweet, annotation) | ||
@tweets.push(newtweet) | ||
newtweet.set_id(@tweets.length-1) | ||
newtweet.id | ||
end | ||
|
||
def get_tweet(id) | ||
tweet = @tweets[id] | ||
end | ||
|
||
def get_most_recent_tweet() | ||
tweet = @tweets[@tweets.length-1] | ||
end | ||
end | ||
|
||
class Tweet | ||
|
||
attr :annotation, :id, :content | ||
|
||
attr :annotation | ||
attr_writer :id | ||
attr_writer :content | ||
|
||
def initialize(id, content, annotation) | ||
@annotation = annotation | ||
@id = id | ||
@content = content | ||
end | ||
|
||
def set_id(id) | ||
@id = id | ||
end | ||
end |