cloudwow-not_relational 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/lib/not_relational/configuration.rb +17 -16
- data/lib/not_relational/domain_model.rb +2 -0
- data/lib/not_relational/property_description.rb +9 -2
- data/lib/not_relational/sdb_formatter.rb +18 -4
- data/lib/not_relational/storage.rb +0 -1
- data/test/models/album.rb +1 -1
- data/test/unit_tests/album_test.rb +18 -0
- metadata +3 -2
data/VERSION.yml
CHANGED
@@ -43,7 +43,7 @@ module NotRelational
|
|
43
43
|
@cipher_key_file = not_relational_config['cipher_key_file']
|
44
44
|
@cipher_key_file ||= "./.cipher_key"
|
45
45
|
if @cipher_key_file and File.exists?(@cipher_key_file)
|
46
|
-
|
46
|
+
@cipher_key=File.open(@cipher_key_file).read
|
47
47
|
end
|
48
48
|
|
49
49
|
@cipher_iv_file=not_relational_config['cipher_iv_file']
|
@@ -54,19 +54,19 @@ module NotRelational
|
|
54
54
|
|
55
55
|
end
|
56
56
|
end
|
57
|
-
def crypto
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
57
|
+
def crypto
|
58
|
+
return @crypto if @crypto
|
59
|
+
options={}
|
60
|
+
if cipher_key
|
61
|
+
options[:cipher_key=]= cipher_key
|
62
|
+
options[:cipher_iv ]= cipher_iv
|
63
|
+
@crypto=Crypto.new()
|
64
|
+
else
|
65
|
+
@crypto=Crypto.new
|
66
|
+
File.open(self.cipher_key_file,'w').write(@crypto.key)
|
67
|
+
File.open(self.cipher_iv_file,'w').write(@crypto.iv)
|
68
|
+
end
|
69
|
+
end
|
70
70
|
def cipher_key
|
71
71
|
return @cipher_key
|
72
72
|
end
|
@@ -80,7 +80,7 @@ end
|
|
80
80
|
config_file_path=nil
|
81
81
|
config_section=nil
|
82
82
|
|
83
|
-
#when using rails use config/database.yml
|
83
|
+
# #when using rails use config/database.yml
|
84
84
|
if Object.const_defined?(:RAILS_ROOT) and ENV.has_key?('RAILS_ENV')
|
85
85
|
config_file_path = File.join("#{RAILS_ROOT}","config","database.yml")
|
86
86
|
|
@@ -89,7 +89,8 @@ end
|
|
89
89
|
|
90
90
|
|
91
91
|
else
|
92
|
-
#when not using rails use try database.yml then try
|
92
|
+
# #when not using rails use try database.yml then try
|
93
|
+
# config/database.yml
|
93
94
|
|
94
95
|
if File.exists?("database.yml")
|
95
96
|
|
@@ -33,6 +33,8 @@ module NotRelational
|
|
33
33
|
unless @attribute_values.has_key?(attribute_name)
|
34
34
|
if description.is_collection
|
35
35
|
@attribute_values[attribute_name]=[]
|
36
|
+
elsif description.value_type==:property_bag
|
37
|
+
@attribute_values[attribute_name]={}
|
36
38
|
else
|
37
39
|
@attribute_values[attribute_name]=nil unless @attribute_values.has_key?(attribute_name)
|
38
40
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module NotRelational
|
2
|
+
|
3
|
+
require 'ya2yaml'
|
2
4
|
require File.dirname(__FILE__) +'/sdb_formatter.rb'
|
3
5
|
require File.dirname(__FILE__) +'/crypto.rb'
|
4
6
|
require File.dirname(__FILE__) +'/configuration.rb'
|
@@ -49,7 +51,10 @@ class PropertyDescription
|
|
49
51
|
result= format_unsigned_integer(value)
|
50
52
|
elsif self.value_type==:float
|
51
53
|
result= format_float(value)
|
52
|
-
|
54
|
+
|
55
|
+
elsif self.value_type==:property_bag
|
56
|
+
result= format_property_bag(value)
|
57
|
+
|
53
58
|
else
|
54
59
|
result= format_string(value.to_s)
|
55
60
|
end
|
@@ -93,7 +98,9 @@ class PropertyDescription
|
|
93
98
|
return parse_unsigned_integer(value)
|
94
99
|
elsif self.value_type==:float
|
95
100
|
return parse_float(value)
|
96
|
-
|
101
|
+
elsif self.value_type==:property_bag
|
102
|
+
return parse_property_bag(value)
|
103
|
+
else
|
97
104
|
return value.to_s
|
98
105
|
end
|
99
106
|
return value
|
@@ -33,16 +33,23 @@ module SdbFormatter
|
|
33
33
|
|
34
34
|
end
|
35
35
|
def parse_float(value)
|
36
|
-
return nil if value==nil
|
36
|
+
return nil if value==nil
|
37
37
|
return value.to_f
|
38
38
|
end
|
39
|
+
|
40
|
+
def parse_property_bag(value)
|
41
|
+
return {} if value==nil
|
42
|
+
return YAML::load(value)
|
43
|
+
|
44
|
+
end
|
45
|
+
|
39
46
|
def parse_unsigned_integer(value)
|
40
47
|
return nil if value==nil
|
41
48
|
return value.to_i
|
42
49
|
end
|
43
50
|
|
44
51
|
def format_reference_set(value)
|
45
|
-
value.to_yaml
|
52
|
+
value.to_yaml#ya2yaml(:syck_compatible => true)
|
46
53
|
|
47
54
|
end
|
48
55
|
|
@@ -91,8 +98,15 @@ module SdbFormatter
|
|
91
98
|
end
|
92
99
|
return zero_pad_integer(value)
|
93
100
|
end
|
94
|
-
|
95
|
-
|
101
|
+
|
102
|
+
def format_property_bag(value)
|
103
|
+
if !value
|
104
|
+
return nil
|
105
|
+
end
|
106
|
+
return value.to_yaml#(:syck_compatible => true)
|
107
|
+
end
|
108
|
+
|
109
|
+
|
96
110
|
|
97
111
|
def zero_pad_integer(value)
|
98
112
|
value=value.to_i
|
data/test/models/album.rb
CHANGED
@@ -14,7 +14,7 @@ class Album < NotRelational::DomainModel
|
|
14
14
|
property :last_update_time_utc ,:date
|
15
15
|
property :is_private, :boolean
|
16
16
|
property :group_id, :string
|
17
|
-
|
17
|
+
property :metadata,:property_bag
|
18
18
|
index :group_and_title ,[:group_id,:title],:unique=>true
|
19
19
|
many_to_many :Mediaitem,:AlbumMediaItem,:album_id,:mediaitem_id,:mediaitems,:order_by=>:created_time
|
20
20
|
belongs_to :Group
|
@@ -174,4 +174,22 @@ class AlbumTest < Test::Unit::TestCase
|
|
174
174
|
assert(found!=nil)
|
175
175
|
assert_equal(1,found.length)
|
176
176
|
end
|
177
|
+
def test_metadata
|
178
|
+
a =Album.new
|
179
|
+
a.user_name='david'
|
180
|
+
a.metadata['x']='x1'
|
181
|
+
a.metadata['y']='y1'
|
182
|
+
a.save
|
183
|
+
|
184
|
+
assert_equal(a.metadata['x'],'x1')
|
185
|
+
assert_equal(a.metadata['y'],'y1')
|
186
|
+
|
187
|
+
NotRelational::RepositoryFactory.instance.clear_session_cache
|
188
|
+
found=Album.find(a.id)
|
189
|
+
assert_not_nil(found.metadata)
|
190
|
+
assert_equal(2,found.metadata.length)
|
191
|
+
assert_equal(found.metadata['x'],'x1')
|
192
|
+
assert_equal(found.metadata['y'],'y1')
|
193
|
+
|
194
|
+
end
|
177
195
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudwow-not_relational
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cloudwow
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-31 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/not_relational/memory_repository.rb
|
44
44
|
- lib/not_relational/memory_storage.rb
|
45
45
|
- lib/not_relational/or_condition.rb
|
46
|
+
- lib/not_relational/property_bag.rb
|
46
47
|
- lib/not_relational/property_description.rb
|
47
48
|
- lib/not_relational/query_string_auth_generator.rb
|
48
49
|
- lib/not_relational/reference.rb
|