Skip to content

Commit

Permalink
U apply rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarrui committed Aug 26, 2019
1 parent 4349e03 commit d739855
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 2 additions & 0 deletions lib/rake_function/check.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Method RakeFunction#check
module RakeFunction
def self.check(gems)
Expand Down
31 changes: 14 additions & 17 deletions lib/rake_function/install.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
# frozen_string_literal: true

# Methods Module RakeFunction
# * debian
# * opensuse
# * debian
# * install_gems
module RakeFunction
def self.debian(packages)
names = ['ssh', 'make', 'gcc', 'ruby-dev']
names.each { |name| system("apt-get install -y #{name}") }
install_gems packages
create_symbolic_link
end

# INFO
# * gems -> packages += ['pry-byebug']
# * OpenSUSE -> 'ruby2.5-rubygem-pry',

def self.opensuse(packages)
names = ['openssh', 'make', 'gcc', 'ruby-devel']
options = '--non-interactive'
names.each do |n|
system("zypper #{options} install #{n}")
end
install_gems packages
install_gems packages, '--no-ri'
create_symbolic_link
end

def self.debian(packages)
names = ['ssh', 'make', 'gcc', 'ruby-dev']
names.each { |name| system("apt-get install -y #{name}") }
install_gems packages, '--no-ri'
create_symbolic_link
end

def self.install_gems(list)
def self.install_gems(list, options = '')
fails = filter_uninstalled_gems(list)
if !fails.empty?
puts '[INFO] Installing gems...'
puts "[INFO] Installing gems (options = #{options})..."
fails.each do |name|
#system("gem install #{name} --no-ri")
system("gem install #{name}")
system("gem install #{name} #{options}")
end
else
puts '[ OK ] Gems installed'
Expand Down
2 changes: 1 addition & 1 deletion tests/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
require_relative 'project/readme/readme_test'
require_relative 'project/configfile_reader_test'
require_relative 'project/name_file_finder_test'
# require_relative 'rubocop_test'
# require_relative 'rubocop_test' # Duration: 60 seg. Require rubocop
12 changes: 12 additions & 0 deletions tests/rubocop_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def setup
@files[:project] << 'lib/project/project_creator.rb'
@files[:project] << 'lib/project/project.rb'

@files[:rake_functions] = []
@files[:rake_functions] << 'lib/rake_function/check.rb'
@files[:rake_functions] << 'lib/rake_function/install.rb'

@files[:report] = []
# @files4 << 'lib/report/formatter/array_formatter.rb'
@files[:report] << 'lib/report/formatter/base_formatter.rb'
Expand Down Expand Up @@ -108,6 +112,14 @@ def test_rubocop_project
end
end

def test_rubocop_rake_functions
@files[:rake_functions].each do |file|
output = `rubocop #{file}`
lines = output.split("\n")
assert_equal true, lines.any?(/file inspected, no offenses detected/)
end
end

def test_rubocop_report
@files[:report].each do |file|
output = `rubocop #{file}`
Expand Down

0 comments on commit d739855

Please sign in to comment.