Class: DiffNews::FileHistory

Inherits:
DefaultHistory show all
Defined in:
lib/file_history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DefaultHistory

#append_changed_revision, #clear, #revision_changed?

Constructor Details

#initialize(provider, uuid, url) ⇒ FileHistory

Returns a new instance of FileHistory.



13
14
15
# File 'lib/file_history.rb', line 13

def initialize provider, uuid, url
  super provider, uuid, url
end

Instance Attribute Details

#revisionsObject (readonly)

Returns the value of attribute revisions.



11
12
13
# File 'lib/file_history.rb', line 11

def revisions
  @revisions
end

Instance Method Details

#file_path(extension) ⇒ Object



17
18
19
# File 'lib/file_history.rb', line 17

def file_path(extension)
   "#{@provider}/#{@uuid}.#{extension}"
end

#loadObject



21
22
23
24
25
# File 'lib/file_history.rb', line 21

def load
  if File.exist? file_path('yml')
    @revisions = YAML.load(File.open(file_path('yml'), 'r:UTF-8', &:read))
  end
end

#storeObject



27
28
29
30
31
32
33
# File 'lib/file_history.rb', line 27

def store
  if @revisions
    File.open(file_path('yml'), 'w:UTF-8') do |file|
      file.write(YAML::dump(@revisions))
    end
  end
end