Sha256: 06ea5799953af2a6f27e12ca2a2bd4414d7130024c64b53adba271366da65189

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

require 'rindle/version'
require 'rindle/index'
require 'rindle/collections'
require 'rindle/collection'
require 'rindle/document'

require 'rindle/mixins/regexp'

# This module is used to load the Kindles state into the
# data structures, which are used to let you access the Kindles
# content in a way, that reminds one of the ActiveRecord usage
#
# Load from a specific path
#
#   Rindle.load(path)
#
# After that you may use the models `Collection` and `Document`.
class Rindle
  @@root_path = nil
  @@collections = nil
  @@index = nil

  class NotLoaded < Exception; end

  class << self
    def root_path
      if @@root_path
        @@root_path
      else
        raise NotLoaded
      end
    end

    def index
      if @@index
        @@index
      else
        raise NotLoaded
      end
    end

    def collections
      if @@collections
        @@collections
      else
        raise NotLoaded
      end
    end

    def load root_path
      @@root_path = root_path
      @@index = Index.load(root_path)
      @@collections = Collections.load(root_path)
    end

    def save
      @@collections.save
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rindle-0.3.4 lib/rindle.rb
rindle-0.3.3 lib/rindle.rb
rindle-0.3.2 lib/rindle.rb
rindle-0.3.1 lib/rindle.rb
rindle-0.3.0 lib/rindle.rb
rindle-0.2.0 lib/rindle.rb
rindle-0.1.1 lib/rindle.rb