dolly 0.6.2 → 0.7.0
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.
- checksums.yaml +4 -4
- data/lib/dolly/document.rb +1 -1
- data/lib/dolly/name_space.rb +11 -5
- data/lib/dolly/version.rb +1 -1
- data/test/document_test.rb +16 -1
- data/test/dummy/log/test.log +21651 -0
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 754dab90c1532d18893458b0b7301b38b319e5a1
|
4
|
+
data.tar.gz: ff8a35e0bdbfe7af08a62e3c42042024d8c1af2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b517028df8a2946914bd15d56c04a279d6c67392de905bb31160753b31366be2ca6dce9e23bbda648882404e01ccdb908f32553c32265c373e866401e0cdbf26
|
7
|
+
data.tar.gz: 0964bd2b62f61ac822fe10da422cc055eb25ce8eb2b8d97302632577ff3eba438072f09318cceddce89dc6789773d07af0a5820b2753750609a8a7cf16ec8ce5
|
data/lib/dolly/document.rb
CHANGED
@@ -5,12 +5,12 @@ module Dolly
|
|
5
5
|
class Document
|
6
6
|
extend Dolly::Connection
|
7
7
|
include Dolly::Query
|
8
|
-
include Dolly::NameSpace
|
9
8
|
|
10
9
|
attr_accessor :rows, :doc, :key
|
11
10
|
class_attribute :properties
|
12
11
|
|
13
12
|
def initialize options = {}
|
13
|
+
options = options.with_indifferent_access
|
14
14
|
init_properties options
|
15
15
|
end
|
16
16
|
|
data/lib/dolly/name_space.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
require "active_model/naming"
|
2
|
-
|
3
|
-
#TODO: remove this module to be part of Dolly::Document
|
4
1
|
module Dolly
|
5
2
|
module NameSpace
|
6
|
-
include ActiveModel::Naming
|
7
3
|
|
8
4
|
def name_paramitized
|
9
|
-
|
5
|
+
underscore name.split("::").last
|
10
6
|
end
|
11
7
|
|
12
8
|
def base_id id
|
@@ -18,5 +14,15 @@ module Dolly
|
|
18
14
|
return id if id =~ %r~^#{name_paramitized}/~
|
19
15
|
"#{name_paramitized}/#{id}"
|
20
16
|
end
|
17
|
+
|
18
|
+
#FROM ActiveModel::Name
|
19
|
+
def underscore(camel_cased_word)
|
20
|
+
camel_cased_word.to_s.gsub(/::/, '/').
|
21
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
22
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
23
|
+
tr("-", "_").
|
24
|
+
downcase
|
25
|
+
end
|
26
|
+
|
21
27
|
end
|
22
28
|
end
|
data/lib/dolly/version.rb
CHANGED
data/test/document_test.rb
CHANGED
@@ -218,9 +218,24 @@ class DocumentTest < ActiveSupport::TestCase
|
|
218
218
|
assert_equal "foo_bar/b", bar.id
|
219
219
|
end
|
220
220
|
|
221
|
+
test 'new document will have id from _id or id strings' do
|
222
|
+
foo = FooBar.new 'id' => 'a'
|
223
|
+
bar = FooBar.new '_id' => 'b'
|
224
|
+
assert_equal "foo_bar/a", foo.id
|
225
|
+
assert_equal "foo_bar/b", bar.id
|
226
|
+
end
|
227
|
+
|
221
228
|
test 'new document with no id' do
|
222
229
|
foo = FooBar.new
|
223
|
-
|
230
|
+
uuid = %r{
|
231
|
+
\A
|
232
|
+
foo_bar /
|
233
|
+
\h{8} # 8 hex chars
|
234
|
+
(?: - \h{4} ){3} # 3 groups of 4 hex chars (hyphen sep)
|
235
|
+
- \h{12} # 12 hex chars (hyphen sep again)
|
236
|
+
\Z
|
237
|
+
}x
|
238
|
+
assert foo.id.match(uuid)
|
224
239
|
end
|
225
240
|
|
226
241
|
private
|