Class: Diffend::Config
- Inherits:
-
Object
- Object
- Diffend::Config
- Defined in:
- lib/diffend/config.rb
Overview
Diffend config object
Constant Summary collapse
- FILENAME =
Name of the diffend config file
'.diffend.yml'
Instance Attribute Summary collapse
-
#build_path ⇒ Object
readonly
Returns the value of attribute build_path.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#shareable_id ⇒ Object
readonly
Returns the value of attribute shareable_id.
-
#shareable_key ⇒ Object
readonly
Returns the value of attribute shareable_key.
Instance Method Summary collapse
-
#commands_url ⇒ String
Provides diffend commands endpoint url.
-
#deployment? ⇒ Boolean
True if we are in deployment mode, false otherwise.
-
#development? ⇒ Boolean
True if we are in development mode, false otherwise.
-
#errors_url ⇒ String
Provides diffend errors endpoint url.
-
#execute? ⇒ Boolean
This method is provided just in case something would go wrong with Diffend but there would be a need to run Bundler anyhow.
-
#ignore_errors? ⇒ Boolean
True if we want to ignore errors, false otherwise.
-
#initialize(command: nil, severity: nil, build_path: nil) ⇒ Diffend::Config
constructor
Build diffend config object.
-
#logger ⇒ Object
Initialize logger.
-
#print_errors ⇒ Object
Print config errors.
- #track_url(request_id) ⇒ String
-
#valid? ⇒ Boolean
True if config is valid, false otherwise.
Constructor Details
#initialize(command: nil, severity: nil, build_path: nil) ⇒ Diffend::Config
Build diffend config object
18 19 20 21 22 23 |
# File 'lib/diffend/config.rb', line 18 def initialize(command: nil, severity: nil, build_path: nil) @log_level = severity @errors = [] build(command, build_path) Diffend::Configs::Validator.call(self) end |
Instance Attribute Details
#build_path ⇒ Object (readonly)
Returns the value of attribute build_path.
9 10 11 |
# File 'lib/diffend/config.rb', line 9 def build_path @build_path end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
9 10 11 |
# File 'lib/diffend/config.rb', line 9 def command @command end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/diffend/config.rb', line 9 def env @env end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/diffend/config.rb', line 9 def errors @errors end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
9 10 11 |
# File 'lib/diffend/config.rb', line 9 def project_id @project_id end |
#shareable_id ⇒ Object (readonly)
Returns the value of attribute shareable_id.
9 10 11 |
# File 'lib/diffend/config.rb', line 9 def shareable_id @shareable_id end |
#shareable_key ⇒ Object (readonly)
Returns the value of attribute shareable_key.
9 10 11 |
# File 'lib/diffend/config.rb', line 9 def shareable_key @shareable_key end |
Instance Method Details
#commands_url ⇒ String
Provides diffend commands endpoint url
61 62 63 64 65 |
# File 'lib/diffend/config.rb', line 61 def commands_url return ENV['DIFFEND_COMMANDS_URL'] if ENV.key?('DIFFEND_COMMANDS_URL') "https://my.diffend.io/api/projects/#{project_id}/bundle/#{command}" end |
#deployment? ⇒ Boolean
Returns true if we are in deployment mode, false otherwise.
54 55 56 |
# File 'lib/diffend/config.rb', line 54 def deployment? !%w[development test].include?(env) end |
#development? ⇒ Boolean
Returns true if we are in development mode, false otherwise.
41 42 43 |
# File 'lib/diffend/config.rb', line 41 def development? @development end |
#errors_url ⇒ String
Provides diffend errors endpoint url
70 71 72 73 74 |
# File 'lib/diffend/config.rb', line 70 def errors_url return ENV['DIFFEND_ERRORS_URL'] if ENV.key?('DIFFEND_ERRORS_URL') "https://my.diffend.io/api/projects/#{project_id}/errors" end |
#execute? ⇒ Boolean
This method is provided just in case something would go wrong with Diffend but there would be a need to run Bundler anyhow. Please don’t use unless aware of the downsides.
49 50 51 |
# File 'lib/diffend/config.rb', line 49 def execute? @execute end |
#ignore_errors? ⇒ Boolean
Returns true if we want to ignore errors, false otherwise.
36 37 38 |
# File 'lib/diffend/config.rb', line 36 def ignore_errors? @ignore_errors end |
#logger ⇒ Object
Initialize logger
26 27 28 |
# File 'lib/diffend/config.rb', line 26 def logger @logger ||= Diffend::Logger.new(@log_level) end |
#print_errors ⇒ Object
Print config errors
84 85 86 |
# File 'lib/diffend/config.rb', line 84 def print_errors @errors.each { |error| logger.fatal(error) } end |
#track_url(request_id) ⇒ String
79 80 81 |
# File 'lib/diffend/config.rb', line 79 def track_url(request_id) "https://my.diffend.io/api/projects/#{project_id}/bundle/#{request_id}/track" end |
#valid? ⇒ Boolean
Returns true if config is valid, false otherwise.
31 32 33 |
# File 'lib/diffend/config.rb', line 31 def valid? @errors.empty? end |