metasploit-model 0.27.3 → 0.27.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.rspec +1 -1
- data/app/models/metasploit/model/association/reflection.rb +0 -3
- data/app/models/metasploit/model/module/ancestor/spec/template.rb +0 -3
- data/app/models/metasploit/model/module/class/spec/template.rb +0 -4
- data/app/models/metasploit/model/module/instance/spec/template.rb +0 -4
- data/app/models/metasploit/model/search/group/base.rb +0 -3
- data/app/models/metasploit/model/search/group/intersection.rb +0 -3
- data/app/models/metasploit/model/search/group/union.rb +0 -3
- data/app/models/metasploit/model/search/operation/association.rb +0 -2
- data/app/models/metasploit/model/search/operation/base.rb +0 -3
- data/app/models/metasploit/model/search/operation/boolean.rb +0 -2
- data/app/models/metasploit/model/search/operation/date.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/base.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/intersection.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/union.rb +0 -2
- data/app/models/metasploit/model/search/operation/integer.rb +1 -5
- data/app/models/metasploit/model/search/operation/null.rb +0 -2
- data/app/models/metasploit/model/search/operation/set.rb +5 -2
- data/app/models/metasploit/model/search/operation/set/integer.rb +1 -3
- data/app/models/metasploit/model/search/operation/set/string.rb +1 -3
- data/app/models/metasploit/model/search/operation/string.rb +1 -5
- data/app/models/metasploit/model/search/operator/association.rb +0 -2
- data/app/models/metasploit/model/search/operator/attribute.rb +0 -2
- data/app/models/metasploit/model/search/operator/base.rb +0 -4
- data/app/models/metasploit/model/search/operator/delegation.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/app.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/author.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/authority.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/platform.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/ref.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/text.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/base.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/intersection.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/union.rb +0 -2
- data/app/models/metasploit/model/search/operator/null.rb +0 -2
- data/app/models/metasploit/model/search/operator/single.rb +0 -2
- data/app/models/metasploit/model/search/query.rb +0 -3
- data/app/models/metasploit/model/spec/template.rb +0 -3
- data/app/models/metasploit/model/visitation/visitor.rb +0 -3
- data/lib/metasploit/model.rb +14 -8
- data/lib/metasploit/model/architecture.rb +320 -326
- data/lib/metasploit/model/association.rb +43 -46
- data/lib/metasploit/model/association/error.rb +29 -33
- data/lib/metasploit/model/association/tree.rb +119 -125
- data/lib/metasploit/model/author.rb +45 -51
- data/lib/metasploit/model/authority.rb +139 -146
- data/lib/metasploit/model/authority/bid.rb +0 -2
- data/lib/metasploit/model/authority/cve.rb +0 -2
- data/lib/metasploit/model/authority/msb.rb +0 -2
- data/lib/metasploit/model/authority/osvdb.rb +0 -2
- data/lib/metasploit/model/authority/pmasa.rb +0 -2
- data/lib/metasploit/model/authority/secunia.rb +0 -2
- data/lib/metasploit/model/authority/us_cert_vu.rb +0 -2
- data/lib/metasploit/model/authority/waraxe.rb +0 -2
- data/lib/metasploit/model/authority/zdi.rb +0 -2
- data/lib/metasploit/model/base.rb +0 -2
- data/lib/metasploit/model/derivation.rb +95 -99
- data/lib/metasploit/model/derivation/full_name.rb +16 -22
- data/lib/metasploit/model/email_address.rb +122 -128
- data/lib/metasploit/model/engine.rb +26 -21
- data/lib/metasploit/model/error.rb +3 -7
- data/lib/metasploit/model/file.rb +0 -2
- data/lib/metasploit/model/invalid.rb +11 -17
- data/lib/metasploit/model/login.rb +0 -3
- data/lib/metasploit/model/login/status.rb +0 -2
- data/lib/metasploit/model/module.rb +19 -23
- data/lib/metasploit/model/module/action.rb +50 -58
- data/lib/metasploit/model/module/ancestor.rb +456 -465
- data/lib/metasploit/model/module/ancestor/spec.rb +3 -2
- data/lib/metasploit/model/module/architecture.rb +27 -35
- data/lib/metasploit/model/module/author.rb +38 -47
- data/lib/metasploit/model/module/class.rb +358 -366
- data/lib/metasploit/model/module/class/spec.rb +3 -2
- data/lib/metasploit/model/module/handler.rb +28 -34
- data/lib/metasploit/model/module/instance.rb +586 -596
- data/lib/metasploit/model/module/instance/spec.rb +3 -2
- data/lib/metasploit/model/module/path.rb +157 -166
- data/lib/metasploit/model/module/platform.rb +25 -33
- data/lib/metasploit/model/module/rank.rb +71 -79
- data/lib/metasploit/model/module/reference.rb +25 -33
- data/lib/metasploit/model/module/stance.rb +15 -21
- data/lib/metasploit/model/module/target.rb +76 -84
- data/lib/metasploit/model/module/target/architecture.rb +27 -37
- data/lib/metasploit/model/module/target/platform.rb +27 -37
- data/lib/metasploit/model/module/type.rb +35 -41
- data/lib/metasploit/model/nilify_blanks.rb +39 -43
- data/lib/metasploit/model/platform.rb +231 -237
- data/lib/metasploit/model/real_pathname.rb +12 -16
- data/lib/metasploit/model/realm.rb +0 -2
- data/lib/metasploit/model/realm/key.rb +0 -2
- data/lib/metasploit/model/reference.rb +102 -108
- data/lib/metasploit/model/search.rb +94 -97
- data/lib/metasploit/model/search/association.rb +163 -169
- data/lib/metasploit/model/search/attribute.rb +131 -139
- data/lib/metasploit/model/search/group.rb +5 -2
- data/lib/metasploit/model/search/operation.rb +32 -29
- data/lib/metasploit/model/search/operation/group.rb +5 -2
- data/lib/metasploit/model/search/operation/value.rb +7 -0
- data/lib/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +1 -1
- data/lib/metasploit/model/search/operation/{string/value.rb → value/string.rb} +1 -1
- data/lib/metasploit/model/search/operator.rb +65 -65
- data/lib/metasploit/model/search/operator/deprecated.rb +8 -2
- data/lib/metasploit/model/search/operator/group.rb +5 -2
- data/lib/metasploit/model/search/operator/help.rb +71 -79
- data/lib/metasploit/model/search/with.rb +72 -78
- data/lib/metasploit/model/spec.rb +133 -136
- data/lib/metasploit/model/spec/error.rb +3 -9
- data/lib/metasploit/model/spec/i18n_exception_handler.rb +0 -2
- data/lib/metasploit/model/spec/pathname_collision.rb +19 -27
- data/lib/metasploit/model/spec/template/write.rb +0 -2
- data/lib/metasploit/model/spec/temporary_pathname.rb +47 -56
- data/lib/metasploit/model/translation.rb +0 -2
- data/lib/metasploit/model/version.rb +1 -1
- data/lib/metasploit/model/visitation.rb +7 -10
- data/lib/metasploit/model/visitation/visit.rb +79 -85
- data/metasploit-model.gemspec +1 -1
- data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/string_spec.rb +1 -1
- data/spec/dummy/config/application.rb +1 -0
- data/spec/lib/metasploit/model/search/operation/{integer/value_spec.rb → value/integer_spec.rb} +2 -2
- data/spec/lib/metasploit/model/search/operation/{string/value_spec.rb → value/string_spec.rb} +2 -2
- data/spec/support/shared/examples/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +2 -2
- data/spec/support/shared/examples/metasploit/model/search/operation/{string/value.rb → value/string.rb} +2 -2
- metadata +16 -13
@@ -1,168 +1,159 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
#
|
158
|
-
# @return [void]
|
159
|
-
# @see Metasploit::Model::File.realpath
|
160
|
-
def normalize_real_path
|
161
|
-
if real_path and File.exist?(real_path)
|
162
|
-
self.real_path = Metasploit::Model::File.realpath(real_path)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
1
|
+
# Concern for sharing common code between `Mdm::Module::Path` and `Metasploit::Framework::Module::Path`. Define
|
2
|
+
# {#gem}, {#name}, and {#real_path} by following the abstract instructions for each attribute.
|
3
|
+
module Metasploit::Model::Module::Path
|
4
|
+
extend ActiveModel::Naming
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
include Metasploit::Model::NilifyBlanks
|
8
|
+
include Metasploit::Model::Translation
|
9
|
+
|
10
|
+
included do
|
11
|
+
include ActiveModel::Dirty
|
12
|
+
include ActiveModel::MassAssignmentSecurity
|
13
|
+
include ActiveModel::Validations
|
14
|
+
include ActiveModel::Validations::Callbacks
|
15
|
+
include Metasploit::Model::RealPathname
|
16
|
+
|
17
|
+
#
|
18
|
+
# Callbacks
|
19
|
+
#
|
20
|
+
|
21
|
+
nilify_blank :gem,
|
22
|
+
:name
|
23
|
+
before_validation :normalize_real_path
|
24
|
+
|
25
|
+
#
|
26
|
+
# Mass Assignment Security
|
27
|
+
#
|
28
|
+
|
29
|
+
attr_accessible :gem
|
30
|
+
attr_accessible :name
|
31
|
+
attr_accessible :real_path
|
32
|
+
|
33
|
+
#
|
34
|
+
# Validations
|
35
|
+
#
|
36
|
+
|
37
|
+
validate :directory
|
38
|
+
validate :gem_and_name
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Attributes
|
43
|
+
#
|
44
|
+
|
45
|
+
# @!attribute [rw] gem
|
46
|
+
# @abstract In an ActiveModel, this should be an `attr_accessor :gem`. In an ActiveRecord, this should be a
|
47
|
+
# string gem column.
|
48
|
+
#
|
49
|
+
# The name of the gem that is adding this module path to metasploit-framework. For paths normally added by
|
50
|
+
# metasploit-framework itself, this would be `'metasploit-framework'`, while for Metasploit Pro this would be
|
51
|
+
# `'metasploit-pro'`. The name used for `gem` does not have to be a gem on rubygems, it just functions as a
|
52
|
+
# namespace for {#name} so that projects using metasploit-framework do not need to worry about collisions on
|
53
|
+
# {#name} which could disrupt the cache behavior.
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
|
57
|
+
# @!attribute [rw] name
|
58
|
+
# @abstract In an ActiveModel, this should be an `attr_accessor :name`. In an ActiveRecord, this should be a
|
59
|
+
# string name column.
|
60
|
+
#
|
61
|
+
# The name of the module path scoped to {#gem}. {#gem} and {#name} uniquely identify this path so that if
|
62
|
+
# {#real_path} changes, the entire cache does not need to be invalidated because the change in {#real_path}
|
63
|
+
# will still be tied to the same ({#gem}, {#name}) tuple.
|
64
|
+
#
|
65
|
+
# @return [String]
|
66
|
+
|
67
|
+
# @!attribute [rw] real_path
|
68
|
+
# @abstract In an ActiveModel, this should be an `attr_accesor :real_path`. In an ActiveRecord, this should
|
69
|
+
# be a text real_path column.
|
70
|
+
#
|
71
|
+
# @note Non-real paths will be converted to real paths in a before validation callback, so take care to either
|
72
|
+
# pass real paths or pay attention when setting {#real_path} and then changing directories before
|
73
|
+
# validating.
|
74
|
+
#
|
75
|
+
# The real (absolute) path to module path.
|
76
|
+
#
|
77
|
+
# @return [String]
|
78
|
+
|
79
|
+
#
|
80
|
+
# Instance Methods
|
81
|
+
#
|
82
|
+
|
83
|
+
# Returns whether {#real_path} is a directory.
|
84
|
+
#
|
85
|
+
# @return [true] if {#real_path} is a directory.
|
86
|
+
# @return [false] if {#real_path} is not a directory.
|
87
|
+
def directory?
|
88
|
+
directory = false
|
89
|
+
|
90
|
+
if real_path and File.directory?(real_path)
|
91
|
+
directory = true
|
92
|
+
end
|
93
|
+
|
94
|
+
directory
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns whether is a named path.
|
98
|
+
#
|
99
|
+
# @return [false] if gem is blank or name is blank.
|
100
|
+
# @return [true] if gem is not blank and name is not blank.
|
101
|
+
def named?
|
102
|
+
named = false
|
103
|
+
|
104
|
+
if gem.present? and name.present?
|
105
|
+
named = true
|
106
|
+
end
|
107
|
+
|
108
|
+
named
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns whether was a named path. This is the equivalent of {#named?}, but checks the old, pre-change
|
112
|
+
# values for {#gem} and {#name}.
|
113
|
+
#
|
114
|
+
# @return [false] is gem_was is blank or name_was is blank.
|
115
|
+
# @return [true] if gem_was is not blank and name_was is not blank.
|
116
|
+
def was_named?
|
117
|
+
was_named = false
|
118
|
+
|
119
|
+
if gem_was.present? and name_was.present?
|
120
|
+
was_named = true
|
121
|
+
end
|
122
|
+
|
123
|
+
was_named
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
# Validates that either {#directory?} is `true`.
|
129
|
+
#
|
130
|
+
# @return [void]
|
131
|
+
def directory
|
132
|
+
unless directory?
|
133
|
+
errors[:real_path] << 'must be a directory'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Validates that either both {#gem} and {#name} are present or both are `nil`.
|
138
|
+
#
|
139
|
+
# @return [void]
|
140
|
+
def gem_and_name
|
141
|
+
if name.present? and gem.blank?
|
142
|
+
errors[:gem] << "can't be blank if name is present"
|
143
|
+
end
|
144
|
+
|
145
|
+
if gem.present? and name.blank?
|
146
|
+
errors[:name] << "can't be blank if gem is present"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# If {#real_path} is set and exists on disk, then converts it to a real path to eliminate any symlinks.
|
151
|
+
#
|
152
|
+
# @return [void]
|
153
|
+
# @see Metasploit::Model::File.realpath
|
154
|
+
def normalize_real_path
|
155
|
+
if real_path and File.exist?(real_path)
|
156
|
+
self.real_path = Metasploit::Model::File.realpath(real_path)
|
166
157
|
end
|
167
158
|
end
|
168
|
-
end
|
159
|
+
end
|
@@ -1,40 +1,32 @@
|
|
1
|
-
|
1
|
+
# Joins {Metasploit::Model::Module::Instance} and {Metasploit::Model::Platform.}
|
2
|
+
module Metasploit::Model::Module::Platform
|
3
|
+
extend ActiveModel::Naming
|
4
|
+
extend ActiveSupport::Concern
|
2
5
|
|
3
|
-
|
4
|
-
module Model
|
5
|
-
module Module
|
6
|
-
# Joins {Metasploit::Model::Module::Instance} and {Metasploit::Model::Platform.}
|
7
|
-
module Platform
|
8
|
-
extend ActiveModel::Naming
|
9
|
-
extend ActiveSupport::Concern
|
6
|
+
include Metasploit::Model::Translation
|
10
7
|
|
11
|
-
|
8
|
+
included do
|
9
|
+
include ActiveModel::Validations
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
#
|
12
|
+
# Validations
|
13
|
+
#
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
validates :module_instance, :presence => true
|
21
|
-
validates :platform, :presence => true
|
22
|
-
end
|
15
|
+
validates :module_instance, :presence => true
|
16
|
+
validates :platform, :presence => true
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
#
|
20
|
+
# Associations
|
21
|
+
#
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
# @!attribute [rw] module_instance
|
24
|
+
# Module that supports {#platform}.
|
25
|
+
#
|
26
|
+
# @return [Metasploit::Model::Module::Instance]
|
32
27
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
28
|
+
# @!attribute [rw] platform
|
29
|
+
# Platform supported by {#module_instance}.
|
30
|
+
#
|
31
|
+
# @return [Metasploit::Model::Platform]
|
32
|
+
end
|
@@ -1,93 +1,85 @@
|
|
1
|
-
|
1
|
+
# Code shared between `Mdm::Module::Rank` and `Metasploit::Framework::Module::Rank`.
|
2
|
+
module Metasploit::Model::Module::Rank
|
3
|
+
extend ActiveModel::Naming
|
4
|
+
extend ActiveSupport::Concern
|
2
5
|
|
3
|
-
|
4
|
-
module Model
|
5
|
-
module Module
|
6
|
-
# Code shared between `Mdm::Module::Rank` and `Metasploit::Framework::Module::Rank`.
|
7
|
-
module Rank
|
8
|
-
extend ActiveModel::Naming
|
9
|
-
extend ActiveSupport::Concern
|
6
|
+
include Metasploit::Model::Translation
|
10
7
|
|
11
|
-
|
8
|
+
#
|
9
|
+
# CONSTANTS
|
10
|
+
#
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
#
|
12
|
+
# Regular expression to ensure that {#name} is a word starting with a capital letter
|
13
|
+
NAME_REGEXP = /\A[A-Z][a-z]+\Z/
|
16
14
|
|
17
|
-
|
18
|
-
|
15
|
+
# Converts {#name} to {#number}. Used for seeding. Seeds exist so that reports can use module_ranks to get the
|
16
|
+
# name of a rank without having to duplicate this constant.
|
17
|
+
NUMBER_BY_NAME = {
|
18
|
+
'Manual' => 0,
|
19
|
+
'Low' => 100,
|
20
|
+
'Average' => 200,
|
21
|
+
'Normal' => 300,
|
22
|
+
'Good' => 400,
|
23
|
+
'Great' => 500,
|
24
|
+
'Excellent' => 600
|
25
|
+
}
|
26
|
+
# Converts {#number} to {#name}. Used to convert *Ranking constants used in `Msf::Modules` back to Strings.
|
27
|
+
NAME_BY_NUMBER = NUMBER_BY_NAME.invert
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
'Low' => 100,
|
25
|
-
'Average' => 200,
|
26
|
-
'Normal' => 300,
|
27
|
-
'Good' => 400,
|
28
|
-
'Great' => 500,
|
29
|
-
'Excellent' => 600
|
30
|
-
}
|
31
|
-
# Converts {#number} to {#name}. Used to convert *Ranking constants used in `Msf::Modules` back to Strings.
|
32
|
-
NAME_BY_NUMBER = NUMBER_BY_NAME.invert
|
29
|
+
included do
|
30
|
+
include ActiveModel::MassAssignmentSecurity
|
31
|
+
include ActiveModel::Validations
|
32
|
+
include Metasploit::Model::Search
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
include Metasploit::Model::Search
|
34
|
+
#
|
35
|
+
# Mass Assignment Security
|
36
|
+
#
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
#
|
38
|
+
attr_accessible :name
|
39
|
+
attr_accessible :number
|
42
40
|
|
43
|
-
|
44
|
-
|
41
|
+
#
|
42
|
+
# Search Attributes
|
43
|
+
#
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
#
|
45
|
+
search_attribute :name, :type => :string
|
46
|
+
search_attribute :number, :type => :integer
|
49
47
|
|
50
|
-
|
51
|
-
|
48
|
+
#
|
49
|
+
# Validations
|
50
|
+
#
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
:numericality => {
|
73
|
-
:only_integer => true
|
74
|
-
}
|
75
|
-
end
|
52
|
+
validates :name,
|
53
|
+
# To ensure NUMBER_BY_NAME and seeds stay in sync.
|
54
|
+
:inclusion => {
|
55
|
+
:in => NUMBER_BY_NAME.keys
|
56
|
+
},
|
57
|
+
# To ensure new seeds follow pattern.
|
58
|
+
:format => {
|
59
|
+
:with => NAME_REGEXP
|
60
|
+
}
|
61
|
+
validates :number,
|
62
|
+
# to ensure NUMBER_BY_NAME and seeds stay in sync.
|
63
|
+
:inclusion => {
|
64
|
+
:in => NUMBER_BY_NAME.values
|
65
|
+
},
|
66
|
+
# To ensure new seeds follow pattern.
|
67
|
+
:numericality => {
|
68
|
+
:only_integer => true
|
69
|
+
}
|
70
|
+
end
|
76
71
|
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
#
|
73
|
+
# Attributes
|
74
|
+
#
|
80
75
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
76
|
+
# @!attribute [rw] name
|
77
|
+
# The name of the rank.
|
78
|
+
#
|
79
|
+
# @return [String]
|
85
80
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
81
|
+
# @!attribute [rw] number
|
82
|
+
# The numerical value of the rank. Higher numbers are better.
|
83
|
+
#
|
84
|
+
# @return [Integer]
|
85
|
+
end
|