metanorma / pubid-iso

Implementation of ISO pubid
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Method #to_s raises an error #244

Closed andrew2net closed 7 months ago

andrew2net commented 8 months ago
> pubid1 = Pubid::Iso::Identifier.parse("ISO/IEC DIR 1 + IEC SUP:2022")
#<Pubid::Iso::Identifier::Directives:0x0000000115fdd980 @copublisher="IEC", @edition=nil, @edition_publisher=nil, @joint_document=#<Pubid::Iso::Identifier::Supplement:0x0000000115fd...

> hash = pubid1.to_h
{:publisher=>"ISO", :number=>"1"@12, :copublisher=>"IEC", :joint_document=>{:publisher=>"", :number=>nil, :year=>2022, :base=>{:publisher=>"IEC", :number=>nil, :edition=>nil, :editi...

> pubid2 = Pubid::Iso::Identifier.create(**hash)
#<Pubid::Iso::Identifier::Directives:0x0000000115fdc940 @copublisher="IEC", @edition=nil, @edition_publisher=nil, @joint_document={:publisher=>"", :number=>nil, :year=>2022, :base=>...

> pubid1 == pubid2
true

> pubid1.to_s
"ISO/IEC DIR 1 + IEC SUP:2022"

# everything is good until next
> pubid2.to_s
#<ArgumentError: wrong number of arguments (given 1, expected 0)>
andrew2net commented 8 months ago

ISO 19115-2:2019/Amd 1:2022 also fails

> hash = Pubid::Iso::Identifier.parse("ISO 19115-2:2019/Amd 1:2022").to_h
{:publisher=>"", :number=>"1"@21, :year=>2022, :base=>{:publisher=>"ISO", :number=>"19115"@4, :year=>2019, :part=>"2"@10, :edition=>nil, :type=>:is}, :edition=>nil, :type=>:amd}

> Pubid::Iso::Identifier.create(**hash).to_s
#<ArgumentError: wrong number of arguments (given 1, expected 0)>
mico commented 8 months ago
> pubid1 = Pubid::Iso::Identifier.parse("ISO/IEC DIR 1 + IEC SUP:2022")
#<Pubid::Iso::Identifier::Directives:0x0000000115fdd980 @copublisher="IEC", @edition=nil, @edition_publisher=nil, @joint_document=#<Pubid::Iso::Identifier::Supplement:0x0000000115fd...

> hash = pubid1.to_h
{:publisher=>"ISO", :number=>"1"@12, :copublisher=>"IEC", :joint_document=>{:publisher=>"", :number=>nil, :year=>2022, :base=>{:publisher=>"IEC", :number=>nil, :edition=>nil, :editi...

> pubid2 = Pubid::Iso::Identifier.create(**hash)
#<Pubid::Iso::Identifier::Directives:0x0000000115fdc940 @copublisher="IEC", @edition=nil, @edition_publisher=nil, @joint_document={:publisher=>"", :number=>nil, :year=>2022, :base=>...

> pubid1 == pubid2
true

> pubid1.to_s
"ISO/IEC DIR 1 + IEC SUP:2022"

# everything is good until next
> pubid2.to_s
#<ArgumentError: wrong number of arguments (given 1, expected 0)>

This case is working for pubid-core 1.12.1 (please update your dependencies)

mico commented 8 months ago

ISO 19115-2:2019/Amd 1:2022 also fails

> hash = Pubid::Iso::Identifier.parse("ISO 19115-2:2019/Amd 1:2022").to_h
{:publisher=>"", :number=>"1"@21, :year=>2022, :base=>{:publisher=>"ISO", :number=>"19115"@4, :year=>2019, :part=>"2"@10, :edition=>nil, :type=>:is}, :edition=>nil, :type=>:amd}

> Pubid::Iso::Identifier.create(**hash).to_s
#<ArgumentError: wrong number of arguments (given 1, expected 0)>

This one still fails for pubid-core 1.12.1

andrew2net commented 8 months ago

This case is working for pubid-core 1.12.1 (please update your dependencies)

Just reinstalled pubid-core 1.12.1 and pubid-iso 0.7.0. Still have the ArgumentError.

$ gem uninstall pubid-core
...
Successfully uninstalled pubid-core-1.12.1

$ gem install pubid-core
...
Successfully uninstalled pubid-iso-0.7.0

$ gem install pubid-core
Fetching pubid-core-1.12.1.gem
Successfully installed pubid-core-1.12.1

$ gem install pubid-iso
Fetching pubid-iso-0.7.0.gem
Successfully installed pubid-iso-0.7.0

$ irb
> 3.2.0 :001 > require 'pubid-iso'
 => true
3.2.0 :002 > hash = Pubid::Iso::Identifier.parse("ISO 19115-2:2019/Amd 1:2022").to_h
 => {:publisher=>"", :number=>"1"@21, :year=>2022, :base=>{:publisher=>"ISO", :number=>"19115"@4, :year=>2019, :part=>"2"@10, :edition=>nil, :type=>:is}, :edition=>nil, :type=>:amd}
3.2.0 :003 > pubid1 = Pubid::Iso::Identifier.parse("ISO/IEC DIR 1 + IEC SUP:2022")
 =>
#<Pubid::Iso::Identifier::Directives:0x00000001127fab58
...
3.2.0 :004 > hash = pubid1.to_h
 =>
{:publisher=>"ISO",
...
3.2.0 :005 > pubid2 = Pubid::Iso::Identifier.create(**hash)
 =>
#<Pubid::Iso::Identifier::Directives:0x00000001115cbcc0
...
3.2.0 :006 > pubid1 == pubid2
 => true
3.2.0 :007 > pubid1.to_s
 => "ISO/IEC DIR 1 + IEC SUP:2022"
3.2.0 :008 > pubid2.to_s
/Users/andrej/.rvm/gems/ruby-3.2.0/gems/pubid-iso-0.7.0/lib/pubid/iso/renderer/dir.rb:10:in `to_h': wrong number of arguments (given 1, expected 0) (ArgumentError)

        joint_params = prerender_params(params[:joint_document].to_h(deep: false), {})
                                                                     ^^^^^^^^^^^
    from /Users/andrej/.rvm/gems/ruby-3.2.0/gems/pubid-iso-0.7.0/lib/pubid/iso/renderer/dir.rb:10:in `render_identifier'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/gems/pubid-iso-0.7.0/lib/pubid/iso/renderer/base.rb:29:in `render_base_identifier'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/gems/pubid-iso-0.7.0/lib/pubid/iso/renderer/base.rb:36:in `render'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/gems/pubid-iso-0.7.0/lib/pubid/iso/identifier/base.rb:246:in `to_s'
    from (irb):8:in `<main>'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/gems/irb-1.11.0/exe/irb:9:in `<top (required)>'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/bin/irb:25:in `load'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/bin/irb:25:in `<main>'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/bin/ruby_executable_hooks:22:in `eval'
    from /Users/andrej/.rvm/gems/ruby-3.2.0/bin/ruby_executable_hooks:22:in `<main>'
ronaldtse commented 8 months ago

This case is working for pubid-core 1.12.1 (please update your dependencies)

@mico you have to specify dependency versions inside the gemspec... users cannot specify dependencies.