cistern 0.5.8 → 0.5.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.
- checksums.yaml +4 -4
- data/lib/cistern/formatter/awesome_print.rb +2 -0
- data/lib/cistern/formatter/formatador.rb +1 -0
- data/lib/cistern/singular.rb +29 -0
- data/lib/cistern/version.rb +1 -1
- data/lib/cistern.rb +1 -0
- data/spec/singular_spec.rb +28 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22130f93692ecf1fd5787a47a26e63fd15e9fec2
|
4
|
+
data.tar.gz: 1d4e233bc2d120ae1b8f95dde7de34e9ecdd7507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6b5ebb39c15d3380389d40986d2e3f8903e15f78187b21a5f745e24a8c461538a5f7c534fe462358976fc2097da1104dff76efbdbb4de037f80876e88b69fc4
|
7
|
+
data.tar.gz: 97aafbc65dff82e996b7799b4ff9625ce448cd1b118569879a6cda8ad843eeeb52dda6e9c547531366fb3ec3701eaedbd110b08e38384fc119f54098b5fe9638
|
@@ -16,6 +16,8 @@ module AwesomePrint::Cistern
|
|
16
16
|
cast = cast_without_cistern(object, type)
|
17
17
|
if object.is_a?(Cistern::Model)
|
18
18
|
cast = :cistern_model
|
19
|
+
elsif object.is_a?(Cistern::Singular)
|
20
|
+
cast = :cistern_model
|
19
21
|
elsif object.is_a?(Cistern::Collection)
|
20
22
|
cast = :cistern_collection
|
21
23
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Cistern::Singular
|
2
|
+
extend Cistern::Attributes::ClassMethods
|
3
|
+
include Cistern::Attributes::InstanceMethods
|
4
|
+
|
5
|
+
attr_accessor :connection
|
6
|
+
|
7
|
+
def inspect
|
8
|
+
if Cistern.formatter
|
9
|
+
Cistern.formatter.call(self)
|
10
|
+
else
|
11
|
+
"#<#{self.class}>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
merge_attributes(options)
|
17
|
+
reload
|
18
|
+
end
|
19
|
+
|
20
|
+
def reload
|
21
|
+
if new_attributes = fetch_attributes
|
22
|
+
merge_attributes(new_attributes)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_attributes
|
27
|
+
raise NotImplementedError
|
28
|
+
end
|
29
|
+
end
|
data/lib/cistern/version.rb
CHANGED
data/lib/cistern.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Cistern::Singular" do
|
4
|
+
class SampleSingular < Cistern::Singular
|
5
|
+
attribute :name
|
6
|
+
attribute :count, type: :number
|
7
|
+
|
8
|
+
def fetch_attributes
|
9
|
+
#test that initialize waits for connection to be defined
|
10
|
+
raise "missing connection" unless connection
|
11
|
+
|
12
|
+
@counter ||= 0
|
13
|
+
@counter += 1
|
14
|
+
{name: "amazing", count: @counter}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should work" do
|
19
|
+
SampleSingular.new(connection: :fake).name.should == "amazing"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should reload" do
|
23
|
+
singular = SampleSingular.new(connection: :fake)
|
24
|
+
old_count = singular.count
|
25
|
+
singular.count.should == old_count
|
26
|
+
singular.reload.count.should > old_count
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cistern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: API client framework extracted from Fog
|
14
14
|
email:
|
@@ -37,12 +37,14 @@ files:
|
|
37
37
|
- lib/cistern/mock.rb
|
38
38
|
- lib/cistern/model.rb
|
39
39
|
- lib/cistern/service.rb
|
40
|
+
- lib/cistern/singular.rb
|
40
41
|
- lib/cistern/timeout.rb
|
41
42
|
- lib/cistern/version.rb
|
42
43
|
- lib/cistern/wait_for.rb
|
43
44
|
- spec/cistern_spec.rb
|
44
45
|
- spec/collection_spec.rb
|
45
46
|
- spec/model_spec.rb
|
47
|
+
- spec/singular_spec.rb
|
46
48
|
- spec/spec_helper.rb
|
47
49
|
- spec/wait_for_spec.rb
|
48
50
|
homepage: http://joshualane.com/cistern
|
@@ -73,6 +75,7 @@ test_files:
|
|
73
75
|
- spec/cistern_spec.rb
|
74
76
|
- spec/collection_spec.rb
|
75
77
|
- spec/model_spec.rb
|
78
|
+
- spec/singular_spec.rb
|
76
79
|
- spec/spec_helper.rb
|
77
80
|
- spec/wait_for_spec.rb
|
78
81
|
has_rdoc:
|