<< | Index | >>
I got error with any ruby version.
% bundle exec bin/brand2csv 01.01.2010-30.02.2010
Info: Suche meldet <Die Suchkriterien sind teilweise unzul>
Info: Suche meldet <Erweiterte Suche>
/path/to/brand2csv/lib/brand2csv.rb:424:in `initialize': undefined method `[]' for nil:NilClass (NoMethodError)
from /path/to/brand2csv/lib/brand2csv.rb:488:in `new'
from /path/to/brand2csv/lib/brand2csv.rb:488:in `getAllHits'
from /path/to/brand2csv/lib/brand2csv.rb:527:in `fetchresult'
from /path/to/brand2csv/lib/brand2csv.rb:560:in `run'
from bin/brand2csv:47:in `<main>'
The result page does not have Seite \d+ von \d+ - Treffer ... text. (pagination).
[1] 2.0.0-p247(#<Brand2csv::Swissreg::Vereinfachte>)> doc.text.length => 8212 [2] 2.0.0-p247(#<Brand2csv::Swissreg::Vereinfachte>)> m = HitRegexpDE.match(doc.text) => nil [14] 2.0.0-p247(#<Brand2csv::Swissreg::Vereinfachte>)> doc.text =~ /Seite\s/ => nil
And I found this Validation Error in result.
This means date format is wrong. (In this case, I gave only Publikationsdatum)
Die Suchkriterien sind teilweise unzulässig (siehe Hinweiszeichen neben den Suchfeldern). Bitte korrigieren Sie Ihre Eingaben.
Swissreg.ch does not handle 30.02.2010 as 28.02.2010.
(Last day of month must be correcct. And 2010 is not leap year, last day is 28)
It works fine. (with 01.01.2010-28.02.2010)
% bundle exec bin/brand2csv 01.01.2010-28.02.2010 Info: Suche meldet <Vereinfachte Trefferliste anzeigen> Info: Suche meldet <Erweiterte Suche> [1] 2.0.0-p247(#<Brand2csv::Swissreg::Vereinfachte>)> m => #<MatchData "Seite 1 von 9 - Treffer 1-250 von 2'001" 1:"1" 2:"9" 3:"1" 4:"250" 5:"2'001">
Swissreg.ch does not care about last day of month. It is too sensitive ... :(.
Then I updated to check date parameter for brand2csv with Date class of Ruby.
[1] 2.0.0-p247(main)> Date.new(2010,10,-1) #<Date: 2010-10-31 ((2455501j,0s,0n),+0s,2299161j)> [2] 2.0.0-p247(main)> Date.new(2010,02,-1) #<Date: 2010-02-28 ((2455256j,0s,0n),+0s,2299161j)>
It creates last day of month with negative value (z.B. -1 )
Validator "Did you mean ?"
% bundle exec bin/brand2csv 01.01.2010-30.02.2010 Did you mean 01.01.2010-28.02.2010 ?
The swissreg_spec send real request to swissreg.ch.
Now following example fails.
% bundle exec rspec
........getAllHits: returned 2 hits
F.......
Failures:
1) Get some simple example from swissreg should get correct results from swissreg
Failure/Error: results.size.should == 1
expected: 1
got: 2 (using ==)
# ./spec/swissreg_spec.rb:16:in `block (2 levels) in <top (required)>'
Finished in 8.45 seconds
16 examples, 1 failure
Failed examples:
rspec ./spec/swissreg_spec.rb:10 # Get some simple example from swissreg should get correct results from swissreg
I updated to pass this example with webmock.
This gem uses Hoe for build & release.
So it does not contain gemspec.
For debug (without hoe), make gemspec like this.
% cd brand2csv % bundle exec rake debug_gem > brand2csv.gemspec % cd /tmp % mkdir test % cd test % bundle init % # add `gem "brand2csv", :path => "/path/to/brand2csv"` % bundle install --path .bundle/gems % bundle exec brand2csv "..." # before do this, please comment out line `if $0 == __FILE__` in bin/brand2csv