Class: Pully

Inherits:
Object
  • Object
show all
Defined in:
lib/pully.rb,
lib/pully/version.rb

Constant Summary collapse

VERSION =
'0.0.2'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePully

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

#branchObject (readonly)

Returns the value of attribute branch.



6
7
8
# File 'lib/pully.rb', line 6

def branch
  @branch
end

#gitObject (readonly)

Returns the value of attribute git.



6
7
8
# File 'lib/pully.rb', line 6

def git
  @git
end

#remoteObject (readonly)

Returns the value of attribute remote.



6
7
8
# File 'lib/pully.rb', line 6

def remote
  @remote
end

Class Method Details

.openObject



8
9
10
# File 'lib/pully.rb', line 8

def self.open
  new.open
end

Instance Method Details

#openObject



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