gennifer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +157 -20
- data/default/recipes/after_recipe.rb +20 -0
- data/default/recipes/article.rb +13 -0
- data/default/recipes/beamer.rb +13 -0
- data/default/recipes/before_recipe.rb +5 -0
- data/default/recipes/cpp.rb +6 -0
- data/default/recipes/cppmake.rb +9 -0
- data/default/recipes/default.rb +5 -0
- data/default/recipes/exam.rb +8 -0
- data/default/recipes/example.rb +33 -0
- data/default/recipes/html.rb +6 -0
- data/default/recipes/htmlerb.rb +6 -0
- data/default/recipes/letter.rb +12 -0
- data/default/recipes/numbers.rb +6 -0
- data/default/recipes/py.rb +6 -0
- data/default/recipes/python.rb +6 -0
- data/default/recipes/python3.rb +6 -0
- data/default/recipes/r.rb +5 -0
- data/default/recipes/rb.rb +5 -0
- data/default/recipes/ruby.rb +6 -0
- data/default/recipes/simple.rb +8 -0
- data/default/recipes/sublime.rb +6 -0
- data/default/recipes/test.rb +13 -0
- data/default/recipes/test2.rb +8 -0
- data/default/recipes/tex.rb +6 -0
- data/default/resources/Makefile +15 -0
- data/default/resources/cpp_file.cpp +16 -0
- data/default/resources/default +1 -0
- data/default/resources/gitignore_basic +23 -0
- data/default/resources/gitignore_latex +35 -0
- data/default/resources/latex_article.tex +598 -0
- data/default/resources/latex_beamer.tex +161 -0
- data/default/resources/latex_exam.tex +259 -0
- data/default/resources/latex_letter.tex +132 -0
- data/default/resources/latex_simple.tex +125 -0
- data/default/resources/new_file +0 -0
- data/default/resources/numbers.txt +8 -0
- data/default/resources/python3_file.py +3 -0
- data/default/resources/python_file.py +4 -0
- data/default/resources/r_file.r +7 -0
- data/default/resources/reference.bib +14 -0
- data/default/resources/ruby_file.rb +2 -0
- data/default/resources/sample-figure.pdf +3648 -8
- data/default/resources/sample-letterhead.pdf +324 -1
- data/default/resources/sample-signature.pdf +836 -2
- data/default/resources/sample_html.html +9 -0
- data/default/resources/sublime-project +8 -0
- data/default/settings.rb +27 -0
- data/lib/gennifer/version.rb +1 -1
- data/lib/recipe_helper.rb +1 -1
- metadata +48 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1b3a8efd28b28d53e021452d16636c554e4ece1
|
4
|
+
data.tar.gz: b896d069ea8db92c0fab2fc33f20d07831452145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 298caf3c9387282d75b39541e74ff91e3a5cfb1153ac6d2913a60652fefdf6d679af80b51e1b7507dc1ce5af8bfd61694b3a141a8af714e3f24ef00c9ee28ab4
|
7
|
+
data.tar.gz: 0f118da76da19d189535f5900e33cc09bb13d3bd052d560de605277a35c921bd3959ca51c3b5f42262c2e03814b9bb3cc0828eccccf7ceeafeecc7e692145797
|
data/README.md
CHANGED
@@ -1,41 +1,178 @@
|
|
1
1
|
# Gennifer
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This is a gem for generating files or projects using recipes and templates. Everything is done by a simple command 'gen'
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
To install the gem:
|
10
8
|
|
11
|
-
|
12
|
-
gem 'gennifer'
|
13
|
-
```
|
9
|
+
$ gem install gennifer
|
14
10
|
|
15
|
-
|
11
|
+
To put default settings in the folder ~/.gennifer
|
16
12
|
|
17
|
-
$
|
13
|
+
$ gen install
|
18
14
|
|
19
|
-
|
15
|
+
## Basic Usage
|
20
16
|
|
21
|
-
|
17
|
+
The gem is customizable but it also comes with a bunch of default functionality
|
18
|
+
out of the box.
|
22
19
|
|
23
|
-
|
20
|
+
To generate a latex article project (with the tex file, the bib file, the figure folder, and .gitignore file):
|
24
21
|
|
25
|
-
|
22
|
+
$ gen project_name article
|
26
23
|
|
27
|
-
|
24
|
+
To generate a latex beamer project instead:
|
28
25
|
|
29
|
-
|
26
|
+
$ gen project_name beamer
|
30
27
|
|
31
|
-
|
28
|
+
Or just a simple tex file:
|
32
29
|
|
33
|
-
|
30
|
+
$ gen file_name.tex tex
|
34
31
|
|
35
|
-
|
32
|
+
To generate a sublime-project file in the current folder to make the current folder a sublime text project:
|
36
33
|
|
34
|
+
$ jem project_name sublime
|
37
35
|
|
38
|
-
|
36
|
+
To generate a ruby file with the name testing.rb :
|
37
|
+
|
38
|
+
$ gen testing.rb ruby
|
39
|
+
|
40
|
+
To generate a python file with the name testing.py :
|
41
|
+
|
42
|
+
$ gen testing.py python
|
43
|
+
|
44
|
+
In fact gennifer would recognize the extension name so that
|
45
|
+
|
46
|
+
$ gen testing.rb
|
47
|
+
$ gen testing.py
|
48
|
+
|
49
|
+
also work as expected.
|
50
|
+
|
51
|
+
To see the help text:
|
52
|
+
|
53
|
+
$ gen help
|
54
|
+
|
55
|
+
## Advanced Usage
|
56
|
+
|
57
|
+
### Settings
|
58
|
+
|
59
|
+
If you have tried `gen project_name article`, you probably notice that the file
|
60
|
+
contain names and information of the author. The default name is Gennifer Lynn
|
61
|
+
Connelly and there are default values for other information too. You can change
|
62
|
+
the values in the file ~/.gennifer/settings.rb. The system settings are those
|
63
|
+
settings which will alter the behaviour of the program. And the users Settings
|
64
|
+
are variables which is available in the recipes.
|
65
|
+
|
66
|
+
### Make your own recipes
|
67
|
+
|
68
|
+
All the recipes are stored in the folder ~/.gennifer/recipes. Each files
|
69
|
+
contains a recipe which can be used with the command `gen`. Each recipe should
|
70
|
+
be in the following format.
|
71
|
+
|
72
|
+
|
73
|
+
class ArticleRecipe
|
74
|
+
def recipe
|
75
|
+
create @full_path
|
76
|
+
create (@full_path + "/#{@full_name}.tex"), 'latex_article.tex'
|
77
|
+
erb (@full_path + "/#{@full_name}.tex")
|
78
|
+
create (@full_path + "/reference.bib"), 'reference.bib'
|
79
|
+
create (@full_path + "/.gitignore"), 'gitignore_latex'
|
80
|
+
create (@full_path + '/figures')
|
81
|
+
create (@full_path + "/figures/sample-figure.pdf"), 'sample-figure.pdf'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Apart from coding the whole recipe using ruby (like using mkdir, cp, mv in
|
86
|
+
FileUtils), there are several method you can use in the recipe. For example,
|
87
|
+
`create` will create a new directory in the target location if only the location
|
88
|
+
is specified. And it will copy a file/directory
|
89
|
+
from the resources folder if a resources location is specified in the second
|
90
|
+
argument.
|
91
|
+
|
92
|
+
A bunch of variables are available in the recipe. For example, if you run
|
93
|
+
`gen myarticle article` from the location ~/Document/projects/, then
|
94
|
+
|
95
|
+
@current_dir # ~/Document/projects/
|
96
|
+
@resources # ~/.gennifer/resources/
|
97
|
+
@full_name # myarticle
|
98
|
+
@base_name # myarticle
|
99
|
+
@ext_name #
|
100
|
+
@recipe # ArticleRecipe
|
101
|
+
@target_dir # ~/Document/projects/
|
102
|
+
@full_path # ~/Document/projects/myarticle/
|
103
|
+
|
104
|
+
If you run `gen ../myfile.rb` from the location ~/Document/projects/, then
|
105
|
+
|
106
|
+
@current_dir # ~/Document/projects/
|
107
|
+
@resources # ~/.gennifer/resources/
|
108
|
+
@full_name # myfile.rb
|
109
|
+
@base_name # myfile
|
110
|
+
@ext_name # .rb
|
111
|
+
@recipe # RbRecipe
|
112
|
+
@target_dir # ~/Document/
|
113
|
+
@full_path # ~/Document/myfile.rb
|
39
114
|
|
40
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
115
|
|
116
|
+
The class name should be in capitalized camelcase and ended with the word
|
117
|
+
Recipe. For example, the command `gen project_name article` will invoke the
|
118
|
+
recipe `ArticleRecipe`.
|
119
|
+
|
120
|
+
The file name and file structure inside the folder ~/.gennifer/recipes are not
|
121
|
+
important. You can use the folder structure to organize the recipes.
|
122
|
+
|
123
|
+
### Recipe by file names
|
124
|
+
|
125
|
+
When the recipe is not specifed, gennifer will use the file name to try to
|
126
|
+
identify the recipe. For example,
|
127
|
+
|
128
|
+
$ gen cat.rb
|
129
|
+
|
130
|
+
Gennifer will try the recipes in the following order: CatRbRecipe, RbRecipe, CatRecipe. Among the default recipes, the RbRecipe would be used. A more
|
131
|
+
complicated example would be
|
132
|
+
|
133
|
+
$ gen application.html.erb
|
134
|
+
|
135
|
+
Gennifer will try the recipes in the following order: ApplicationHtmlErbRecipe,
|
136
|
+
HtmlErbRecipe, ErbRecipe, HtmlRecipe, ApplicationRecipe.
|
137
|
+
|
138
|
+
If everything tried and still there is no recipe found, Gennifer will use the
|
139
|
+
DefaultRecipe. This recipe is specified in the file ~/.gennifer/recipes/default.rb
|
140
|
+
|
141
|
+
|
142
|
+
### Special recipes
|
143
|
+
|
144
|
+
Among all the recipes, there are three of them which are special. The
|
145
|
+
AfterRecipe, BeforeRecipe, and DefaultRecipe. As mentioned before, the
|
146
|
+
DefaultRecipe is the recipe which is called when no suitable recipe is found
|
147
|
+
for a certain file/project name. The BeforeRecipe is the recipe which is run
|
148
|
+
before any recipes and the AfterRecipe is run after any recipes.
|
149
|
+
|
150
|
+
|
151
|
+
### Other arguments
|
152
|
+
|
153
|
+
You can supply extra arugments to the `gen` command to customize the behaviour
|
154
|
+
of each recipe. All extra arguments are available in the recipe. For example,
|
155
|
+
|
156
|
+
$ gen testing.rb exe
|
157
|
+
|
158
|
+
will generate a testing.rb file and make the file executable. This is specified
|
159
|
+
in the first line of the AfterRecipe (`executable @full_path if check_argv('exe')`). The part `check_argv('exe')` check whether `exe` is
|
160
|
+
included in the arguments and it can be used to check for other extra arguments.
|
161
|
+
|
162
|
+
|
163
|
+
### ERB support
|
164
|
+
|
165
|
+
You can use the method erb in recipe (see ArticleRecipe). This will use erb to
|
166
|
+
process the file before it is generated. Gennifer uses erb to fill in
|
167
|
+
information like name and address using the information specified in the
|
168
|
+
settings.rb.
|
169
|
+
|
170
|
+
### Combining multiple recipes
|
171
|
+
|
172
|
+
You can invoke another recipe by using `invoke(TargetRecipe)` in the recipe
|
173
|
+
file. Notice that the program wont stop if you recursively invoke the same
|
174
|
+
recipe from itself.
|
175
|
+
|
176
|
+
## License
|
177
|
+
|
178
|
+
This gem is not released for public use yet.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class AfterRecipe
|
2
|
+
def recipe
|
3
|
+
executable @full_path if check_argv('exe')
|
4
|
+
`#{Settings::EDITOR} #{@full_path}` if check_argv('edit')
|
5
|
+
|
6
|
+
if check_argv('bin') then
|
7
|
+
new_location= File.expand_path(Settings::BINFOLDER + '/' + @full_name)
|
8
|
+
if File.exists?(new_location)
|
9
|
+
FileUtils.rm_rf(@full_path)
|
10
|
+
else
|
11
|
+
FileUtils.mv(@full_path , new_location)
|
12
|
+
end
|
13
|
+
executable new_location
|
14
|
+
`#{Settings::EDITOR} #{new_location}`
|
15
|
+
end
|
16
|
+
|
17
|
+
puts(@full_name + ' generation finished') if Settings::VERBOSE
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
class ArticleRecipe
|
3
|
+
def recipe
|
4
|
+
create @full_path
|
5
|
+
create (@full_path + "/#{@full_name}.tex"), 'latex_article.tex'
|
6
|
+
erb (@full_path + "/#{@full_name}.tex")
|
7
|
+
create (@full_path + "/reference.bib"), 'reference.bib'
|
8
|
+
create (@full_path + "/.gitignore"), 'gitignore_latex'
|
9
|
+
create (@full_path + '/figures')
|
10
|
+
create (@full_path + "/figures/sample-figure.pdf"), 'sample-figure.pdf'
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
class BeamerRecipe
|
3
|
+
def recipe
|
4
|
+
create @full_path
|
5
|
+
create (@full_path + "/#{@full_name}.tex"), 'latex_beamer.tex'
|
6
|
+
erb (@full_path + "/#{@full_name}.tex")
|
7
|
+
create (@full_path + "/reference.bib"), 'reference.bib'
|
8
|
+
create (@full_path + "/.gitignore"), 'gitignore_latex'
|
9
|
+
create (@full_path + '/figures')
|
10
|
+
create (@full_path + "/figures/sample-figure.pdf"), 'sample-figure.pdf'
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
class ExampleRecipe # This is the name of the recipe, it's in Capitalized CamelCase ended with 'Recipe'. This recipe can be invoked by 'jen FILENAME example'.
|
3
|
+
def recipe # every recipe file must containt the method 'recipe'.
|
4
|
+
# put the code which generates the files here. Here is a list of helper methods:
|
5
|
+
|
6
|
+
|
7
|
+
# To make new directory:
|
8
|
+
# create DIRECTORY_NAME
|
9
|
+
# To copy directory from resources:
|
10
|
+
# create "#{@target_dir}/DIRECTORY_NAME", "RESOURCES_NAME"
|
11
|
+
# To copy file from resources:
|
12
|
+
# create (@target_dir + "/FILE_NAME"), "RESOURCES_NAME"
|
13
|
+
# To invoke another recipe
|
14
|
+
# invoke(AnotherRecipe)
|
15
|
+
# To evaluate the file using erb
|
16
|
+
# erb(FILENAME)
|
17
|
+
# To get whether a word is in the argument or new_location
|
18
|
+
# check_argv(WORD)
|
19
|
+
# To make a file executable
|
20
|
+
# executable FILENAME
|
21
|
+
|
22
|
+
# Here are the available variables
|
23
|
+
# @current_dir
|
24
|
+
# @resources
|
25
|
+
# @full_name
|
26
|
+
# @base_name
|
27
|
+
# @ext_name
|
28
|
+
# @recipe
|
29
|
+
# @target_dir
|
30
|
+
# @full_path
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
class LetterRecipe
|
3
|
+
def recipe
|
4
|
+
create @full_path
|
5
|
+
create (@full_path + "/#{@full_name}.tex"), 'latex_letter.tex'
|
6
|
+
erb (@full_path + "/#{@full_name}.tex")
|
7
|
+
create (@full_path + "/.gitignore"), 'gitignore_latex'
|
8
|
+
create (@full_path + '/figures')
|
9
|
+
create (@full_path + "/figures/sample-letterhead.pdf"), 'sample-letterhead.pdf'
|
10
|
+
create (@full_path + "/figures/sample-signature.pdf"), 'sample-signature.pdf'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//============================================================================
|
2
|
+
// Name : HelloWorldMake.cpp
|
3
|
+
// Author :
|
4
|
+
// Version :
|
5
|
+
// Copyright : Your copyright notice
|
6
|
+
// Description : Hello World in C, Ansi-style
|
7
|
+
//============================================================================
|
8
|
+
|
9
|
+
#include <stdio.h>
|
10
|
+
#include <stdlib.h>
|
11
|
+
|
12
|
+
int main(void)
|
13
|
+
{
|
14
|
+
puts("Hello World!!!!!!");
|
15
|
+
return EXIT_SUCCESS;
|
16
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
This is a default template.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
*.log
|
3
|
+
*.7z
|
4
|
+
*.dmg
|
5
|
+
*.gz
|
6
|
+
*.iso
|
7
|
+
*.jar
|
8
|
+
*.rar
|
9
|
+
*.tar
|
10
|
+
*.zip
|
11
|
+
*.sql
|
12
|
+
*.sqlite
|
13
|
+
*.com
|
14
|
+
*.class
|
15
|
+
*.dll
|
16
|
+
*.exe
|
17
|
+
.DS_Store
|
18
|
+
.DS_Store?
|
19
|
+
._*
|
20
|
+
.Spotlight-V100
|
21
|
+
.Trashes
|
22
|
+
ehthumbs.db
|
23
|
+
Thumbs.db
|
24
|
+
|
25
|
+
*.aux
|
26
|
+
*.bbl
|
27
|
+
*.bcf
|
28
|
+
*.blg
|
29
|
+
*.fdb_latexmk
|
30
|
+
*.synctex.gz
|
31
|
+
*.out
|
32
|
+
*.snm
|
33
|
+
*.toc
|
34
|
+
*.run.xml
|
35
|
+
*.na
|