Class: FossilWikiFuse
- Inherits:
-
Object
- Object
- FossilWikiFuse
- Defined in:
- lib/fossil_wiki_fuse.rb
Instance Method Summary collapse
- #can_delete?(path) ⇒ Boolean
- #can_write?(path) ⇒ Boolean
- #contents(path) ⇒ Object
- #delete(path) ⇒ Object
- #file?(path) ⇒ Boolean
-
#initialize ⇒ FossilWikiFuse
constructor
A new instance of FossilWikiFuse.
- #read_file(path) ⇒ Object
- #size(path) ⇒ Object
- #times(path) ⇒ Object
- #touch(path, body) ⇒ Object
- #write_to(path, body) ⇒ Object
Constructor Details
#initialize ⇒ FossilWikiFuse
Returns a new instance of FossilWikiFuse.
4 5 6 |
# File 'lib/fossil_wiki_fuse.rb', line 4 def initialize @mtimes = {} end |
Instance Method Details
#can_delete?(path) ⇒ Boolean
33 34 35 |
# File 'lib/fossil_wiki_fuse.rb', line 33 def can_delete? path `#{CMD} delete page "#{path[1..-1]}"` end |
#can_write?(path) ⇒ Boolean
19 20 21 |
# File 'lib/fossil_wiki_fuse.rb', line 19 def can_write? path true end |
#contents(path) ⇒ Object
7 8 9 |
# File 'lib/fossil_wiki_fuse.rb', line 7 def contents path `#{CMD} list`.split("\n").delete_if { |x| x.match "/" } end |
#delete(path) ⇒ Object
36 37 38 |
# File 'lib/fossil_wiki_fuse.rb', line 36 def delete path true end |
#file?(path) ⇒ Boolean
10 11 12 |
# File 'lib/fossil_wiki_fuse.rb', line 10 def file? path contents(nil).include?("#{path[1..-1]}") end |
#read_file(path) ⇒ Object
13 14 15 |
# File 'lib/fossil_wiki_fuse.rb', line 13 def read_file path `#{CMD} export "#{path[1..-1]}"` end |
#size(path) ⇒ Object
16 17 18 |
# File 'lib/fossil_wiki_fuse.rb', line 16 def size path read_file(path).size end |
#times(path) ⇒ Object
30 31 32 |
# File 'lib/fossil_wiki_fuse.rb', line 30 def times path [0, @mtimes[path], 0] end |
#touch(path, body) ⇒ Object
39 40 41 |
# File 'lib/fossil_wiki_fuse.rb', line 39 def touch(path, body) write_to path, body end |
#write_to(path, body) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/fossil_wiki_fuse.rb', line 22 def write_to path, body return if caller[0][/`.*'/][1..-2] == "truncate" action = ((file?(path))?"commit":"create") Open3.popen3("#{CMD}#{action} \"#{path[1..-1]}\"") do |stdin, stdout, stderr| stdin.puts body end @mtimes[path] = Time.now.to_i end |