class Syslibgem::CLI
The user cli usin thor
Public Instance Methods
ask_to_learn(gems)
click to toggle source
# File lib/syslibgem.rb, line 49 def ask_to_learn(gems) puts 'I don\'t know about these gems would you like to help me? (y/n)'.yellow puts gems.join(', ').red learn(gems) if input end
input()
click to toggle source
# File lib/syslibgem.rb, line 71 def input STDOUT.flush input = STDIN.gets.chomp if 'yY'.include? input true else false end end
install_lunix(libraries)
click to toggle source
# File lib/syslibgem.rb, line 35 def install_lunix(libraries) libraries.each do |pkg| puts "Do you want to install #{pkg} library? (y/n)".blue system("sudo apt-get -y install #{pkg}") if input end end
install_mac(libraries)
click to toggle source
# File lib/syslibgem.rb, line 42 def install_mac(libraries) libraries.each do |pkg| puts "Do you want to install #{pkg} library? (y/n)".blue system("bower install #{pkg} --no-interactive") if input end end
learn(gems)
click to toggle source
# File lib/syslibgem.rb, line 56 def learn(gems) gems.each do |gem| puts "Do you want teach me #{gem} libraries? (y/n)".blue push_new_gem(gem) if input end end
push_new_gem(gem)
click to toggle source
# File lib/syslibgem.rb, line 63 def push_new_gem(gem) puts 'add the dependencies names sperated by comma'.blue STDOUT.flush line = STDIN.gets.chomp deps = line.delete(' ').split(',') Server.create(gem, deps) unless deps.empty? end
show()
click to toggle source
# File lib/syslibgem.rb, line 12 def show gems = Bundler.load.specs.map(&:name) respose = Server.load(gems) libraries = respose['data']['dependencies'] unknown = respose['data']['unknown'] os_name = Server.find_os system_libraries_install(os_name, libraries) ask_to_learn(unknown) end
system_libraries_install(os_name, libraries)
click to toggle source
# File lib/syslibgem.rb, line 22 def system_libraries_install(os_name, libraries) puts 'Your system needs to install these libraries to be able to run bundle install'.yellow puts libraries.join(', ').red if os_name == 'lunix' install_lunix(libraries) elsif os_name == 'mac' install_mac(libraries) else abort 'sorry your os is not supported'.red end end