uber 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/uber/options.rb +7 -5
- data/lib/uber/version.rb +1 -1
- data/test/options_test.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 516c9e7445cdc09ca9cc33afce8ffbb32494d1c0
|
4
|
+
data.tar.gz: d9e02ab06a8282723242cd9486331a44f1c42ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c517333088ac322d06847427c10694c6fbea60e20e74e433fb0f41f035478ea326c85169e6bf80572c81e6170684cb0b659ce5311a2ffc6476f09600913896d9
|
7
|
+
data.tar.gz: 4cb7b1e5069343dc6209794f01f23af9305bec11a4d8dad6be89f3ab18e62793edf78272b56ab655a1ac1dbfb5fea7905aaf5ecc5ef8bbf0133ab1ed0d1037e3
|
data/CHANGES.md
CHANGED
data/lib/uber/options.rb
CHANGED
@@ -41,13 +41,15 @@ module Uber
|
|
41
41
|
|
42
42
|
class Value # TODO: rename to Value.
|
43
43
|
def initialize(value, options={})
|
44
|
-
@value, @
|
44
|
+
@value, @dynamic = value, options[:dynamic]
|
45
45
|
|
46
|
-
|
46
|
+
@callable = true if @value.kind_of?(Proc)
|
47
|
+
|
48
|
+
return if options.has_key?(:dynamic)
|
47
49
|
|
48
50
|
# conventional behaviour:
|
49
|
-
@
|
50
|
-
@
|
51
|
+
@dynamic = true if @callable
|
52
|
+
@dynamic = true if @value.is_a?(Symbol)
|
51
53
|
end
|
52
54
|
|
53
55
|
def evaluate(context, *args)
|
@@ -57,7 +59,7 @@ module Uber
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def dynamic?
|
60
|
-
@
|
62
|
+
@dynamic
|
61
63
|
end
|
62
64
|
|
63
65
|
private
|
data/lib/uber/version.rb
CHANGED
data/test/options_test.rb
CHANGED
@@ -10,6 +10,7 @@ class UberOptionTest < MiniTest::Spec
|
|
10
10
|
it { Value.new(true).dynamic?.must_equal nil }
|
11
11
|
it { Value.new("loud").dynamic?.must_equal nil }
|
12
12
|
it { Value.new(:loud, :dynamic => false).dynamic?.must_equal false }
|
13
|
+
it { Value.new("loud", :dynamic => true).dynamic?.must_equal true }
|
13
14
|
|
14
15
|
it { Value.new(lambda {}).dynamic?.must_equal true }
|
15
16
|
it { Value.new(Proc.new{}).dynamic?.must_equal true }
|
@@ -27,6 +28,8 @@ class UberOptionTest < MiniTest::Spec
|
|
27
28
|
it { Value.new(:version).evaluate(object.extend(version)).must_equal 999 }
|
28
29
|
it { Value.new("version", :dynamic => true).evaluate(object.extend(version)).must_equal 999 }
|
29
30
|
it { Value.new(:version, :dynamic => false).evaluate(object.extend(version)).must_equal :version }
|
31
|
+
|
32
|
+
it { Value.new(lambda { :loud }, :dynamic => true).evaluate(object).must_equal :loud }
|
30
33
|
end
|
31
34
|
|
32
35
|
describe "passing options" do
|