lib/cp8_cli/repo.rb in cp8_cli-4.0.1 vs lib/cp8_cli/repo.rb in cp8_cli-4.1.0
- old
+ new
@@ -1,7 +1,16 @@
module Cp8Cli
class Repo
+ def self.current
+ path = Command.read("git config --get remote.origin.url").match(/github.com[:\/](\S+\/\S+)\.git/)[1]
+ new(path)
+ end
+
+ def initialize(path)
+ @path = path
+ end
+
def user
path.split('/').first
end
def name
@@ -12,10 +21,8 @@
"https://github.com/#{user}/#{name}"
end
private
- def path
- @_path ||= Command.read("git config --get remote.origin.url").match(/github.com[:\/](\S+\/\S+)\.git/)[1]
- end
+ attr_reader :path
end
end