Class: EnvironmentInformation::Queries::ComplexVersion
- Defined in:
- lib/environment_information/queries/complex_version.rb
Overview
EnvironmentInformation::Queries::ComplexVersion
Instance Method Summary collapse
-
#initialize(for_this_program = nil, run_already = true) ⇒ ComplexVersion
constructor
# === initialize.
-
#program_name? ⇒ Boolean
# === program_name? ========================================================================= #.
-
#program_version? ⇒ Boolean
(also: #version?)
# === program_version? ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#return_version_of(this_program = @program_name) ⇒ Object
# === return_version_of ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#set_program_name(i) ⇒ Object
# === set_program_name ========================================================================= #.
Methods inherited from Base
#cd, #commandline_arguments?, #e, #esystem, #first_argument?, #gold, #is_on_roebe?, #is_rbt_available?, #lightblue, #log_dir?, #mediumaquamarine, #report_left_right, #set_commandline_arguments
Constructor Details
#initialize(for_this_program = nil, run_already = true) ⇒ ComplexVersion
#
initialize
The first argument is mandatory.
#
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/environment_information/queries/complex_version.rb', line 25 def initialize( for_this_program = nil, run_already = true ) reset set_program_name( for_this_program ) # ======================================================================= # # === Handle blocks given next # ======================================================================= # if block_given? yielded = yield if yielded.is_a? Hash if yielded.has_key? :prefix_to_use @prefix_to_use << yielded.delete(:prefix_to_use) end end end run if run_already end |
Instance Method Details
#program_name? ⇒ Boolean
#
program_name?
#
75 76 77 |
# File 'lib/environment_information/queries/complex_version.rb', line 75 def program_name? @program_name end |
#program_version? ⇒ Boolean Also known as: version?
#
program_version?
#
82 83 84 |
# File 'lib/environment_information/queries/complex_version.rb', line 82 def program_version? @program_version end |
#reset ⇒ Object
#
reset
#
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/environment_information/queries/complex_version.rb', line 50 def reset # ======================================================================= # # === @program_name # ======================================================================= # @program_name = ''.dup # ======================================================================= # # === @program_version # ======================================================================= # @program_version = nil # ======================================================================= # # === @prefix_to_use # ======================================================================= # @prefix_to_use = ''.dup end |
#return_version_of(this_program = @program_name) ⇒ Object
#
return_version_of
#
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/environment_information/queries/complex_version.rb', line 89 def return_version_of( this_program = @program_name ) _ = ::EnvironmentInformation.query_to_use_for_the_individual_components? if _.nil? _ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components end if _.has_key?(this_program) cmd_to_run = _[this_program] case cmd_to_run # ===================================================================== # # === :custom_busybox # ===================================================================== # when :custom_busybox @program_version = ::EnvironmentInformation.return_version_of_busybox # ===================================================================== # # === :custom_xrandr # ===================================================================== # when :custom_xrandr @program_version = ::EnvironmentInformation.return_version_of_xrandr # ===================================================================== # # === :custom_xvid # ===================================================================== # when :custom_xvid @program_version = ::EnvironmentInformation.return_version_of_xvid # ===================================================================== # # === :custom_boost # ===================================================================== # when :custom_boost @program_version = ::EnvironmentInformation.return_version_of_boost # ===================================================================== # # === :custom_mpc # ===================================================================== # when :custom_mpc @program_version = ::EnvironmentInformation.return_version_of_mpc else result = `#{@prefix_to_use}#{cmd_to_run} #{ERROR_LINE}`.to_s.strip.dup if result.include? ' #' # Handle "uname -a" aka Linux darkstar.example.net 5.4.50 #1 SMP result = result.split(' #').first.strip end @program_version = result end return nil if @program_version.nil? if @program_version.include? '# HMMER ' # <- Specifically for "hammer". @program_version = @program_version.scan( /# HMMER (\d{0,2}\.\d{0,2}\.\d{0,2})/ ).flatten.first.to_s end if @program_version.include? 'extracts blocks from damag' # bzip2recover @program_version = @program_version.scan( /bzip2recover (\d{0,2}\.\d{0,2}\.\d{0,2}): extracts blocks from damaged .bz2 files/ ).flatten.first.to_s.dup end # ===================================================================== # # === Handle Imagemagick: 'Version: ImageMagick 7.0.10-28' # ===================================================================== # if @program_version.include? 'Version: ImageMagick ' @program_version = @program_version.scan( /Version: ImageMagick (\d{0,2}\.\d{0,2}\.\d{0,2}-\d{0,2})/ ).flatten.first.to_s.tr('-','.') end # ===================================================================== # # === Handle 'KDE Frameworks: 5.73.0' # ===================================================================== # if @program_version.include? 'KDE Frameworks: ' @program_version = @program_version.scan( /KDE Frameworks: (\d{0,2}\.\d{0,2}\.\d{0,2})/ ).flatten.first.to_s end # ===================================================================== # # === Handle 'ncurses 6.2.20200212' aka ncurses # ===================================================================== # if @program_version.include? 'ncurses ' @program_version = @program_version.scan( /ncurses (\d{1,1}\.\d{1,1})/ ).flatten.first.to_s end # ===================================================================== # # === Handle ruby 'ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]' # ===================================================================== # if @program_version.include? 'ruby ' @program_version = @program_version.scan( /^ruby (\d{1,1}\.\d{1,1}\.\d{1,1})/ ).flatten.first.to_s end # ===================================================================== # # === Handle patchelf '0.12.20200827.8d3a16e' # # This can also include output such as "patchelf 0.14.3". # ===================================================================== # if @program_version.include? 'patchelf ' @program_version = @program_version.scan( /^patchelf (\d{1,1}\.\d{1,2}\.?\d{0,2})/ ).flatten.first.to_s end # ===================================================================== # # We have to be careful with the next, as a few programs report the # version on the second line, not on the first. # ===================================================================== # if @program_version.include? N @program_version = @program_version.split(N).first.strip end # ===================================================================== # # Next handle cases such as the following two examples: # # "ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers" # "openjdk version \"14.0.2\" 2020-07-14" # "ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers" # # ===================================================================== # if @program_version.include? ' version ' @program_version = @program_version.scan( / version n?"?(\d{0,2}\.\d{1,2}\.?\d{0,2})"?/ # See: See: https://rubular.com/r/39cIQqXin2oco0 ).flatten.first.to_s.strip end # ===================================================================== # # Handle cases such as: "nginx/1.18.0" # ===================================================================== # if @program_version.include? '/' @program_version = @program_version.split('/').last.strip end if @program_version.include?('(') and # Specifically for XTERM. @program_version.include?(')') @program_version = @program_version.split('(').last.to_s.delete(')') # 7.7.0(359) end if @program_version.include? '-' # Specifically to fix relion: "3.1.0-commit-GITDIR" @program_version = @program_version.split('-').first.to_s.strip end if @program_version.include? COMMAND_NOT_FOUND @program_version = nil elsif @program_version.include? ' ' # =================================================================== # # Assume input such as: "GNU ld (GNU Binutils) 2.35" # =================================================================== # @program_version = @program_version.split(' ').last end end return @program_version end |
#run ⇒ Object
#
run
#
233 234 235 |
# File 'lib/environment_information/queries/complex_version.rb', line 233 def run return_version_of end |
#set_program_name(i) ⇒ Object
#
set_program_name
#
68 69 70 |
# File 'lib/environment_information/queries/complex_version.rb', line 68 def set_program_name(i) @program_name = i.to_sym if i end |