Class: RWGet::Store
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Store
constructor
A new instance of Store.
- #put(key, tmpfile) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Store
Returns a new instance of Store.
7 8 9 |
# File 'lib/rwget/store.rb', line 7 def initialize( = {}) @root = "." end |
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
5 6 7 |
# File 'lib/rwget/store.rb', line 5 def root @root end |
Instance Method Details
#put(key, tmpfile) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rwget/store.rb', line 11 def put(key, tmpfile) path = File.join(@root, key) path = File.join(path, "index.html") unless path.split("/").last =~ /\.|\?/ dir = File.dirname(path) if(File.file?(dir)) tmp = "#{dir}.index.html.#{Time.now.to_f}" mv dir, tmp mkdir_p(dir) mv tmp, File.join(dir, "index.html") else mkdir_p(dir) end mv tmpfile.path, path end |