Sha256: 33eed6c92c3d9dab63874442c92e2540d5902147d2cb3b4cc88fca8860b9cdf1
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
require "appraisal/file" require "yaml" module Appraisal class TravisCIHelper NO_CONFIGURATION_WARNING = <<-WARNING.strip.gsub(/\s+/, " ") Note: Run `appraisal generate --travis` to generate Travis CI configuration. WARNING INVALID_CONFIGURATION_WARNING = <<-WARNING.strip.gsub(/\s+/, " ") Warning: Your gemfiles directive in .travis.yml is incorrect. Run `appraisal generate --travis` to get the correct configuration. WARNING # @see http://docs.travis-ci.com/user/languages/ruby/ GEMFILES_CONFIGURATION_KEY = "gemfile".freeze def self.display_instruction puts "# Put this in your .travis.yml" puts "#{GEMFILES_CONFIGURATION_KEY}:" File.each do |appraisal| puts " - #{appraisal.relative_gemfile_path}" end end def self.validate_configuration_file ConfigurationValidator.new.validate end class ConfigurationValidator CONFIGURATION_FILE = ".travis.yml" def validate if has_configuration_file? if has_no_gemfiles_configuration? $stderr.puts(NO_CONFIGURATION_WARNING) elsif has_invalid_gemfiles_configuration? $stderr.puts(INVALID_CONFIGURATION_WARNING) end end end private def has_configuration_file? ::File.exist?(CONFIGURATION_FILE) end def has_no_gemfiles_configuration? !(configuration && configuration.has_key?(GEMFILES_CONFIGURATION_KEY)) end def has_invalid_gemfiles_configuration? if configuration && configuration[GEMFILES_CONFIGURATION_KEY] appraisal_paths = File.new.appraisals.map(&:relative_gemfile_path).sort travis_gemfile_paths = configuration[GEMFILES_CONFIGURATION_KEY].sort appraisal_paths != travis_gemfile_paths end end def configuration YAML.load_file(CONFIGURATION_FILE) rescue nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
appraisal-2.1.0 | lib/appraisal/travis_ci_helper.rb |
appraisal-2.0.2 | lib/appraisal/travis_ci_helper.rb |