Class: Limarka::Cli
- Inherits:
-
Thor
- Object
- Thor
- Limarka::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/limarka/cli.rb
Instance Method Summary collapse
- #cronograma ⇒ Object
- #exec ⇒ Object
- #fig(arquivo = nil) ⇒ Object
- #importa(arquivo) ⇒ Object
- #menu ⇒ Object
- #tab ⇒ Object
Instance Method Details
#cronograma ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/limarka/cli.rb', line 209 def cronograma # https://github.com/abntex/limarka/issues/90 tex = <<TEX \\begin{table}[htbp] \\centering \\caption{Cronograma de atividades} \\label{tab:cronograma} \\begin{tabular}{|c|c|c|c|c|c|} \\hline Fase & Março & Abril & Maio & Junho & Julho \\\\ \\hline 1 & \\textbullet & & & & \\\\ 2 & & \\textbullet & & & \\\\ 3 & & & \\textbullet & & \\\\ 4 & & & & \\textbullet & \\\\ 5 & & & & & \\textbullet \\\\ \\hline \\end{tabular} \\legend{Fonte: Autor.} \\end{table} \\begin{table}[htbp] \\centering \\caption{Cronograma de atividades} \\label{tab:cronograma} \\begin{tabular}{|l|c|c|c|c|c|} \\hline Atividade & Março & Abril & Maio & Junho & Julho \\\\ \\hline XXXXXXXXXXXXXXXX & \\textbullet & & & & \\\\ XXXXXXXXXXXXXXXX & & \\textbullet & & & \\\\ XXXXXXXX & & & \\textbullet & & \\\\ XXXXXXXX & & & & \\textbullet & \\\\ XXXXXXXX & & & & & \\textbullet \\\\ \\hline \\end{tabular} \\legend{Fonte: Autor.} \\end{table} TEX puts tex end |
#exec ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/limarka/cli.rb', line 31 def exec if ([:version]) then puts "limarka "+Limarka::VERSION return end #options[:output_dir] = File.absolute_path(options[:output_dir]) Dir.chdir([:input_dir]) do t = Limarka::Trabalho.new t.atualiza_de_arquivos() cv = Limarka::Conversor.new(t,) cv.convert cv.usa_pdftotext = false cv.compila if [:compila_tex] end end |
#fig(arquivo = nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/limarka/cli.rb', line 70 def fig(arquivo=nil) if ([:clipboard]) then arquivo = Clipboard.paste # Ler do clipboard, requer xclip: sudo apt-get install xclip end if (arquivo) then if arquivo.start_with?("file://") then arquivo = arquivo[7,-1] end end if ([:interativo]) then arquivo = ask_figura_arquivo(arquivo) valida_figura_arquivo(arquivo) # antecipando validação issue #78 legenda = ask_figura_legenda fonte = ask_figura_fonte rotulo = ask_figura_rotulo(rotulo, arquivo) valida_figura_rotulo(rotulo) # antecipando validação issue #78 dimensoes = ask_figura_dimensoes else legenda = [:legenda] fonte = [:fonte] rotulo = [:rotulo] if (not arquivo) then arquivo = ask_figura_arquivo(nil) end valida_figura_arquivo(arquivo) # antecipando validação issue #78 rotulo = "fig:" + propoe_rotulo(File.basename arquivo, ".*") if rotulo.nil? valida_figura_rotulo(rotulo) # antecipando validação issue #78 dimensoes = [:dimensoes] end dimensoes.each do |dim| escala = (dim.to_f)/100 figura_tex = <<TEX \\begin{figure}[htbp] \\caption{\\label{#{rotulo}}#{legenda}} \\begin{center} \\includegraphics[width=#{escala}\\textwidth]{#{arquivo}} \\end{center} \\legend{Fonte: #{fonte}} \\end{figure} TEX say figura_tex end say "\n<!--Para referenciar a figura acima no texto utilize: Figura \\ref\{#{rotulo}} \n-->\n" end |
#importa(arquivo) ⇒ Object
52 53 54 55 |
# File 'lib/limarka/cli.rb', line 52 def importa(arquivo) diretorio = File.dirname(arquivo) system "pandoc", "-t", "markdown", "-o", "#{diretorio}/trabalho-academico.md", arquivo end |
#menu ⇒ Object
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/limarka/cli.rb', line 252 def table = Terminal::Table.new :title => "Menu interativo - limarka v#{Limarka::VERSION}\n#{Dir.pwd}", :headings => ['Comando', 'Descrição'] do |t| t << ["exec", "Executa o limarka."] t << ["figura","Imprime código para adição de Figura."] t << ["tabela","Imprime código para adição de Tabela."] t << ["cronograma","Imprime código para inclusão de Cronograma."] t << ["rascunho","Executa o limarka lendo de rascunho.md"] t << ["web","Imprime o endereço da documentação online."] t << ["menu","Imprime esse menu."] t << ["sair","Termina o menu interativo."] end puts table puts "Pressione TAB para completar o comando ao digitar: 'sa'+TAB completa para 'sair'" sair = false until sair do cmd = ask("Qual comando deseja executar?", :limited_to => ["exec", "figura", "tabela", "cronograma","rascunho","web","menu","sair"]) case cmd when "sair" sair = true when "menu" puts table when "exec" system "limarka","exec" when "web" puts "https://github.com/abntex/limarka/wiki" puts "" when "figura" system "limarka", "fig","-i" when "tabela" system "limarka", "tab" when "cronograma" system "limarka", "cronograma" when "rascunho" system "limarka", "exec", "--rascunho=rascunho.md" else "You gave me #{cmd} -- I have no idea what to do with that." end end end |
#tab ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/limarka/cli.rb', line 136 def tab legenda = [:legenda] fonte = [:fonte] rotulo_lido = [:rotulo] if rotulo_lido then rotulo = rotulo_lido else rotulo = "tab:"+(Time.now.to_i % 100000).to_s end nota = [:nota] if nota then nota_linha = " \\nota{#{nota}}%\n" else nota_linha = "" end valida_tabela_rotulo(rotulo) say <<TEX \\begin{table}[htb] \\ABNTEXfontereduzida \\caption{#{legenda}} \\label{#{rotulo}} \\begin{tabular}{p{2.6cm}|p{6.0cm}|p{2.25cm}|p{3.40cm}} %\\hline \\textbf{Nível de Investigação} & \\textbf{Insumos} & \\textbf{Sistemas de Investigação} & \\textbf{Produtos} \\\\ \\hline Meta-nível & Filosofia\\index{filosofia} da Ciência & Epistemologia & Paradigma \\\\ \\hline Nível do objeto & Paradigmas do metanível e evidências do nível inferior & Ciência & Teorias e modelos \\\\ \\hline Nível inferior & Modelos e métodos do nível do objeto e problemas do nível inferior & Prática & Solução de problemas \\\\ % \\hline \\end{tabular} \\legend{Fonte: #{fonte}} \\end{table} \\begin{table}[htb] \\IBGEtab{% \\caption{#{legenda}}% \\label{#{rotulo}} }{% \\begin{tabular}{ccc} \\toprule Nome & Nascimento & Documento \\\\ \\midrule \\midrule Maria da Silva & 11/11/1111 & 111.111.111-11 \\\\ \\midrule João Souza & 11/11/2111 & 211.111.111-11 \\\\ \\midrule Laura Vicuña & 05/04/1891 & 3111.111.111-11 \\\\ \\bottomrule \\end{tabular}% }{% \\fonte{#{fonte}}% #{nota_linha}} \\end{table} <!-- Para referenciar a tabela acima no texto utilize: Tabela \\ref\{#{rotulo}} --> TEX # say tabela_tex end |