blendris 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +4 -0
- data/Manifest +32 -0
- data/PostInstall.txt +1 -0
- data/README.rdoc +79 -0
- data/Rakefile +22 -0
- data/autotest/discover.rb +3 -0
- data/blendris.gemspec +32 -0
- data/lib/blendris.rb +25 -0
- data/lib/blendris/accessor.rb +62 -0
- data/lib/blendris/errors.rb +3 -0
- data/lib/blendris/integer.rb +19 -0
- data/lib/blendris/list.rb +37 -0
- data/lib/blendris/model.rb +141 -0
- data/lib/blendris/node.rb +46 -0
- data/lib/blendris/reference.rb +51 -0
- data/lib/blendris/reference_base.rb +68 -0
- data/lib/blendris/reference_set.rb +65 -0
- data/lib/blendris/set.rb +39 -0
- data/lib/blendris/string.rb +19 -0
- data/lib/blendris/types.rb +14 -0
- data/lib/blendris/utils.rb +39 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/list_spec.rb +17 -0
- data/spec/model_spec.rb +180 -0
- data/spec/redis-tools_spec.rb +15 -0
- data/spec/ref_spec.rb +40 -0
- data/spec/set_spec.rb +20 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +85 -0
- data/spec/string_spec.rb +20 -0
- data/tasks/rspec.rake +21 -0
- metadata +128 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "redis connection accessor" do
|
4
|
+
|
5
|
+
it "should connect for reading and writing" do
|
6
|
+
testkey = prefix + "test-string"
|
7
|
+
|
8
|
+
redis.get(testkey).should == nil
|
9
|
+
redis.set(testkey, "foo").should == true
|
10
|
+
redis.get(testkey).should == "foo"
|
11
|
+
redis.del(testkey).should == true
|
12
|
+
redis.del(testkey).should == false
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/ref_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "references" do
|
4
|
+
|
5
|
+
it "should handle complex transitions" do
|
6
|
+
|
7
|
+
@vegetable.foods.count.should == 0
|
8
|
+
@fruit.foods.count.should == 0
|
9
|
+
@onion.category.should be_nil
|
10
|
+
|
11
|
+
@vegetable.foods << @onion
|
12
|
+
|
13
|
+
@vegetable.foods.count.should == 1
|
14
|
+
@vegetable.foods.first.should == @onion
|
15
|
+
@fruit.foods.count.should == 0
|
16
|
+
@onion.category.should == @vegetable
|
17
|
+
|
18
|
+
@fruit.foods << @onion
|
19
|
+
|
20
|
+
@vegetable.foods.count.should == 0
|
21
|
+
@fruit.foods.count.should == 1
|
22
|
+
@fruit.foods.first.should == @onion
|
23
|
+
@onion.category.should == @fruit
|
24
|
+
|
25
|
+
@onion.category = nil
|
26
|
+
|
27
|
+
@vegetable.foods.count.should == 0
|
28
|
+
@fruit.foods.count.should == 0
|
29
|
+
@onion.category.should be_nil
|
30
|
+
|
31
|
+
@onion.category = @vegetable
|
32
|
+
|
33
|
+
@vegetable.foods.count.should == 1
|
34
|
+
@vegetable.foods.first.should == @onion
|
35
|
+
@fruit.foods.count.should == 0
|
36
|
+
@onion.category.should == @vegetable
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/spec/set_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "redis sets" do
|
4
|
+
|
5
|
+
it "should read and write" do
|
6
|
+
@onion.qualities.count.should == 0
|
7
|
+
|
8
|
+
@onion.qualities << %w( delicious white weepy delicious )
|
9
|
+
|
10
|
+
@onion.qualities.count.should == 3
|
11
|
+
@onion.qualities.to_a.sort.should == %w( delicious weepy white )
|
12
|
+
|
13
|
+
@onion.qualities.delete("weepy").should == true
|
14
|
+
@onion.qualities.delete("weepy").should == false
|
15
|
+
|
16
|
+
@onion.qualities.count.should == 2
|
17
|
+
@onion.qualities.to_a.sort.should == %w( delicious white )
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
gem 'rspec'
|
6
|
+
require 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
|
+
require 'blendris'
|
11
|
+
|
12
|
+
include Blendris
|
13
|
+
|
14
|
+
module TestFixtures
|
15
|
+
|
16
|
+
class Food < Model
|
17
|
+
|
18
|
+
key "food", :name
|
19
|
+
|
20
|
+
string :name
|
21
|
+
string :description, :default => "a tasty food"
|
22
|
+
integer :calories, :default => 0
|
23
|
+
set :qualities
|
24
|
+
list :sales
|
25
|
+
ref :category, :class => "TestFixtures::Category", :reverse => :foods
|
26
|
+
ref :sibling, :class => Food, :reverse => :sibling
|
27
|
+
refs :friends, :class => Food, :reverse => :friends
|
28
|
+
ref :something
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class Category < Model
|
33
|
+
|
34
|
+
key "category", :name
|
35
|
+
|
36
|
+
string :name
|
37
|
+
refs :foods, :class => "TestFixtures::Food", :reverse => :category
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
class FavoriteFood < Model
|
42
|
+
|
43
|
+
key "person", :person, :food
|
44
|
+
|
45
|
+
string :person
|
46
|
+
ref :food, :class => Food
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
class Website < Blendris::Model
|
51
|
+
key "website", :title
|
52
|
+
|
53
|
+
string :title
|
54
|
+
string :url
|
55
|
+
set :paths
|
56
|
+
refs :sister_sites, :class => Website, :reverse => :sister_sites
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
Spec::Runner.configure do |config|
|
62
|
+
config.before(:each) do
|
63
|
+
extend RedisAccessor
|
64
|
+
extend TestFixtures
|
65
|
+
|
66
|
+
RedisAccessor.prefix = "blendris-spec:"
|
67
|
+
RedisAccessor.flush_keys
|
68
|
+
|
69
|
+
@vegetable = Category.create("vegetable")
|
70
|
+
@onion = Food.create("onion")
|
71
|
+
@beans = Food.create("beans")
|
72
|
+
|
73
|
+
@fruit = Category.create("fruit")
|
74
|
+
@apple = Food.create("apple")
|
75
|
+
@lemon = Food.create("lemon")
|
76
|
+
|
77
|
+
@meat = Category.create("meat")
|
78
|
+
@steak = Food.create("steak")
|
79
|
+
end
|
80
|
+
|
81
|
+
config.after(:each) do
|
82
|
+
RedisAccessor.flush_keys
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
data/spec/string_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "redis strings" do
|
4
|
+
|
5
|
+
it "should read and write" do
|
6
|
+
@onion.description.should == "a tasty food"
|
7
|
+
|
8
|
+
@onion.description = "a delicious vegetable"
|
9
|
+
@onion.description.should == "a delicious vegetable"
|
10
|
+
|
11
|
+
@onion.description = ""
|
12
|
+
@onion.description.should == ""
|
13
|
+
|
14
|
+
@onion.description = nil
|
15
|
+
@onion.description.should == "a tasty food"
|
16
|
+
|
17
|
+
lambda { @onion.description = 12 }.should raise_exception(TypeError)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blendris
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex McHale
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDAphbGV4
|
14
|
+
bWNoYWxlMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
|
15
|
+
b20wHhcNMTAwMjExMjEyNTU4WhcNMTEwMjExMjEyNTU4WjBBMRMwEQYDVQQDDAph
|
16
|
+
bGV4bWNoYWxlMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
|
17
|
+
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9mTbsd+4JqyuW
|
18
|
+
z/J6OxXyyzb89ydr/wKmJZMyQmD7w/Qf3V8uGW9+NlYbRMJZYqY08QhTbSX3IW6c
|
19
|
+
6Hj4Xo0wqR0Fd6c0Vxdt9m5LZDEo2H+2jisgDBYFUN1itg+FGZtGczISlmG34tWN
|
20
|
+
efWA+DgtzKD9UG13AtzxoxfqeY03v0+/1/SCtpvbZrungWND8sg9sHSxsME0xB9d
|
21
|
+
u6BkunOrdy7iqd105MuPHL35SLhr57GKU/hjR2+FKAauT4eu7CeQXEWCBPXizknN
|
22
|
+
5w/HNs311sBJmzaZwDiX98e+/X10tMxJqWo4t4Us7Ke8b/0uYbuwWoaoKWjM3UYX
|
23
|
+
ppWhyNNFAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
24
|
+
BBQK0Aj0bDKnLJrVNjdgNAXnVaS1qDANBgkqhkiG9w0BAQUFAAOCAQEAU/1kVZUf
|
25
|
+
wjl9bhqLZXgcKgIkzgVYwDcqFE0OdBXFD/N+oNBfV80iN/R8iCf6y4dymYDzWalD
|
26
|
+
Rho49BN531OSYbWAD0lv5/MQYDpH8uHU4cDTzV1cYkOcjFVGsO26aPM7q1SoMhf+
|
27
|
+
8tCJEl/PSHrV6JmgGRDy6YTnbQGSKPNmykEZep8wWEFXMSW9OmwaeyZyEuWUZIS4
|
28
|
+
RtAGR/Bf1/mwYLD0ZZPvsgRy0yBrTeJoaRzJXCT08cN8xBX9sa+PFsjpc267TFsv
|
29
|
+
b0cDNnwAzS78yK9xMdpD5l7/mqtfdQPVLfvra4sMBknSW3ukOP3S/WUOfKOz7Ohf
|
30
|
+
V3OoCfxVK/4Dqg==
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2010-02-11 00:00:00 -06:00
|
34
|
+
default_executable:
|
35
|
+
dependencies: []
|
36
|
+
|
37
|
+
description: A redis library for Ruby
|
38
|
+
email: alexmchale@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README.rdoc
|
45
|
+
- lib/blendris.rb
|
46
|
+
- lib/blendris/accessor.rb
|
47
|
+
- lib/blendris/errors.rb
|
48
|
+
- lib/blendris/integer.rb
|
49
|
+
- lib/blendris/list.rb
|
50
|
+
- lib/blendris/model.rb
|
51
|
+
- lib/blendris/node.rb
|
52
|
+
- lib/blendris/reference.rb
|
53
|
+
- lib/blendris/reference_base.rb
|
54
|
+
- lib/blendris/reference_set.rb
|
55
|
+
- lib/blendris/set.rb
|
56
|
+
- lib/blendris/string.rb
|
57
|
+
- lib/blendris/types.rb
|
58
|
+
- lib/blendris/utils.rb
|
59
|
+
- tasks/rspec.rake
|
60
|
+
files:
|
61
|
+
- History.txt
|
62
|
+
- Manifest
|
63
|
+
- PostInstall.txt
|
64
|
+
- README.rdoc
|
65
|
+
- Rakefile
|
66
|
+
- autotest/discover.rb
|
67
|
+
- lib/blendris.rb
|
68
|
+
- lib/blendris/accessor.rb
|
69
|
+
- lib/blendris/errors.rb
|
70
|
+
- lib/blendris/integer.rb
|
71
|
+
- lib/blendris/list.rb
|
72
|
+
- lib/blendris/model.rb
|
73
|
+
- lib/blendris/node.rb
|
74
|
+
- lib/blendris/reference.rb
|
75
|
+
- lib/blendris/reference_base.rb
|
76
|
+
- lib/blendris/reference_set.rb
|
77
|
+
- lib/blendris/set.rb
|
78
|
+
- lib/blendris/string.rb
|
79
|
+
- lib/blendris/types.rb
|
80
|
+
- lib/blendris/utils.rb
|
81
|
+
- script/console
|
82
|
+
- script/destroy
|
83
|
+
- script/generate
|
84
|
+
- spec/list_spec.rb
|
85
|
+
- spec/model_spec.rb
|
86
|
+
- spec/redis-tools_spec.rb
|
87
|
+
- spec/ref_spec.rb
|
88
|
+
- spec/set_spec.rb
|
89
|
+
- spec/spec.opts
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- spec/string_spec.rb
|
92
|
+
- tasks/rspec.rake
|
93
|
+
- blendris.gemspec
|
94
|
+
has_rdoc: true
|
95
|
+
homepage: http://github.com/alexmchale/blendris
|
96
|
+
licenses: []
|
97
|
+
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options:
|
100
|
+
- --line-numbers
|
101
|
+
- --inline-source
|
102
|
+
- --title
|
103
|
+
- Blendris
|
104
|
+
- --main
|
105
|
+
- README.rdoc
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: "1.2"
|
119
|
+
version:
|
120
|
+
requirements: []
|
121
|
+
|
122
|
+
rubyforge_project: blendris
|
123
|
+
rubygems_version: 1.3.5
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: A redis library for Ruby
|
127
|
+
test_files: []
|
128
|
+
|
metadata.gz.sig
ADDED
Binary file
|