Class: Vimpack::Models::Repo

Inherits:
Base
  • Object
show all
Extended by:
Utils::File, Utils::Git
Defined in:
lib/vimpack/models/repo.rb

Defined Under Namespace

Classes: AlreadyInitialized, NotInitialized, OriginRemoteUnset

Instance Attribute Summary

Attributes included from Utils::File

#bundle_path, #home_path, #pack_path, #script_path, #vim_path

Class Method Summary collapse

Methods included from Utils::Git

add_submodule, init_repo, init_submodule, remove_submodule, replace_contents, repo_add_dot, repo_add_remote, repo_clone, repo_commit, repo_exec, repo_pull, repo_push, repo_remote?, sanitize_commands, update_submodule

Methods included from Utils::Process

#run_process!, #run_process_and_wait!, #run_process_or_die!, #wait_for_child, #within_dir

Methods included from Utils::Io

#die!, #exit_with_error!, #say, #scream

Methods included from Utils::File

create_link, directory_exists?, file_exists?, make_dir, move_path, remove_directory, remove_link, setup_paths, symlink_exists?, template, template_path

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Vimpack::Models::Base

Class Method Details

.git_exec(subcommand, commands) ⇒ Object



40
41
42
# File 'lib/vimpack/models/repo.rb', line 40

def git_exec(subcommand, commands)
  repo_exec(subcommand, commands)
end

.initialize!(repo_url = nil) ⇒ Object



13
14
15
16
17
18
# File 'lib/vimpack/models/repo.rb', line 13

def initialize!(repo_url=nil)
  raise_if_initialized!
  @repo_url = repo_url
  backup_existing_vim_environment
  @repo_url.nil? ? initialize_vimpack_repo : initialize_vimpack_remote_repo
end

.initialized?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/vimpack/models/repo.rb', line 20

def initialized?
  directory_exists?(pack_path.to_s)
end

.installed_script_namesObject



44
45
46
47
48
49
50
# File 'lib/vimpack/models/repo.rb', line 44

def installed_script_names
  Dir.glob(script_directories).each.inject([]) do |scripts, script_dir|
    script_name = ::File.split(script_dir)[-1]
    scripts << script_name unless script_name == 'pathogen.vim'
    scripts
  end
end

.installed_scriptsObject



52
53
54
55
56
# File 'lib/vimpack/models/repo.rb', line 52

def installed_scripts
  installed_script_names.each.inject([]) do |scripts, script_name|
    scripts << Script.info(script_name)
  end
end

.publish!(message) ⇒ Object

Raises:



32
33
34
35
36
37
38
# File 'lib/vimpack/models/repo.rb', line 32

def publish!(message)
  raise OriginRemoteUnset unless origin_set?
  repo_add_dot
  repo_commit(message)
  repo_push
  true
end

.raise_if_initialized!Object

Raises:



24
25
26
# File 'lib/vimpack/models/repo.rb', line 24

def raise_if_initialized!
  raise AlreadyInitialized if initialized?
end

.raise_unless_initialized!Object

Raises:



28
29
30
# File 'lib/vimpack/models/repo.rb', line 28

def raise_unless_initialized!
  raise NotInitialized unless initialized?
end