Module: RakeFunction
- Defined in:
- lib/teuton/rake_function/check.rb,
lib/teuton/rake_function/install.rb
Overview
Methods Module RakeFunction
- opensuse
- debian
- install_gems
Class Method Summary collapse
- .check(gems) ⇒ Object
- .check_gems(gems) ⇒ Object
- .check_tests ⇒ Object
- .debian(packages) ⇒ Object
- .filter_uninstalled_gems(list) ⇒ Object
- .install_gems(list, options = '') ⇒ Object
- .opensuse(packages) ⇒ Object
Class Method Details
.check(gems) ⇒ Object
5 6 7 8 9 |
# File 'lib/teuton/rake_function/check.rb', line 5 def self.check(gems) puts "[INFO] Version #{Application::VERSION}" check_gems gems check_tests end |
.check_gems(gems) ⇒ Object
11 12 13 14 |
# File 'lib/teuton/rake_function/check.rb', line 11 def self.check_gems(gems) fails = filter_uninstalled_gems(gems) puts "[ERROR] Gems to install!: #{fails.join(',')}" unless fails == [] end |
.check_tests ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/teuton/rake_function/check.rb', line 16 def self.check_tests testfile = File.join('.', 'tests', 'all.rb') a = File.read(testfile).split("\n") b = a.select { |i| i.include? '_test' } d = File.join('.', 'tests', '**', '*_test.rb') e = Dir.glob(d) unless b.size == e.size puts "[FAIL] Some ruby tests are not executed by #{testfile}" end puts "[INFO] Running #{testfile}" system(testfile) end |
.debian(packages) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/teuton/rake_function/install.rb', line 18 def self.debian(packages) names = %w[ssh make gcc ruby-dev] names.each { |name| system("apt-get install -y #{name}") } install_gems packages, '--no-ri' create_symbolic_link end |
.filter_uninstalled_gems(list) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/teuton/rake_function/check.rb', line 32 def self.filter_uninstalled_gems(list) cmd = `gem list`.split("\n") names = cmd.map { |i| i.split(' ')[0] } fails = [] list.each { |i| fails << i unless names.include?(i) } fails end |
.install_gems(list, options = '') ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/teuton/rake_function/install.rb', line 25 def self.install_gems(list, = '') fails = filter_uninstalled_gems(list) if !fails.empty? puts "[INFO] Installing gems (options = #{options})..." fails.each do |name| system("gem install #{name} #{options}") end else puts '[ OK ] Gems installed' end end |
.opensuse(packages) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/teuton/rake_function/install.rb', line 8 def self.opensuse(packages) names = %w[openssh make gcc ruby-dev] = '--non-interactive' names.each do |n| system("zypper #{options} install #{n}") end install_gems packages, '--no-ri' create_symbolic_link end |