farseer 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faf7eb2a08edee2ef9fac3c334377895fdec31998d3f4de95f97d87c6cdc8d25
4
- data.tar.gz: af09bea3a95f554886f66ef09034a0723c7384d57a924534a94da1166ea8d2fc
3
+ metadata.gz: 2700438309a0da4774a6b4c33aa2f8dc01a61e4ae6eae9db5b5d4bc917f45263
4
+ data.tar.gz: da6f37d9b9582cfb731a39d6de9a7afbe4678b5e67df717008b8fdfa39281409
5
5
  SHA512:
6
- metadata.gz: 9da67d2aeab63fc0d89e43d9034ebc9f3c4abe5e79736d2508231907ed1acaff01cb6e7cb0e3337f0c06540977a97c07d0badd1e632e8aaf474c07a42fe044f2
7
- data.tar.gz: a27eb0388cf156ee964a90788de733bd9ad923ef1abbde9a7121812ffd30021c15d806ea0a108f9772ed3af3e4a06c8e2f699b4412afa383dfab297ff98989f1
6
+ metadata.gz: 9fdc000cff13a63b7ecd370d2a9f454736bc43a5b41ff4b001fdbc07a46ff5b6f2c17101eb27be07499c73b39faace6e00ca61ec04cfebac408054a16ba4cab2
7
+ data.tar.gz: a147d2daafaa1205e316fdcb811ddd8ae78150d060cf890081bd7ad46f2566398fad6b6941711355f13e2f897e37ac290b877e9e418a138a78759beb2fa0eeb3
data/CHANGELOG.md ADDED
@@ -0,0 +1,87 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.6.0] - 2024-06-03
11
+ ### Added
12
+ - `Farseer::Opt` to parse `0` to `1` times the wrapped parser. (`?`)
13
+ - `Farseer::Any` to parse `0` to multiple times the wrapped parser. (`*`)
14
+ - `Farseer::Many` to parse `1` to multiple times the wrapped parser. (`+`)
15
+ - A couple of instances of `Farseer::Chars` as constants:
16
+ - `Farseer::Chars::DIGITS` to parse digits from `0` to `9`.
17
+ - `Farseer::Chars::BASIC_MATH_OP` to parse symbols `+`, `-`, `*`, `/`.
18
+ - Enabled more `Lint` `rubocop` rules.
19
+ - Enabled `Performance` `rubocop` rules.
20
+
21
+ ### Changed
22
+ - Updated development dependencies
23
+
24
+ ## [0.5.0] - 2024-06-03
25
+ ### Added
26
+ - `Farseer::Char` as a single character parser.
27
+ - `Farseer::Chars` as a single character from set parser.
28
+ - Multiple instances of `Farseer::Char` as constants:
29
+ - `Farseer::Char::L_PARENS` for `(`.
30
+ - `Farseer::Char::R_PARENS` for `)`.
31
+ - `Farseer::Char::PLUS` for `+`.
32
+ - `Farseer::Char::MINUS` for `-`.
33
+ - `Farseer::Char::STAR` for `*`.
34
+ - `Farseer::Char::SLASH` for `/`.
35
+ - Enabled `Lint` `rubocop` rules.
36
+ - Enabled a couple more `Layout` `rubocop` rules.
37
+
38
+ ### Changed
39
+ - Update `muina` version requirement to `~> 0.5`
40
+
41
+ ## [0.4.0] - 2024-06-03
42
+ ### Added
43
+ - `Farseer.any_char_parser` to parse a single character from a given set.
44
+ - `irb` development dependency.
45
+ - `.gitignore.local` symlink to `.git/info/exclude`.
46
+
47
+ ### Changed
48
+ - Stop using `module_function` and change methods into singleton methods.
49
+ - Update `bundler` version.
50
+
51
+ ## [0.3.0] - 2024-06-02
52
+ ### Added
53
+ - `Farseer#ws_parser` to parse all leading whitespace.
54
+ - Multiple development dependencies:
55
+ - `flay`, `flog`, `guard`, `guard-rspec`, `guard-rubocop`, `lefthook`, and
56
+ `rubocop-performance` with corresponding `binstubs`.
57
+ - `Guardfile` with `rspec` and `rubocop` guards.
58
+ - `.lefthook.yml` including `pre-commit` and `pre-push` hooks, and `audit` and
59
+ `full_audit` tasks.
60
+
61
+ ### Changed
62
+ - Bump `muina` required version to `~> 0.4`.
63
+ - Enabled `Lint` `rubocop` department.
64
+
65
+
66
+ ## [0.2.0] - 2024-06-02
67
+ ### Added
68
+ - `Farseer::Result` to hold the result of succesful parses.
69
+ - `Farseer#char_parser` to parse a single specific character.
70
+ - `muina` as a dependency.
71
+ - `bin/console` to jump into `irb` with the project loaded.
72
+
73
+
74
+ ## [0.1.0] - 2024-06-02
75
+ ### Added
76
+ - Initial gem relase.
77
+ - Set up code quality dependencies:
78
+ - `rake`: for running common tasks.
79
+ - `rubocop`: for linting.
80
+ - `rspec`: for testing.
81
+ - `simplecov`: for code coverage.
82
+ - License the project with `The Unlicense`.
83
+ - `Rakefile` with `gem`, `rubocop`, and `rspec` tasks.
84
+ - `SECURITY.md` to keep track of maintained versions.
85
+ - `Farseer::VERSION`: Keep the gem version in a constant.
86
+ - `.ruby-version` for rbenv, with version `3.2.2`
87
+ - This `CHANGELOG.md`
data/SECURITY.md ADDED
@@ -0,0 +1,14 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Currently supported version are:
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 0.6.0 | :white_check_mark: |
10
+ | < 0.6.0 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ If you find any vulnerability please open an issue.
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Farseer
4
+ class Any
5
+ def initialize(parser)
6
+ @parser = parser
7
+ freeze
8
+ end
9
+
10
+ def parse(input)
11
+ helper(input)
12
+ end
13
+
14
+ def helper(input, tokens = [])
15
+ @parser.parse(input)
16
+ .bind { |r| helper(r.rest, [*tokens, r.token]) }
17
+ .map_none { Result.new(tokens.join, input) }
18
+ end
19
+ end
20
+ end
data/lib/farseer/chars.rb CHANGED
@@ -7,11 +7,13 @@ module Farseer
7
7
  freeze
8
8
  end
9
9
 
10
+ DIGITS = new(('0'..'9').to_a)
11
+ BASIC_MATH_OP = new(['+', '-', '*', '/'])
12
+
10
13
  def parse(input)
11
- if @chars.any? { |char| char == input[0] }
12
- Maybe.return(Result.new(input[0], input[1..]))
13
- else
14
- Maybe.none
14
+ case input[0]
15
+ when *@chars then Maybe.return(Result.new(input[0], input[1..]))
16
+ else Maybe.none
15
17
  end
16
18
  end
17
19
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Farseer
4
+ class Many
5
+ def initialize(parser)
6
+ @parser = parser
7
+ freeze
8
+ end
9
+
10
+ def parse(input)
11
+ @parser.parse(input)
12
+ .bind { |r| helper(r.rest, [r.token]) }
13
+ end
14
+
15
+ def helper(input, tokens = [])
16
+ @parser.parse(input)
17
+ .bind { |r| helper(r.rest, [*tokens, r.token]) }
18
+ .map_none { Result.new(tokens.join, input) }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Farseer
4
+ class Opt
5
+ def initialize(parser)
6
+ @parser = parser
7
+ freeze
8
+ end
9
+
10
+ def parse(input)
11
+ @parser.parse(input)
12
+ .map_none { Result.new('', input) }
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Farseer
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  public_constant :VERSION
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farseer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaporyhumo
@@ -45,11 +45,16 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - CHANGELOG.md
48
49
  - LICENSE
49
50
  - README.md
51
+ - SECURITY.md
50
52
  - lib/farseer.rb
53
+ - lib/farseer/any.rb
51
54
  - lib/farseer/char.rb
52
55
  - lib/farseer/chars.rb
56
+ - lib/farseer/many.rb
57
+ - lib/farseer/opt.rb
53
58
  - lib/farseer/result.rb
54
59
  - lib/farseer/version.rb
55
60
  homepage: https://github.com/vaporyhumo/farseer