Class: RanchHand::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ranch_hand/base.rb

Class Method Summary collapse

Class Method Details

.initObject



10
11
12
13
14
# File 'lib/ranch_hand/base.rb', line 10

def self.init
  RanchHand::Logger.info("initializing ranch-hand for project")
  RanchHand::Config.create
  RanchHand::Logger.info("initialization complete")
end

.install_ohmyzshObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ranch_hand/base.rb', line 16

def self.install_ohmyzsh
  RanchHand::Logger.info("installing ranch-hand Oh My Zsh shortcuts")

  unless ENV['ZSH_CUSTOM'] || ENV['ZSH']
    RanchHand::Logger.warn("Could not find $ZSH_CUSTOM or $ZSH in your environment, can not install shortcuts")
    return
  end

  zsh_custom_dir = ENV['ZSH_CUSTOM'] || File.join(ENV['ZSH'], 'custom')

  zsh_plugin_dir = File.join(zsh_custom_dir, 'plugins', 'ranch-hand')
  FileUtils.mkdir_p(zsh_plugin_dir)

  current_path = File.expand_path(File.dirname(__FILE__))
  gem_plugin_path = File.join(current_path, '..', '..', 'files', 'ranch-hand.plugin.zsh')

  FileUtils.cp(gem_plugin_path, zsh_plugin_dir)

  RanchHand::Logger.info("installation complete")
  RanchHand::Logger.info("Don't forget to add 'ranch-hand' to your plugins in ~/.zshrc -- e.g. plugins=(ranch-hand) -- and then 'source ~/.zshrc'")
end

.setupObject



3
4
5
6
7
8
# File 'lib/ranch_hand/base.rb', line 3

def self.setup
  RanchHand::Logger.info("setting up ranch-hand")
  FileUtils.mkdir_p(RanchHand::RANCH_HAND_HOME)
  File.new(RanchHand::STORE_FILE, 'w+', 0640)
  RanchHand::Logger.info("complete")
end

.update_configObject



38
39
40
41
42
# File 'lib/ranch_hand/base.rb', line 38

def self.update_config
  RanchHand::Logger.info("updating ranch-hand config for project")
  RanchHand::Config.update
  RanchHand::Logger.info("update complete")
end