view · edit · sidebar · attach · print · history

Index>

20160419-ydim-html-ruby-1-9

Summary

  • Fix error in YDIM html by porting it to Ruby 1.9
  • oddb2xml should not emit products with empty name or name containing only a dot

Commits

Index

Keep in Mind for work to do
  • Fix dojo error http://www.sitepen.com/blog/2012/10/31/debugging-dojo-common-error-messages/#forgot-dom-ready
  • I removed on May-27 tests for ix_registrationss, fix_sequences, fix_compositions, fix_packages from test/test_plugin/swissmedic.rb,as he could not find any references for them in the src code. Did I erroneously remove stuff when cleaning up the swissmedic import earlier?
  • The whole test for older/newer Packages must be adapted to xlsx. One must compare the rows (e.g. by creating csv files) and do the same stuff in xlsx!
  • creat gem: task: input=file with ean-codes, standard output show ean-codes + atc-code. Source is Swissmedic Packungen.xlsx or XML.
  • Import via data/medreg_companies.yaml
  • Fix problem with radioactivatum 99m-technetio when parsing Wirkstoffe
  • Fix galenic_forms when parsing swissmedic.xlsx
  • Cleanup generic_type. Replace it everywhere by sl_generic_type and adapt code accordingly.
  • Get updated ATC-codes from EPha for oddb.org, too.
  • Use refdatabase for oddb.org, too.
  • Check whether we should revert the part which touche src/plugin/text_info.rb of commit 17af82ba4d76a5838683411b260de265531f9e74. We should improve test/stub/oddbapp.rb to work similar for update/pointer as the real oddbapp. In this case we would have a good Stub for plugins. May we need a different stub when working with plugins (which create/modify/destroy ODDB-Objects), when in most other cases a very simple stub is sufficient.
  • When a logged in admin user changes an atc_code of a product, the corresponding atc_class must update its sequences, too.
  • Order of entering search type and value should not matter. Both should show long URL with search
  • Remove parser for minifi (but keep the minifi)
  • BSV-Plugin does not send mail. Is it sending two mails at once?
  • remove obsolete pdf_patinfo in model, admin/views

Fix error in YDIM html by porting it to Ruby 1.9

Trying to get rid of error in pdfinvoice and pdf-writer like pdfinvoice/invoice.rb:100: invalid multibyte char (US-ASCII) (SyntaxError)

When I tried sudo -u apache /usr/bin/ruby19 -rubygems /usr/bin/ydimd I got the following error:

/usr/local/lib64/ruby/gems/1.9.1/gems/needle-1.3.0/lib/needle/thread.rb:42:in `lock': undefined method `critical=' for Thread:Class (NoMethodError)
        from <internal:prelude>:8:in `synchronize'
        from /usr/local/lib64/ruby/gems/1.9.1/gems/needle-1.3.0/lib/needle/service-point.rb:117:in `instance'
        from /usr/local/lib64/ruby/gems/1.9.1/gems/needle-1.3.0/lib/needle/container.rb:308:in `get'
        from /usr/local/lib64/ruby/gems/1.9.1/gems/needle-1.3.0/lib/needle/registry.rb:124:in `bootstrap'
        from /usr/local/lib64/ruby/gems/1.9.1/gems/needle-1.3.0/lib/needle/registry.rb:106:in `initialize'
        from /usr/lib64/ruby/site_ruby/1.9.1/ydim/server.rb:71:in `new'
        from /usr/lib64/ruby/site_ruby/1.9.1/ydim/server.rb:71:in `initialize'
        from /usr/bin/ydimd:35:in `new'
        from /usr/bin/ydimd:35:in `<main>'

I had forgotten that needle does not work under Ruby 1.9 and 2.0. It runs fine under 2.1 and later.

Trying to make pdf-writer run its test using ruby19 bin/techbook.

  • Must change a few instances of each to each_line as Ruby 1.8 no longer has an each method for the class String.
  • Added a magic encoding: utf-8 to lib/pdf/writer.rb
  • Fixed generation of PDF header in PDF::Writer with some lines found in prawn/document/internals.rb (render_header).

Must fix now the following error

uby19 bin/techbook 
Using default document 'manual.pwd'.
/usr/local/lib64/ruby/gems/1.9.1/gems/transaction-simple-1.4.0.2/lib/transaction/simple.rb:161:in `dump'
/usr/local/lib64/ruby/gems/1.9.1/gems/transaction-simple-1.4.0.2/lib/transaction/simple.rb:161:in `start_transaction'
/usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:469:in `techbook_heading'
/usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:566:in `block in techbook_parse'
/usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:537:in `each'
/usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:537:in `techbook_parse'
/usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:886:in `run'
bin/techbook:24:in `<main>'
/usr/local/lib64/ruby/gems/1.9.1/gems/transaction-simple-1.4.0.2/lib/transaction/simple.rb:161:in `dump': no _dump_data is defined for class Mutex (TypeError)
        from /usr/local/lib64/ruby/gems/1.9.1/gems/transaction-simple-1.4.0.2/lib/transaction/simple.rb:161:in `start_transaction'
        from /usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:469:in `techbook_heading'
        from /usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:566:in `block in techbook_parse'
        from /usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:537:in `each'
        from /usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:537:in `techbook_parse'
        from /usr/lib64/ruby/site_ruby/1.9.1/pdf/techbook.rb:886:in `run'
        from bin/techbook:24:in `<main>'

Creating a Gemfile to simplify testing. Switched to Ruby 2.3.0 and I got a little further. Next errors are

 bundle exec bin/techbook 
Using default document 'manual.pwd'.

Error in document around line 205:
  undefined method `/' for nil:NilClass
Backtrace:
/home/niklaus/git/pdf-writer/lib/pdf/techbook.rb:692:in `eval'
/home/niklaus/git/pdf-writer/lib/pdf/writer/graphics.rb:549:in `add_image_from_file'
(eval):10:in `block in techbook_directive_endeval'
/home/niklaus/git/pdf-writer/lib/pdf/techbook.rb:692:in `eval'
/home/niklaus/git/pdf-writer/lib/pdf/techbook.rb:692:in `block in techbook_directive_endeval'

Error in document around line 210:
  undefined method `/' for nil:NilClass
Backtrace:
/home/niklaus/git/pdf-writer/lib/pdf/techbook.rb:692:in `eval'
/home/niklaus/git/pdf-writer/lib/pdf/writer/graphics.rb:549:in `add_image_from_file'
(eval):10:in `block in techbook_directive_endeval'
/home/niklaus/git/pdf-writer/lib/pdf/techbook.rb:692:in `eval'
/home/niklaus/git/pdf-writer/lib/pdf/techbook.rb:692:in `block in techbook_directive_endeval'

Error in document around line 361:
  (eval):50: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
1<Introduction to PDF::Writer for Ruby>Introduction

Files like pdf-writer/images/bluesmoke.jpg are read but don't get recognized as JPEG, but as OTHER type. This must be fixed.

Porting some fixes:

There is even a pull request which would get Ruby 2.0 compatibity, see https://github.com/metaskills/pdf-writer/pull/3. Even this one has another pull request from https://github.com/jcrate/pdf-writer.git.

But both have problems running bin/textbook under ruby 2.3 and 2.1. Installing ruby 2.0 to see whether they work there.

With a small patch bin/techbook works now.

Started a Gemfile for ydim-html. Now must first create a Gemfile for ydim as we want to have a separate Gem ydim for auto-invoicing. Solved. Now starting sudo -u apache /home/niklaus/.rbenv/shims/bundle exec bin/ydim-htmld in /var/www/ydim.ywesee.com complains about pdfinvoice/config

Starting ydimd also complains about pdfinvoice/config. We must therefore add it to the ydim source.

Now ydimd begins to starts, connects to the database and throws the error

/home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `initialize' may cause serious problems
/home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `object_id' may cause serious problems
/home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `__send__' may cause serious problems
FEHLER:  Relation &#65533;object&#65533; existiert bereits
FEHLER:  Relation &#65533;prefetchable_index&#65533; existiert bereits
FEHLER:  Relation &#65533;extent_index&#65533; existiert bereits
FEHLER:  Relation &#65533;object_connection&#65533; existiert bereits
FEHLER:  Relation &#65533;target_id_index&#65533; existiert bereits
FEHLER:  Relation &#65533;collection&#65533; existiert bereits
/home/niklaus/.rbenv/versions/2.3.0/lib/ruby/2.3.0/delegate.rb:387:in `__getobj__': not delegated (ArgumentError)
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/2.3.0/delegate.rb:340:in `block in delegating_block'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/ruby-dbi-dcd6239fd5f8/lib/dbi/handles/statement.rb:214:in `fetch'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/ruby-dbi-dcd6239fd5f8/lib/dbi/handles/statement.rb:240:in `each'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/ruby-dbi-dcd6239fd5f8/lib/dbi/handles/database.rb:130:in `block in select_all'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/ruby-dbi-dcd6239fd5f8/lib/dbi/handles/database.rb:88:in `execute'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/ruby-dbi-dcd6239fd5f8/lib/dbi/handles/database.rb:128:in `select_all'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dbd-pg-0.3.9/lib/dbd/pg/database.rb:173:in `columns'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/ruby-dbi-dcd6239fd5f8/lib/dbi/handles/database.rb:161:in `columns'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:39:in `block in method_missing'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:29:in `next_connection'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:38:in `method_missing'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/storage.rb:526:in `setup'
        from /home/niklaus/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/odba-1.1.0/lib/odba/cache.rb:473:in `setup'
        from /home/niklaus/git/ydim/bin/ydimd:20:in `<main>'

Pushed patches from last week and today:

Maybe a need a onigurama for Ruby 2.3.0 as well.

Will investigate tomorrow.

oddb2xml should not emit products with empty name or name containing only a dot

Looking for problematic cases via

 grep 'DSCRD>.</DSCR' ausgabe/2.3.6/oddb2xml__e/oddb_article.xml 
    <DSCRD>y</DSCRD>
    <DSCRD>.</DSCRD>

But I cannot find any empty description.

Changing the oddb2xml to require a minimal length of 3 and a maximal length of 120 (max seen 108) for the german/french description.

Had to reorganize a little bit the build_article/product, as the DSCRD/DSCRF must be checked before emitting them.

Seems to work. Comitted locally the changes. Running oddb2xml -e and bundle exec rspec a second time to ensure, that everything is okay.

Should be fixed with the following commits:

view · edit · sidebar · attach · print · history
Page last modified on April 19, 2016, at 05:40 PM