Hi Raphael, I wrote a basic test suite and pushed a variation of your fix up to rubygems. I did a little refactoring at the same time and it was easier to do the fix at a different spot. Check it out:
https://github.com/peterkeen/ledger-web/commit/7eefd6a683ea3c59f541b7a89a9cf2e75a048a99#L5R39 Ruby's CSV module doesn't like the backslash-escaped double quotes. It prefers double double quotes instead. Here's the test for that implementation: https://github.com/peterkeen/ledger-web/commit/7eefd6a683ea3c59f541b7a89a9cf2e75a048a99#L10R28 As for your other problem, I'm not quite sure what's going on. What ledger, ruby, and postgres versions are you running? --Pete On Sun, Mar 18, 2012 at 8:00 AM, Peter Keen <[email protected]> wrote: > Interesting. Just this morning I decided to sit down and write some > tests, so this will be one of my first ones. I'll hopefully have some > answers for this and the blank lines problem later today. > > --Pete > > On Sun, Mar 18, 2012 at 7:09 AM, Raphael Lorenzeto > <[email protected]> wrote: >> Hi Peter, >> >> I'm trying to use ledger_web as well but I stumbled upon a different issue: >> some of my commodities have numbers and spaces and as stated on the docs, in >> this case you have to enclose the commodity with '"'. >> >> So far so good. The problem is that when ledger exports the data these '"' >> come as '\"' which conflict with the CSV quotes. >> >> I managed to overcome this by changing db.rb: >> >> [...] >> print " loading into database...." >> s = IO.read(file.path).gsub('\"', "'") >> FasterCSV.parse(s) do |row| >> [...] >> >> Replacing the double quotes by simple quotes. >> >> Is there a more elegant way and could you commit this so future users would >> not have this issue as well? >> >> Thanks. >> Raphael >> >> >> On Saturday, March 17, 2012 6:55:17 PM UTC-3, Peter Keen wrote: >>> >>> Hi Bill, >>> >>> I'm sorry you've had so many problems with ledger_web! It's completely >>> my fault, I forgot a line in the gemspec file. If you take a look at >>> the commit[1] you'll see exactly what I missed. >>> >>> I pushed a new version up to rubygems (1.4.2). If you install that you >>> should find a ledger_web binary in the appropriate bin directory. >>> >>> With regards to your postgres problem, it looks like your linux >>> distribution installed a (very sane) default of requiring passwords >>> for all accounts. PostgreSQL accounts are separate from system >>> accounts. To set a password on your database account, run the >>> following ($ and postgres=# are prompts): >>> >>> $ sudo su -u postgres psql >>> postgres=# alter role your_user_name with password 'your password'; >>> postgres=# commit; >>> postgres=# \q >>> >>> To change the database URL that ledger_web uses, put the following >>> into ~/.ledger_web/config.rb: >>> >>> ,-- >>> | LedgerWeb::Config.new do |config| >>> | config.set :database_url, >>> "postgres://username:password@hostname/databasename" >>> | end >>> `-- >>> >>> Replace the username, password, hostname, and databasename with the >>> appropriate values. >>> >>> I hope this helps you get up and running! Again, I'm sorry about the >>> missed gemspec option. >>> >>> --Pete >>> >>> [1]: >>> https://github.com/peterkeen/ledger-web/commit/1335e8aa2fc20f06c5aa9b401e3d2fa25ec58c18#L0R24 >>> >>> On Sat, Mar 17, 2012 at 2:18 PM, Bill Harris >>> <[email protected]> wrote: >>> > Peter Keen <[email protected]> writes: >>> > >>> >> I don't know debian but a few things to check: >>> >> >>> >> - is it in /usr/local/bin >>> >> - is it in /usr/local/share/<something>/? >>> > >>> > Peter, >>> > >>> > I just installed ruby-full today to make sure I had everything, and >>> > then, as root, I installed ledger_web, as you describe on your git >>> > page. >>> > >>> > I still get >>> > >>> > ,---- >>> > | $ ledger_web >>> > | bash: ledger_web: command not found >>> > `---- >>> > >>> > I figured it must have done _something_, so I searched for it. After >>> > eliding a bunch of "Permission denied lines (e.g., lots of /proc/...), I >>> > see >>> > >>> > ,---- >>> > | $ find / -name ledger_web* -print >>> > | >>> > /home/myname/.gem/specs/rubygems.org%80/quick/Marshal.4.8/ledger_web-1.3.gemspec >>> > | /home/myname/.gem/ruby/1.8/cache/ledger_web-1.3.gem >>> > | /var/lib/gems/1.8/bin/ledger_web >>> > | /var/lib/gems/1.8/specifications/ledger_web-1.3.gemspec >>> > | /var/lib/gems/1.8/doc/ledger_web-1.3 >>> > | /var/lib/gems/1.8/doc/ledger_web-1.3/rdoc/files/lib/ledger_web_rb.html >>> > | /var/lib/gems/1.8/doc/ledger_web-1.3/rdoc/files/lib/ledger_web >>> > | /var/lib/gems/1.8/cache/ledger_web-1.3.gem >>> > | /var/lib/gems/1.8/gems/ledger_web-1.3 >>> > | /var/lib/gems/1.8/gems/ledger_web-1.3/ledger_web.gemspec >>> > | /var/lib/gems/1.8/gems/ledger_web-1.3/lib/ledger_web >>> > | /var/lib/gems/1.8/gems/ledger_web-1.3/lib/ledger_web.rb >>> > | /var/lib/gems/1.8/gems/ledger_web-1.3/bin/ledger_web >>> > `---- >>> > >>> > I figure the stuff in ~/.gem is setup material, but the rest went into >>> > /var -- is that right? >>> > >>> > An entry for ledger_web looks like >>> > >>> > ,---- >>> > | -rwxr-xr-x 1 root root 391 Mar 17 13:16 ledger_web >>> > `---- >>> > >>> > so I tried to run it as myself (you said that was the expected mode of >>> > operation). That gave me >>> > >>> > ,---- >>> > | $ /var/lib/gems/1.8/bin/ledger_web >>> > | >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/adapters/postgres.rb:231:in >>> > `initialize': PGError: fe_sendauth: no password supplied >>> > (Sequel::DatabaseConnectionError) >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/adapters/postgres.rb:231:in >>> > `connect' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/adapters/postgres.rb:231:in >>> > `connect' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/database/misc.rb:48:in >>> > `initialize' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool.rb:92:in >>> > `call' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool.rb:92:in >>> > `make_new' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:127:in >>> > `make_new' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:113:in >>> > `available' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:103:in >>> > `acquire' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:147:in >>> > `sync' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:147:in >>> > `synchronize' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:147:in >>> > `sync' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:102:in >>> > `acquire' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/connection_pool/threaded.rb:74:in >>> > `hold' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/database/connecting.rb:225:in >>> > `synchronize' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/adapters/postgres.rb:259:in >>> > `execute' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/adapters/postgres.rb:393:in >>> > `check_database_errors' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/adapters/postgres.rb:257:in >>> > `execute' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/database/query.rb:74:in >>> > `execute_dui' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/database/query.rb:67:in >>> > `execute_ddl' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/database/schema_methods.rb:377:in >>> > `create_table_from_generator' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/database/schema_methods.rb:97:in >>> > `create_table' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/extensions/migration.rb:629:in >>> > `schema_dataset' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/extensions/migration.rb:382:in >>> > `initialize' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/extensions/migration.rb:542:in >>> > `initialize' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/extensions/migration.rb:333:in >>> > `new' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/extensions/migration.rb:333:in >>> > `run' >>> > | from >>> > /var/lib/gems/1.8/gems/sequel-3.32.0/lib/sequel/extensions/migration.rb:317:in >>> > `apply' >>> > | from >>> > /var/lib/gems/1.8/gems/ledger_web-1.3/lib/ledger_web/db.rb:7 >>> > | from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in >>> > `gem_original_require' >>> > | from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in >>> > `require' >>> > | from /var/lib/gems/1.8/gems/ledger_web-1.3/lib/ledger_web.rb:6 >>> > | from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in >>> > `gem_original_require' >>> > | from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in >>> > `require' >>> > | from /var/lib/gems/1.8/gems/ledger_web-1.3/bin/ledger_web:7 >>> > | from /var/lib/gems/1.8/bin/ledger_web:19:in `load' >>> > | from /var/lib/gems/1.8/bin/ledger_web:19 >>> > `---- >>> > >>> > I found there was already a ledger db, so I ran as me >>> > >>> > ,---- >>> > | dropdb ledger >>> > | createdb ledger >>> > `---- >>> > >>> > but I still got that list of messages. >>> > >>> > Does this suggest anything? Is it possibly a Ruby 1.8 vs. 1.9 problem? >>> > Do I need to pass the ledger db a password? If so, how? >>> > >>> > Thanks, >>> > >>> > Bill >>> > -- >>> > Bill Harris >>> > Facilitated Systems >>> > http://makingsense.facilitatedsystems.com/
