jruby-scala-collections 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/jruby/scala_support.rb +16 -5
  2. metadata +1 -1
@@ -46,7 +46,7 @@ module JRuby::ScalaSupport
46
46
  @raw
47
47
  end
48
48
 
49
- def blank?
49
+ def empty?
50
50
  @raw.isEmpty
51
51
  end
52
52
 
@@ -68,6 +68,10 @@ module JRuby::ScalaSupport
68
68
  end
69
69
  end
70
70
 
71
+ def keys
72
+ @raw.keys.toSeq.from_scala
73
+ end
74
+
71
75
  def has_key?(key)
72
76
  @raw.contains(key)
73
77
  end
@@ -264,7 +268,7 @@ module JRuby::ScalaSupport
264
268
  @size
265
269
  end
266
270
 
267
- def blank?
271
+ def empty?
268
272
  false
269
273
  end
270
274
 
@@ -291,11 +295,11 @@ module JRuby::ScalaSupport
291
295
 
292
296
  def [](index)
293
297
  if index < 0
294
- @raw.send("_#{size + index + 1}")
298
+ @raw.send("_#{size + index + 1}").from_scala
295
299
  elsif index >= size
296
300
  nil
297
301
  else
298
- @raw.send("_#{index + 1}")
302
+ @raw.send("_#{index + 1}").from_scala
299
303
  end
300
304
  end
301
305
 
@@ -341,7 +345,14 @@ class Object
341
345
  when Java::scala.collection.Seq, Java::scala.collection.immutable.Seq
342
346
  JRuby::ScalaSupport::Seq::Immutable.new(self)
343
347
  when Java::scala.Product
344
- match = self.class.to_s.match(/^Java::Scala::Tuple(\d+)$/)
348
+ # Sometimes tuples have some wraping classes, like "#<Class:...>" on top
349
+ # of them. Some magic is needed to find actual tuple name.
350
+ match = nil
351
+ self.class.ancestors.find do |klass|
352
+ match = klass.to_s.match(/^Java::Scala::Tuple(\d+)$/)
353
+ ! match.nil?
354
+ end
355
+
345
356
  if match
346
357
  size = match[1].to_i
347
358
  JRuby::ScalaSupport::Tuple.new(self, size)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-scala-collections
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: