Permalink
Browse files

Test for ::Generator first, to prevent warnings on JRuby.

  • Loading branch information...
1 parent 766b04c commit 5ceca165f9d41787399a8bc169dddaf1ef892bb9 @postmodern committed May 28, 2012
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/combinatorics/generator.rb
@@ -1,16 +1,12 @@
require 'enumerator'
-
-begin
- require 'generator' # 1.8.7
-rescue LoadError
-end
+require 'generator' if RUBY_VERSION < '1.9'
module Combinatorics
# auto-detects the `Generator` class.
- Generator = if defined?(::Enumerator::Generator) # 1.9
- ::Enumerator::Generator
- elsif defined?(::Generator) # 1.8.7
+ Generator = if defined?(::Generator) # 1.8.7
::Generator
+ elsif defined?(::Enumerator::Generator) # 1.9
+ ::Enumerator::Generator
else
raise("unable to find the Generator class")
end

0 comments on commit 5ceca16

Please sign in to comment.