Class: Textools::App

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/textools/commands.rb

Instance Method Summary collapse

Instance Method Details

#cleanObject



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/textools/commands.rb', line 58

def clean
  # workaround as default options does not work
  parent_directory = options[:working_directory] || '.'

  require "fileutils"
  %w{*.aux *.bbl *.log *.pdf *.pgf *.dvi *.synctex* *.toc *.blg}.each do |pattern|
    Dir.glob(File.join(parent_directory,pattern)).each do |file|
      remove_file file
    end
  end
end

#create(name) ⇒ Object



11
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
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/textools/commands.rb', line 11

def create(name)
  # workaround as default options does not work
  parent_directory = options[:working_directory]
  if parent_directory
    directory = File.join(parent_directory,name)
  else
    directory = name
  end

  # create project directory
  empty_directory(directory)

  # copy required files
  ['.gitignore', 'clean.bat', 'clean.sh', "README"].each do |file|
    copy_file file,File.join(directory,file)
  end

  # directories
  empty_directory(File.join(directory, "images"))
  empty_directory(File.join(directory, "includes"))

  template("main.tex.erb",File.join(directory,"#{name}.tex"))
  template("header.tex.erb",File.join(directory,"header.tex"))
  template("content.tex.erb",File.join(directory,"content.tex"))

  if options.texlipse?
    @name = name
    template(".project.erb",File.join(directory,".project"))
    template(".texlipse.erb",File.join(directory,".texlipse"))
  elsif options.texniccenter?
    @name = name
    template("name.tcp.erb",File.join(directory,"#{name}.tcp"))
  end

  # create containing directory
  inside(directory, :verbose => true) do |folder|

    # initialize git repository
    run("git init")
    # add all files to the staging area
    run("git add .")

  end
end