doubly initialized constants

7 views
Skip to first unread message

rogerdpack

unread,
Aug 31, 2011, 7:12:35 PM8/31/11
to Ruby FS Stack
With jruby I get this:

>> require 'ruby-fs-stack'
c:/dev/ruby/downloads/jruby/lib/ruby/gems/1.8/gems/ruby-fs-stack-0.5.3/
lib/ruby-fs-stack/enunciate/familytree.rb:7924 warning: already
initialized constant Info
c:/dev/ruby/downloads/jruby/lib/ruby/gems/1.8/gems/ruby-fs-stack-0.5.3/
lib/ruby-fs-stack/enunciate/familytree.rb:7927 warning: already
initialized constant Warn
c:/dev/ruby/downloads/jruby/lib/ruby/gems/1.8/gems/ruby-fs-stack-0.5.3/
lib/ruby-fs-stack/enunciate/familytree.rb:7930 warning: already
initialized constant Error
c:/dev/ruby/downloads/jruby/lib/ruby/gems/1.8/gems/ruby-fs-stack-0.5.3/
lib/ruby-fs-stack/familytree/ordinance.rb:11 warning: already
initialized constant Sealing_to_Parents
c:/dev/ruby/downloads/jruby/lib/ruby/gems/1.8/gems/ruby-fs-stack-0.5.3/
lib/ruby-fs-stack/familytree/ordinance.rb:14 warning: already
initialized constant Sealing_to_Spouse

Anybody know what might be going on here? Is this a jruby bug?
-r

Jimmy Z

unread,
Sep 1, 2011, 3:23:58 PM9/1/11
to Ruby FS Stack
The Enunciate project, used by the FamilySearch API engineers,
generates the Ruby data model and has a bug in that it declares the
constants inside of each module rather than in a separate file
(Identity, FamilyTree, etc.). It doesn't break anything, but emits a
warning.

As a workaround/hack, I did the following:

with_warnings_suppressed do
require 'ruby-fs-stack/enunciate/familytree'
end

the with_warnings_suppressed method is found here:

https://github.com/jimmyz/ruby-fs-stack/blob/master/lib/ruby-fs-stack/warning_suppressor.rb

So, that is why it doesn't show up in Ruby 1.8 or 1.9. I don't know
how to suppress the warnings in jRuby.

--
Jimmy Z

Roger Pack

unread,
Nov 29, 2011, 3:48:53 PM11/29/11
to ruby-f...@googlegroups.com


the with_warnings_suppressed method is found here:

https://github.com/jimmyz/ruby-fs-stack/blob/master/lib/ruby-fs-stack/warning_suppressor.rb

So, that is why it doesn't show up in Ruby 1.8 or 1.9. I don't know
how to suppress the warnings in jRuby.

Created http://jira.codehaus.org/browse/JRUBY-6239 FWIW.
-r
Reply all
Reply to author
Forward
0 new messages