record_redis 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c11177d1227be344bd47d3b984b7e57a901e0928
4
- data.tar.gz: 87396ea689c2256d50f5efc6544b1263781dbc9e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTcyZmY2ZDAwYWZmZTAyZDJiODFlNDJiYjhlZTAxZDY5ZDU0OWFkNg==
5
+ data.tar.gz: !binary |-
6
+ MTM2MDZlYzgyZTc1OGI3MTg5MTU1YzcwNTkxYmRhZmU1MzYwNzc0OQ==
5
7
  SHA512:
6
- metadata.gz: 8ebbddfc671b7f0b020ef7443c321e9a8704a040d1752c0da222720f75bd096a7e7c9e21bfe6af52aa668335596f9fa31e868b9d08fca75106d9fee220e883f9
7
- data.tar.gz: 16a8e37abdbe8ccb7f53a47b1b19a458107b41aac6c2487e754455f1eb8a1e94514e667e7d66cfb9c61974e593afc8401b4f0cbd062077c2bb572a6384a33ccb
8
+ metadata.gz: !binary |-
9
+ ZDEwY2FiNDU5MmViZTNkYTY3MzY1NDRjZDQ1MGI1NjA2ZmIwNzZmYjIyN2M2
10
+ NmU3MzU5NDg3MzIyZjlkYWJjZDU0OTcwZTdmNGJlOTE1M2ExNzM1OWY0NDMy
11
+ ZDhjMjg4NGE0ZTg4Mjg4OTViOWQwZGI4MzY3ZGM2MzBlNjFkODE=
12
+ data.tar.gz: !binary |-
13
+ NzIyYTZiMDE3ZDkxNDJjYjhhZWIwNGU1MTFiOWY1OWJhMzFhYzQ3Yjk2OGQy
14
+ YmQxYTNiNjVmNTZhODk5MWI3ZGFhYzg1NmQ2MGM0MTI4MGNjOWVjZDNlZWFk
15
+ ODhjZjA3ZGM1Yjc0Y2JjYWYwZmY0MzI2ZmFmZjBjOGVhZTdmNTM=
@@ -21,7 +21,7 @@ module RedisRecord
21
21
  model
22
22
  end
23
23
 
24
- def self.find_all
24
+ def self.find_all(*args)
25
25
  models = Array.new
26
26
  name= self.name
27
27
  RedisRecord::Connection.connect unless RedisRecord::Connection.isConnected?
@@ -38,9 +38,24 @@ module RedisRecord
38
38
  else
39
39
  return nil
40
40
  end
41
+ if args.size > 0
42
+ models = redis_sort(models,args.first[:sort]) if args.first[:sort]
43
+ end
41
44
  models
42
45
  end
43
46
 
47
+ def self.redis_sort(elements,order)
48
+ attribute= order.split(" ").first
49
+ direction= order.split(" ").last
50
+
51
+ if direction=="dsc"
52
+ elements.sort {|a,b| b.send(attribute) <=> a.send(attribute)}
53
+ else
54
+ elements.sort {|a,b| a.send(attribute) <=> b.send(attribute)}
55
+ end
56
+
57
+
58
+ end
44
59
  def update(attributes)
45
60
  @hash_of_properties.merge!(attributes)
46
61
  name= self.class
@@ -25,7 +25,7 @@ module RedisRecord
25
25
  def self.make_has_many_relation(name)
26
26
  class_eval <<-EOD
27
27
  def #{name}
28
- #{name}.find_all_by_#{self.name}Key(self.Key)
28
+ #{name}.find_all_by_#{self.name}Key(self.Key.to_s)
29
29
  end
30
30
  EOD
31
31
  end
@@ -40,7 +40,7 @@ module RedisRecord
40
40
  def self.make_has_one_relation(name)
41
41
  class_eval <<-EOD
42
42
  def #{name}
43
- #{name}.find_by_#{self.name}Key(self.Key)
43
+ #{name}.find_by_#{self.name}Key(self.Key.to_s)
44
44
  end
45
45
  EOD
46
46
  end
@@ -1,3 +1,3 @@
1
1
  module RedisRecord
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -2,11 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe RedisRecord::Base do
4
4
 
5
+
5
6
  describe '#properties' do
6
7
  it 'should have a method #name and #format' do
7
8
  network= Network.new
8
- network.methods.to_s.include?("Name=").should be_true
9
- network.methods.to_s.include?("Format=").should be_true
9
+ network.methods.to_s.include?("Name=").should == true
10
+ network.methods.to_s.include?("Format=").should == true
10
11
  end
11
12
 
12
13
  it 'must change the value of the name property' do
@@ -20,13 +21,13 @@ describe RedisRecord::Base do
20
21
  describe '#create' do
21
22
  it 'should should be true to create a entity' do
22
23
  network= Network.create({"Name" => "paul"})
23
- network.should be_true
24
+ network.should == true
24
25
 
25
26
  end
26
27
 
27
28
  it 'should be true to create a entity with empty key' do
28
29
  network= Network.create({"Name" => "paul", "Key" => ""})
29
- network.should be_true
30
+ network.should == true
30
31
  end
31
32
  end
32
33
 
@@ -53,9 +54,15 @@ describe RedisRecord::Base do
53
54
  end
54
55
 
55
56
  describe '#find_by_' do
57
+
58
+ before(:all) do
59
+ redis_fixture= RedisRecord::Fixture.new
60
+ redis_fixture.fixture "Network"
61
+ end
62
+
56
63
  it 'must find a Entry with the given name' do
57
- name= "testNetwork"
58
- result= Network.find_by_Name("testNetwork")
64
+ name= "f_name"
65
+ result= Network.find_by_Name("f_name")
59
66
  result.Name.should == name
60
67
  end
61
68
  end
@@ -81,7 +88,19 @@ describe RedisRecord::Base do
81
88
  it 'should remove a existing entity' do
82
89
  Network.create({"Name" => "paul", "Key" => "1234567890_for_delete"})
83
90
  network= Network.find("1234567890_for_delete")
84
- network.delete.should be_true
91
+ network.delete.should == 1
92
+ end
93
+ end
94
+
95
+ describe '#find_all with sort' do
96
+
97
+ redis_fixture= RedisRecord::Fixture.new
98
+ redis_fixture.fixture "Network"
99
+
100
+ it 'must find all Entries for the given attribute sort by a attribute' do
101
+ networks = Network.find_all({:sort => "Name dsc"})
102
+ networks.first.Name.should == "s_name"
85
103
  end
104
+
86
105
  end
87
106
  end
@@ -4,7 +4,7 @@ describe RedisRecord::Connection do
4
4
  before (:all) do
5
5
  @host = "127.0.0.1"
6
6
  @port = "6379"
7
- @db = 0
7
+ @db = 2
8
8
  end
9
9
 
10
10
  it 'must set a host for a connection' do
@@ -23,20 +23,20 @@ describe RedisRecord::Connection do
23
23
  describe '#connect' do
24
24
  it 'has to connect to a given redis db' do
25
25
  redis = RedisRecord::Connection.connect
26
- RedisRecord::Connection.isConnected?.should be_true
26
+ RedisRecord::Connection.isConnected?.should == true
27
27
  end
28
28
 
29
29
  it 'has to reconnect to a given redis db' do
30
30
  redis = RedisRecord::Connection.connect
31
31
  redis.client.disconnect
32
32
  redis = RedisRecord::Connection.connect
33
- RedisRecord::Connection.isConnected?.should be_true
33
+ RedisRecord::Connection.isConnected?.should == true
34
34
  end
35
35
 
36
36
  it 'should be false to check a failed redis connection' do
37
37
  redis = RedisRecord::Connection.connect
38
38
  redis.client.disconnect
39
- RedisRecord::Connection.isConnected?.should be_false
39
+ RedisRecord::Connection.isConnected?.should == false
40
40
  end
41
41
  end
42
42
 
@@ -6,10 +6,6 @@ describe RedisRecord::Fixture do
6
6
  #code
7
7
  end
8
8
 
9
- before(:all) do
10
- RedisRecord::Fixture::Fixture_Path= "./spec/fixtures/"
11
- end
12
-
13
9
  it 'should load a fixtures yaml' do
14
10
  fixture= RedisRecord::Fixture.new
15
11
  erg = fixture.load(RedisRecord::Fixture::Fixture_Path+"network")
@@ -13,12 +13,14 @@ end
13
13
  describe RedisRecord::Base do
14
14
 
15
15
  it 'Site must have a Network' do
16
- network= Network.create({:Name => "paul", :Key => "1234567890"})
17
- site= Site.create({:Name => "paul", :Key => "1234567890", :NetworkKey=>"1234567890"})
16
+ network= Network.create({"Name" => "paul", "Key" => "1234567890"})
17
+ site= Site.create({"Name" => "paul", "Key" => "1234567890", "NetworkKey"=>"1234567890"})
18
18
  site= Site.find("1234567890")
19
19
  site.Network.Name.should=="paul"
20
20
  end
21
21
  it 'Network must have a Site' do
22
+ network= Network.create({"Name" => "paul", "Key" => "1234567890"})
23
+ Site.create({"Name" => "paul", "Key" => "1234567890", "NetworkKey"=>"1234567890"})
22
24
  network= Network.find("1234567890")
23
25
  network.Site.first.Name.should=="paul"
24
26
  end
data/spec/spec_helper.rb CHANGED
@@ -30,7 +30,7 @@ end
30
30
  RedisRecord::Connection::Host= @host
31
31
  @port = "6379"
32
32
  RedisRecord::Connection::Port= @port
33
- @db = 0
33
+ @db = 2
34
34
  RedisRecord::Connection::Db= @db
35
35
  RedisRecord::Connection.connect
36
-
36
+ RedisRecord::Fixture::Fixture_Path= "./spec/fixtures/"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Schlimper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -28,42 +28,42 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: a redis orm mapper for rails
@@ -73,8 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - ".gitignore"
77
- - ".rspec"
76
+ - .gitignore
77
+ - .rspec
78
78
  - Gemfile
79
79
  - LICENSE.txt
80
80
  - README.md
@@ -103,12 +103,12 @@ require_paths:
103
103
  - lib
104
104
  required_ruby_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ">="
106
+ - - ! '>='
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - ! '>='
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []