conduit 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/conduit/core/driver.rb +54 -1
- data/lib/conduit/version.rb +1 -1
- data/spec/classes/core/driver_spec.rb +18 -0
- data/spec/support/my_driver/driver.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79be33c1882943bb158bcd403b0f4d40491df8fe
|
4
|
+
data.tar.gz: 739d6d61d288369a9598c4b8518db0e4a043aaaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfea45c3620b3ef19080e35cbb28e614b83c306f282fe5c94ae229ac275b114185cfe64a4f13b66eebdc9560ec069fafc6500ec1e582217d2edb4c9c46892b8c
|
7
|
+
data.tar.gz: a4780423b228734f538b1791edccdc1625e237469804ab35d5cc23a1c9597b4a56ada871353deaa5cceaef504e8309fa731f5b4bd5dd980d613c1236c630fb5b
|
data/lib/conduit/core/driver.rb
CHANGED
@@ -5,7 +5,9 @@
|
|
5
5
|
# e.g.
|
6
6
|
# => module Conduit::Driver
|
7
7
|
# => class MyDriver < Conduit::Core::Driver
|
8
|
-
# => required_credentials :
|
8
|
+
# => required_credentials :username, :password
|
9
|
+
# => required_attributes :subdomain
|
10
|
+
# => optional_attributes :quux
|
9
11
|
# =>
|
10
12
|
# => action :purchase
|
11
13
|
# => action :activate
|
@@ -35,6 +37,35 @@ module Conduit
|
|
35
37
|
credentials.merge(args)
|
36
38
|
end
|
37
39
|
|
40
|
+
# Set required attributes
|
41
|
+
# Useful for specifying attributes that
|
42
|
+
# MUST be set for every request.
|
43
|
+
#
|
44
|
+
# e.g.
|
45
|
+
# required_attributes :foo, :bar, :baz
|
46
|
+
# => <Set {:foo, :bar, :baz}>
|
47
|
+
#
|
48
|
+
def required_attributes(*args)
|
49
|
+
required_attribute_set.tap do |attrs|
|
50
|
+
attrs.merge(args)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Set optional attributes
|
55
|
+
# Useful for specifying overrides and other
|
56
|
+
# attributes that MAY be set for every
|
57
|
+
# request.
|
58
|
+
#
|
59
|
+
# e.g.
|
60
|
+
# optional_attributes :quux
|
61
|
+
# => <Set {:quux}>
|
62
|
+
#
|
63
|
+
def optional_attributes(*args)
|
64
|
+
optional_attribute_set.tap do |attrs|
|
65
|
+
attrs.merge(args)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
38
69
|
# Set available actions
|
39
70
|
#
|
40
71
|
# e.g.
|
@@ -56,6 +87,16 @@ module Conduit
|
|
56
87
|
@credentials ||= Set.new
|
57
88
|
end
|
58
89
|
|
90
|
+
# Storage array for permitted attributes
|
91
|
+
#
|
92
|
+
# e.g.
|
93
|
+
# Conduit::Driver::Fusion.permitted_attributes
|
94
|
+
# => <Set {:foo, :bar, :baz, :quuz}>
|
95
|
+
#
|
96
|
+
def permitted_attributes
|
97
|
+
required_attribute_set + optional_attribute_set
|
98
|
+
end
|
99
|
+
|
59
100
|
# Storage array for required credentials
|
60
101
|
#
|
61
102
|
# e.g.
|
@@ -78,6 +119,18 @@ module Conduit
|
|
78
119
|
self.name.demodulize.underscore.downcase
|
79
120
|
end
|
80
121
|
|
122
|
+
# Returns the current set of required attributes
|
123
|
+
#
|
124
|
+
def required_attribute_set
|
125
|
+
@required_attribute_set ||= Set.new
|
126
|
+
end
|
127
|
+
|
128
|
+
# Returns the current set of optional attributes
|
129
|
+
#
|
130
|
+
def optional_attribute_set
|
131
|
+
@optional_attribute_set ||= Set.new
|
132
|
+
end
|
133
|
+
|
81
134
|
end
|
82
135
|
end
|
83
136
|
end
|
data/lib/conduit/version.rb
CHANGED
@@ -15,6 +15,24 @@ shared_examples_for Conduit::Core::Driver do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
describe '.permitted_attributes' do
|
19
|
+
it 'returns the union of required and optional attributes' do
|
20
|
+
subject.permitted_attributes.should == %i(subdomain mock).to_set
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'required_attributes' do
|
25
|
+
it 'should return only the required attributes' do
|
26
|
+
subject.required_attributes.should eql %i(subdomain).to_set
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'optional_attributes' do
|
31
|
+
it 'should return only the optional attributes' do
|
32
|
+
subject.optional_attributes.should eql %i(mock).to_set
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
18
36
|
end
|
19
37
|
|
20
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conduit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kelley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|