Class: Reservoir::Version
- Inherits:
-
Object
- Object
- Reservoir::Version
- Defined in:
- lib/reservoir/version.rb,
lib/reservoir/version_arguments.rb
Instance Attribute Summary collapse
-
#version ⇒ Object
Returns the value of attribute version.
-
#version_info ⇒ Object
Returns the value of attribute version_info.
-
#version_parts ⇒ Object
Returns the value of attribute version_parts.
Class Method Summary collapse
Instance Method Summary collapse
- #go(script_name) ⇒ Object
-
#initialize(data = {}) ⇒ Version
constructor
A new instance of Version.
- #possible_commands(script_name) ⇒ Object
- #read(version_info) ⇒ Object
- #remote_server ⇒ Object
- #remote_user ⇒ Object
- #success? ⇒ Boolean
Constructor Details
Instance Attribute Details
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/reservoir/version.rb', line 7 def version @version end |
#version_info ⇒ Object
Returns the value of attribute version_info.
7 8 9 |
# File 'lib/reservoir/version.rb', line 7 def version_info @version_info end |
#version_parts ⇒ Object
Returns the value of attribute version_parts.
7 8 9 |
# File 'lib/reservoir/version.rb', line 7 def version_parts @version_parts end |
Class Method Details
.known_scripts ⇒ Object
5 6 7 8 9 |
# File 'lib/reservoir/version_arguments.rb', line 5 def self.known_scripts { "ruby" => "ruby --version", } end |
Instance Method Details
#go(script_name) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/reservoir/version.rb', line 32 def go(script_name) @success = false possible_commands(script_name).each do |command| if @caller.go(command) && read(@caller.response) break end end @success end |
#possible_commands(script_name) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/reservoir/version.rb', line 23 def possible_commands(script_name) return [] if script_name.nil? || script_name == "" known_scripts = Version.known_scripts[script_name] return [ known_scripts ] unless known_scripts.nil? all = ["--version","-version"].collect { |args| "#{script_name} #{args}"} all << "npm view #{script_name} | grep version:" all end |
#read(version_info) ⇒ Object
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 |
# File 'lib/reservoir/version.rb', line 46 def read(version_info) @version_info = version_info @version_parts = nil @version = nil @success = false major_minor_revision_match = /(\d*)\.(\d*)\.(\d*)/ mmr_patchlevel_match = /(\d*)\.(\d*)\.(\d*).*(patchlevel)\s*(\d*)/ rvm_match = /rvm\s*(\d*)\.(\d*)\.(\d*)/ m = version_info.match(mmr_patchlevel_match) unless m.nil? @version_parts = [ m[1], m[2], m[3], m[5] ] @version = @version_parts[0..2].join(".") + "-p" + m[5] @success = true return @success end if major_minor_revision(rvm_match) return @success end if major_minor_revision(major_minor_revision_match) return @success end @version_info = nil @success end |
#remote_server ⇒ Object
18 19 20 |
# File 'lib/reservoir/version.rb', line 18 def remote_server @caller.remote_server end |
#remote_user ⇒ Object
14 15 16 |
# File 'lib/reservoir/version.rb', line 14 def remote_user @caller.remote_user end |
#success? ⇒ Boolean
42 43 44 |
# File 'lib/reservoir/version.rb', line 42 def success? @success end |