class FossilWikiFuse
Public Class Methods
new()
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 4 def initialize @mtimes = {} end
Public Instance Methods
can_delete?(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 33 def can_delete? path `#{CMD} delete page "#{path[1..-1]}"` end
can_write?(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 19 def can_write? path true end
contents(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 7 def contents path `#{CMD} list`.split("\n").delete_if { |x| x.match "/" } end
delete(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 36 def delete path true end
file?(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 10 def file? path contents(nil).include?("#{path[1..-1]}") end
read_file(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 13 def read_file path `#{CMD} export "#{path[1..-1]}"` end
size(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 16 def size path read_file(path).size end
times(path)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 30 def times path [0, @mtimes[path], 0] end
touch(path, body)
click to toggle source
# File lib/fossil_wiki_fuse.rb, line 39 def touch(path, body) write_to path, body end
write_to(path, body)
click to toggle source
# 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