Sha256: e8bf7dd5578a925849c61bee1788594d1dea845daa46355c40f305e8e9e7e718

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

# try try/31_api_redis_try.rb

require 'bone'
#Bone.debug = true
@token = 'atoken'
@secret = Bone.random_secret

## Can set the base uri without a token
Bone.source = 'redis://localhost:8045'
#=> 'redis://localhost:8045'

## Knows to use the redis API
Bone.api
#=> Bone::API::Redis

## Can generate a token
@generated_token, secret = *Bone.generate
@generated_token.size
#=> 24

## Can register a token
token = Bone.register @token, @secret
#=> 'atoken'

## Can set token directly
Bone.token = @token
Bone.token
#=> @token

## Can check secret via API
Bone.api.secret @token
#=> @secret

## Knows a valid token
Bone.token? @token
#=> true

## Knows an invalid token
Bone.token? 'bogustoken'
#=> false

## Empty key returns nil
Bone['bogus']
#=> nil

## Make request to API directly
Bone.api.get Bone.token, Bone.secret, 'bogus'
#=> nil

## Set a value
Bone['akey1'] = 'value1'
Bone['akey1']
#=> 'value1'

## Get a value
Bone['akey1']
#=> 'value1'

## Knows all keys
Bone.keys
#=> ["akey1"]

## Knows when a key exists
Bone.key? :akey1
#=> true

## Knows when a key doesn't exist
Bone.key? :bogus
#=> false


Bone.destroy @token
Bone.destroy @generated_token

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bone-0.3.2 try/31_api_redis_try.rb
bone-0.3.1 try/31_api_redis_try.rb
bone-0.3.0 try/31_api_redis_try.rb