Class: LaTeXProjectTemplate
- Inherits:
-
Object
- Object
- LaTeXProjectTemplate
- Defined in:
- lib/latex_project_template.rb,
lib/latex_project_template/task.rb
Defined Under Namespace
Classes: Cleaning, Component, Configuration, Directory, ErbObject, LPTConfig, Latexmk, Task
Constant Summary collapse
- DEFAULT_CONFIG =
".latex_project_template"
Instance Method Summary collapse
-
#create(opts = {}) ⇒ Object
opts is an IO to which progress are outputed.
-
#initialize(dir, template, home_directory = nil) ⇒ LaTeXProjectTemplate
constructor
A new instance of LaTeXProjectTemplate.
Constructor Details
#initialize(dir, template, home_directory = nil) ⇒ LaTeXProjectTemplate
Returns a new instance of LaTeXProjectTemplate.
216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/latex_project_template.rb', line 216 def initialize(dir, template, home_directory = nil) @config = LaTeXProjectTemplate::Configuration.new(home_directory) @target_dir = File.(dir) unless @template = @config.template_exist?(template) raise ArgumentError, "Can not find template: #{template}" end if File.exist?(@target_dir) raise ArgumentError, "File #{@target_dir} exists." end @project_name = File.basename(dir).sub(/\/$/, '') end |
Instance Method Details
#create(opts = {}) ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/latex_project_template.rb', line 250 def create(opts = {}) FileUtils.mkdir_p(@target_dir) files = create_files if io = opts[:io] file_paths = files.map do |path| path.sub(@target_dir, '').sub(/^\//, '') end io.puts "Create the following files from template '#{@template.name}'" io.puts file_paths.join("\n") end if !opts[:no_git] create_git if opts[:io] opts[:io].puts "Create git repository and commit all files." end end end |