formatafacil 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +2 -0
- data/bin/bundler +16 -0
- data/bin/console +14 -0
- data/bin/formatafacil +16 -0
- data/bin/gli +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +7 -0
- data/exe/formatafacil +77 -0
- data/formatafacil.gemspec +34 -0
- data/lib/formatafacil/artigo_tarefa.rb +165 -0
- data/lib/formatafacil/formato.rb +9 -0
- data/lib/formatafacil/tarefa.rb +19 -0
- data/lib/formatafacil/tarefa_chooser.rb +19 -0
- data/lib/formatafacil/template.rb +36 -0
- data/lib/formatafacil/version.rb +3 -0
- data/lib/formatafacil.rb +8 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 248bb81ec28017d9e035d82bfdbab949c742ab15
|
4
|
+
data.tar.gz: 949b8371e945e597e4662122cf5b53056529b158
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: feedfb98167ddadaaf8d780e2f38d4b9da852ccdc1eb2a7dd58dae8b6b03ab8bc34cae3a6ce4f58f724955fa23498ce4426e328bcdae83bc5c001ec874c0f709
|
7
|
+
data.tar.gz: c901aea1575fab15a502de59c456ef67b241b59a32d1871cd4b28441b600e651db00b370f3dacb7ef92aeefed8c2dc89e33fe14a865a588ae0b5cb98e41e879f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Eduardo de Santana Medeiros Alexandre
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Formatafacil
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'formatafacil'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install formatafacil
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
TODO: Write usage instructions here
|
23
|
+
|
24
|
+
|
25
|
+
# A command line app
|
26
|
+
As [David said], a cli command utility should:
|
27
|
+
|
28
|
+
## have a clear and concise purpose
|
29
|
+
|
30
|
+
Gerar arquivos PDFs de texto com formatações que o público brasileiro
|
31
|
+
necessita.
|
32
|
+
|
33
|
+
## be easy to use
|
34
|
+
|
35
|
+
Para gerar um artigo no [formato sbc (Sociedade brasileira de computação)](http://www.sbc.org.br/en/index.php?option=com_jdownloads&task=view.download&catid=32&cid=38&Itemid=195):
|
36
|
+
|
37
|
+
formatafacil artigo -t sbc
|
38
|
+
|
39
|
+
## be helpful
|
40
|
+
|
41
|
+
Com esta aplicação você poderá gerar artigos para o SBC, monografia, dissertação, tese, etc.
|
42
|
+
|
43
|
+
## play well with others
|
44
|
+
|
45
|
+
formatafacil artigo -t sbc --log log.txt --input artigo.md --output meu-artigo-sbc.pdf
|
46
|
+
|
47
|
+
## delight casual users
|
48
|
+
|
49
|
+
Lista templates:
|
50
|
+
|
51
|
+
formatafacil templates
|
52
|
+
|
53
|
+
Cria um diretório e estrutura de um artigo no formato do sbc:
|
54
|
+
|
55
|
+
formatafacil cria --template=artigo-sbc
|
56
|
+
|
57
|
+
## make configuration easy for advanced users
|
58
|
+
|
59
|
+
TODO
|
60
|
+
|
61
|
+
## install and distribute painlessly
|
62
|
+
|
63
|
+
gem install formatafacil
|
64
|
+
|
65
|
+
## be well-tested and as bug free as possible
|
66
|
+
|
67
|
+
TODO
|
68
|
+
|
69
|
+
## be easy to maintain
|
70
|
+
|
71
|
+
TODO
|
72
|
+
|
73
|
+
|
74
|
+
## Development
|
75
|
+
|
76
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec formatafacil` to use the code located in this directory, ignoring other installed copies of this gem.
|
77
|
+
|
78
|
+
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
1. Fork it ( https://github.com/[my-github-username]/formatafacil/fork )
|
83
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/bundler
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'bundler' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('bundler', 'bundler')
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "formatafacil"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/formatafacil
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'formatafacil' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('formatafacil', 'formatafacil')
|
data/bin/gli
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'gli' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('gli', 'gli')
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('diff-lcs', 'htmldiff')
|
data/bin/ldiff
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'ldiff' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('diff-lcs', 'ldiff')
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/setup
ADDED
data/exe/formatafacil
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'gli'
|
4
|
+
require 'logger'
|
5
|
+
require "formatafacil"
|
6
|
+
require 'formatafacil/template'
|
7
|
+
require 'formatafacil/artigo_tarefa'
|
8
|
+
require 'formatafacil/tarefa_chooser'
|
9
|
+
|
10
|
+
include GLI::App
|
11
|
+
|
12
|
+
program_desc 'Gera documentos na norma da ABNT a partir de textos escritos em Markdown.'
|
13
|
+
|
14
|
+
version Formatafacil::VERSION
|
15
|
+
|
16
|
+
subcommand_option_handling :normal
|
17
|
+
arguments :strict
|
18
|
+
|
19
|
+
desc 'Emite mensages de log para o arquivo formatafacil.log'
|
20
|
+
switch :logfile
|
21
|
+
|
22
|
+
|
23
|
+
desc 'Gera artigos em latex e compila para pdf'
|
24
|
+
command :artigo do |c|
|
25
|
+
|
26
|
+
c.desc 'Gera o arquivo pdf compilando o arquivo latex'
|
27
|
+
c.switch :pdf
|
28
|
+
|
29
|
+
c.desc 'Seleciona o modelo do artigo'
|
30
|
+
c.flag [:m,:modelo]
|
31
|
+
|
32
|
+
c.action do |global,options,args|
|
33
|
+
if (global['logfile'])
|
34
|
+
logger = Logger.new('formatafacil.log')
|
35
|
+
else
|
36
|
+
logger = Logger.new(STDERR)
|
37
|
+
end
|
38
|
+
logger.level = Logger::WARN
|
39
|
+
|
40
|
+
begin
|
41
|
+
tarefa = Formatafacil::ArtigoTarefa.new()
|
42
|
+
tarefa.logger = logger
|
43
|
+
tarefa.executa
|
44
|
+
rescue Exception => e
|
45
|
+
logger.error {e.message}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Auto detecta o comando com base no arquivo de configuração'
|
52
|
+
command :auto do |c|
|
53
|
+
|
54
|
+
|
55
|
+
c.action do |global,options,args|
|
56
|
+
|
57
|
+
if (global['logfile'])
|
58
|
+
logger = Logger.new('formatafacil.log')
|
59
|
+
else
|
60
|
+
logger = Logger.new(STDERR)
|
61
|
+
end
|
62
|
+
logger.level = Logger::WARN
|
63
|
+
|
64
|
+
begin
|
65
|
+
tarefa = Formatafacil::TarefaChooser.new().escolhe_tarefa
|
66
|
+
tarefa.logger = logger
|
67
|
+
tarefa.executa
|
68
|
+
rescue Exception => e
|
69
|
+
logger.error {e.message}
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
exit run(ARGV)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'formatafacil/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "formatafacil"
|
8
|
+
spec.version = Formatafacil::VERSION
|
9
|
+
spec.authors = ["Eduardo de Santana Medeiros Alexandre"]
|
10
|
+
spec.email = ["eduardo.ufpb@gmail.com"]
|
11
|
+
|
12
|
+
if spec.respond_to?(:metadata)
|
13
|
+
#spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
14
|
+
end
|
15
|
+
|
16
|
+
spec.summary = %q{Compila arquivos escritos em Markdown para formatos.}
|
17
|
+
spec.description = %q{Com essa ferramenta você poderá compilar trabalhos de conclusão de curso (monografia, dissertação ou tese) ou artigos com as normas da ABNT ou outra específica }
|
18
|
+
spec.homepage = "https://github.com/edusantana/formatafacil"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
|
31
|
+
spec.add_dependency "gli"
|
32
|
+
spec.add_dependency "formatafacil-templates"
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'formatafacil/template'
|
2
|
+
require 'formatafacil/tarefa'
|
3
|
+
require 'open3'
|
4
|
+
require 'yaml'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Formatafacil
|
8
|
+
|
9
|
+
class ArtigoTarefa < Tarefa
|
10
|
+
attr_accessor 'modelo'
|
11
|
+
attr_accessor 'artigo' # conteúdo lidos os arquivos
|
12
|
+
attr_accessor 'artigo_latex' # conteúdo convertido
|
13
|
+
|
14
|
+
attr_accessor 'arquivo_texto'
|
15
|
+
attr_accessor 'arquivo_resumo'
|
16
|
+
attr_accessor 'arquivo_abstract'
|
17
|
+
attr_accessor 'arquivo_ingles'
|
18
|
+
attr_accessor 'arquivo_bibliografia'
|
19
|
+
attr_accessor 'arquivo_saida_yaml'
|
20
|
+
attr_accessor 'arquivo_saida_pdf'
|
21
|
+
attr_accessor 'arquivo_saida_latex'
|
22
|
+
|
23
|
+
def initialize(h={})
|
24
|
+
@arquivo_texto = 'artigo.md'
|
25
|
+
@arquivo_resumo = 'config/resumo.md'
|
26
|
+
@arquivo_abstract = 'config/abstract.md'
|
27
|
+
@arquivo_ingles = 'config/ingles.yaml'
|
28
|
+
@arquivo_bibliografia ='bibliografia.md'
|
29
|
+
@arquivo_saida_yaml = 'artigo.yaml'
|
30
|
+
@arquivo_saida_pdf = 'artigo.pdf'
|
31
|
+
@arquivo_saida_latex = 'artigo.tex'
|
32
|
+
@artigo = {}
|
33
|
+
@artigo_latex = {}
|
34
|
+
h.each {|k,v| send("#{k}=",v)}
|
35
|
+
end
|
36
|
+
|
37
|
+
def executa
|
38
|
+
ler_configuracao
|
39
|
+
executa_com_configuracao
|
40
|
+
end
|
41
|
+
|
42
|
+
def executa_com_configuracao
|
43
|
+
converte_configuracao_para_latex
|
44
|
+
salva_configuracao_yaml_para_inclusao_em_pandoc
|
45
|
+
executa_pandoc_salvando_latex
|
46
|
+
executa_pdflatex
|
47
|
+
end
|
48
|
+
|
49
|
+
# Ler as configurações dos arquivos:
|
50
|
+
#
|
51
|
+
# @arquivo_resumo
|
52
|
+
def ler_configuracao
|
53
|
+
@artigo.merge!(YAML.load(ler_arquivo(Formatafacil::Tarefa.arquivo_configuracao)))
|
54
|
+
converte_parametros_para_boolean
|
55
|
+
|
56
|
+
@modelo = @artigo['modelo']
|
57
|
+
|
58
|
+
@artigo['abstract'] = ler_arquivo(@arquivo_abstract)
|
59
|
+
@artigo.merge!(ler_metadados_do_arquivo(@arquivo_abstract))
|
60
|
+
@artigo['resumo'] = ler_arquivo(@arquivo_resumo)
|
61
|
+
@artigo['bibliografia'] = ler_arquivo(@arquivo_bibliografia)
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def ler_metadados_do_arquivo(arquivo)
|
66
|
+
result = {}
|
67
|
+
meta = JSON.parse(`pandoc -t json #{arquivo}`)[0]['unMeta']
|
68
|
+
meta.each do |k,v|
|
69
|
+
result[k]=converte_valor_da_arvore_pandoc(v)
|
70
|
+
end
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
def converte_valor_da_arvore_pandoc(node)
|
75
|
+
# {"boo_false"=>{"t"=>"MetaBool", "c"=>false}, "boo_true"=>{"t"=>"MetaBool", "c"=>true}, "nome_do_parametro"=>{"t"=>"MetaInlines", "c"=>[{"t"=>"Str", "c"=>"valor"}, {"t"=>"Space", "c"=>[]}, {"t"=>"Str", "c"=>"do"}, {"t"=>"Space", "c"=>[]}, {"t"=>"Str", "c"=>"parâmetro"}]}, "numero"=>{"t"=>"MetaString", "c"=>"15"}}
|
76
|
+
result = nil
|
77
|
+
|
78
|
+
case node['t']
|
79
|
+
when "MetaString"
|
80
|
+
result = node['c']
|
81
|
+
when "MetaBool"
|
82
|
+
result = node['c']
|
83
|
+
when "MetaInlines"
|
84
|
+
string = ""
|
85
|
+
node['c'].each do |node|
|
86
|
+
case node['t']
|
87
|
+
when 'Str'
|
88
|
+
string += node['c']
|
89
|
+
when 'Space'
|
90
|
+
string += " "
|
91
|
+
end
|
92
|
+
end
|
93
|
+
if "sim".casecmp(string).zero?
|
94
|
+
result = true
|
95
|
+
elsif "não".casecmp(string).zero?
|
96
|
+
result = false
|
97
|
+
else
|
98
|
+
result = string
|
99
|
+
end
|
100
|
+
else
|
101
|
+
result = node
|
102
|
+
end
|
103
|
+
result
|
104
|
+
end
|
105
|
+
|
106
|
+
def ler_arquivo(arquivo)
|
107
|
+
result = ""
|
108
|
+
File.open(arquivo, 'r') { |f| result = f.read }
|
109
|
+
result
|
110
|
+
end
|
111
|
+
|
112
|
+
def converte_parametros_para_boolean
|
113
|
+
['incluir_abstract'].each do |param|
|
114
|
+
case @artigo[param]
|
115
|
+
when true
|
116
|
+
@artigo[param] = true
|
117
|
+
when 'sim'
|
118
|
+
@artigo[param] = true
|
119
|
+
when 'Sim'
|
120
|
+
@artigo[param] = true
|
121
|
+
else
|
122
|
+
@artigo[param] = false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def converte_configuracao_para_latex
|
128
|
+
@artigo_latex.merge!(@artigo)
|
129
|
+
|
130
|
+
['resumo','abstract','bibliografia'].each {|key|
|
131
|
+
Open3.popen3("pandoc --smart -f markdown -t latex") {|stdin, stdout, stderr, wait_thr|
|
132
|
+
pid = wait_thr.pid # pid of the started process.
|
133
|
+
stdin.write @artigo[key]
|
134
|
+
stdin.close
|
135
|
+
@artigo_latex[key] = stdout.read
|
136
|
+
}
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def salva_configuracao_yaml_para_inclusao_em_pandoc
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
File.open(@arquivo_saida_yaml, 'w'){ |file|
|
146
|
+
file.write @artigo_latex.to_yaml
|
147
|
+
file.write("---")
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
def executa_pandoc_salvando_latex
|
153
|
+
t = Formatafacil::Template.new()
|
154
|
+
data_dir = t.directory
|
155
|
+
|
156
|
+
system "pandoc --smart -s #{@arquivo_texto} #{@arquivo_saida_yaml} --data-dir=#{data_dir} --template=#{modelo} -f markdown -t latex -o #{@arquivo_saida_latex}"
|
157
|
+
end
|
158
|
+
|
159
|
+
def executa_pdflatex
|
160
|
+
#system "pdflatex #{@arquivo_saida_latex}"
|
161
|
+
#system "pdflatex #{@arquivo_saida_latex}"
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Formatafacil
|
2
|
+
class Tarefa
|
3
|
+
attr_accessor :logger
|
4
|
+
|
5
|
+
def initialize(h={})
|
6
|
+
h.each {|k,v| send("#{k}=",v)}
|
7
|
+
end
|
8
|
+
|
9
|
+
def executa
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def self.arquivo_configuracao
|
14
|
+
'config/1-configuracoes-gerais.yaml'
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'formatafacil/tarefa'
|
2
|
+
|
3
|
+
module Formatafacil
|
4
|
+
|
5
|
+
class ArquivoConfiguracaoAusenteException < Exception
|
6
|
+
end
|
7
|
+
|
8
|
+
class TarefaChooser
|
9
|
+
|
10
|
+
def escolhe_tarefa
|
11
|
+
raise Formatafacil::ArquivoConfiguracaoAusenteException, "Não foi possível localizar o arquivo de configuração: #{Formatafacil::Tarefa.arquivo_configuracao}" unless File.exist?(Formatafacil::Tarefa.arquivo_configuracao)
|
12
|
+
Formatafacil::ArtigoTarefa.new
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'formatafacil/tarefa'
|
2
|
+
|
3
|
+
|
4
|
+
module Formatafacil
|
5
|
+
class Template
|
6
|
+
|
7
|
+
attr_accessor 'modelos'
|
8
|
+
# Derectory of templates
|
9
|
+
attr_accessor 'directory'
|
10
|
+
|
11
|
+
def initialize()
|
12
|
+
@modelos = {}
|
13
|
+
|
14
|
+
# ler os templates do projeto formatafacil-templates
|
15
|
+
$LOAD_PATH.each { |dir|
|
16
|
+
files = Dir["#{dir}/formatafacil/templates/*.latex"]
|
17
|
+
files.each { |file|
|
18
|
+
if file
|
19
|
+
@modelos[File.basename(file, '.tex')] = file
|
20
|
+
@directory = "#{dir}/formatafacil"
|
21
|
+
end
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def executa
|
28
|
+
end
|
29
|
+
|
30
|
+
# $LOAD_PATH.each { |dir| ... look for resources relative to dir ... }
|
31
|
+
def list
|
32
|
+
modelos.keys
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/formatafacil.rb
ADDED
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: formatafacil
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eduardo de Santana Medeiros Alexandre
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: formatafacil-templates
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: 'Com essa ferramenta você poderá compilar trabalhos de conclusão de curso
|
84
|
+
(monografia, dissertação ou tese) ou artigos com as normas da ABNT ou outra específica '
|
85
|
+
email:
|
86
|
+
- eduardo.ufpb@gmail.com
|
87
|
+
executables:
|
88
|
+
- formatafacil
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CODE_OF_CONDUCT.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- bin/bundler
|
101
|
+
- bin/console
|
102
|
+
- bin/formatafacil
|
103
|
+
- bin/gli
|
104
|
+
- bin/htmldiff
|
105
|
+
- bin/ldiff
|
106
|
+
- bin/rake
|
107
|
+
- bin/rspec
|
108
|
+
- bin/setup
|
109
|
+
- exe/formatafacil
|
110
|
+
- formatafacil.gemspec
|
111
|
+
- lib/formatafacil.rb
|
112
|
+
- lib/formatafacil/artigo_tarefa.rb
|
113
|
+
- lib/formatafacil/formato.rb
|
114
|
+
- lib/formatafacil/tarefa.rb
|
115
|
+
- lib/formatafacil/tarefa_chooser.rb
|
116
|
+
- lib/formatafacil/template.rb
|
117
|
+
- lib/formatafacil/version.rb
|
118
|
+
homepage: https://github.com/edusantana/formatafacil
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.4.6
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Compila arquivos escritos em Markdown para formatos.
|
142
|
+
test_files: []
|