class GitBundle::BranchConfig
Constants
- BRANCH_CONFIG_FILE
Attributes
filename[R]
Public Class Methods
new(filename = nil)
click to toggle source
# File lib/git_bundle/branch_config.rb, line 8 def initialize(filename = nil) @filename = filename || BRANCH_CONFIG_FILE end
Public Instance Methods
branch(repo_name)
click to toggle source
# File lib/git_bundle/branch_config.rb, line 30 def branch(repo_name) source = current[repo_name] if source.include?(' ') source.split(' ').last else source end end
changed?()
click to toggle source
# File lib/git_bundle/branch_config.rb, line 43 def changed? current != read end
current()
click to toggle source
# File lib/git_bundle/branch_config.rb, line 16 def current return @current if defined?(@current) @current = read end
path()
click to toggle source
# File lib/git_bundle/branch_config.rb, line 12 def path File.join(Dir.pwd, filename) end
read()
click to toggle source
# File lib/git_bundle/branch_config.rb, line 39 def read File.exist?(path) ? YAML.load_file(path) || {} : nil end
remote(repo_name)
click to toggle source
# File lib/git_bundle/branch_config.rb, line 21 def remote(repo_name) source = current[repo_name] if source.include?(' ') source.split(' ').first else nil end end
save()
click to toggle source
# File lib/git_bundle/branch_config.rb, line 47 def save if changed? File.open(path, 'w') { |file| file.write(current.to_yaml.lines[1..-1].join) } if File.exist?(path) puts "\t#{colorize('update', 34, bold: true)}\t#{filename}" else puts "\t#{colorize('create', 32, bold: true)}\t#{filename}" end else puts "\t#{colorize('identical', 34, bold: true)}\t#{filename}" end end