gennifer 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +157 -20
  3. data/default/recipes/after_recipe.rb +20 -0
  4. data/default/recipes/article.rb +13 -0
  5. data/default/recipes/beamer.rb +13 -0
  6. data/default/recipes/before_recipe.rb +5 -0
  7. data/default/recipes/cpp.rb +6 -0
  8. data/default/recipes/cppmake.rb +9 -0
  9. data/default/recipes/default.rb +5 -0
  10. data/default/recipes/exam.rb +8 -0
  11. data/default/recipes/example.rb +33 -0
  12. data/default/recipes/html.rb +6 -0
  13. data/default/recipes/htmlerb.rb +6 -0
  14. data/default/recipes/letter.rb +12 -0
  15. data/default/recipes/numbers.rb +6 -0
  16. data/default/recipes/py.rb +6 -0
  17. data/default/recipes/python.rb +6 -0
  18. data/default/recipes/python3.rb +6 -0
  19. data/default/recipes/r.rb +5 -0
  20. data/default/recipes/rb.rb +5 -0
  21. data/default/recipes/ruby.rb +6 -0
  22. data/default/recipes/simple.rb +8 -0
  23. data/default/recipes/sublime.rb +6 -0
  24. data/default/recipes/test.rb +13 -0
  25. data/default/recipes/test2.rb +8 -0
  26. data/default/recipes/tex.rb +6 -0
  27. data/default/resources/Makefile +15 -0
  28. data/default/resources/cpp_file.cpp +16 -0
  29. data/default/resources/default +1 -0
  30. data/default/resources/gitignore_basic +23 -0
  31. data/default/resources/gitignore_latex +35 -0
  32. data/default/resources/latex_article.tex +598 -0
  33. data/default/resources/latex_beamer.tex +161 -0
  34. data/default/resources/latex_exam.tex +259 -0
  35. data/default/resources/latex_letter.tex +132 -0
  36. data/default/resources/latex_simple.tex +125 -0
  37. data/default/resources/new_file +0 -0
  38. data/default/resources/numbers.txt +8 -0
  39. data/default/resources/python3_file.py +3 -0
  40. data/default/resources/python_file.py +4 -0
  41. data/default/resources/r_file.r +7 -0
  42. data/default/resources/reference.bib +14 -0
  43. data/default/resources/ruby_file.rb +2 -0
  44. data/default/resources/sample-figure.pdf +3648 -8
  45. data/default/resources/sample-letterhead.pdf +324 -1
  46. data/default/resources/sample-signature.pdf +836 -2
  47. data/default/resources/sample_html.html +9 -0
  48. data/default/resources/sublime-project +8 -0
  49. data/default/settings.rb +27 -0
  50. data/lib/gennifer/version.rb +1 -1
  51. data/lib/recipe_helper.rb +1 -1
  52. metadata +48 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff35e3df1f794dec0816d0842cb897efae5d4850
4
- data.tar.gz: 057739a7c096baf25645f5b28d13c3167c60b939
3
+ metadata.gz: d1b3a8efd28b28d53e021452d16636c554e4ece1
4
+ data.tar.gz: b896d069ea8db92c0fab2fc33f20d07831452145
5
5
  SHA512:
6
- metadata.gz: 5586c6bd0864224a559874b1c21afb3573ae47469df1549ed6c1ae2c7da25ac09ca749180f9b85e944fa478256d8313a39866a5d141f0237829e07f8a706d96a
7
- data.tar.gz: 0c45264f82d24d98bf8b8fecd7a6a165fa1a34e221f93bdc70c77f81784b16800220eb6a8429df6e9da17397612f450c7feadcd5a9975f3c27476bf16abaf49d
6
+ metadata.gz: 298caf3c9387282d75b39541e74ff91e3a5cfb1153ac6d2913a60652fefdf6d679af80b51e1b7507dc1ce5af8bfd61694b3a141a8af714e3f24ef00c9ee28ab4
7
+ data.tar.gz: 0f118da76da19d189535f5900e33cc09bb13d3bd052d560de605277a35c921bd3959ca51c3b5f42262c2e03814b9bb3cc0828eccccf7ceeafeecc7e692145797
data/README.md CHANGED
@@ -1,41 +1,178 @@
1
1
  # Gennifer
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gennifer`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- Add this line to your application's Gemfile:
7
+ To install the gem:
10
8
 
11
- ```ruby
12
- gem 'gennifer'
13
- ```
9
+ $ gem install gennifer
14
10
 
15
- And then execute:
11
+ To put default settings in the folder ~/.gennifer
16
12
 
17
- $ bundle
13
+ $ gen install
18
14
 
19
- Or install it yourself as:
15
+ ## Basic Usage
20
16
 
21
- $ gem install gennifer
17
+ The gem is customizable but it also comes with a bunch of default functionality
18
+ out of the box.
22
19
 
23
- ## Usage
20
+ To generate a latex article project (with the tex file, the bib file, the figure folder, and .gitignore file):
24
21
 
25
- TODO: Write usage instructions here
22
+ $ gen project_name article
26
23
 
27
- ## Development
24
+ To generate a latex beamer project instead:
28
25
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+ $ gen project_name beamer
30
27
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+ Or just a simple tex file:
32
29
 
33
- ## Contributing
30
+ $ gen file_name.tex tex
34
31
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gennifer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
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
- ## License
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,5 @@
1
+ class BeforeRecipe
2
+ def recipe
3
+ puts('Generating ' + @full_name) if Settings::VERBOSE
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class CppRecipe
3
+ def recipe
4
+ create @full_path, 'cpp_file.rb'
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+
2
+ class CppMakeRecipe
3
+ def recipe
4
+ create @full_path
5
+ create (@full_path + "/#{@full_name}.cpp"), 'cpp_file.cpp'
6
+ create (@full_path + "/Makefile"), 'Makefile'
7
+ create (@full_path + "/.gitignore"), 'gitignore_basic'
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class DefaultRecipe
2
+ def recipe
3
+ create @full_path, "default"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+
2
+ class ExamRecipe
3
+ def recipe
4
+ create @full_path
5
+ create (@full_path + "/#{@file_name}.tex"), 'latex_exam.tex'
6
+ create (@full_path + "/.gitignore"), 'gitignore_latex'
7
+ end
8
+ 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,6 @@
1
+
2
+ class HtmlRecipe
3
+ def recipe
4
+ create @full_path, 'sample_html.html'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class HtmlErbRecipe
3
+ def recipe
4
+ create @full_path, 'sample_html.html'
5
+ end
6
+ 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,6 @@
1
+ class NumbersRecipe
2
+ def recipe
3
+ create @full_path, 'numbers.txt'
4
+ erb @full_path
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class PyRecipe
3
+ def recipe
4
+ create @full_path, 'python3_file.py'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class PythonRecipe
3
+ def recipe
4
+ create @full_path, 'python_file.py'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class Python3Recipe
3
+ def recipe
4
+ create @full_path, 'python3_file.py'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class RRecipe
2
+ def recipe
3
+ create @full_path, 'r_file.r'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RbRecipe
2
+ def recipe
3
+ create @full_path, 'ruby_file.rb'
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class RubyRecipe
3
+ def recipe
4
+ create @full_path, 'ruby_file.rb'
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+
2
+ class SimpleRecipe
3
+ def recipe
4
+ create @full_path
5
+ create (@full_path + "/#{@full_name}.tex"), 'latex_simple.tex'
6
+ create (@full_path + "/.gitignore"), 'gitignore_latex'
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class SublimeRecipe
3
+ def recipe
4
+ create (@target_dir + '/' + @full_name + '.sublime-project'), 'sublime-project'
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+
2
+ class TestRecipe
3
+ def recipe
4
+ puts "Testing"
5
+ puts 'Name: ' + Settings::NAME
6
+ puts 'Email: ' + Settings::EMAIL
7
+
8
+ puts @argv
9
+ #
10
+ invoke(Test2Recipe)
11
+
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+
2
+ class Test2Recipe
3
+ def recipe
4
+ puts "Testing 2"
5
+ puts 'Name: ' + Settings::NAME
6
+ puts 'Email: ' + Settings::EMAIL
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class TexRecipe
3
+ def recipe
4
+ create @full_path, 'latex_simple.tex'
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ CXXFLAGS = -O2 -g -Wall -fmessage-length=0
2
+
3
+ OBJS = variable_name.o
4
+
5
+ LIBS =
6
+
7
+ TARGET = variable_name
8
+
9
+ $(TARGET): $(OBJS)
10
+ $(CXX) -o $(TARGET) $(OBJS) $(LIBS)
11
+
12
+ all: $(TARGET)
13
+
14
+ clean:
15
+ rm -f $(OBJS) $(TARGET)
@@ -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,23 @@
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
@@ -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