cascading-configuration-array-sorted 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/README.rdoc +1 -1
- data/lib/cascading-configuration-array-sorted.rb +4 -15
- data/lib/cascading-configuration-array-sorted/CascadingConfiguration/Array/Sorted.rb +46 -4
- metadata +5 -10
- data/lib/cascading-configuration-array-sorted/CascadingConfiguration/Array/Sorted/Interface.rb +0 -111
- data/lib/cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/CompositingArray.rb +0 -7
- data/lib/cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/CompositingArray/Interface.rb +0 -157
- data/lib/cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/ModuleSupportMethods.rb +0 -45
- data/spec/_private_/CascadingConfiguration/Array/Sorted/CompositingArray_spec.rb +0 -1008
data/README.md
CHANGED
data/README.rdoc
CHANGED
@@ -1,30 +1,19 @@
|
|
1
1
|
|
2
|
+
require 'compositing-array-sorted'
|
3
|
+
|
2
4
|
if $__cascading_configuration__spec__development
|
3
|
-
require_relative '../../
|
5
|
+
require_relative '../../variable/lib/cascading-configuration-variable.rb'
|
4
6
|
else
|
5
|
-
require 'cascading-configuration-
|
7
|
+
require 'cascading-configuration-variable'
|
6
8
|
end
|
7
9
|
|
8
10
|
module ::CascadingConfiguration
|
9
11
|
module Array
|
10
12
|
module Sorted
|
11
|
-
class CompositingArray < ::CascadingConfiguration::Array::CompositingArray
|
12
|
-
module Interface
|
13
|
-
end
|
14
|
-
end
|
15
|
-
module ModuleSupportMethods
|
16
|
-
end
|
17
|
-
module Interface
|
18
|
-
end
|
19
13
|
end
|
20
14
|
end
|
21
15
|
end
|
22
16
|
|
23
|
-
require_relative 'cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/CompositingArray/Interface.rb'
|
24
|
-
require_relative 'cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/CompositingArray.rb'
|
25
|
-
require_relative 'cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/ModuleSupportMethods.rb'
|
26
|
-
|
27
|
-
require_relative 'cascading-configuration-array-sorted/CascadingConfiguration/Array/Sorted/Interface.rb'
|
28
17
|
require_relative 'cascading-configuration-array-sorted/CascadingConfiguration/Array/Sorted.rb'
|
29
18
|
|
30
19
|
|
@@ -2,11 +2,53 @@
|
|
2
2
|
module ::CascadingConfiguration::Array::Sorted
|
3
3
|
|
4
4
|
# Configuration modules for storage of settings arrays
|
5
|
-
include ::CascadingConfiguration::
|
5
|
+
include ::CascadingConfiguration::Inheritance
|
6
|
+
|
7
|
+
##############################################
|
8
|
+
# attr_configuration_sorted_array #
|
9
|
+
# attr_module_configuration_sorted_array #
|
10
|
+
# attr_local_configuration_sorted_array #
|
11
|
+
# attr_object_configuration_sorted_array #
|
12
|
+
# attr_instance_configuration_sorted_array #
|
13
|
+
##############################################
|
14
|
+
|
15
|
+
def attr_configuration_sorted_array( *configuration_names, & define_block ) ;; end
|
16
|
+
def attr_module_configuration_sorted_array( *configuration_names, & define_block ) ;; end
|
17
|
+
def attr_class_configuration_sorted_array( *configuration_names, & define_block ) ;; end
|
18
|
+
def attr_local_configuration_sorted_array( *configuration_names, & define_block ) ;; end
|
19
|
+
def attr_object_configuration_sorted_array( *configuration_names, & define_block ) ;; end
|
20
|
+
def attr_instance_configuration_sorted_array( *configuration_names, & define_block ) ;; end
|
21
|
+
|
22
|
+
ccsa = self
|
23
|
+
cca = ::CascadingConfiguration::Array
|
24
|
+
ccv = ::CascadingConfiguration::Variable
|
25
|
+
ccm = ::CascadingConfiguration::Methods
|
26
|
+
|
27
|
+
setter_proc = ::Proc.new do |instance, configuration_name, value|
|
28
|
+
|
29
|
+
return instance.__send__( configuration_name ).replace( value )
|
6
30
|
|
7
|
-
|
8
|
-
|
31
|
+
end
|
32
|
+
|
33
|
+
getter_proc = ::Proc.new do |instance, configuration_name|
|
34
|
+
|
35
|
+
composite_sorted_array = nil
|
36
|
+
|
37
|
+
if ccv.has_configuration_variable?( instance, configuration_name )
|
38
|
+
composite_sorted_array = ccv.get_configuration_variable( instance, configuration_name )
|
39
|
+
else
|
40
|
+
parent_composite_array = nil
|
41
|
+
if ancestor = ::CascadingConfiguration::Variable.ancestor( instance, configuration_name )
|
42
|
+
parent_composite_array = ancestor.__send__( configuration_name )
|
43
|
+
end
|
44
|
+
composite_sorted_array = ::CompositingArray::Sorted.new( parent_composite_array )
|
45
|
+
ccv.set_configuration_variable( instance, configuration_name, composite_sorted_array )
|
46
|
+
end
|
47
|
+
|
48
|
+
return composite_sorted_array
|
49
|
+
|
50
|
+
end
|
9
51
|
|
10
|
-
|
52
|
+
ccm.declare_compositing_configuration_object( self, :sorted_array, setter_proc, getter_proc )
|
11
53
|
|
12
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cascading-configuration-array-sorted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cascading-configuration-array
|
16
|
-
requirement: &
|
16
|
+
requirement: &70197420283240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,20 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70197420283240
|
25
25
|
description: Provides :attr_configuration_sorted_array.
|
26
26
|
email: asher@ridiculouspower.com
|
27
27
|
executables: []
|
28
28
|
extensions: []
|
29
29
|
extra_rdoc_files: []
|
30
30
|
files:
|
31
|
-
- lib/cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/CompositingArray/Interface.rb
|
32
|
-
- lib/cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/CompositingArray.rb
|
33
|
-
- lib/cascading-configuration-array-sorted/_private_/CascadingConfiguration/Array/Sorted/ModuleSupportMethods.rb
|
34
|
-
- lib/cascading-configuration-array-sorted/CascadingConfiguration/Array/Sorted/Interface.rb
|
35
31
|
- lib/cascading-configuration-array-sorted/CascadingConfiguration/Array/Sorted.rb
|
36
32
|
- lib/cascading-configuration-array-sorted.rb
|
37
|
-
- spec/_private_/CascadingConfiguration/Array/Sorted/CompositingArray_spec.rb
|
38
33
|
- spec/CascadingConfiguration/Array/Sorted_spec.rb
|
39
34
|
- README.md
|
40
35
|
- README.rdoc
|
@@ -58,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
53
|
version: '0'
|
59
54
|
requirements: []
|
60
55
|
rubyforge_project: cascading-configuration-array-sorted
|
61
|
-
rubygems_version: 1.8.
|
56
|
+
rubygems_version: 1.8.11
|
62
57
|
signing_key:
|
63
58
|
specification_version: 3
|
64
59
|
summary: Support package for cascading-configuration.
|
data/lib/cascading-configuration-array-sorted/CascadingConfiguration/Array/Sorted/Interface.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
|
2
|
-
module ::CascadingConfiguration::Array::Sorted::Interface
|
3
|
-
|
4
|
-
######################
|
5
|
-
# self.setter_proc #
|
6
|
-
######################
|
7
|
-
|
8
|
-
def self.setter_proc( configuration_name )
|
9
|
-
|
10
|
-
return Proc.new do |array|
|
11
|
-
|
12
|
-
return ::CascadingConfiguration::Array::Sorted.set_composite_sorted_array( self,
|
13
|
-
configuration_name,
|
14
|
-
array )
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
######################
|
21
|
-
# self.getter_proc #
|
22
|
-
######################
|
23
|
-
|
24
|
-
def self.getter_proc( configuration_name )
|
25
|
-
|
26
|
-
return Proc.new do
|
27
|
-
|
28
|
-
return ::CascadingConfiguration::Array::Sorted.composite_sorted_array( self,
|
29
|
-
configuration_name )
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
#####################################
|
36
|
-
# attr_configuration_sorted_array #
|
37
|
-
#####################################
|
38
|
-
|
39
|
-
# defines configuration in class or module
|
40
|
-
# configuration cascades downward to instance including all classes or modules in-between
|
41
|
-
def attr_configuration_sorted_array( *configuration_names )
|
42
|
-
|
43
|
-
return ::CascadingConfiguration::Variable.
|
44
|
-
define_cascading_configuration( self,
|
45
|
-
::CascadingConfiguration::Array::Sorted::Interface,
|
46
|
-
*configuration_names )
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
############################################
|
51
|
-
# attr_module_configuration_sorted_array #
|
52
|
-
############################################
|
53
|
-
|
54
|
-
# defines configuration in class or module
|
55
|
-
# configuration cascades downward to last class or module
|
56
|
-
def attr_module_configuration_sorted_array( *configuration_names )
|
57
|
-
|
58
|
-
return ::CascadingConfiguration::Variable.
|
59
|
-
define_module_configuration( self,
|
60
|
-
::CascadingConfiguration::Array::Sorted::Interface,
|
61
|
-
*configuration_names )
|
62
|
-
|
63
|
-
end
|
64
|
-
alias_method :attr_class_configuration_sorted_array, :attr_module_configuration_sorted_array
|
65
|
-
|
66
|
-
###########################################
|
67
|
-
# attr_local_configuration_sorted_array #
|
68
|
-
###########################################
|
69
|
-
|
70
|
-
# defines configuration in present class or module context
|
71
|
-
# configuration does not cascade
|
72
|
-
def attr_local_configuration_sorted_array( *configuration_names )
|
73
|
-
|
74
|
-
return ::CascadingConfiguration::Variable.
|
75
|
-
define_local_configuration( self,
|
76
|
-
::CascadingConfiguration::Array::Sorted::Interface,
|
77
|
-
*configuration_names )
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
############################################
|
82
|
-
# attr_object_configuration_sorted_array #
|
83
|
-
############################################
|
84
|
-
|
85
|
-
# defines configuration in present instance
|
86
|
-
# configuration does not cascade
|
87
|
-
def attr_object_configuration_sorted_array( *configuration_names )
|
88
|
-
|
89
|
-
return ::CascadingConfiguration::Variable.
|
90
|
-
define_object_configuration( self,
|
91
|
-
::CascadingConfiguration::Array::Sorted::Interface,
|
92
|
-
*configuration_names )
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
##############################################
|
97
|
-
# attr_instance_configuration_sorted_array #
|
98
|
-
##############################################
|
99
|
-
|
100
|
-
# defines configuration in present class or module context
|
101
|
-
# configuration does not cascade
|
102
|
-
def attr_instance_configuration_sorted_array( *configuration_names )
|
103
|
-
|
104
|
-
return ::CascadingConfiguration::Variable.
|
105
|
-
define_instance_configuration( self,
|
106
|
-
::CascadingConfiguration::Array::Sorted::Interface,
|
107
|
-
*configuration_names )
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
|
2
|
-
module ::CascadingConfiguration::Array::Sorted::CompositingArray::Interface
|
3
|
-
|
4
|
-
##############
|
5
|
-
# reverse! #
|
6
|
-
##############
|
7
|
-
|
8
|
-
def reverse!
|
9
|
-
|
10
|
-
@sort_order_reversed = ! @sort_order_reversed
|
11
|
-
|
12
|
-
super
|
13
|
-
|
14
|
-
@sub_composite_arrays.each do |this_sub_array|
|
15
|
-
this_sub_array.reverse!
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
##############
|
21
|
-
# collect! #
|
22
|
-
# map! #
|
23
|
-
##############
|
24
|
-
|
25
|
-
def collect!
|
26
|
-
|
27
|
-
return to_enum unless block_given?
|
28
|
-
|
29
|
-
replacement_array = [ ]
|
30
|
-
self.each_with_index do |this_object, index|
|
31
|
-
replacement_object = yield( this_object )
|
32
|
-
replacement_array[ index ] = replacement_object
|
33
|
-
end
|
34
|
-
|
35
|
-
replace( replacement_array )
|
36
|
-
|
37
|
-
return self
|
38
|
-
|
39
|
-
end
|
40
|
-
alias_method :map!, :collect!
|
41
|
-
|
42
|
-
###########
|
43
|
-
# sort! #
|
44
|
-
###########
|
45
|
-
|
46
|
-
def sort!( & block )
|
47
|
-
|
48
|
-
if block_given?
|
49
|
-
self.each_with_index do |this_member, index|
|
50
|
-
unless index + 1 == count
|
51
|
-
yield( this_member, self[ index + 1 ] )
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
return self
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
##############
|
61
|
-
# sort_by! #
|
62
|
-
##############
|
63
|
-
|
64
|
-
def sort_by!( & block )
|
65
|
-
|
66
|
-
return to_enum unless block_given?
|
67
|
-
|
68
|
-
self.each do |this_member|
|
69
|
-
yield( this_member )
|
70
|
-
end
|
71
|
-
|
72
|
-
return self
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
##################################################################################################
|
77
|
-
private ######################################################################################
|
78
|
-
##################################################################################################
|
79
|
-
|
80
|
-
###############
|
81
|
-
# non_cascading_set #
|
82
|
-
###############
|
83
|
-
|
84
|
-
def non_cascading_set( index, object )
|
85
|
-
|
86
|
-
# we ignore the index and insert in sorted order
|
87
|
-
|
88
|
-
# if index matches an existing index we remove it and insert
|
89
|
-
|
90
|
-
# otherwise we simply insert
|
91
|
-
|
92
|
-
unless index >= count
|
93
|
-
delete_at( index )
|
94
|
-
end
|
95
|
-
|
96
|
-
@parent_and_interpolated_object_count += 1
|
97
|
-
|
98
|
-
non_cascading_insert( index, object )
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
##################
|
103
|
-
# non_cascading_insert #
|
104
|
-
##################
|
105
|
-
|
106
|
-
def non_cascading_insert( index, *objects )
|
107
|
-
|
108
|
-
# we ignore the index and insert in sorted order
|
109
|
-
|
110
|
-
# we have to have at least one member for comparison-based insert (to retain sorted order)
|
111
|
-
|
112
|
-
objects.each do |this_object|
|
113
|
-
|
114
|
-
insert_occurred = false
|
115
|
-
|
116
|
-
if this_object.nil?
|
117
|
-
if @sort_order_reversed
|
118
|
-
super( count, this_object )
|
119
|
-
else
|
120
|
-
super( 0, this_object )
|
121
|
-
end
|
122
|
-
next
|
123
|
-
end
|
124
|
-
|
125
|
-
self.each_with_index do |this_member, this_index|
|
126
|
-
|
127
|
-
if @sort_order_reversed
|
128
|
-
|
129
|
-
case this_object <=> this_member
|
130
|
-
when 0, 1
|
131
|
-
super( this_index, this_object )
|
132
|
-
insert_occurred = true
|
133
|
-
break
|
134
|
-
end
|
135
|
-
|
136
|
-
else
|
137
|
-
|
138
|
-
case this_object <=> this_member
|
139
|
-
when 0, -1
|
140
|
-
super( this_index, this_object )
|
141
|
-
insert_occurred = true
|
142
|
-
break
|
143
|
-
end
|
144
|
-
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
unless insert_occurred
|
150
|
-
super( count, this_object )
|
151
|
-
end
|
152
|
-
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
|
2
|
-
module ::CascadingConfiguration::Array::Sorted::ModuleSupportMethods
|
3
|
-
|
4
|
-
############################
|
5
|
-
# composite_sorted_array #
|
6
|
-
############################
|
7
|
-
|
8
|
-
def composite_sorted_array( configuration_instance, configuration_name )
|
9
|
-
|
10
|
-
composite_sorted_array = nil
|
11
|
-
|
12
|
-
if ::CascadingConfiguration::Variable.has_configuration_variable?( configuration_instance,
|
13
|
-
configuration_name )
|
14
|
-
composite_sorted_array = ::CascadingConfiguration::Variable.
|
15
|
-
get_configuration_variable( configuration_instance,
|
16
|
-
configuration_name )
|
17
|
-
else
|
18
|
-
composite_sorted_array = ::CascadingConfiguration::Array::Sorted::CompositingArray.
|
19
|
-
new( configuration_instance, configuration_name )
|
20
|
-
end
|
21
|
-
|
22
|
-
return composite_sorted_array
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
################################
|
27
|
-
# set_composite_sorted_array #
|
28
|
-
################################
|
29
|
-
|
30
|
-
def set_composite_sorted_array( configuration_instance, configuration_name, array )
|
31
|
-
|
32
|
-
composite_sorted_array = composite_sorted_array( configuration_instance, configuration_name )
|
33
|
-
|
34
|
-
# we want the array to supplant existing config
|
35
|
-
# clear the array (excludes everything explicitly)
|
36
|
-
composite_sorted_array.clear
|
37
|
-
|
38
|
-
# push array elements (removes anything excluded from exclude)
|
39
|
-
composite_sorted_array.push( *array )
|
40
|
-
|
41
|
-
return composite_sorted_array
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|