Sha256: e74693c0ac65347f520df5912374e7b504c557962593d6017a93d8eec4785101

Contents?: true

Size: 616 Bytes

Versions: 2

Compression:

Stored size: 616 Bytes

Contents

module Brah

  def self.run(git_remote_output)
    Brah.new(git_remote_output).run
  end

  class Brah
    attr_reader :command

    def initialize(git_remote_output)
      raise("No remotes found!") if git_remote_output.empty?
      parsed_command = convert_ssh_to_http(git_remote_output)
      @command = "open #{parsed_command}"
    end

    def run
      system(command)
    end

    private

      def convert_ssh_to_http(git_remote_output)
        git_remote_output.match(/origin\t(\S+)/)[1].
          gsub(/\.git$/, "").
          gsub("com:", "com/").
          gsub("git@", "https://")
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brah-0.5.0 lib/brah.rb
brah-0.4.0 lib/brah.rb