class Danger::DangerWelcomeMessage

Show the greeting on a pull request.

@example Show the greeting

welcome_message.greet

@example When you want to greet with your words

welcome_message.custom_words = <<-CUSTOM_WORDS
  Hi, @#{github.pr_author}!!
  Welcome to #{github.pr_json[:base][:repo][:full_name]}! Thanks so much for joining us.
CUSTOM_WORDS

welcome_message.greet

@example When you want to see the greeting irrespective of the conditions

welcome_message.greet_test

@see soudai-s/danger-welcome_message @tags monday, weekends, time, rattata

Attributes

custom_words[W]

Custom words for greeting

@return [String]

Public Instance Methods

greet() click to toggle source

Greet when a new member makes a first pull request

@return [void]

# File lib/welcome_message/plugin.rb, line 32
def greet
  message greeting_words if new_member?
end
greet_test() click to toggle source

Greet every time

@return [void]

# File lib/welcome_message/plugin.rb, line 39
def greet_test
  message greeting_words
end

Private Instance Methods

collaborators() click to toggle source
# File lib/welcome_message/plugin.rb, line 49
def collaborators
  @collaborators ||= github.api.collaborators(repo).map { |c| c.login }
end
experienced_people() click to toggle source
# File lib/welcome_message/plugin.rb, line 53
def experienced_people
  @experienced_people ||= github.api.pull_requests(repo).map { |pr| pr.user.login }.uniq
end
greeting_words() click to toggle source
# File lib/welcome_message/plugin.rb, line 62
def greeting_words
  @custom_words || "Welcome, #{github.pr_author} 🎉"
end
new_member?() click to toggle source
# File lib/welcome_message/plugin.rb, line 57
def new_member?
  new_members = collaborators - experienced_people
  new_members.include? github.pr_author
end
repo() click to toggle source
# File lib/welcome_message/plugin.rb, line 45
def repo
  @repository ||= github.pr_json[:base][:repo][:full_name]
end