farseer 0.1.0 → 0.3.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: 238fd129d9699a389fb3cf9bef59a95993914607241cc954191ac08065033b0a
4
- data.tar.gz: aae60547d3a5f13dba7f6915dad362c72583d055b18419a0c4f2590b85389bf4
3
+ metadata.gz: d5e83ade307369289f0309fc0256195a5a3a04fe32fb0fd04861ee82cbd4951f
4
+ data.tar.gz: 7b8f7f64e9df97de253b9fa63d4ff452c47baafcbabb9693f0b4f39d30190015
5
5
  SHA512:
6
- metadata.gz: 8e0d0adccbeb4911239704e7f2a309ab2af546ce3501511d37b07d7354518a36067abb0407dc6ef0a7936e9c53ae1461081ddf68f2213361c6c1a165a972b61d
7
- data.tar.gz: e38631ef62deb3172a4fd58b170c960c4e5c0e47332969738716d10f55e4a3e19c803af06de332599242fe0984d38bc8ef04d3f70cb69c9a825f40937d828d37
6
+ metadata.gz: 8b262cadaffd22a2d97d5c3a5bad3f216a71df75b2c87d8536e1310249b8b5053735c2d6a918716edcbaface20c3629a45527ccd07503223118ae2daf92a4150
7
+ data.tar.gz: d7f8ef841e8b6f32dfda21fa2000ef80f30a28e7339394940b7b67b7ae12a052e99474d013b15f2359d1b52e09d4c8a06722990ba40c04622cb4d4ba6d72f3c3
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Farseer
4
+ class Result
5
+ def initialize(token, rest)
6
+ @token = token
7
+ @rest = rest
8
+ freeze
9
+ end
10
+ attr_reader :token, :rest
11
+
12
+ def eql?(other)
13
+ self.class.eql?(other.class) and
14
+ self.token.eql?(other.token) and
15
+ self.rest.eql?(other.rest)
16
+ end
17
+ alias == eql?
18
+ end
19
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Farseer
4
- VERSION = '0.1.0'
4
+ VERSION = '0.3.0'
5
5
  public_constant :VERSION
6
6
  end
data/lib/farseer.rb CHANGED
@@ -1,10 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'muina'
3
4
  require 'zeitwerk'
4
5
  loader = Zeitwerk::Loader::for_gem
5
6
  loader.setup
6
7
 
7
8
  module Farseer
9
+ WS_REGEX = /^(\s*)(.*)$/
10
+ Maybe = Muina::Maybe
11
+
12
+ module_function
13
+
14
+ def char_parser
15
+ ->(char, input) { Farseer.__send__(:char_parser_helper, char, input) }.curry
16
+ end
17
+
18
+ def ws_parser
19
+ ->(input) {
20
+ match = input.match(WS_REGEX)
21
+
22
+ Maybe.return(Result.new(match[1], match[2]))
23
+ }
24
+ end
25
+
26
+ def char_parser_helper(char, input)
27
+ case input[0]
28
+ when char then Maybe.return(Result.new(input[0], input[1..]))
29
+ else Maybe.none
30
+ end
31
+ end
32
+ private :char_parser_helper
8
33
  end
9
34
 
10
35
  loader.eager_load
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farseer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.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
+ - !ruby/object:Gem::Dependency
14
+ name: muina
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.4'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: zeitwerk
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -34,6 +48,7 @@ files:
34
48
  - LICENSE
35
49
  - README.md
36
50
  - lib/farseer.rb
51
+ - lib/farseer/result.rb
37
52
  - lib/farseer/version.rb
38
53
  homepage: https://github.com/vaporyhumo/farseer
39
54
  licenses: