shogun 2.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shogun/control.rb +0 -1
- data/lib/shogun/database.rb +26 -2
- data/lib/shogun/denormalizer.rb +3 -3
- data/lib/shogun/normalizer.rb +4 -0
- data/lib/shogun/version.rb +1 -1
- data/spec/lib/shogun/denormalizer_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cba5f44740220ceed421671ca29aaf67451e1c8
|
4
|
+
data.tar.gz: 94496c87fe09aed639148d73f84ab094abe7db52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b6a4534a71e86e45934c7f049b3cc8e761061c71b796373d308a5406ea067a9749801e8568ccc9703e5c7e74f16125dcacbc84be7bfd5f7c579d38e5965d5a0
|
7
|
+
data.tar.gz: fb797d95f7f69233ad534fbb3c09270c01c02b076717b4ba18d8ed818dc14813f3d42b2de6245ccb165fec069f164b2e92ef1d151ccb4ffee768e25b003c5692
|
data/lib/shogun/control.rb
CHANGED
data/lib/shogun/database.rb
CHANGED
@@ -36,9 +36,33 @@ module Shogun
|
|
36
36
|
ActiveRecord::LogSubscriber.logger = @logger
|
37
37
|
ActiveRecord::LogSubscriber.colorize_logging = false
|
38
38
|
ActiveRecord::Base.time_zone_aware_attributes = true
|
39
|
-
ActiveRecord::Base.default_timezone = (
|
39
|
+
ActiveRecord::Base.default_timezone = (timezone || default_timezone).to_sym
|
40
40
|
ActiveRecord::Base.logger = @logger
|
41
|
-
ActiveRecord::Base.establish_connection(
|
41
|
+
ActiveRecord::Base.establish_connection(uri)
|
42
|
+
end
|
43
|
+
|
44
|
+
private def url
|
45
|
+
self.class.const_get("URL")
|
46
|
+
end
|
47
|
+
|
48
|
+
private def uri
|
49
|
+
"#{url}?#{query}"
|
50
|
+
end
|
51
|
+
|
52
|
+
private def query
|
53
|
+
configuration.to_query
|
54
|
+
end
|
55
|
+
|
56
|
+
private def configuration
|
57
|
+
self.class.const_get("CONFIGURATION")
|
58
|
+
end
|
59
|
+
|
60
|
+
private def timezone
|
61
|
+
self.class.const_get("TIMEZONE")
|
62
|
+
end
|
63
|
+
|
64
|
+
private def default_timezone
|
65
|
+
self.class.const_get("DEFAULT_TIMEZONE")
|
42
66
|
end
|
43
67
|
end
|
44
68
|
end
|
data/lib/shogun/denormalizer.rb
CHANGED
@@ -14,7 +14,7 @@ module Shogun
|
|
14
14
|
|
15
15
|
def as_document
|
16
16
|
{
|
17
|
-
|
17
|
+
namespace => document,
|
18
18
|
meta_key => @meta,
|
19
19
|
links_key => @links,
|
20
20
|
linked_key => @linked
|
@@ -31,8 +31,8 @@ module Shogun
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
private def
|
35
|
-
self.class.const_get("
|
34
|
+
private def namespace
|
35
|
+
self.class.const_get("NAMESPACE")
|
36
36
|
end
|
37
37
|
|
38
38
|
private def meta_key
|
data/lib/shogun/normalizer.rb
CHANGED
data/lib/shogun/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe Shogun::Denormalizer do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
let(:denormalizer) { denormalizer_klass.new(object: presenter, fields: fields) }
|
10
|
-
let(:
|
10
|
+
let(:namespace) { "accounts" }
|
11
11
|
let(:presenter) { instance_double("Presenter") }
|
12
12
|
let(:links) { { "a" => "b" } }
|
13
13
|
let(:meta) { { "c" => "d" } }
|
@@ -23,7 +23,7 @@ describe Shogun::Denormalizer do
|
|
23
23
|
allow(presenter).to receive(:linked).and_return(linked)
|
24
24
|
allow(presenter).to receive(:a).and_return(a)
|
25
25
|
allow(presenter).to receive(:b).and_return(b)
|
26
|
-
allow(denormalizer).to receive(:
|
26
|
+
allow(denormalizer).to receive(:namespace).and_return(namespace)
|
27
27
|
allow(denormalizer).to receive(:mapping).and_return(mapping)
|
28
28
|
end
|
29
29
|
|
@@ -46,8 +46,8 @@ describe Shogun::Denormalizer do
|
|
46
46
|
expect(as_document).to have_key(Shogun::Denormalizer::LINKED_KEY)
|
47
47
|
end
|
48
48
|
|
49
|
-
it "contains the
|
50
|
-
expect(as_document).to have_key(
|
49
|
+
it "contains the namespace key" do
|
50
|
+
expect(as_document).to have_key(namespace)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|