Module: Wordsmith::Init
- Included in:
- Wordsmith
- Defined in:
- lib/wordsmith/init.rb
Instance Method Summary collapse
-
#init(args = []) ⇒ Object
start a new wordsmith directory with skeleton structure.
Instance Method Details
#init(args = []) ⇒ Object
start a new wordsmith directory with skeleton structure
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wordsmith/init.rb', line 5 def init(args = []) name = Array(args).shift raise "needs a directory name" unless name raise "directory already exists" if File.exists?(name) info "Creating wordsmith directory structure in #{name}" template_dir = File.join(WORDSMITH_ROOT, 'template') ign = Dir.glob(template_dir + '/.[a-z]*') FileUtils.cp_r template_dir, name # also copy files that start with . FileUtils.cp_r ign, name if Git.init(local(name)) info "Initialized empty Git repository in #{File.join(local(name), '.git')}" @git = Git.open(local(name)) @git.add '.' info "git add ." @git.commit 'initial commit' info "git commit -m 'initial commit'" end end |