Class: KnapsackPro::Config::Env
- Inherits:
-
Object
- Object
- KnapsackPro::Config::Env
- Defined in:
- lib/knapsack_pro/config/env.rb
Class Method Summary collapse
- .branch ⇒ Object
- .branch_encrypted ⇒ Object
- .branch_encrypted? ⇒ Boolean
- .ci_env_for(env_name) ⇒ Object
- .ci_node_build_id ⇒ Object
- .ci_node_index ⇒ Object
- .ci_node_total ⇒ Object
- .commit_hash ⇒ Object
- .endpoint ⇒ Object
- .fixed_queue_split ⇒ Object
- .fixed_test_suite_split ⇒ Object
- .log_level ⇒ Object
- .mode ⇒ Object
- .modify_default_rspec_formatters ⇒ Object
- .modify_default_rspec_formatters? ⇒ Boolean
- .project_dir ⇒ Object
- .queue_id ⇒ Object
- .queue_recording_enabled ⇒ Object
- .queue_recording_enabled? ⇒ Boolean
- .recording_enabled ⇒ Object
- .recording_enabled? ⇒ Boolean
- .repository_adapter ⇒ Object
- .salt ⇒ Object
- .subset_queue_id ⇒ Object
- .test_dir ⇒ Object
- .test_file_pattern ⇒ Object
- .test_files_encrypted ⇒ Object
- .test_files_encrypted? ⇒ Boolean
- .test_suite_token ⇒ Object
- .test_suite_token_cucumber ⇒ Object
- .test_suite_token_minitest ⇒ Object
- .test_suite_token_rspec ⇒ Object
- .test_suite_token_spinach ⇒ Object
Class Method Details
.branch ⇒ Object
28 29 30 31 |
# File 'lib/knapsack_pro/config/env.rb', line 28 def branch ENV['KNAPSACK_PRO_BRANCH'] || ci_env_for(:branch) end |
.branch_encrypted ⇒ Object
90 91 92 |
# File 'lib/knapsack_pro/config/env.rb', line 90 def branch_encrypted ENV['KNAPSACK_PRO_BRANCH_ENCRYPTED'] end |
.branch_encrypted? ⇒ Boolean
94 95 96 |
# File 'lib/knapsack_pro/config/env.rb', line 94 def branch_encrypted? branch_encrypted == 'true' end |
.ci_env_for(env_name) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/knapsack_pro/config/env.rb', line 158 def ci_env_for(env_name) value = nil ci_list = KnapsackPro::Config::CI.constants - [:Base] ci_list.each do |ci_name| ci_class = Object.const_get("KnapsackPro::Config::CI::#{ci_name}") ci = ci_class.new value = ci.send(env_name) break unless value.nil? end value end |
.ci_node_build_id ⇒ Object
17 18 19 20 21 |
# File 'lib/knapsack_pro/config/env.rb', line 17 def ci_node_build_id ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] || ci_env_for(:node_build_id) || 'missing-build-id' end |
.ci_node_index ⇒ Object
11 12 13 14 15 |
# File 'lib/knapsack_pro/config/env.rb', line 11 def ci_node_index (ENV['KNAPSACK_PRO_CI_NODE_INDEX'] || ci_env_for(:node_index) || 0).to_i end |
.ci_node_total ⇒ Object
5 6 7 8 9 |
# File 'lib/knapsack_pro/config/env.rb', line 5 def ci_node_total (ENV['KNAPSACK_PRO_CI_NODE_TOTAL'] || ci_env_for(:node_total) || 1).to_i end |
.commit_hash ⇒ Object
23 24 25 26 |
# File 'lib/knapsack_pro/config/env.rb', line 23 def commit_hash ENV['KNAPSACK_PRO_COMMIT_HASH'] || ci_env_for(:commit_hash) end |
.endpoint ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/knapsack_pro/config/env.rb', line 102 def endpoint env_name = 'KNAPSACK_PRO_ENDPOINT' return ENV[env_name] if ENV[env_name] case mode when :development 'http://api.knapsackpro.dev:3000' when :test 'https://api-staging.knapsackpro.com' when :production 'https://api.knapsackpro.com' else required_env(env_name) end end |
.fixed_queue_split ⇒ Object
122 123 124 |
# File 'lib/knapsack_pro/config/env.rb', line 122 def fixed_queue_split ENV.fetch('KNAPSACK_PRO_FIXED_QUEUE_SPLIT', false) end |
.fixed_test_suite_split ⇒ Object
118 119 120 |
# File 'lib/knapsack_pro/config/env.rb', line 118 def fixed_test_suite_split ENV.fetch('KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT', true) end |
.log_level ⇒ Object
170 171 172 173 174 175 176 177 178 |
# File 'lib/knapsack_pro/config/env.rb', line 170 def log_level { 'fatal' => ::Logger::FATAL, 'error' => ::Logger::ERROR, 'warn' => ::Logger::WARN, 'info' => ::Logger::INFO, 'debug' => ::Logger::DEBUG, }[ENV['KNAPSACK_PRO_LOG_LEVEL'].to_s.downcase] || ::Logger::DEBUG end |
.mode ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/knapsack_pro/config/env.rb', line 147 def mode mode = ENV['KNAPSACK_PRO_MODE'] return :production if mode.nil? mode = mode.to_sym if [:development, :test, :production].include?(mode) mode else raise ArgumentError.new('Wrong mode name') end end |
.modify_default_rspec_formatters ⇒ Object
82 83 84 |
# File 'lib/knapsack_pro/config/env.rb', line 82 def modify_default_rspec_formatters ENV.fetch('KNAPSACK_PRO_MODIFY_DEFAULT_RSPEC_FORMATTERS', true) end |
.modify_default_rspec_formatters? ⇒ Boolean
86 87 88 |
# File 'lib/knapsack_pro/config/env.rb', line 86 def modify_default_rspec_formatters? modify_default_rspec_formatters.to_s == 'true' end |
.project_dir ⇒ Object
33 34 35 36 |
# File 'lib/knapsack_pro/config/env.rb', line 33 def project_dir ENV['KNAPSACK_PRO_PROJECT_DIR'] || ci_env_for(:project_dir) end |
.queue_id ⇒ Object
66 67 68 |
# File 'lib/knapsack_pro/config/env.rb', line 66 def queue_id ENV['KNAPSACK_PRO_QUEUE_ID'] || raise('Missing Queue ID') end |
.queue_recording_enabled ⇒ Object
58 59 60 |
# File 'lib/knapsack_pro/config/env.rb', line 58 def queue_recording_enabled ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] end |
.queue_recording_enabled? ⇒ Boolean
62 63 64 |
# File 'lib/knapsack_pro/config/env.rb', line 62 def queue_recording_enabled? queue_recording_enabled == 'true' end |
.recording_enabled ⇒ Object
50 51 52 |
# File 'lib/knapsack_pro/config/env.rb', line 50 def recording_enabled ENV['KNAPSACK_PRO_RECORDING_ENABLED'] end |
.recording_enabled? ⇒ Boolean
54 55 56 |
# File 'lib/knapsack_pro/config/env.rb', line 54 def recording_enabled? recording_enabled == 'true' end |
.repository_adapter ⇒ Object
46 47 48 |
# File 'lib/knapsack_pro/config/env.rb', line 46 def repository_adapter ENV['KNAPSACK_PRO_REPOSITORY_ADAPTER'] end |
.salt ⇒ Object
98 99 100 |
# File 'lib/knapsack_pro/config/env.rb', line 98 def salt required_env('KNAPSACK_PRO_SALT') end |
.subset_queue_id ⇒ Object
70 71 72 |
# File 'lib/knapsack_pro/config/env.rb', line 70 def subset_queue_id ENV['KNAPSACK_PRO_SUBSET_QUEUE_ID'] || raise('Missing Subset Queue ID') end |
.test_dir ⇒ Object
42 43 44 |
# File 'lib/knapsack_pro/config/env.rb', line 42 def test_dir ENV['KNAPSACK_PRO_TEST_DIR'] end |
.test_file_pattern ⇒ Object
38 39 40 |
# File 'lib/knapsack_pro/config/env.rb', line 38 def test_file_pattern ENV['KNAPSACK_PRO_TEST_FILE_PATTERN'] end |
.test_files_encrypted ⇒ Object
74 75 76 |
# File 'lib/knapsack_pro/config/env.rb', line 74 def test_files_encrypted ENV['KNAPSACK_PRO_TEST_FILES_ENCRYPTED'] end |
.test_files_encrypted? ⇒ Boolean
78 79 80 |
# File 'lib/knapsack_pro/config/env.rb', line 78 def test_files_encrypted? test_files_encrypted == 'true' end |
.test_suite_token ⇒ Object
126 127 128 129 |
# File 'lib/knapsack_pro/config/env.rb', line 126 def test_suite_token env_name = 'KNAPSACK_PRO_TEST_SUITE_TOKEN' ENV[env_name] || raise("Missing environment variable #{env_name}. You should set environment variable like #{env_name}_RSPEC (note there is suffix _RSPEC at the end). knapsack_pro gem will set #{env_name} based on #{env_name}_RSPEC value. If you use other test runner than RSpec then use proper suffix.") end |
.test_suite_token_cucumber ⇒ Object
139 140 141 |
# File 'lib/knapsack_pro/config/env.rb', line 139 def test_suite_token_cucumber ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER'] end |
.test_suite_token_minitest ⇒ Object
135 136 137 |
# File 'lib/knapsack_pro/config/env.rb', line 135 def test_suite_token_minitest ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST'] end |
.test_suite_token_rspec ⇒ Object
131 132 133 |
# File 'lib/knapsack_pro/config/env.rb', line 131 def test_suite_token_rspec ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC'] end |
.test_suite_token_spinach ⇒ Object
143 144 145 |
# File 'lib/knapsack_pro/config/env.rb', line 143 def test_suite_token_spinach ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH'] end |