Sha256: 3ddd50e82aec7d56cde293dadb19ed9f1ccb63bd85e45fa57b9eda9bb8e59469

Contents?: true

Size: 1.93 KB

Versions: 48

Compression:

Stored size: 1.93 KB

Contents

require "thor"

module Coveralls
  class CommandLine < Thor

    desc "push", "Runs your test suite and pushes the coverage results to Coveralls."
    def push
      return unless ensure_can_run_locally!
      ENV["COVERALLS_RUN_LOCALLY"] = "true"
      cmds = "bundle exec rake"
      if File.exist?('.travis.yml')
        cmds = YAML.load_file('.travis.yml')["script"] || cmds rescue cmds
      end
      cmds.each { |cmd| system cmd }
      ENV["COVERALLS_RUN_LOCALLY"] = nil
    end

    desc "report", "Runs your test suite locally and displays coverage statistics."
    def report
      ENV["COVERALLS_NOISY"] = "true"
      exec "bundle exec rake"
      ENV["COVERALLS_NOISY"] = nil
    end

    desc "open", "View this repository on Coveralls."
    def open
      open_token_based_url "https://coveralls.io/repos/%@"
    end

    desc "service", "View this repository on your CI service's website."
    def service
      open_token_based_url "https://coveralls.io/repos/%@/service"
    end

    desc "last", "View the last build for this repository on Coveralls."
    def last
      open_token_based_url "https://coveralls.io/repos/%@/last_build"
    end

    desc "version", "See version"
    def version
      Coveralls::Output.puts Coveralls::VERSION
    end

    private

    def open_token_based_url url
      config = Coveralls::Configuration.configuration
      if config[:repo_token]
        url = url.gsub("%@", config[:repo_token])
        `open #{url}`
      else
        Coveralls::Output.puts "No repo_token configured."
      end
    end

    def ensure_can_run_locally!
      config = Coveralls::Configuration.configuration
      if config[:repo_token].nil?
        Coveralls::Output.puts "Coveralls cannot run locally because no repo_secret_token is set in .coveralls.yml", :color => "red"
        Coveralls::Output.puts "Please try again when you get your act together.", :color => "red"

        return false
      end
      true
    end

  end
end

Version data entries

48 entries across 39 versions & 7 rubygems

Version Path
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/coveralls-0.8.23/lib/coveralls/command.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/coveralls-0.8.23/lib/coveralls/command.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/coveralls-0.8.23/lib/coveralls/command.rb
tdiary-5.1.0 vendor/bundle/gems/coveralls-0.8.23/lib/coveralls/command.rb
coveralls-0.8.23 lib/coveralls/command.rb
coveralls-revelry-0.8.24 lib/coveralls/command.rb
tdiary-5.0.13 vendor/bundle/gems/coveralls-0.8.22/lib/coveralls/command.rb
tdiary-5.0.12.1 vendor/bundle/gems/coveralls-0.8.22/lib/coveralls/command.rb
coveralls-revelry-0.8.23 lib/coveralls/command.rb
tdiary-5.0.11 vendor/bundle/gems/coveralls-0.8.22/lib/coveralls/command.rb
coveralls-0.8.22 lib/coveralls/command.rb
tdiary-5.0.9 vendor/bundle/gems/coveralls-0.8.21/lib/coveralls/command.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/coveralls-0.8.21/lib/coveralls/command.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/coveralls-0.8.21/lib/coveralls/command.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/coveralls-0.8.21/lib/coveralls/command.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/coveralls-0.8.21/lib/coveralls/command.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/coveralls-0.8.21/lib/coveralls/command.rb
coveralls-0.8.21 lib/coveralls/command.rb
coveralls-0.8.20 lib/coveralls/command.rb
coveralls-0.8.19 lib/coveralls/command.rb