Mysql support and other fixes - #11
Conversation
* Minimal config file * Better rescueing on DB connection
* Extended host option with '[:PORT]' * More doc
…ation * Fixed hostname:port option
|
|
||
| or: | ||
|
|
||
| $ gnucash-invoice -a mysql -h db.somewhere.net -d dbname -u user -p sekreet |
There was a problem hiding this comment.
Probably it's better to change to simply accept --db argument that will be a URL like:
sqlite:///path/to/db.sqlite3
mysql://user:pass@db.somewherenet/dbname
There was a problem hiding this comment.
Not saying I insist. Just a thought,
| @@ -0,0 +1,6 @@ | |||
| # constants | |||
| DATE_FMT = "%Y-%m-%d".freeze # ISO | |||
There was a problem hiding this comment.
Can you move those constants under GnuCash module? And place them inside of lib/gnucash.rb?
There was a problem hiding this comment.
I'm fine if you will move it to lib/gnucash/constants.rb though or lib/gnucash/core.rb for example.
| 'Invoice ID', 'Customer', 'Reference', 'Opened at', 'Posted at', | ||
| 'Due at' | ||
| ] | ||
| puts INVOICE_LIST_HDR |
There was a problem hiding this comment.
I don't think these two should be constants.
I think we should add teminal-table gem instead and use it here:
puts Terminal::Table.new({
:headings => ['Invoice ID', 'Customer', 'Reference', 'Opened at', 'Posted at', 'Due at']
:rows => Invoice.all.map { |invoice| [invoice.id, ...] }
})| rescue GnuCash::NoDatabaseFound, | ||
| GnuCash::NoDatabaseConnection, | ||
| Sequel::DatabaseConnectionError => e | ||
| abort("ERROR: #{options[:db].inspect}: Can't connect to database: #{e}") |
There was a problem hiding this comment.
It's better to use wording:
abort("ERROR: Can't connect to database #{options[:db].inspect}\n#{e}")| # other exceptions beyond this point are *bugs* | ||
| # rescue => e | ||
| # abort("ERROR: #{options[:db].inspect}: #{e}") | ||
|
|
| meta charset="utf-8" | ||
| title = "#{invoice.id} (#{invoice.posted? ? invoice.posted_at : "DRAFT"})" | ||
| style type="text/css" = embedded_asset('main.css') | ||
| / CSS must not be HTML-escaped |
There was a problem hiding this comment.
in fact there's no need in this comment at all :D
|
I'm pretty happy to merge this after some comments will be addressed |
|
Thanks for the comment. I'll review and correct! |
|
Thank you! |
Added support for MySql with related options. Tested with GnuCash 3.x (warning: since v2.7, GnuCash DB must be updated).
Fixed template to pass W3C validation and avoid HTML escaping of embedded CSS.
Some more doc.