Sha256: 5cffa2e8eb87eec52ba3401c6e85f46e189b23f39ec97304248420a9f619b503

Contents?: true

Size: 654 Bytes

Versions: 5

Compression:

Stored size: 654 Bytes

Contents

#
# Store and retrieve a history by provider and uuid
#

require 'revision'
require 'yaml'

module DiffNews

  class FileHistory < DefaultHistory
    attr_reader :revisions

    def initialize provider, uuid
      super provider, uuid
    end

    def file_path(extension)
       "#{@provider}/#{@uuid}.#{extension}"
    end
  
    def load
      if File.exist? file_path('yml')
        @revisions = YAML.load(File.open(file_path('yml'), 'r:UTF-8', &:read))
      end
    end

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
diff_news-0.9.4 lib/file_history.rb
diff_news-0.9.3 lib/file_history.rb
diff_news-0.9.2 lib/file_history.rb
diff_news-0.9.1 lib/file_history.rb
diff_news-0.9.0 lib/file_history.rb