Class: Rebuild::GitConfig
- Inherits:
-
Object
- Object
- Rebuild::GitConfig
- Includes:
- Singleton
- Defined in:
- lib/rebuild/git_config.rb
Instance Method Summary collapse
- #add_rebuild_config ⇒ Object
- #has_rebuild_config? ⇒ Boolean
-
#initialize ⇒ GitConfig
constructor
A new instance of GitConfig.
- #rebuild_config ⇒ Object
Constructor Details
#initialize ⇒ GitConfig
Returns a new instance of GitConfig.
9 10 11 12 |
# File 'lib/rebuild/git_config.rb', line 9 def initialize return unless File.exists?(gitconfig_path) @config = ParseConfig.new(gitconfig_path) end |
Instance Method Details
#add_rebuild_config ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rebuild/git_config.rb', line 19 def add_rebuild_config git_config = if File.exists?(gitconfig_path) File.read(gitconfig_path) else '' end rebuild_config = <<-EOS.unindent [rebuild] # if true, everytime git pull update = false # you can change script run directory scriptdir = / # if present, you can `rebuild` without argument # repo = username/dotfiles # cloned directory path # directory = ~/src/dotfiles EOS File.write(gitconfig_path, "#{git_config}\n#{rebuild_config}") Logger.info('Succeed to update ~/.gitconfig') end |
#has_rebuild_config? ⇒ Boolean
14 15 16 17 |
# File 'lib/rebuild/git_config.rb', line 14 def has_rebuild_config? return false unless @config @config.params["rebuild"] != nil end |
#rebuild_config ⇒ Object
45 46 47 48 |
# File 'lib/rebuild/git_config.rb', line 45 def rebuild_config return {} unless @config symbolize_keys(@config.params["rebuild"] || {}) end |