rns 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
4
6
 
5
7
  # Only build master branch
6
8
  branches:
data/Gemfile CHANGED
@@ -4,4 +4,8 @@ gemspec
4
4
 
5
5
  group :test do
6
6
  gem 'rake'
7
+
8
+ platform :ruby_18 do
9
+ gem 'minitest'
10
+ end
7
11
  end
data/lib/rns.rb CHANGED
@@ -39,7 +39,7 @@ module Rns
39
39
 
40
40
  # Imports methods from objects into this namespace class as private instance methods.
41
41
  def import(imports)
42
- ns_methods = instance_methods()
42
+ ns_methods = instance_methods.map(&:to_sym)
43
43
  @_import_hash = array_to_key_value_tuples(imports).reduce({}) do |h, (obj, methods)|
44
44
  if !obj.frozen?
45
45
  raise ImportError, "#{obj} cannot be imported into Namespace because it is not frozen"
@@ -1,3 +1,3 @@
1
1
  module Rns
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -1,7 +1,26 @@
1
- require 'minitest/autorun'
1
+ require 'minitest/unit'
2
2
  require 'rns'
3
+ MiniTest::Unit.autorun
3
4
 
4
5
  class RnsTest < MiniTest::Unit::TestCase
6
+
7
+ class << self
8
+
9
+ private
10
+
11
+ # Are class variables scoped to the block they are accessed in?
12
+ # This is true in Ruby 1.9.2, but not 1.8.7 or 1.9.3...
13
+ def cvars_are_block_scoped?
14
+ c = Class.new { def set_it!() @@cvar = :something end }
15
+ c.new.set_it!
16
+ begin
17
+ remove_class_variable(:@@cvar) != :something
18
+ rescue NameError
19
+ true
20
+ end
21
+ end
22
+ end
23
+
5
24
  Math = Rns do
6
25
  def inc(n)
7
26
  n + 1
@@ -64,16 +83,19 @@ class RnsTest < MiniTest::Unit::TestCase
64
83
  end
65
84
  end
66
85
 
67
- def test_cvars_cant_be_set
68
- m = Rns do
69
- def set_cvar
70
- @@cvar = "something"
86
+ # If class variables aren't block-scoped, they're effectively out of
87
+ # Rns's jurisdiction.
88
+ if cvars_are_block_scoped?
89
+ def test_cvars_cant_be_set
90
+ m = Rns do
91
+ def set_cvar
92
+ @@cvar = "something"
93
+ end
71
94
  end
72
- end
73
95
 
74
- # this fails on 1.8.7
75
- assert_raises_frozen_error do
76
- m.set_cvar
96
+ assert_raises_frozen_error do
97
+ m.set_cvar
98
+ end
77
99
  end
78
100
  end
79
101
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-23 00:00:00.000000000 Z
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard