Class: Gitoc::Cli
Instance Method Summary collapse
Instance Method Details
#check ⇒ Object
12 13 14 15 16 17 18 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/gitoc/cli.rb', line 12 def check init_base # Get all repositories from the filesystem # and tag them with :fs repositories = repositories_fs.map do |repository_fs| [repository_fs, [:fs]] end # Add missing repositories from the GiTOC file # and tag all repositories from the GiTOC file with :toc repositories_gitoc.each do |repository_gitoc| _, = repositories.find {|repository_fs, _| repository_fs == repository_gitoc } if << :toc else repositories << [repository_gitoc, [:toc]] end end # Sort repositories list # and build table rows: [path, url, comment] rows = repositories.sort_by {|repository, _| repository.rel_path }.map do |repository, | path, url = repository.to_hash.values url = "-" if url.nil? || url.empty? comment = .include?(:fs) && .include?(:toc) ? "" : {fs: "not in GiTOC", toc: "not on filesystem"}[.first] [path, url, comment] end print_table rows end |
#clone ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gitoc/cli.rb', line 57 def clone init_base each_repository do |repo| if repo.exist? puts "Skip repository, #{repo.path} already exists." next end repo.clone end end |
#clone_or_pull ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/gitoc/cli.rb', line 85 def clone_or_pull init_base each_repository do |repo| if repo.exist? repo.pull else repo.clone end end end |
#generate ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/gitoc/cli.rb', line 46 def generate init_base toc = repositories_fs.map(&:to_hash) # Write git_toc file gitoc.write toc.to_yaml puts "Write #{gitoc}" end |
#pull ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gitoc/cli.rb', line 71 def pull init_base each_repository do |repo| unless repo.exist? puts "Skip repository, #{repo.path} doesn't exist." next end repo.pull end end |