Module: Stone

Defined in:
lib/stone/version.rb,
lib/stone.rb,
lib/stone/query.rb,
lib/stone/resource.rb,
lib/stone/callbacks.rb,
lib/stone/data_store.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Resource, VERSION Classes: Callbacks, DataStore, Query

Class Method Summary collapse

Class Method Details

.empty_datastoreObject

For spec stuff only



22
23
24
25
26
# File 'lib/stone.rb', line 22

def empty_datastore
  if File.exists? STONE_ROOT/"sandbox_for_specs/datastore"
    FileUtils.rm_rf STONE_ROOT/"sandbox_for_specs/datastore"
  end
end

.start(path, resources, framework = nil) ⇒ Object

Creates or updates a datastore at path

Parameters

path<String>

Path to create or update datastore (usually an application’s root)

resources<Array>

A list of resources that exist for the application



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/stone.rb', line 33

def start(path, resources, framework = nil)
  DataStore.local_dir = path/"datastore"

  # create the datastore dir unless it exists
  FileUtils.mkdir_p(DataStore.local_dir) unless File.exists?(DataStore.local_dir)

  # create a .stone_metadata that contains the resource locations
  # for Stone::Utilities to use
  File.open(DataStore.local_dir/".stone_metadata", "w") do |out|
    YAML.dump({:rsrc_path => File.dirname(resources.first)}, out)
  end unless File.exists?(DataStore.local_dir/".stone_metadata")

  # load each resource unless a framework has already done it
  resources.each do |resource|
    require resource unless framework == :merb || framework == :rails
    name = File.basename(resource,".rb").pluralize
    unless File.exists? DataStore.local_dir/name
      FileUtils.mkdir_p(DataStore.local_dir/name)
    end
  end
end