kase 0.1.1 → 0.1.2
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/CHANGELOG.md +4 -0
- data/kase.gemspec +1 -1
- data/lib/kase/switcher.rb +19 -6
- data/lib/kase/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e196cce0e928c43b3b1fed7042abbe6f99e975c
|
4
|
+
data.tar.gz: 2b8cfd61df68dc2cb32bfad689e7f4151ed94bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9dffb5a26c729de9f6a6f8984a126708035034b544fe3d626073a1a01f86b83f244150e3ae2923ddef3b0bcbd839990b25402d56717d4a6f8fa59b24e00edd2
|
7
|
+
data.tar.gz: 8dcd7eb8dceebe67c2e0487b77d7095b0535eb431409d21141ac0aa07d2fa2a05a9af5c79927634ba4c31833ff4f25db4d5cbabc72eafcf8fd67f61757371ad5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
* (Your contributions here)
|
4
4
|
|
5
|
+
# Version 0.1.2 (2016-04-06)
|
6
|
+
|
7
|
+
* Fixed instance variables lookup inside DSL, [#4](https://github.com/lasseebert/kase/issues/4), [lasseebert](https://github.com/lasseebert)
|
8
|
+
|
5
9
|
# Version 0.1.1 (2016-04-02)
|
6
10
|
|
7
11
|
* Added error message to NoMatchError, [hosh](https://github.com/hosh)
|
data/kase.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Lasse Skindstad Ebert"]
|
10
10
|
spec.email = ["lasse@lasseebert.dk"]
|
11
11
|
|
12
|
-
spec.summary = %q{A tool to
|
12
|
+
spec.summary = %q{A tool to pattern match [:ok, result]-like return values}
|
13
13
|
spec.homepage = "https://github.com/lasseebert/kase"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/kase/switcher.rb
CHANGED
@@ -36,24 +36,37 @@ module Kase
|
|
36
36
|
def switch(&block)
|
37
37
|
context = eval("self", block.binding)
|
38
38
|
dsl = DSL.new(self, context)
|
39
|
-
|
40
|
-
dsl.instance_eval(&block)
|
39
|
+
dsl.__call(&block)
|
41
40
|
validate!
|
42
41
|
result
|
43
42
|
end
|
44
43
|
|
45
44
|
class DSL
|
46
45
|
def initialize(switcher, context)
|
47
|
-
@
|
48
|
-
@
|
46
|
+
@__switcher = switcher
|
47
|
+
@__context = context
|
48
|
+
end
|
49
|
+
|
50
|
+
def __call(&block)
|
51
|
+
@__context.instance_variables.each do |name|
|
52
|
+
next if name.to_s =~ /^@__/
|
53
|
+
instance_variable_set(name, @__context.instance_variable_get(name))
|
54
|
+
end
|
55
|
+
|
56
|
+
instance_eval(&block)
|
57
|
+
|
58
|
+
instance_variables.each do |name|
|
59
|
+
next if name.to_s =~ /^@__/
|
60
|
+
@__context.instance_variable_set(name, instance_variable_get(name))
|
61
|
+
end
|
49
62
|
end
|
50
63
|
|
51
64
|
def on(*args, &block)
|
52
|
-
@
|
65
|
+
@__switcher.on(*args, &block)
|
53
66
|
end
|
54
67
|
|
55
68
|
def method_missing(method, *args, &block)
|
56
|
-
@
|
69
|
+
@__context.send(method, *args, &block)
|
57
70
|
end
|
58
71
|
end
|
59
72
|
end
|
data/lib/kase/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Skindstad Ebert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,5 +110,5 @@ rubyforge_project:
|
|
110
110
|
rubygems_version: 2.5.1
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
|
-
summary: A tool to
|
113
|
+
summary: A tool to pattern match [:ok, result]-like return values
|
114
114
|
test_files: []
|