textools 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in textools.gemspec
4
+ gemspec
@@ -0,0 +1,29 @@
1
+ # Textools
2
+
3
+ ## Installation
4
+
5
+ $> gem install textools
6
+
7
+ ## Usage
8
+
9
+ Creating a new LaTeX project works like this:
10
+
11
+ $> textools create test
12
+ create test
13
+ create test/.gitignore
14
+ create test/clean.bat
15
+ create test/clean.sh
16
+ create test/images
17
+ create test/includes
18
+ inside test
19
+ run git init
20
+ run git add .
21
+
22
+ Inside a LaTeX project, you can remove any temporary files like this:
23
+
24
+ $> textools clean
25
+ remove test.pdf
26
+
27
+ ## URLs
28
+
29
+ * https://github.com/simonharrer/textools
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rake/testtask"
4
+ Rake::TestTask.new do |t|
5
+ t.test_files = FileList['test/**/test*.rb']
6
+ t.verbose = true
7
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "textools"
3
+ Textools::App.start
@@ -0,0 +1,6 @@
1
+ require 'textools/version'
2
+ require 'textools/commands'
3
+
4
+ module Textools
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,63 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+
4
+ module Textools
5
+
6
+ class App < Thor
7
+ include Thor::Actions
8
+
9
+ desc 'create PROJECT_NAME', 'create a new LaTeX project'
10
+ method_options :working_directory => '.'
11
+ def create(name)
12
+ # workaround as default options does not work
13
+ parent_directory = options[:working_directory] || '.'
14
+
15
+ directory = File.join(parent_directory,name)
16
+
17
+ # create project directory
18
+ empty_directory(directory)
19
+
20
+ # copy required files
21
+ ['.gitignore', 'clean.bat', 'clean.sh'].each do |file|
22
+ copy_file file,File.join(directory,file)
23
+ end
24
+
25
+ # directories
26
+ empty_directory(File.join(directory, "images"))
27
+ empty_directory(File.join(directory, "includes"))
28
+
29
+ # create containing directory
30
+ inside(File.join(parent_directory,name), :verbose => true) do |folder|
31
+
32
+ # initialize git repository
33
+ run("git init")
34
+ # add all files to the staging area
35
+ run("git add .")
36
+
37
+ end
38
+ end
39
+
40
+ desc 'clean','cleans the current LaTeX project'
41
+ method_options :working_directory => "."
42
+ def clean
43
+ # workaround as default options does not work
44
+ parent_directory = options[:working_directory] || '.'
45
+
46
+ require "fileutils"
47
+ %w{*.aux *.bbl *.log *.pdf *.pgf *.dvi *.synctex* *.toc *.blg}.each do |pattern|
48
+ Dir.glob(File.join(parent_directory,pattern)).each do |file|
49
+ remove_file file
50
+ end
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ # set the starting point of the templates search to the lib/textools/templates folder
57
+ def self.source_root
58
+ File.join(File.dirname(__FILE__),'templates')
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,9 @@
1
+ *.aux
2
+ *.bbl
3
+ *.log
4
+ *.pdf
5
+ *.pgf
6
+ *.dvi
7
+ *.synctex*
8
+ *.toc
9
+ *.blg
@@ -0,0 +1,9 @@
1
+ rm *.aux
2
+ rm *.bbl
3
+ rm *.log
4
+ rm *.pdf
5
+ rm *.pgf
6
+ rm *.dvi
7
+ rm *.synctex*
8
+ rm *.toc
9
+ rm *.blg
@@ -0,0 +1,9 @@
1
+ rm *.aux
2
+ rm *.bbl
3
+ rm *.log
4
+ rm *.pdf
5
+ rm *.pgf
6
+ rm *.dvi
7
+ rm *.synctex*
8
+ rm *.toc
9
+ rm *.blg
@@ -0,0 +1,3 @@
1
+ module Textools
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,43 @@
1
+ require 'test/unit'
2
+ require 'textools/commands'
3
+ require 'tmpdir'
4
+
5
+ module Textools
6
+
7
+ class TestApp < Test::Unit::TestCase
8
+
9
+ def test_create
10
+ Dir.mktmpdir do |dir|
11
+
12
+ project = 'test'
13
+
14
+ App.new([],{'working_directory' => dir}).create(project)
15
+
16
+ assert Dir.exists?(File.join(dir,project))
17
+ assert File.exists?(File.join(dir,project,'.gitignore')), "no .gitignore"
18
+ assert File.exists?(File.join(dir,project,'clean.bat')), "no clean.bat file"
19
+ assert !File.exists?(File.join(dir,project,'clean.rb')), "no clean.rb file"
20
+ assert File.exists?(File.join(dir,project,'clean.sh')), "no clean.sh file"
21
+ assert Dir.exists?(File.join(dir,project,'images')), "no images folder"
22
+ assert Dir.exists?(File.join(dir,project,'includes')), "no includes folder"
23
+ assert Dir.exists?(File.join(dir,project,'.git')), "no git folder"
24
+ end
25
+ end
26
+
27
+ def test_clean
28
+
29
+ Dir.mktmpdir do |dir|
30
+
31
+ File.open(File.join(dir,"test.pdf"), "w") do |f|
32
+ f << "asdf"
33
+ end
34
+
35
+ App.new([],{'working_directory' => dir}).clean
36
+
37
+ assert !File.exists?(File.join(dir,"test.pdf")),"test.pdf should be deleted"
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "textools/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "textools"
7
+ s.version = Textools::VERSION
8
+ s.authors = ["Simon Harrer"]
9
+ s.email = ["simon.harrer@gmail.com"]
10
+ s.homepage = "https://github.com/simonharrer/textools"
11
+ s.summary = %q{Command Line Tools for Generating and Maintaining LaTeX Projects.}
12
+ s.description = s.summary
13
+
14
+ s.rubyforge_project = "textools"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency "thor"
22
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: textools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Simon Harrer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &29282088 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *29282088
25
+ description: Command Line Tools for Generating and Maintaining LaTeX Projects.
26
+ email:
27
+ - simon.harrer@gmail.com
28
+ executables:
29
+ - textools
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - README.md
36
+ - Rakefile
37
+ - bin/textools
38
+ - lib/textools.rb
39
+ - lib/textools/commands.rb
40
+ - lib/textools/templates/.gitignore
41
+ - lib/textools/templates/clean.bat
42
+ - lib/textools/templates/clean.sh
43
+ - lib/textools/version.rb
44
+ - test/textools/test_commands.rb
45
+ - textools.gemspec
46
+ homepage: https://github.com/simonharrer/textools
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project: textools
66
+ rubygems_version: 1.8.11
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Command Line Tools for Generating and Maintaining LaTeX Projects.
70
+ test_files: []