configurability 3.1.2 → 3.2.0.pre20170417124946

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: 7c45a9143a15707d91401576cb803aceedd10855
4
- data.tar.gz: 73ccce66fcded9ec68e40913f17a9524cdb1c88b
3
+ metadata.gz: 0e8dd8f36e8946a47bb0995306511f0b294cb017
4
+ data.tar.gz: 328e482e54d855294152c4cdd6c3a681537970a0
5
5
  SHA512:
6
- metadata.gz: 2429a91eacfdac2d85086a7c27df4eef69df8e9829305cb305beb406c47e130028a0e0e6de015c032524e3a793e504857de5c64033fe129935db1c596e4a15bf
7
- data.tar.gz: a167625e37fd5e66f1416d3c68751dc1ab7bfa2c7fdc0690dc102f5a86d7f291851d27491a51f154f146c98b1d9fe2cc5aafba4e7faaedeaa09edceaf0802c8a
6
+ metadata.gz: 0d44d26d9266ebdf4356507f42714471015a99c3a889d9b373ed89a8958db681ce35a0e4af16962d74aceb5d803c6b511c4dd473d72ed1b49d203424081d7781
7
+ data.tar.gz: 6050a8d1125b623b4ffa2f4795c7df05ad846977e01cdee654ff944c4bc9deee16f7488781f1b66b0eef93ccdba997fe9bb72dde84262abe7ed782647a6817ef
data/README.md CHANGED
@@ -75,7 +75,7 @@ some settings:
75
75
  setting :user
76
76
  setting :password
77
77
  setting :port do |value|
78
- Integer( value )
78
+ Integer( value ) if value
79
79
  end
80
80
  end
81
81
  end
@@ -85,7 +85,12 @@ three subkey settings under it (with getters and setters) to the class. It also
85
85
  adds a `configure` class method that will set whichever of the settings are
86
86
  passed to it, defaulting the `url` to the provided value if it's not given.
87
87
 
88
- The `setting` can include a block which is given the config value before it's set; from this block you can do validity-checking, cast it to something other than a String, etc. The new value will be set to the return value of the block.
88
+ The `setting` can include a block which is given the config value before it's
89
+ set; from this block you can do validity-checking, cast it to something other
90
+ than a String, etc. The new value will be set to the return value of the block.
91
+ Note that this will be called with the default for the setting when it's
92
+ declared, so the block should be able to handle the default (even if it's
93
+ `nil`).
89
94
 
90
95
  If your config file (e.g., `config.yml`) looks like this:
91
96
 
@@ -39,17 +39,46 @@ class Configurability::SettingInstaller
39
39
 
40
40
  ### Add accessors with the specified +name+ to the target.
41
41
  def add_setting_accessors( name, options, &writer_hook )
42
- reader = lambda { self.instance_variable_get("@#{name}") }
43
- writer = lambda do |value|
44
- value = writer_hook[ value ] if writer_hook
45
- self.instance_variable_set( "@#{name}", value )
46
- end
42
+ reader = self.make_setting_reader( name, options )
43
+ writer = self.make_setting_writer( name, options, &writer_hook )
47
44
 
48
45
  self.target.define_singleton_method( "#{name}", &reader )
49
46
  self.target.define_singleton_method( "#{name}=", &writer )
50
47
  end
51
48
 
52
49
 
50
+ ### Create the body of the setting reader method with the specified +name+ and +options+.
51
+ def make_setting_reader( name, options )
52
+ if options[:use_class_vars]
53
+ return lambda do
54
+ Loggability[ Configurability ].debug "Using class variables for %s of %p" %
55
+ [ name, self ]
56
+ self.class_variable_get("@@#{name}")
57
+ end
58
+ else
59
+ return lambda { self.instance_variable_get("@#{name}") }
60
+ end
61
+ end
62
+
63
+
64
+ ### Create the body of the setting writer method with the specified +name+ and +options+.
65
+ def make_setting_writer( name, options, &writer_hook )
66
+ if options[:use_class_vars]
67
+ return lambda do |value|
68
+ Loggability[ Configurability ].debug "Using class variables for %s of %p" %
69
+ [ name, self ]
70
+ value = writer_hook[ value ] if writer_hook
71
+ self.class_variable_set( "@@#{name}", value )
72
+ end
73
+ else
74
+ return lambda do |value|
75
+ value = writer_hook[ value ] if writer_hook
76
+ self.instance_variable_set( "@#{name}", value )
77
+ end
78
+ end
79
+ end
80
+
81
+
53
82
  ### Add a default for +name+ to the CONFIG_DEFAULTS constant of the target, creating
54
83
  ### it if necessary.
55
84
  def add_default( name, options )
@@ -684,6 +684,27 @@ describe Configurability do
684
684
  end
685
685
 
686
686
 
687
+ it "allows the use of class variables instead of class-instance variables for settings on a Class" do
688
+ superclass = Class.new
689
+ superclass.extend( Configurability )
690
+ superclass.configurability( :plugin ) do
691
+ setting :api_key, default: 'service_api_key', use_class_vars: true
692
+ setting :environment, default: 'development'
693
+ end
694
+
695
+ subclass = Class.new( superclass )
696
+
697
+ expect {
698
+ superclass.api_key = 'QzCoukGwAWDMjyTkQzWnCXhhgEs'
699
+ }.to change { subclass.api_key }.
700
+ from( 'service_api_key' ).
701
+ to( 'QzCoukGwAWDMjyTkQzWnCXhhgEs' )
702
+ expect {
703
+ superclass.environment = 'production'
704
+ }.to_not change { subclass.environment }.
705
+ from( nil )
706
+ end
707
+
687
708
  end
688
709
 
689
710
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configurability
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.0.pre20170417124946
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -9,34 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
- - |
13
- -----BEGIN CERTIFICATE-----
14
- MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MQwwCgYDVQQDDANnZWQx
15
- GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
16
- HhcNMTYwODIwMTgxNzQyWhcNMTcwODIwMTgxNzQyWjA+MQwwCgYDVQQDDANnZWQx
17
- GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
18
- ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC/JWGRHO+USzR97vXjkFgt
19
- 83qeNf2KHkcvrRTSnR64i6um/ziin0I0oX23H7VYrDJC9A/uoUa5nGRJS5Zw/+wW
20
- ENcvWVZS4iUzi4dsYJGY6yEOsXh2CcF46+QevV8iE+UmbkU75V7Dy1JCaUOyizEt
21
- TH5UHsOtUU7k9TYARt/TgYZKuaoAMZZd5qyV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2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
38
- -----END CERTIFICATE-----
39
- date: 2017-01-16 00:00:00.000000000 Z
12
+ - certs/ged.pem
13
+ date: 2017-04-17 00:00:00.000000000 Z
40
14
  dependencies:
41
15
  - !ruby/object:Gem::Dependency
42
16
  name: loggability
@@ -72,14 +46,14 @@ dependencies:
72
46
  requirements:
73
47
  - - "~>"
74
48
  - !ruby/object:Gem::Version
75
- version: '0.8'
49
+ version: '0.9'
76
50
  type: :development
77
51
  prerelease: false
78
52
  version_requirements: !ruby/object:Gem::Requirement
79
53
  requirements:
80
54
  - - "~>"
81
55
  - !ruby/object:Gem::Version
82
- version: '0.8'
56
+ version: '0.9'
83
57
  - !ruby/object:Gem::Dependency
84
58
  name: hoe-highline
85
59
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +116,14 @@ dependencies:
142
116
  requirements:
143
117
  - - "~>"
144
118
  - !ruby/object:Gem::Version
145
- version: '3.15'
119
+ version: '3.16'
146
120
  type: :development
147
121
  prerelease: false
148
122
  version_requirements: !ruby/object:Gem::Requirement
149
123
  requirements:
150
124
  - - "~>"
151
125
  - !ruby/object:Gem::Version
152
- version: '3.15'
126
+ version: '3.16'
153
127
  description: |-
154
128
  Configurability is a unified, non-intrusive, assume-nothing configuration system
155
129
  for Ruby. It lets you keep the configuration for multiple objects in a single
@@ -169,7 +143,6 @@ extra_rdoc_files:
169
143
  files:
170
144
  - ChangeLog
171
145
  - History.md
172
- - LICENSE
173
146
  - Manifest.txt
174
147
  - README.md
175
148
  - Rakefile
@@ -203,12 +176,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
176
  version: 2.2.0
204
177
  required_rubygems_version: !ruby/object:Gem::Requirement
205
178
  requirements:
206
- - - ">="
179
+ - - ">"
207
180
  - !ruby/object:Gem::Version
208
- version: '0'
181
+ version: 1.3.1
209
182
  requirements: []
210
183
  rubyforge_project:
211
- rubygems_version: 2.6.8
184
+ rubygems_version: 2.6.11
212
185
  signing_key:
213
186
  specification_version: 4
214
187
  summary: Configurability is a unified, non-intrusive, assume-nothing configuration
checksums.yaml.gz.sig DELETED
@@ -1 +0,0 @@
1
- �g���ڱ?��u�$hDn ���4yPB�����~\��m&߷�.ߚ��$�H�H��?h����yd��J��^㪠���K������֘������G��V������
data.tar.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- �0�?h
2
- sأ����NZ< l$�3]����ŝo*���V2�n�~j�_�$�Ӈ���d��p S�Z���v���j��Q�s|�|�f�I�'st�.�e�}����sLM2=�r��רo�P�$�ܝ|�#�^�*��@��I� �q5`�s�g����
3
- ��Љ��XH5vaZA�m�
data/LICENSE DELETED
@@ -1,27 +0,0 @@
1
- Copyright (c) 2010-2016 Michael Granger and Mahlon E. Smith
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice,
8
- this list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author/s, nor the names of the project's
15
- contributors may be used to endorse or promote products derived from this
16
- software without specific prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
metadata.gz.sig DELETED
Binary file