Module: Danger::Dangerfile::DSL
- Included in:
- Danger::Dangerfile
- Defined in:
- lib/danger/dangerfile_dsl.rb
Enviroment collapse
-
#env ⇒ EnvironmentManager
readonly
objects, which you can use to pull out extra bits of information.
Enviroment collapse
-
#fail(message) ⇒ Object
Declares a CI blocking error.
- #initialize ⇒ Object
-
#message(message) ⇒ Object
Print out a generate message on the PR.
-
#method_missing(method_sym, *_arguments, &_block) ⇒ Object
When an undefined method is called, we check to see if it’s something that either the ‘scm` or the `request_source` can handle.
-
#warn(message) ⇒ Object
Specifies a problem, but not critical.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *_arguments, &_block) ⇒ Object
When an undefined method is called, we check to see if it’s something that either the ‘scm` or the `request_source` can handle. This opens us up to letting those object extend themselves naturally.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/danger/dangerfile_dsl.rb', line 48 def method_missing(method_sym, *_arguments, &_block) unless AvailableValues.all.include?(method_sym) raise "Unknown method '#{method_sym}', please check out the documentation for available variables".red end if AvailableValues.scm.include?(method_sym) # SCM Source return env.scm.send(method_sym) end if AvailableValues.request_source.include?(method_sym) # Request Source return env.request_source.send(method_sym) end end |
Instance Attribute Details
#env ⇒ EnvironmentManager (readonly)
objects, which you can use to pull out extra bits of information. Warning the api of these objects is not considered a part of the Dangerfile public API, and is viable to change occasionally on the whims of developers.
10 11 12 |
# File 'lib/danger/dangerfile_dsl.rb', line 10 def env @env end |
Instance Method Details
#fail(message) ⇒ Object
Declares a CI blocking error
22 23 24 25 |
# File 'lib/danger/dangerfile_dsl.rb', line 22 def fail() self.errors << puts "Raising error '#{}'" end |
#initialize ⇒ Object
12 13 14 15 16 |
# File 'lib/danger/dangerfile_dsl.rb', line 12 def initialize self.warnings = [] self.errors = [] self. = [] end |
#message(message) ⇒ Object
Print out a generate message on the PR
40 41 42 43 |
# File 'lib/danger/dangerfile_dsl.rb', line 40 def () self. << puts "Printing message '#{}'" end |
#warn(message) ⇒ Object
Specifies a problem, but not critical
31 32 33 34 |
# File 'lib/danger/dangerfile_dsl.rb', line 31 def warn() self.warnings << puts "Printing warning '#{}'" end |