kleisli-run 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDE2YjNmMDJlMGFjYjc5YjAyMmJkNjQ0MWE0NWJmYTZkZmY2OGRjYw==
4
+ NWU4ODZmODNhMmU3MWI2OWZmYmExMWU5NzM1YzlmMGMzMThmY2Y1Yw==
5
5
  data.tar.gz: !binary |-
6
- ODgxY2NkYjUwYTdhMWJkYmE5OTA4OGM3YzI5ZTRkZDQ2NDcwNDExYg==
6
+ YTY4ZGY5OTRhYjQ3OGRhYTNiN2MxMzRiZDE4ZjIyOWY4ODY2ZmEyOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2Q4NDNmMjgxZjM1OWU3MGE3NWJiZDUxNGFhNmNhZWEwNWE2ODVjZWIxOTdh
10
- ZWJhYTNhM2JkYjk4MTFhMTA4NDMyZTBlMzkwNDBiN2JlMjM5ODFkZDgyMzVl
11
- NTNmNDQ2OGRkOGE1YTFjOGIyZDFiZmM3MmI0ZjkwNDQ4N2QyODg=
9
+ N2U1Mzc4ZTQ4NTIzODRhOGMyNDgyYWMxYThlMzg4YWNmMTVkZmMxNjg5Y2Uy
10
+ ZWVhYmYzMzhiMjllMGM2OTljYTc2OWIzYTVhOTgzMzNmODhhYmMwNjM0ZTEw
11
+ NTQ2NDYyYjVmNzI4MTAzZjNiMTk0ZDQxNjhiNWVmZDc0NDEzMjA=
12
12
  data.tar.gz: !binary |-
13
- NTAxMWFjY2FmODI5M2ZhMmE3NTBkOGM3MTNhNGIxNGUwODE4NThiOGY3NWYz
14
- NjhmZjgxZGE1NDFkNDE4Yzc0NmMwMDI2NTJlYjM1Mjc0Y2U4NGEyZTdiODg4
15
- MGUzMGY5MTdjNTc1ODE2NzcyYWIzOGQxNzEzNjM1MjA3MDYzNjc=
13
+ NzJhNTMwNmRkYzMxMDVlYTU5YmI0NzFhNjkzNmVlYWY4OGEyNDk1NGUwNmYw
14
+ ZDY1YmUxZTNlOWRkMDU2YmE0ZTA2MWIyNDNjYWQ1OWRjMmQ4NGY1ODY1YmE4
15
+ YTQ2MjIxNTU5NTZjYjA4MGIyYWE1NjcyMzUyZThjMmRjYzQwZTY=
@@ -1,5 +1,5 @@
1
1
  module Kleisli
2
2
  module Run
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/lib/kleisli/run.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  require "kleisli/run/version"
2
- require 'ostruct'
3
2
 
4
3
  module Kleisli
5
4
 
6
- def self.run(&block)
7
- r = Runner.new(block.binding)
5
+ def self.run(runner_impl = Runner, &block)
6
+ r = runner_impl.new(block.binding)
8
7
  begin
9
8
  res = r.instance_eval(&block)
10
9
  r.start.fmap { res }
@@ -17,7 +16,7 @@ module Kleisli
17
16
  attr_reader :start
18
17
 
19
18
  def initialize(block_binding)
20
- @struct = OpenStruct.new
19
+ @hash = {}
21
20
  @stopped = false
22
21
  @start = false
23
22
  @o_self = block_binding.eval('self')
@@ -26,9 +25,17 @@ module Kleisli
26
25
  def extract(val, m)
27
26
  called = false
28
27
  @start = m unless @start
29
- m >-> i { called = true; @struct.send("#{val}=".to_sym, i) }
28
+ m >-> i { called = true; set_value(val, i) }
30
29
  raise MonadTerminator.new(m) unless called
31
- @struct.send(val)
30
+ get_value(val)
31
+ end
32
+
33
+ def set_value(k, v)
34
+ @hash[k] = v
35
+ end
36
+
37
+ def get_value(k)
38
+ @hash[k]
32
39
  end
33
40
 
34
41
  def method_missing(m, *args)
@@ -39,9 +46,9 @@ module Kleisli
39
46
  return extract(m, args.first[:from])
40
47
  end
41
48
  if args.empty?
42
- @struct.send(m)
49
+ get_value(m)
43
50
  else
44
- @struct.send("#{m}=".to_sym, args.first)
51
+ set_value(m, args.first)
45
52
  end
46
53
  end
47
54
  end
@@ -96,5 +96,4 @@ class RunTest < Minitest::Test
96
96
  end
97
97
  assert(Success(10), s)
98
98
  end
99
-
100
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kleisli-run
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Zeligson