rns 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/Gemfile +4 -0
- data/lib/rns.rb +1 -1
- data/lib/rns/version.rb +1 -1
- data/test/rns_test.rb +31 -9
- metadata +2 -2
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
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"
|
data/lib/rns/version.rb
CHANGED
data/test/rns_test.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
|
-
require 'minitest/
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
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.
|
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-
|
12
|
+
date: 2012-07-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|