yac 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/yac.rb +14 -29
  2. data/yac.gemspec +1 -1
  3. metadata +1 -1
data/lib/yac.rb CHANGED
@@ -199,37 +199,22 @@ module Yac
199
199
 
200
200
  def init
201
201
  FileUtils.mkdir_p(CONFIG['root'])
202
- if CONFIG['main']['clone-from']
203
- if File.exist?(@main_path)
204
- puts "Main repository has already been initialized."
205
- else
206
- puts "Initialize main repository from #{CONFIG['main']['clone-from']} to #{CONFIG['root']}/main"
207
- Git.clone(CONFIG['main']['clone-from'], 'main', :path => CONFIG['root'])
208
- puts "Main repository initialized."
209
- end
210
- else
211
- puts "ERROR: configuration for main repository repository is missing!"
212
- return
213
- end
214
-
215
- unless File.exist?(@pri_path)
216
- if CONFIG['private'] && CONFIG['private']['clone-from']
217
- puts "Initialize private repository from #{CONFIG['private']['clone-from']} to #{CONFIG['root']}/private"
218
- Git.clone(CONFIG['private']['clone-from'], 'private', :path => CONFIG['root'])
219
- puts "Private repository initialized."
220
- else
221
- puts "Initialize private repository from scratch to #{CONFIG['root']}/private"
222
- git = Git.init(@pri_path)
223
- git.add
224
- git.commit_all("init private repository")
225
- puts "Private repository initialized."
202
+ {"main" => @main_path,"private" => @pri_path}.each do |name,path|
203
+ unless File.exist?(path)
204
+ if CONFIG["#{name}"] && CONFIG["#{name}"]['clone-from']
205
+ puts "Initialize #{name} repository from #{CONFIG[name]['clone-from']} to #{CONFIG['root']}/#{name}"
206
+ Git.clone(CONFIG["#{name}"]['clone-from'], name, :path => CONFIG['root'])
207
+ else
208
+ puts "Initialize #{name} repository from scratch to #{CONFIG['root']}/#{name}"
209
+ git = Git.init(path)
210
+ git.add
211
+ git.commit_all("init #{name} repository")
212
+ end
213
+ puts "#{name} repository initialized."
214
+ @main_git = Git.open(@main_path) if File.exist?(@main_path)
215
+ @pri_git = Git.open(@pri_path)if File.exist?(@pri_path)
226
216
  end
227
- else
228
- puts "Private repository has already been initialized."
229
217
  end
230
- @main_git = Git.open(@main_path) if File.exist?(@main_path)
231
- @pri_git = Git.open(@pri_path)if File.exist?(@pri_path)
232
- puts "Repository init done."
233
218
  end
234
219
 
235
220
  def prepare_dir
@@ -1,5 +1,5 @@
1
1
  GEM = "yac"
2
- VER = "0.0.3"
2
+ VER = "0.0.4"
3
3
  DATE = %q{2008-10-11}
4
4
  AUTHOR = "Jinzhu Zhang"
5
5
  EMAIL = "wosmvp@gmail.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jinzhu Zhang