kase 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb222da1a962d8afccb1b98556a72e2e4160897e
4
- data.tar.gz: 6b10ed97e49ae29112a432bc84fbda91171980c8
3
+ metadata.gz: 8e196cce0e928c43b3b1fed7042abbe6f99e975c
4
+ data.tar.gz: 2b8cfd61df68dc2cb32bfad689e7f4151ed94bb0
5
5
  SHA512:
6
- metadata.gz: c1fb61b66deed365819d02994d2384b83c5ebfc687297c04c6b5a9349efde4e4a56b63e71deb129eceb0f8bdf8f9c286900e608f01acb33a14b1603577fc3a39
7
- data.tar.gz: 8027035e607c4df711bbc2a07b55e01e6a207aa039371df62a66f64842e2a579242dd5ddf12ef61a2b12ff7c07c9f62dbdb8da15b047a47284cc27640c3313a1
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 parse [:ok, result]-like return values}
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
- @switcher = switcher
48
- @context = context
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
- @switcher.on(*args, &block)
65
+ @__switcher.on(*args, &block)
53
66
  end
54
67
 
55
68
  def method_missing(method, *args, &block)
56
- @context.send(method, *args, &block)
69
+ @__context.send(method, *args, &block)
57
70
  end
58
71
  end
59
72
  end
data/lib/kase/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kase
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-02 00:00:00.000000000 Z
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 parse [:ok, result]-like return values
113
+ summary: A tool to pattern match [:ok, result]-like return values
114
114
  test_files: []