Class: Vendorise::Arborist

Inherits:
Object
  • Object
show all
Defined in:
lib/vendorise/arborist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, url, branch) ⇒ Arborist

Returns a new instance of Arborist.



5
6
7
8
9
# File 'lib/vendorise/arborist.rb', line 5

def initialize(path, url, branch)
  @path = path
  @url = url
  @branch = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



3
4
5
# File 'lib/vendorise/arborist.rb', line 3

def branch
  @branch
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/vendorise/arborist.rb', line 3

def path
  @path
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/vendorise/arborist.rb', line 3

def url
  @url
end

Instance Method Details

#subtree_already_exists?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/vendorise/arborist.rb', line 11

def subtree_already_exists?
  Dir.exist?(path)
end

#subtree_commandObject



15
16
17
18
# File 'lib/vendorise/arborist.rb', line 15

def subtree_command
  cmd = subtree_already_exists? ? "pull" : "add"
  "git subtree #{cmd} --prefix #{path} #{url} #{branch} --squash"
end