Class: LogStash::Util::PluginVersion
- Inherits:
-
Object
- Object
- LogStash::Util::PluginVersion
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/logstash/util/plugin_version.rb
Constant Summary collapse
- GEM_NAME_PREFIX =
'logstash'
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(*options) ⇒ PluginVersion
constructor
A new instance of PluginVersion.
Constructor Details
#initialize(*options) ⇒ PluginVersion
Returns a new instance of PluginVersion.
15 16 17 18 19 20 21 |
# File 'lib/logstash/util/plugin_version.rb', line 15 def initialize(*) if .size == 1 && .first.is_a?(Gem::Version) @version = .first else @version = Gem::Version.new(.join('.')) end end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/logstash/util/plugin_version.rb', line 13 def version @version end |
Class Method Details
.find_plugin_version!(type, name) ⇒ Object
40 41 42 43 |
# File 'lib/logstash/util/plugin_version.rb', line 40 def self.find_plugin_version!(type, name) plugin_name = [GEM_NAME_PREFIX, type, name].join('-') find_version!(plugin_name) end |
.find_version!(name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/logstash/util/plugin_version.rb', line 23 def self.find_version!(name) begin spec = Gem::Specification.find_by_name(name) if spec.nil? # Checking for nil? is a workaround for situations where find_by_name # is not able to find the real spec, as for example with pre releases # of plugins spec = Gem::Specification.find_all_by_name(name).first end new(spec.version) rescue Gem::LoadError # Rescuing the LoadError and raise a Logstash specific error. # Likely we can't find the gem in the current GEM_PATH raise LogStash::PluginNoVersionError end end |
Instance Method Details
#<=>(other) ⇒ Object
45 46 47 |
# File 'lib/logstash/util/plugin_version.rb', line 45 def <=>(other) version <=> other.version end |