Class: BuPr::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/bu_pr/configuration.rb

Constant Summary collapse

ATTRS =
%i(
  branch
  title
  token
  repo
)

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Configuration

Returns a new instance of Configuration.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :branch (String)

    Base branch name

  • :title (String)

    pull-request title

  • :token (String)

    GitHub access token

  • :repo (String)

    GitHub repository name



19
20
21
22
23
24
25
# File 'lib/bu_pr/configuration.rb', line 19

def initialize opts = {}
  @branch = opts.fetch(:branch) { ENV.fetch("BUPR_BRANCH") { "master" } }
  @title  = opts.fetch(:title)  { ENV.fetch("BUPR_TITLE")  { default_title } }

  @token  = opts.fetch(:token) { ENV["BUPR_TOKEN"] }
  @repo   = opts.fetch(:repo)  { ENV["BUPR_REPO"] }
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/bu_pr/configuration.rb', line 28

def valid?
  token? && branch? && title? && repo?
end