Class: Dotpack::Repo
- Inherits:
-
Object
- Object
- Dotpack::Repo
- Defined in:
- lib/dotpack/repo.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/dotpack/repo.rb', line 8 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/dotpack/repo.rb', line 8 def path @path end |
Class Method Details
.all ⇒ Object
12 13 14 15 16 17 |
# File 'lib/dotpack/repo.rb', line 12 def self.all return @repos unless @repos.nil? FileUtils.mkdir_p REPO_DIR @repos = Dir[REPO_DIR + '/*'].map{|p| Repo.new(p)} @repos end |
.find_by_name(name) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/dotpack/repo.rb', line 19 def self.find_by_name(name) repos = all() repos.each do |r| return r if r.name == name end nil end |
Instance Method Details
#update ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dotpack/repo.rb', line 27 def update Dir.chdir @path return false unless system "git fetch origin >/dev/null 2>&1" commits = `git log HEAD..origin/master --oneline` return false if commits == "" last = commits.lines.last.split(' ').first puts "Updated #{@name} to #{last}" system "git pull -f origin master >/dev/null" true end |