cistern 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42aadc8d27a58a072c8338e1e575e03e2d17b20f
4
- data.tar.gz: 41510985135dbe04bd392882acf61c24d86333c7
3
+ metadata.gz: 22130f93692ecf1fd5787a47a26e63fd15e9fec2
4
+ data.tar.gz: 1d4e233bc2d120ae1b8f95dde7de34e9ecdd7507
5
5
  SHA512:
6
- metadata.gz: 86c4634fd7ca6824279227821a7f5336a37bfc01f28bf2bc8bf583b74b0ecaba27b963d1e6d7f4523701d8a5a6a75e09831dc3653b2ea01f29dd5544dfaa528b
7
- data.tar.gz: c1a09a5a40070f4a373acdd2edebceb0e24673653024b439d4c049c00e77a439e8098f3f3ccf429a79d2fae47f066fbe2e1ebd9dfb6aa3509a4b74f9daac5078
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
@@ -5,6 +5,7 @@ module Cistern::Formatter::Formatador
5
5
  case model
6
6
  when Cistern::Collection then collection_inspect(model)
7
7
  when Cistern::Model then model_inspect(model)
8
+ when Cistern::Singular then model_inspect(model)
8
9
  else model.inspect
9
10
  end
10
11
  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
@@ -1,3 +1,3 @@
1
1
  module Cistern
2
- VERSION = "0.5.8"
2
+ VERSION = "0.5.9"
3
3
  end
data/lib/cistern.rb CHANGED
@@ -15,6 +15,7 @@ module Cistern
15
15
  require 'cistern/collection'
16
16
  require 'cistern/model'
17
17
  require 'cistern/service'
18
+ require 'cistern/singular'
18
19
 
19
20
  extend WaitFor
20
21
 
@@ -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.8
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-04 00:00:00.000000000 Z
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: