This file is indexed.

/usr/lib/ruby/1.8/moneta/couch.rb is in libmoneta-ruby1.8 0.6.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
begin
  require "couchrest"
rescue LoadError
  puts "You need the couchrest gem to use the CouchDB store"
  exit
end

module Moneta
  class Couch
    include Defaults
    
    def initialize(options = {})
      @db = ::CouchRest.database!(options[:db])
      unless options[:skip_expires]
        @expiration = Moneta::Couch.new(:db => "#{options[:db]}_expiration", :skip_expires => true)
        self.extend(StringExpires)
      end
    end

    def key?(key)
      !self[key].nil?
    rescue RestClient::ResourceNotFound
      false
    end

    alias has_key? key?

    def [](key)
      @db.get(key)["data"]
    rescue RestClient::ResourceNotFound
      nil
    end

    def []=(key, value)
      @db.save_doc("_id" => key, :data => value)
    rescue RestClient::RequestFailed
      self[key]
    end

    def delete(key)
      value = @db.get(key)
      @db.delete_doc({"_id" => value["_id"], "_rev" => value["_rev"]}) if value
      value["data"]
    rescue RestClient::ResourceNotFound
      nil
    end

    def update_key(key, options = {})
      val = self[key]
      self.store(key, val, options)
    rescue RestClient::ResourceNotFound
      nil
    end

    def clear
      @db.recreate!
    end

    def delete_store
      @db.delete!
    end
  end
end