Class: Pully
- Inherits:
-
Object
- Object
- Pully
- Defined in:
- lib/pully.rb,
lib/pully/version.rb
Constant Summary collapse
- VERSION =
'0.0.2'
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Pully
constructor
A new instance of Pully.
- #open ⇒ Object
Constructor Details
#initialize ⇒ Pully
Returns a new instance of Pully.
12 13 14 15 16 17 18 |
# File 'lib/pully.rb', line 12 def initialize dir = '.' dir += '/..' until File.directory?("#{dir}/.git") @git = Git.open(dir) @branch = Git::Lib.new.send(:command, 'rev-parse --abbrev-ref HEAD') @remote = process_remote(@git.config['remote.origin.url']) end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
6 7 8 |
# File 'lib/pully.rb', line 6 def branch @branch end |
#git ⇒ Object (readonly)
Returns the value of attribute git.
6 7 8 |
# File 'lib/pully.rb', line 6 def git @git end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
6 7 8 |
# File 'lib/pully.rb', line 6 def remote @remote end |
Class Method Details
.open ⇒ Object
8 9 10 |
# File 'lib/pully.rb', line 8 def self.open new.open end |
Instance Method Details
#open ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pully.rb', line 20 def open link = "#{remote.gsub('.git', '')}/compare/#{branch}?expand=1" if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ system "start #{link}" elsif RbConfig::CONFIG['host_os'] =~ /darwin/ system "open #{link}" elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/ system "xdg-open #{link}" end end |