To develop and test your application locally, you can use the Google Cloud
Datastore
Emulator,
which provides local
emulation of the
production Google Cloud Datastore environment. You can start the Google Cloud
Datastore emulator using the gcloud command-line tool.
When you run the Cloud Datastore emulator you will see a message similar to the
following printed:
If you are using a library that supports the DATASTORE_EMULATOR_HOST
environment variable, run:
export DATASTORE_EMULATOR_HOST=localhost:8978
Now you can connect to the emulator using the DATASTORE_EMULATOR_HOST
environment variable:
require"google/cloud/datastore"
# Make Datastore use the emulatorENV["DATASTORE_EMULATOR_HOST"]="localhost:8978"
datastore=Google::Cloud::Datastore.newproject:"emulator-project-id"
task=datastore.entity"Task","emulatorTask"do|t|t["type"]="Testing"
t["done"]=falset["priority"]=5t["description"]="UseDatastoreEmulator"
enddatastore.savetask