Module: ORS::Helpers::ParseHelpers

Included in:
ORS::Helpers
Defined in:
lib/ors/helpers.rb

Overview

Helpers for Commands when parsing in ARGV

Instance Method Summary collapse

Instance Method Details

#parse_remote_and_or_branchObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ors/helpers.rb', line 6

def parse_remote_and_or_branch
  option = ORS.config[:args].shift

  unless option.nil?
    if option.match(/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+$/)
      remote, *branch = option.split("/")

      ORS.config[:remote] = remote
      ORS.config[:branch] = branch.join('/')
    else
      ORS.config[:remote] = option
    end
  end
end