cistern 2.3.0 → 2.4.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/.gitignore +1 -0
- data/.travis.yml +5 -1
- data/Appraisals +3 -0
- data/CHANGELOG.md +17 -1
- data/Gemfile +2 -0
- data/README.md +319 -127
- data/gemfiles/ruby_lt_2.0.gemfile +24 -0
- data/lib/cistern.rb +1 -0
- data/lib/cistern/attributes.rb +101 -110
- data/lib/cistern/collection.rb +2 -0
- data/lib/cistern/formatter/awesome_print.rb +1 -1
- data/lib/cistern/hash.rb +19 -5
- data/lib/cistern/hash_support.rb +6 -0
- data/lib/cistern/model.rb +1 -0
- data/lib/cistern/request.rb +2 -0
- data/lib/cistern/singular.rb +12 -22
- data/lib/cistern/version.rb +1 -1
- data/spec/attributes_spec.rb +1 -1
- data/spec/coverage_spec.rb +1 -1
- data/spec/hash_spec.rb +35 -0
- data/spec/model_spec.rb +14 -0
- data/spec/singular_spec.rb +25 -17
- metadata +6 -2
data/lib/cistern/version.rb
CHANGED
data/spec/attributes_spec.rb
CHANGED
@@ -75,7 +75,7 @@ describe Cistern::Attributes, 'parsing' do
|
|
75
75
|
it 'should parse string' do
|
76
76
|
expect(TypeSpec.new(name: 1).name).to eq('1')
|
77
77
|
expect(TypeSpec.new(name: "b").name).to eq('b')
|
78
|
-
expect(TypeSpec.new(name: nil).name).to eq(
|
78
|
+
expect(TypeSpec.new(name: nil).name).to eq(nil)
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should allow nils in string types' do
|
data/spec/coverage_spec.rb
CHANGED
@@ -30,6 +30,6 @@ describe 'coverage', :coverage do
|
|
30
30
|
|
31
31
|
it "should store how many times an attribute's reader is called" do
|
32
32
|
expect(CoverageSpec.attributes[:used][:coverage_hits]).to eq(2)
|
33
|
-
expect(CoverageSpec.attributes[:unused][:coverage_hits]).to eq(
|
33
|
+
expect(CoverageSpec.attributes[:unused][:coverage_hits]).to eq(3)
|
34
34
|
end
|
35
35
|
end
|
data/spec/hash_spec.rb
CHANGED
@@ -49,3 +49,38 @@ describe 'Cistern::Hash' do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
shared_examples_for 'hash_support' do
|
54
|
+
it { should respond_to(:hash_except) }
|
55
|
+
it { should respond_to(:hash_except!) }
|
56
|
+
it { should respond_to(:hash_slice) }
|
57
|
+
it { should respond_to(:hash_stringify_keys) }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe Cistern::Model do
|
61
|
+
subject { Class.new(Sample::Model).new }
|
62
|
+
|
63
|
+
include_examples 'hash_support'
|
64
|
+
end
|
65
|
+
|
66
|
+
describe Cistern::Collection do
|
67
|
+
subject { Class.new(Sample::Collection).new }
|
68
|
+
|
69
|
+
include_examples 'hash_support'
|
70
|
+
end
|
71
|
+
|
72
|
+
describe Cistern::Singular do
|
73
|
+
subject { Class.new(Sample::Singular) do
|
74
|
+
def reload
|
75
|
+
attributes
|
76
|
+
end
|
77
|
+
end.new({}) }
|
78
|
+
|
79
|
+
include_examples 'hash_support'
|
80
|
+
end
|
81
|
+
|
82
|
+
describe Cistern::Request do
|
83
|
+
subject { Class.new(Sample::Request).new({}) }
|
84
|
+
|
85
|
+
include_examples 'hash_support'
|
86
|
+
end
|
data/spec/model_spec.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Cistern::Model' do
|
4
|
+
describe 'inheritance' do
|
5
|
+
it 'provides the child with the attributes of the parent' do
|
6
|
+
parent = Class.new(Sample::Model) do
|
7
|
+
attribute :parent
|
8
|
+
end
|
9
|
+
|
10
|
+
child = Class.new(parent) do
|
11
|
+
attribute :child
|
12
|
+
end
|
13
|
+
|
14
|
+
expect(parent.attributes.keys).to contain_exactly(:parent)
|
15
|
+
expect(child.attributes.keys).to contain_exactly(:parent, :child)
|
16
|
+
end
|
17
|
+
end
|
4
18
|
describe '#update' do
|
5
19
|
class UpdateSpec < Sample::Model
|
6
20
|
identity :id
|
data/spec/singular_spec.rb
CHANGED
@@ -1,35 +1,43 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Cistern::Singular' do
|
4
|
-
class
|
5
|
-
attribute :name
|
4
|
+
class Settings < Sample::Singular
|
5
|
+
attribute :name, type: :string
|
6
6
|
attribute :count, type: :number
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
fail 'missing cistern' unless cistern
|
8
|
+
def save
|
9
|
+
result = @@settings = attributes.merge(dirty_attributes)
|
11
10
|
|
12
|
-
|
13
|
-
@counter += 1
|
14
|
-
{ name: 'amazing', count: @counter }
|
11
|
+
merge_attributes(result)
|
15
12
|
end
|
16
|
-
end
|
17
13
|
|
18
|
-
|
19
|
-
|
14
|
+
def get
|
15
|
+
settings = @@settings ||= {}
|
16
|
+
settings[:count] ||= 0
|
17
|
+
settings[:count] += 1
|
18
|
+
|
19
|
+
merge_attributes(settings)
|
20
|
+
end
|
20
21
|
end
|
21
22
|
|
23
|
+
let!(:service) { Sample.new }
|
24
|
+
|
22
25
|
describe 'deprecation', :deprecated do
|
23
26
|
it 'responds to #service' do
|
24
|
-
sample =
|
27
|
+
sample = service.settings.load
|
28
|
+
|
25
29
|
expect(sample.service).to eq(sample.cistern)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
|
-
it '
|
30
|
-
singular =
|
31
|
-
|
32
|
-
expect
|
33
|
-
|
33
|
+
it 'reloads' do
|
34
|
+
singular = service.settings(count: 0)
|
35
|
+
|
36
|
+
expect { singular.reload }.to change(singular, :count).by(1)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'updates' do
|
40
|
+
service.settings.update(name: 6)
|
41
|
+
expect(service.settings.load.name).to eq('6')
|
34
42
|
end
|
35
43
|
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: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: API client framework extracted from Fog
|
14
14
|
email:
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- ".gemrelease"
|
21
21
|
- ".gitignore"
|
22
22
|
- ".travis.yml"
|
23
|
+
- Appraisals
|
23
24
|
- CHANGELOG.md
|
24
25
|
- Gemfile
|
25
26
|
- Guardfile
|
@@ -28,6 +29,7 @@ files:
|
|
28
29
|
- Rakefile
|
29
30
|
- TODO.md
|
30
31
|
- cistern.gemspec
|
32
|
+
- gemfiles/ruby_lt_2.0.gemfile
|
31
33
|
- lib/cistern.rb
|
32
34
|
- lib/cistern/attributes.rb
|
33
35
|
- lib/cistern/client.rb
|
@@ -41,6 +43,7 @@ files:
|
|
41
43
|
- lib/cistern/formatter/default.rb
|
42
44
|
- lib/cistern/formatter/formatador.rb
|
43
45
|
- lib/cistern/hash.rb
|
46
|
+
- lib/cistern/hash_support.rb
|
44
47
|
- lib/cistern/mock.rb
|
45
48
|
- lib/cistern/model.rb
|
46
49
|
- lib/cistern/request.rb
|
@@ -105,3 +108,4 @@ test_files:
|
|
105
108
|
- spec/spec_helper.rb
|
106
109
|
- spec/support/service.rb
|
107
110
|
- spec/wait_for_spec.rb
|
111
|
+
has_rdoc:
|