Class: GitCloner::Core
- Inherits:
-
Object
- Object
- GitCloner::Core
- Defined in:
- lib/git_cloner_core.rb
Overview
GitCloner Core
Constant Summary collapse
- GIT_CLONER_FILE =
"Gitclonerfile"- GIT_CLONER_TEMPLATE =
<<-EOS # encoding: utf-8 # default_output place # default_output is required # default_output allow only String # default_output's default value => "./" default_output "./" # git repositries # repo allow only Array(in Array, Hash[:place, :output]) # repo's default value => [] repos [ { place: 'https://github.com/tbpgr/rspec_piccolo.git', output: './tmp' } ] EOS
Instance Method Summary collapse
-
#execute ⇒ Object
clone git repositories.
-
#init ⇒ Object
generate Gitclonerfile to current directory.
Instance Method Details
#execute ⇒ Object
clone git repositories
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/git_cloner_core.rb', line 35 def execute dsl = get_dsl base = Dir.pwd default_output = dsl.git_cloner.default_output tmp_repos = dsl.git_cloner.repos fail ArgumentError, 'invalid repos. repos must be Array.' unless tmp_repos.is_a? Array tmp_repos.each do |repo| fail ArgumentError, 'invalid repos. repos-Array must have Hash' unless repo.is_a? Hash fail ArgumentError, 'invalid key. Hash must contain :place key' unless repo.has_key? :place repo_name = get_repo_name repo[:place] target_dir = get_output(repo[:output], default_output) FileUtils.mkdir_p(target_dir) unless Dir.exists? target_dir Dir.chdir(target_dir) result = system("git clone #{repo[:place]} --depth=1") remove_dot_git_directory repo_name (result, repo_name) Dir.chdir base end end |
#init ⇒ Object
generate Gitclonerfile to current directory.
30 31 32 |
# File 'lib/git_cloner_core.rb', line 30 def init File.open(GIT_CLONER_FILE, "w") {|f|f.puts GIT_CLONER_TEMPLATE} end |