Class: Snapper
- Inherits:
-
Object
- Object
- Snapper
- Defined in:
- lib/snapper.rb,
lib/snapper/version.rb
Constant Summary collapse
- SNAPPER_DIR =
ENV['SNAPPER_DIR'] || "#{ENV['HOME']}/.snapper"
- VERSION =
"0.0.2"- @@instance =
Snapper.new
Instance Attribute Summary collapse
-
#snapper_file ⇒ Object
readonly
Returns the value of attribute snapper_file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Snapper
constructor
A new instance of Snapper.
Constructor Details
#initialize ⇒ Snapper
Returns a new instance of Snapper.
10 11 12 13 14 |
# File 'lib/snapper.rb', line 10 def initialize FileUtils.mkdir_p(SNAPPER_DIR) unless File.exists?(SNAPPER_DIR) @uuid = UUID.new @snapper_file = File.new("/tmp/#{@uuid.generate}.snapper", "w+") end |
Instance Attribute Details
#snapper_file ⇒ Object (readonly)
Returns the value of attribute snapper_file.
8 9 10 |
# File 'lib/snapper.rb', line 8 def snapper_file @snapper_file end |
Class Method Details
.instance ⇒ Object
18 19 20 |
# File 'lib/snapper.rb', line 18 def self.instance return @@instance end |
.restore(name) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/snapper.rb', line 27 def self.restore(name) file = File.open("#{SNAPPER_DIR}/#{name}.snapper") while line = file.gets IRB.CurrentContext.evaluate(line, 0) end end |
.snap(name) ⇒ Object
22 23 24 25 |
# File 'lib/snapper.rb', line 22 def self.snap(name) FileUtils.cp(instance.snapper_file.path, "#{SNAPPER_DIR}/#{name}.snapper") return true end |