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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74042f34cbbd0e62cd7b38412d5aee3188dd2f0c
4
- data.tar.gz: 070cdb6f7cebfc9d53013bc21b95b35acb3d72c7
3
+ metadata.gz: 79be33c1882943bb158bcd403b0f4d40491df8fe
4
+ data.tar.gz: 739d6d61d288369a9598c4b8518db0e4a043aaaa
5
5
  SHA512:
6
- metadata.gz: 9e9166923c8f53dda87b9b8df3e307e8acc98231b16c3f9b9902d9db8ef98f095d60d796a51e9a99dbe5057340d3db31e5f57121416a15410b4afeb558c6b5d0
7
- data.tar.gz: a298a62148b83b3fdbb2dffc983a909744a24926cfffdf44bd3f8095d69c83cef7d1ae8592e551b2502db58fd5c4ed7f7859998e3b122360b6159076360c8973
6
+ metadata.gz: bfea45c3620b3ef19080e35cbb28e614b83c306f282fe5c94ae229ac275b114185cfe64a4f13b66eebdc9560ec069fafc6500ec1e582217d2edb4c9c46892b8c
7
+ data.tar.gz: a4780423b228734f538b1791edccdc1625e237469804ab35d5cc23a1c9597b4a56ada871353deaa5cceaef504e8309fa731f5b4bd5dd980d613c1236c630fb5b
@@ -5,7 +5,9 @@
5
5
  # e.g.
6
6
  # => module Conduit::Driver
7
7
  # => class MyDriver < Conduit::Core::Driver
8
- # => required_credentials :foo, :bar, :baz
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
@@ -1,3 +1,3 @@
1
1
  module Conduit
2
- VERSION = '0.5.3'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -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
@@ -2,6 +2,8 @@ module Conduit::Driver::MyDriver
2
2
  extend Conduit::Core::Driver
3
3
 
4
4
  required_credentials :username, :password
5
+ required_attributes :subdomain
6
+ optional_attributes :mock
5
7
  action :foo
6
8
 
7
- end
9
+ 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.5.3
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-09 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport