view · edit · sidebar · attach · print · history

20101224-check-problem_Ruby_1_8_7-study-ydim

<< Masa.20101227-setup-ydim | 2010 | Masa.20101223-testcase-ch_oddb_org-generics_xls >>


  1. Look for description regarding Ruby 1.8.7 problem
  2. Look for a Oniguruma patch for Ruby 1.8.7
  3. Check differences between Oniguruma ver.2 and ver.5 suspend
  4. Setup YDIM

Goal
  • Find problems / 60%
Milestones
  1. Search joblog
  2. Oniguruma patch suspend
Summary
Commits
ToDo Tomorrow

Memo

 bin/ruby -I /usr/lib64/ruby/site_ruby/1.8 test4.rb
Keep in Mind
  1. swissmedic_followers debug
  2. different page 2010, 2011 and navigator link at the bottom of page PM-Wiki Markup for paging between pages
  3. On Ice
  4. export_fachinfo test locally (weekend)
  5. backup script (weekend)
  6. emerge --sync

Look for description regarding Ruby 1.8.7 problem

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:

Look for a Oniguruma patch for Ruby 1.8.7

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

  • Oniguruma gem is biding to Oniguruma library without compiling
  • but we have to use the different expression (new Class) from the normal Regexp class
  • For example, the following code does not run by the Oniguruma gem, but Ruby1.9 can
p /(?<foo>bar)\k<foo>/.match("barbarbar")
  • The following code can run with Ruby1.8.7 with Oniguruma gem
require 'rubygems'
require 'oniguruma'

p Oniguruma::ORegexp.new('/(?<foo>bar)\k<foo>/').match("barbarbar")

Conclusion

  • Oniguruma gem cannot be replaced with the current oniguruma patched Ruby 1.8.6

Check differences between Oniguruma ver.2 and ver.5

History Oniguruma

Notes

  • The latest version 2 is 2.5.9
  • Version 5 is coming from a branch of version 2.2.5

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

  • There are many 'Updates'([impl]) and 'Bug fixes'([bug]) other than these above
  • I cannot understand which regular expressions are improved from this profile
    • (It is clear that hexadecimal digit char type \h is added in version 3)

Setup YDIM

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

  • This is used from oddb.org, bbmb.ch, etc.

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

  • I have to create 'ydim' database

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

  • Good

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

  • This is like 'bin/admin' in oddb.org

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

  • I guess I need to set up a virtual host for ydim

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
  • I must stop 'AutoInvoicer'
  • Also I should check the other thread processes

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

  • I have to set something, probably ydim.yml.

Next ToDo

  1. ydim.yml
  2. ydim-html.yml
  3. virtual host
view · edit · sidebar · attach · print · history
Page last modified on July 13, 2011, at 12:04 PM