smerge 0.0.1 → 0.1.0

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: 26dd9d275e84f9b95f4bdcf5d40a83b874435371
4
- data.tar.gz: 89d15861537a97ab06da286556bbd44dde35a4a7
3
+ metadata.gz: 1732cab9c4a4271972f13e67765bb107cbea5654
4
+ data.tar.gz: 2d1465d5b8ad029ebcd7ce783ccc1f258739cabe
5
5
  SHA512:
6
- metadata.gz: 56c5f01a5934eef211a6ca13a5ff63a931ebd172aa817d15881722840a19fc91c4f382867e618c2ff640f140dd5eabd833418c8ba0d531bbee295cda56fbb1d2
7
- data.tar.gz: ab7bd25ce1152fdb64209153ce9f276e7f965424fae52c454ba25c0c9ff272dfb6f45475c0f832635b6cb404d428b6d81bcd721d8ece423294fa828895986c31
6
+ metadata.gz: 7667abbaa6ada1b0df23ad3e4b9fff88ed00d41ab2b266b5b0e761752b0bea9e728b29bc554b88c4cb7c3d569ffa709a8c86c1827199031fd8d6a657693c431b
7
+ data.tar.gz: f80c5c13b4c5660c029fa2b811421a0fb484410bc5380e0ce7bb564f314835d8c85c00677f0fa9e6c3425f8a58471f2280319bf1001df8db89db8c06efee0534
@@ -1,4 +1,4 @@
1
- require 'smerge/models/rule'
1
+ require 'smerge/rule'
2
2
 
3
3
  module Smerge
4
4
  class Config
@@ -1,5 +1,7 @@
1
1
  module Smerge
2
2
  class Engine
3
+ using Matchers
4
+
3
5
  def initialize(rules)
4
6
  @rules = rules
5
7
  end
@@ -7,10 +9,10 @@ module Smerge
7
9
  def call(left, right)
8
10
  @rules.each do |rule|
9
11
  next unless rule.match(left, right)
10
- return rule.execute(left, right)
12
+ return rule.call(left, right)
11
13
  end
12
14
 
13
- nil
15
+ right
14
16
  end
15
17
  end
16
18
  end
@@ -0,0 +1,13 @@
1
+ module Smerge
2
+ module Matchers
3
+ refine Regexp do
4
+ alias_method :match_string, :match
5
+
6
+ def match(obj)
7
+ match_string(obj)
8
+ rescue TypeError => _
9
+ false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,6 @@
1
1
  require 'smerge/matchers/class'
2
2
  require 'smerge/matchers/object'
3
+ require 'smerge/matchers/regexp'
3
4
 
4
5
  module Smerge
5
6
  class Rule
@@ -20,8 +21,8 @@ module Smerge
20
21
  self.right.match(right)
21
22
  end
22
23
 
23
- def execute(left, right)
24
- block.call(left, right)
24
+ def call(left, right)
25
+ self.block.call(left, right)
25
26
  end
26
27
  end
27
28
  end
@@ -2,10 +2,6 @@ require 'smerge'
2
2
  using Smerge::Local
3
3
 
4
4
  Smerge.setup do |c|
5
- c.rule Object, Object do |left, right|
6
- right
7
- end
8
-
9
5
  c.rule Object, nil do |left, right|
10
6
  left
11
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smerge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Thorner
@@ -23,7 +23,8 @@ files:
23
23
  - lib/smerge/imports/local.rb
24
24
  - lib/smerge/matchers/class.rb
25
25
  - lib/smerge/matchers/object.rb
26
- - lib/smerge/models/rule.rb
26
+ - lib/smerge/matchers/regexp.rb
27
+ - lib/smerge/rule.rb
27
28
  - lib/smerge/setup.rb
28
29
  homepage: https://github.com/benthorner/smerge
29
30
  licenses: