which_ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,11 +15,16 @@ module WhichRuby
15
15
  alias_method :rt, :ruby_type
16
16
 
17
17
  def is_ruby_type?(type)
18
+ type = type.to_sym
18
19
  ruby_type == (@@mappings[type] || type)
19
20
  end
20
21
 
21
22
  alias_method :r?, :is_ruby_type?
22
23
 
24
+ def ruby_scope(type)
25
+ yield if is_ruby_type?(type)
26
+ end
27
+
23
28
  def ruby_version
24
29
  RUBY_VERSION
25
30
  end
@@ -31,6 +31,15 @@ access the API:
31
31
  => true
32
32
  </pre>
33
33
 
34
+ define execution scopes:
35
+
36
+ <pre>
37
+ > ruby_scope(:jruby){"foo"}
38
+ => "foo"
39
+ > ruby_scope(:rbx){"foo"}
40
+ => nil
41
+ </pre>
42
+
34
43
  h2. Examples
35
44
 
36
45
  Run the examples with different runtimes, jruby for example:
@@ -45,4 +45,9 @@ class TestWhichRuby < Test::Unit::TestCase
45
45
  assert_equal(true, @helper.jruby?)
46
46
  end
47
47
 
48
+ def test_ruby_scope
49
+ @helper.stubs(:ruby_engine).returns("jruby")
50
+ assert_equal("foo", @helper.ruby_scope(:jruby){"foo"})
51
+ assert_equal(nil, @helper.ruby_scope(:ree){"foo"})
52
+ end
48
53
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: which_ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Peter Schr\xC3\xB6der"