<< Masa.20101227-setup-ydim | 2010 | Masa.20101223-testcase-ch_oddb_org-generics_xls >>
suspend
suspend
Memo
bin/ruby -I /usr/lib64/ruby/site_ruby/1.8 test4.rb
EMail from Hannes-san
We had to build Ruby with the oniguruma Library, because some of the regular expressions need lookbehind patterns. At the moment, the Oniguruma-Patches are only compatible with Ruby 1.8.6, not 1.8.7. You can get them here:
There is --with-rubydir option in ./configure of Oniguruma
masa@masa ~/work/onig-5.9.1 $ ./configure --help Optional Packages: --with-rubydir=RUBYDIR specify value for RUBYDIR (default ..)
Oniguruma sample
p "tone of 12345Hz".gsub(/(?<=\d)(?=(?:\d\d\d)+(?!\d))/, ',')
If Oniguruma works
masa@masa ~/work $ ruby1.9 -v ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-linux] masa@masa ~/work $ ruby1.9 oni_sam.rb "tone of 12,345Hz"
If Oniguruma does not work
masa@masa ~/work $ bin/ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux] masa@masa ~/work $ bin/ruby oni_sam.rb oni_sam.rb:1: undefined (?...) sequence: /(?<=\d)(?=(?:\d\d\d)+(?!\d))/
Oniguruma (gem) test
require 'rubygems' require 'oniguruma' reg = Oniguruma::ORegexp.new( '(?<before>.*)(a)(?<after>.*)' ) match = reg.match( 'terraforming' ) puts match[0] <= 'terraforming' puts match[:before] <= 'terr' puts match[:after] <= 'forming'
Result
masa@masa ~/work $ bin/ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux] masa@masa ~/work $ bin/ruby -I /usr/lib64/ruby/site_ruby/1.8 /usr/bin/gem list *** LOCAL GEMS *** archive-tarsimple (1.1.1) gd2 (1.1.1) oniguruma (1.1.0) parseexcel (0.5.2) masa@masa ~/work $ cat test.rb require 'rubygems' require 'oniguruma' reg = Oniguruma::ORegexp.new( '(?<before>.*)(a)(?<after>.*)' ) match = reg.match( 'terraforming' ) puts match[0] <= 'terraforming' puts match[:before] <= 'terr' puts match[:after] <= 'forming' masa@masa ~/work $ bin/ruby -I /usr/lib64/ruby/site_ruby/1.8 test.rb true true true
Notes
p /(?<foo>bar)\k<foo>/.match("barbarbar")
require 'rubygems' require 'oniguruma' p Oniguruma::ORegexp.new('/(?<foo>bar)\k<foo>/').match("barbarbar")
Conclusion
History Oniguruma
Notes
grep '[new]'
2010/01/09: Version 5.9.2 2008/02/19: [new] add: onig_reg_init(). 2008/02/19: [new] add: onig_free_body(). 2008/02/19: [new] add: onig_new_without_alloc(). 2006/12/05: [new] add flag ONIGENC_CASE_FOLD_TURKISH_AZERI and 2006/11/20: [new] add Hiragana/Katakana properties into Shift_JIS. 2006/11/17: [new] add Hiragana/Katakana properties into EUC-JP. 2006/10/19: Version 5.0.0 2006/09/21: [new] add Unicode Properties. (enc/unicode.c) 2006/08/17: [new] add config USE_COMBINATION_EXPLOSION_CHECK. 2006/03/22: [new] add API onig_noname_group_capture_is_active(). 2006/01/24: Version 4.0.0 2006/01/19: [new] add new config USE_UNICODE_ALL_LINE_TERMINATORS. 2005/11/20: [new] add new config USE_CRNL_AS_LINE_TERMINATOR. 2005/06/30: [new] (contributed by KUBO Takehiro) 2005/06/10: [new] add ONIG_SYNTAX_PERL_NG. (Perl + named group) 2005/03/23: [new] add ONIG_SYNTAX_ASIS. 2005/03/23: [new] add ONIG_SYN_OP2_INEFFECTIVE_ESCAPE. 2005/02/01: [new] add onig_get_default_ambig_flag() and 2004/10/30: [new] add hexadecimal digit char type. (\h, \H) 2004/07/01: [new] add onig_get_syntax_{op,op2,behavior,options}. 2004/06/10: [new] add onig_copy_encoding(). 2004/05/25: [new] support UTF-32LE. (ONIG_ENCODING_UTF32_LE) 2004/05/25: [new] support UTF-32BE. (ONIG_ENCODING_UTF32_BE) 2004/05/21: [new] add onig_get_capture_tree() and 2004/05/14: Version 3.0.0 2004/04/26: [new] add onig_get_match_stack_limit_size() and 2004/04/20: [new] add onig_copyright(). 2004/04/15: [new] add onig_get_ambig_flag(). 2004/04/07: [new] support UTF-16 LE. (ONIG_ENCODING_UTF16_LE) 2004/03/26: [new] support UTF-16 BE. (ONIG_ENCODING_UTF16_BE) 2004/03/16: Version 2.2.5
Notes
Problem
From the 1.1.2011 the VAT in Switzerland for all of our clients will change from 7.6% to 8.0%. The best thing would be if we do not have to change the old invoices but the new VAT becomes valid from the 1.1.2011 for all new invoices that are being sent out. So all new invoices from 1.1.2011 will have a correctly calculated VAT of 8% and all the old bills that have already been sent out until 31.12.2010 will have a VAT of 7.6%.
Source
YDIM: ywesee Distributed Invoice Manager
Run test
masa@masa ~/ywesee/ydim $ bin/ydimd /usr/lib64/ruby/site_ruby/1.8/DBD/Pg/Pg.rb:118:in `initialize': FATAL: database "ydim" does not exist (DBI::OperationalError) from /usr/lib64/ruby/site_ruby/1.8/DBD/Pg/Pg.rb:62:in `new' from /usr/lib64/ruby/site_ruby/1.8/DBD/Pg/Pg.rb:62:in `connect' from /usr/lib64/ruby/site_ruby/1.8/dbi.rb:448:in `connect' from /usr/lib64/ruby/site_ruby/1.8/dbi.rb:221:in `connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:60:in `_connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:59:in `times' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:59:in `_connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:56:in `connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:56:in `synchronize' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:56:in `connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:19:in `initialize' from bin/ydimd:18:in `new' from bin/ydimd:18
Note
Create database
sudo -u postgres createdb -E UTF8 -T template0 ydim
Download data from ydim server
Restore data
$ zcat ydim-backup.gz | psql -U postgres ydim
Run again
masa@masa ~/ywesee/ydim $ bin/ydimd /usr/lib64/ruby/site_ruby/1.8/DBD/Pg/Pg.rb:118:in `initialize': FATAL: role "ydim" does not exist (DBI::OperationalError) from /usr/lib64/ruby/site_ruby/1.8/DBD/Pg/Pg.rb:62:in `new' from /usr/lib64/ruby/site_ruby/1.8/DBD/Pg/Pg.rb:62:in `connect' from /usr/lib64/ruby/site_ruby/1.8/dbi.rb:448:in `connect' from /usr/lib64/ruby/site_ruby/1.8/dbi.rb:221:in `connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:60:in `_connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:59:in `times' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:59:in `_connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:56:in `connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:56:in `synchronize' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:56:in `connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:19:in `initialize' from bin/ydimd:18:in `new' from bin/ydimd:18
Create user 'ydim'
masa@masa ~/ywesee/ydim $ createuser ydim -P Geben Sie das Passwort der neuen Rolle ein: Geben Sie es noch einmal ein: Soll die neue Rolle ein Superuser sein? (j/n) j
Run again
masa@masa ~/ywesee/ydim $ bin/ydimd ERROR: relation "object" already exists ERROR: relation "prefetchable_index" already exists ERROR: relation "extent_index" already exists ERROR: relation "object_connection" already exists ERROR: relation "target_id_index" already exists ERROR: relation "collection" already exists ERROR: relation "target_id_ydim_invoice_unique_id" already exists ERROR: relation "target_id_ydim_debitor_unique_id" already exists ERROR: relation "target_id_ydim_autoinvoice_unique_id" already exists ERROR: relation "target_id_ydim_debitor_name" already exists ERROR: relation "target_id_ydim_debitor_email" already exists ERROR: relation "target_id_ydim_invoice_status" already exists I, [2010-12-24T15:01:13.767933 #28782] INFO -- AutoInvoicer: next run Sat Dec 25 01:00:00 2010, sleeping 35926 seconds I, [2010-12-24T15:01:13.768499 #28782] INFO -- CurrencyUpdater: next run Sat Dec 25 02:00:00 2010, sleeping 39526 seconds I, [2010-12-24T15:01:13.768568 #28782] INFO -- StatusUpdater: next run Sat Dec 25 01:00:00 2010, sleeping 35926 seconds I, [2010-12-24T15:01:13.768888 #28782] INFO -- start: starting ydim-server on druby://localhost:12375
Note
ydim-edit
masa@masa ~/ywesee/ydim $ bin/ydim-edit I, [2010-12-24T15:05:35.567311 #28868] INFO -- StatusUpdater: next run Sat Dec 25 01:00:00 2010, sleeping 35664 seconds irb(main):001:0> YDIM::Server.config.vat_rate => 7.6 irb(main):002:0> YDIM::Server.config.vat_rate = 8.0 => 8.0 irb(main):003:0> YDIM::Server.config.vat_rate => 8.0
Note
git ydim-html and copy files to ydim directory
masa@masa ~/ywesee/ydim-html $ cp -r bin ../ydim/ masa@masa ~/ywesee/ydim-html $ cp -r doc ../ydim/ masa@masa ~/ywesee/ydim-html $ cp -r lib ../ydim/
Note
Note
I, [2010-12-24T15:41:01.743433 #29477] INFO -- AutoInvoicer: next run Sat Dec 25 01:00:00 2010, sleeping 33538 seconds I, [2010-12-24T15:41:01.743998 #29477] INFO -- CurrencyUpdater: next run Sat Dec 25 02:00:00 2010, sleeping 37138 seconds I, [2010-12-24T15:41:01.744067 #29477] INFO -- StatusUpdater: next run Sat Dec 25 01:00:00 2010, sleeping 33538 seconds I, [2010-12-24T15:41:01.744389 #29477] INFO -- start: starting ydim-server on druby://localhost:12375
Run ydim-html
masa@masa ~/ywesee/ydim $ bin/ydim-htmld /home/masa/ywesee/ydim/lib/ydim/html/view/htmlgrid.rb:17: warning: already initialized constant HTTP_HEADERS /home/masa/ywesee/ydim/lib/ydim/html/view/htmlgrid.rb:80: warning: already initialized constant STRIPED_BG /home/masa/ywesee/ydim/lib/ydim/html.rb:3: warning: already initialized constant VERSION /home/masa/ywesee/ydim/lib/ydim/html/util/server.rb:18:in `read': can't convert nil into String (TypeError) from /home/masa/ywesee/ydim/lib/ydim/html/util/server.rb:18:in `initialize' from bin/ydim-htmld:32:in `new' from bin/ydim-htmld:32
Note
Next ToDo