Class: KnapsackPro::Config::Env
- Inherits:
-
Object
- Object
- KnapsackPro::Config::Env
- Defined in:
- lib/knapsack_pro/config/env.rb
Class Method Summary collapse
- .branch ⇒ Object
- .ci_env_for(env_name) ⇒ Object
- .ci_node_index ⇒ Object
- .ci_node_total ⇒ Object
- .commit_hash ⇒ Object
- .endpoint ⇒ Object
- .mode ⇒ Object
- .project_dir ⇒ Object
- .recording_enabled ⇒ Object
- .recording_enabled? ⇒ Boolean
- .repository_adapter ⇒ Object
- .test_file_pattern ⇒ Object
- .test_suite_token ⇒ Object
- .test_suite_token_cucumber ⇒ Object
- .test_suite_token_minitest ⇒ Object
- .test_suite_token_rspec ⇒ Object
Class Method Details
.branch ⇒ Object
22 23 24 25 |
# File 'lib/knapsack_pro/config/env.rb', line 22 def branch ENV['KNAPSACK_PRO_BRANCH'] || ci_env_for(:branch) end |
.ci_env_for(env_name) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/knapsack_pro/config/env.rb', line 91 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_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
17 18 19 20 |
# File 'lib/knapsack_pro/config/env.rb', line 17 def commit_hash ENV['KNAPSACK_PRO_COMMIT_HASH'] || ci_env_for(:commit_hash) end |
.endpoint ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/knapsack_pro/config/env.rb', line 48 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 'http://api-staging.knapsackpro.com' when :production 'http://api.knapsackpro.com' else required_env(env_name) end end |
.mode ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/knapsack_pro/config/env.rb', line 80 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 |
.project_dir ⇒ Object
27 28 29 30 |
# File 'lib/knapsack_pro/config/env.rb', line 27 def project_dir ENV['KNAPSACK_PRO_PROJECT_DIR'] || ci_env_for(:project_dir) end |
.recording_enabled ⇒ Object
40 41 42 |
# File 'lib/knapsack_pro/config/env.rb', line 40 def recording_enabled ENV['KNAPSACK_PRO_RECORDING_ENABLED'] end |
.recording_enabled? ⇒ Boolean
44 45 46 |
# File 'lib/knapsack_pro/config/env.rb', line 44 def recording_enabled? recording_enabled == 'true' end |
.repository_adapter ⇒ Object
36 37 38 |
# File 'lib/knapsack_pro/config/env.rb', line 36 def repository_adapter ENV['KNAPSACK_PRO_REPOSITORY_ADAPTER'] end |
.test_file_pattern ⇒ Object
32 33 34 |
# File 'lib/knapsack_pro/config/env.rb', line 32 def test_file_pattern ENV['KNAPSACK_PRO_TEST_FILE_PATTERN'] end |
.test_suite_token ⇒ Object
64 65 66 |
# File 'lib/knapsack_pro/config/env.rb', line 64 def test_suite_token required_env('KNAPSACK_PRO_TEST_SUITE_TOKEN') end |
.test_suite_token_cucumber ⇒ Object
76 77 78 |
# File 'lib/knapsack_pro/config/env.rb', line 76 def test_suite_token_cucumber ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER'] end |
.test_suite_token_minitest ⇒ Object
72 73 74 |
# File 'lib/knapsack_pro/config/env.rb', line 72 def test_suite_token_minitest ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST'] end |
.test_suite_token_rspec ⇒ Object
68 69 70 |
# File 'lib/knapsack_pro/config/env.rb', line 68 def test_suite_token_rspec ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC'] end |