Class: SimpleCov::Badger::Configuration

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/simplecov_badger/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
# File 'lib/simplecov_badger/configuration.rb', line 12

def initialize
  super(self.class.options)
end

Class Method Details

.optionsObject



3
4
5
6
7
8
9
10
# File 'lib/simplecov_badger/configuration.rb', line 3

def self.options
  {
    post_url: "https://coverage.traels.it/badges",
    repo_url: `git config --get remote.origin.url`.strip,
    run_if: -> { `git rev-parse --abbrev-ref HEAD` == "master\n" },
    token: ENV["SIMPLECOV_BADGER_TOKEN"]
  }
end

Instance Method Details

#badge_urlObject



22
23
24
# File 'lib/simplecov_badger/configuration.rb', line 22

def badge_url
  "#{post_url}/#{encoded_repo_url}"
end

#encoded_repo_urlObject



16
17
18
19
20
# File 'lib/simplecov_badger/configuration.rb', line 16

def encoded_repo_url
  raise SimpleCov::Badger::Error, "repo_url is nil" if repo_url.nil?

  Base64.urlsafe_encode64(repo_url)
end