farseer 0.2.0 → 0.4.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
  SHA256:
3
- metadata.gz: 3b8bac73063c688f56761f2caa1b1d39e85d5b6d223c91b6ac740e67cabef2fd
4
- data.tar.gz: 0e7dc8649076c4e3a4dc64fe82ddd33502aefac07d88d9c25f6afd03697c34c5
3
+ metadata.gz: 0def0ee29c72d62793716f625d64e599c00f02a30f790062d9e7ae61fb905fea
4
+ data.tar.gz: 53701b2c7ce3ed0ff8744b43d48587be8ee4530cb776be24cd5ba87eb908dd19
5
5
  SHA512:
6
- metadata.gz: 720de5181905dc67ba3d8d79d0b521f9e2b04e363b222e16056a59da06aaac70b7cf521229fbda7063cadd7719361512cfc4aa62bb66a7811e25a71d1085144e
7
- data.tar.gz: 5194bf97b874845e39f5e1c1f5cedc110dbf603f3fc97f55f482ff6d69dece2a6df67a525dfffdfb1cf0bb3ee31423a46d44ae9649f03d1f39be018d52a668f0
6
+ metadata.gz: 5ef7c3e3fc84215f25c5ea48d9e8af9d5c8bbed1f4bd01bd0756259c5228008ef0c519d01987da29b0dc200dcddc3e5161de9063a6af3c8611ba7e7c1e54c2fc
7
+ data.tar.gz: a3d7fab449c4904680e265547c4416ddff9c2a16ba0b4c047ecb9975d6fedc825d50b78e2c0ff52d8a5aaa84b9e4ce1dda4348fe869bf76f276877280a06b107
@@ -10,7 +10,7 @@ module Farseer
10
10
  attr_reader :token, :rest
11
11
 
12
12
  def eql?(other)
13
- self.class.eql?(other.class) and
13
+ self.class.eql?(other.class) and
14
14
  self.token.eql?(other.token) and
15
15
  self.rest.eql?(other.rest)
16
16
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Farseer
4
- VERSION = '0.2.0'
4
+ VERSION = '0.4.0'
5
5
  public_constant :VERSION
6
6
  end
data/lib/farseer.rb CHANGED
@@ -6,18 +6,41 @@ loader = Zeitwerk::Loader::for_gem
6
6
  loader.setup
7
7
 
8
8
  module Farseer
9
+ WS_REGEX = /^(\s*)(.*)$/
9
10
  Maybe = Muina::Maybe
10
11
 
11
- module_function
12
+ def self.any_char_parser
13
+ ->(chars, input) { Farseer.__send__(:any_char_parser_helper, chars, input) }.curry
14
+ end
15
+
16
+ def self.char_parser
17
+ ->(char, input) { Farseer.__send__(:char_parser_helper, char, input) }.curry
18
+ end
12
19
 
13
- def char_parser
14
- ->(char, input) {
15
- case input[0]
16
- when char then Maybe.return(Result.new(input[0], input[1..]))
17
- else Maybe.none
18
- end
20
+ def self.ws_parser
21
+ ->(input) {
22
+ match = input.match(WS_REGEX)
23
+
24
+ Maybe.return(Result.new(match[1], match[2]))
19
25
  }
20
26
  end
27
+
28
+ private
29
+
30
+ def self.char_parser_helper(char, input)
31
+ case input[0]
32
+ when char then Maybe.return(Result.new(input[0], input[1..]))
33
+ else Maybe.none
34
+ end
35
+ end
36
+
37
+ def self.any_char_parser_helper(chars, input)
38
+ if chars.any? { |char| char == input[0] }
39
+ Maybe.return(Result.new(input[0], input[1..]))
40
+ else
41
+ Maybe.none
42
+ end
43
+ end
21
44
  end
22
45
 
23
46
  loader.eager_load
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farseer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaporyhumo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-02 00:00:00.000000000 Z
11
+ date: 2024-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: muina
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement