Last active
May 6, 2017 13:18
-
-
Save Maumagnaguagno/fbf0b59d939bf750483e721e88715564 to your computer and use it in GitHub Desktop.
Assistant - Execute basic Ruby .travis.yml files locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
module Assistant | |
extend self | |
def test(filename) | |
data = YAML.load_file(filename) | |
case data['language'] | |
when 'ruby' then test_ruby(data) | |
else puts "Language #{data['language']} is unknown" | |
end | |
end | |
def test_ruby(data) | |
success = true | |
before_script = data['before_script'] | |
before_script = [before_script] if before_script.instance_of?(String) | |
script = data['script'] | |
script = [script] if script.instance_of?(String) | |
#data['rvm'].each {|version| | |
# system("rvm use #{version}") | |
puts "Ruby #{RUBY_VERSION} #{RUBY_PLATFORM} #{RUBY_RELEASE_DATE}" | |
execute(before_script) if before_script | |
success &&= execute(script) | |
#} | |
success | |
end | |
def execute(script) | |
success = true | |
script.each {|command| | |
puts command | |
unless system(command) | |
puts "#{command} exited with #{$?.exitstatus}" | |
success = false | |
end | |
} | |
success | |
end | |
end | |
Assistant.test('.travis.yml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment