Class: QCS
- Inherits:
-
Object
- Object
- QCS
- Defined in:
- lib/qcs.rb
Instance Attribute Summary collapse
-
#mainPro ⇒ Object
Returns the value of attribute mainPro.
-
#repos ⇒ Object
Returns the value of attribute repos.
Instance Method Summary collapse
- #checkout(branch) ⇒ Object
- #clone(repoInfo) ⇒ Object
-
#initialize(filePath) ⇒ QCS
constructor
A new instance of QCS.
- #install ⇒ Object
- #pull ⇒ Object
Constructor Details
#initialize(filePath) ⇒ QCS
Returns a new instance of QCS.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/qcs.rb', line 19 def initialize(filePath) fileText = IO.read(filePath) @repos = Array.new JSON.parse(fileText).each do |repo| name = repo["name"] url = repo["url"] branch = repo["branch"] parsed = RepoInfo.new(name, url, branch) @repos.push(parsed) if repo["isMain"] == 1 @mainPro = parsed end end end |
Instance Attribute Details
#mainPro ⇒ Object
Returns the value of attribute mainPro.
17 18 19 |
# File 'lib/qcs.rb', line 17 def mainPro @mainPro end |
#repos ⇒ Object
Returns the value of attribute repos.
17 18 19 |
# File 'lib/qcs.rb', line 17 def repos @repos end |
Instance Method Details
#checkout(branch) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/qcs.rb', line 70 def checkout(branch) @repos.each do |repoInfo| Dir.chdir(repoInfo.name) do hint = "check out #{repoInfo.name} ..." puts(hint.green) result = `git checkout #{branch}` puts result end end end |
#clone(repoInfo) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/qcs.rb', line 61 def clone(repoInfo) unless Dir.exist?(repoInfo.name) hint = "clone #{repoInfo.name} ..." puts hint result = `git clone -b #{repoInfo.branch} #{repoInfo.url} #{repoInfo.name}` puts result end end |
#install ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/qcs.rb', line 50 def install @repos.each do |repoInfo| clone repoInfo end Dir.chdir(@mainPro.name) do puts "pod install ... #{Dir.pwd}" result = `pod install` puts result end end |
#pull ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/qcs.rb', line 34 def pull @repos.each do |repoInfo| unless Dir.exist?(repoInfo.name) clone(repoInfo) return end Dir.chdir(repoInfo.name) do hint = "pull out #{repoInfo.name} ..." puts(hint.green) result = `git pull` puts result end end end |