Class: FastCI::Configuration
- Inherits:
-
Object
- Object
- FastCI::Configuration
- Defined in:
- lib/fast_ci/configuration.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#author ⇒ Object
Returns the value of attribute author.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#build_id ⇒ Object
Returns the value of attribute build_id.
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#commit_msg ⇒ Object
Returns the value of attribute commit_msg.
-
#fastci_api_url ⇒ Object
Returns the value of attribute fastci_api_url.
-
#fastci_main_url ⇒ Object
Returns the value of attribute fastci_main_url.
-
#orig_build_id ⇒ Object
Returns the value of attribute orig_build_id.
-
#run_key ⇒ Object
Returns the value of attribute run_key.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
Instance Method Summary collapse
- #guess_author ⇒ Object
- #guess_branch ⇒ Object
- #guess_build_id ⇒ Object
- #guess_commit ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fast_ci/configuration.rb', line 8 def initialize # Settings defaults self.run_key = nil self.build_id = guess_build_id self.commit = guess_commit self.commit_msg = `git log -1 --pretty=%B`.chomp self.branch = guess_branch self.api_url = ENV["FAST_CI_API_URL"] || "apx.fast.ci" self.secret_key = ENV.fetch("FAST_CI_SECRET_KEY") self. = self.fastci_main_url = ENV.fetch('FASTCI_MAIN_URL', 'https://events.ruby.ci') self.fastci_api_url = ENV.fetch('FASTCI_API_RB_URL', 'https://ruby.fast.ci') self.orig_build_id = ENV['FSCI_ORIG_BUILD_ID'] end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def api_url @api_url end |
#author ⇒ Object
Returns the value of attribute author.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def @author end |
#branch ⇒ Object
Returns the value of attribute branch.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def branch @branch end |
#build_id ⇒ Object
Returns the value of attribute build_id.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def build_id @build_id end |
#commit ⇒ Object
Returns the value of attribute commit.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def commit @commit end |
#commit_msg ⇒ Object
Returns the value of attribute commit_msg.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def commit_msg @commit_msg end |
#fastci_api_url ⇒ Object
Returns the value of attribute fastci_api_url.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def fastci_api_url @fastci_api_url end |
#fastci_main_url ⇒ Object
Returns the value of attribute fastci_main_url.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def fastci_main_url @fastci_main_url end |
#orig_build_id ⇒ Object
Returns the value of attribute orig_build_id.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def orig_build_id @orig_build_id end |
#run_key ⇒ Object
Returns the value of attribute run_key.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def run_key @run_key end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
5 6 7 |
# File 'lib/fast_ci/configuration.rb', line 5 def secret_key @secret_key end |
Instance Method Details
#guess_author ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/fast_ci/configuration.rb', line 31 def = `git show | grep Author:` name, email = .scan(/Author: (.*) <(.*)>/).first { name: name, email: email } end |
#guess_branch ⇒ Object
54 55 56 57 58 59 |
# File 'lib/fast_ci/configuration.rb', line 54 def guess_branch %w[FSCI_BRANCH _BRANCH _REF].find do |keyword| key = ENV.keys.find { |k| k[keyword] } break ENV[key] if key && ENV[key] end || `git rev-parse --abbrev-ref HEAD`.chomp end |
#guess_build_id ⇒ Object
40 41 42 43 44 45 |
# File 'lib/fast_ci/configuration.rb', line 40 def guess_build_id %w[FSCI_BUILD_ID GITHUB_RUN_ID BUILD_ID CIRCLE_BUILD_NUM].find do |keyword| key = ENV.keys.find { |k| k[keyword] } break ENV[key] if key && ENV[key] end || guess_commit end |
#guess_commit ⇒ Object
47 48 49 50 51 52 |
# File 'lib/fast_ci/configuration.rb', line 47 def guess_commit %w[FSCI_COMMIT _COMMIT _SHA1 _SHA].find do |keyword| key = ENV.keys.find { |k| k[keyword] } break ENV[key] if key && ENV[key] end || `git rev-parse HEAD`.chomp end |
#reset ⇒ Object
23 24 25 |
# File 'lib/fast_ci/configuration.rb', line 23 def reset initialize end |