Class: SysLibs::Task
- Inherits:
-
Object
- Object
- SysLibs::Task
- Defined in:
- lib/sys_libs.rb
Instance Method Summary collapse
-
#getMissingLibs(packagesArray, os) ⇒ Object
Send a post request to the server to retrieve the required sys libs.
-
#getOS ⇒ Object
Get the current os.
-
#getPackages ⇒ Object
Read the project’s Gemfile, fetch all uncommented gems and add to array.
Instance Method Details
#getMissingLibs(packagesArray, os) ⇒ Object
Send a post request to the server to retrieve the required sys libs
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 |
# File 'lib/sys_libs.rb', line 44 def getMissingLibs(packagesArray, os) response = RestClient.post "https://eventtus-task.herokuapp.com/packages/search", { :packages => packagesArray, :os => os } body = JSON.parse(response.body) body.each do |key, value| puts key["name"] + " needs the following sys libs to be installed:" key["dependencies"].each do |d| puts d["name"] end #This is the bonus part regarding installing the missing libs #It was not tested as I had technical issues with my machine so I just commented it # puts "Trying to download the required libs..." # key["dependencies"].each do |d| # case key["os"] # when "mac" # system("brew install "+ d["name"]) # when "linux" # system("apt-get install "+ d["name"]) # when "unix" # system("apt-get install "+ d["name"]) # else # puts "It is recommended you download those libs before proceeding." # end # end end end |
#getOS ⇒ Object
Get the current os
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sys_libs.rb', line 25 def getOS @os ||= ( host_os = RbConfig::CONFIG['host_os'] case host_os when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows when /darwin|mac os/ :mac when /linux/ :linux when /solaris|bsd/ :unix else raise Error::WebDriverError, "unknown os: #{host_os.inspect}" end ) end |
#getPackages ⇒ Object
Read the project’s Gemfile, fetch all uncommented gems and add to array
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sys_libs.rb', line 8 def getPackages @packagesArray = [] f = File.open("Gemfile", "r") f.each_line do |line| if !line.include?"#" and line.include? "gem" and !line.include?"rubygems.org" and !line.include? "gemspec" name = line.split(" ")[1].slice(1..-2) if name[-1].chr == "'" name = name.slice(0..-2) end @packagesArray << (name) end end f.close return @packagesArray end |