Class: GitTools::Submodule
- Inherits:
-
Object
- Object
- GitTools::Submodule
- Defined in:
- lib/git_tools/submodules.rb
Class Method Summary collapse
- .add(repo, location) ⇒ Object
- .checkout ⇒ Object
- .individual_tasks(yaml, &block) ⇒ Object
- .install_all(yaml) ⇒ Object
- .load_yaml(yaml) ⇒ Object
- .message(name, &block) ⇒ Object
- .remove(submodule) ⇒ Object
- .submodule_update(name) ⇒ Object
- .update_all(yaml) ⇒ Object
Class Method Details
.add(repo, location) ⇒ Object
17 18 19 |
# File 'lib/git_tools/submodules.rb', line 17 def self.add(repo, location) system("git submodule add #{repo} #{location}") end |
.checkout ⇒ Object
21 22 23 24 |
# File 'lib/git_tools/submodules.rb', line 21 def self.checkout system("git submodule init") system("git submodule update") end |
.individual_tasks(yaml, &block) ⇒ Object
47 48 49 50 |
# File 'lib/git_tools/submodules.rb', line 47 def self.individual_tasks(yaml, &block) @config = load_yaml(yaml) @config.each_key { |name| yield name } end |
.install_all(yaml) ⇒ Object
12 13 14 15 |
# File 'lib/git_tools/submodules.rb', line 12 def self.install_all(yaml) @config = load_yaml(yaml) @config.each { |plugin, repo| add(repo, plugin) } end |
.load_yaml(yaml) ⇒ Object
35 36 37 |
# File 'lib/git_tools/submodules.rb', line 35 def self.load_yaml(yaml) YAML::load(File.open(yaml))['submodules'] end |
.message(name, &block) ⇒ Object
40 41 42 43 44 |
# File 'lib/git_tools/submodules.rb', line 40 def self.(name, &block) puts "Updating #{name.to_s}" yield puts "\n" end |
.remove(submodule) ⇒ Object
26 27 28 |
# File 'lib/git_tools/submodules.rb', line 26 def self.remove(submodule) system("git rm --cache vendor/plugins/#{submodule}") end |
.submodule_update(name) ⇒ Object
30 31 32 33 |
# File 'lib/git_tools/submodules.rb', line 30 def self.submodule_update(name) dir = name == "rails" ? "vendor/rails/" : "vendor/plugins/#{name}" system("cd #{dir} && git remote update && git merge origin/master") end |
.update_all(yaml) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/git_tools/submodules.rb', line 5 def self.update_all(yaml) @config = load_yaml(yaml) @config.each_key do |name| (name) { submodule_update(name) } end end |