srx 0.4.0 → 0.5.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: dd12a62cf9596aa2792d986d8bb7c63d2b624d15a8e3f87053fb5ac3baa36a94
4
- data.tar.gz: 358ccbb5310e6ca626a5459130c63a14c429043c0cc2d6333e49dbef7657448a
3
+ metadata.gz: 153660bff1d0fc6c00bebc7fae34b11d9f70b16c54628ebf5023f8815b105b45
4
+ data.tar.gz: 1e01d70b8f8a3cb032e62137f7ab1224e3942bb2314a47c05af295ff6431ba35
5
5
  SHA512:
6
- metadata.gz: ec8d917c4ef8710f8e79bdeeb9ee88c23c3696f84689e1eec44a2559c85763a69530b99d8e2a104949d57349d7f1948f12c264a5fe341d5fe08deec350e5daf3
7
- data.tar.gz: b3b8c1e7db078cc1d8792b59b47d009bbee104af387cec6eacf060aa3e22d126710db8752de68f8b11dd328d3a88a83fe65ea871ae4f623412108517729a2897
6
+ metadata.gz: e3ac37ecbb4bba2c31d90d32f3b4c0ae4cd236a70e6ab25c340f35c52e12364d4aad14dff01e0b8381fd28811ea46f6f861d1ff23540c0f280575cbbd24d1262
7
+ data.tar.gz: b89f432b242e1bd8e2b8e5917888d78f75ef9749b2add35e9991a4d33e38be8876c110e107b994f27bdaf214612f231c1cd2041a0090759f053d839f7bd3d741
data/.rubocop.yml CHANGED
@@ -1,5 +1,9 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ inherit_mode:
4
+ merge:
5
+ - Exclude
6
+
3
7
  AllCops:
4
8
  TargetRubyVersion: 2.4
5
9
  SuggestExtensions: false
data/.rubocop_todo.yml CHANGED
@@ -1,15 +1,15 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-02-15 14:53:27 UTC using RuboCop version 1.9.1.
3
+ # on 2021-02-25 04:43:35 UTC using RuboCop version 1.10.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 6
9
+ # Offense count: 5
10
10
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
11
11
  Metrics/AbcSize:
12
- Max: 26
12
+ Max: 24
13
13
 
14
14
  # Offense count: 6
15
15
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
@@ -25,9 +25,9 @@ Metrics/CyclomaticComplexity:
25
25
  # Offense count: 9
26
26
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
27
27
  Metrics/MethodLength:
28
- Max: 25
28
+ Max: 26
29
29
 
30
- # Offense count: 2
30
+ # Offense count: 1
31
31
  # Configuration parameters: IgnoredMethods.
32
32
  Metrics/PerceivedComplexity:
33
33
  Max: 10
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.0] - 2021-02-25
4
+
5
+ - When `nil` is supplied for the `language` parameter, it is now treated as the
6
+ empty string for rule-matching purposes (previously it would match no rules)
7
+
3
8
  ## [0.4.0] - 2021-02-18
4
9
 
5
10
  - Optimize memory usage
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- srx (0.4.0)
4
+ srx (0.5.0)
5
5
  nokogiri (~> 1.11)
6
6
 
7
7
  GEM
data/lib/srx/data.rb CHANGED
@@ -130,13 +130,13 @@ module Srx
130
130
  # Eagerly load everything for this class because before_break and
131
131
  # after_break can be legitimately nil, so lazy loading gets ugly.
132
132
 
133
- @break = @xml['break'].nil? || @xml['break'] == 'yes'
133
+ @break = @xml['break'].then { |brk| brk.nil? || brk == 'yes' }
134
134
 
135
135
  @before_break = xpath(:beforebreak).first&.text.then do |pattern|
136
136
  IcuRegex.compile(pattern) if pattern
137
137
  end
138
138
 
139
- @after_break ||= xpath(:afterbreak).first&.text.then do |pattern|
139
+ @after_break = xpath(:afterbreak).first&.text.then do |pattern|
140
140
  IcuRegex.compile(pattern) if pattern
141
141
  end
142
142
  end
data/lib/srx/engine.rb CHANGED
@@ -45,9 +45,11 @@ module Srx
45
45
  names.flat_map { |name| rule_map[name].rules }
46
46
  end
47
47
 
48
- # @param language [String]
48
+ # @param language [String] nil treated as empty string
49
49
  # @return [Array<String>]
50
50
  def rule_names(language)
51
+ language ||= ''
52
+
51
53
  @data.map_rules.map do |lang_map|
52
54
  next unless lang_map.language_pattern.match?(language)
53
55
 
@@ -58,7 +60,6 @@ module Srx
58
60
  end
59
61
 
60
62
  # @param str [String]
61
- # @param pos [Integer] the position to start searching from
62
63
  # @param rules [Array<Data::LanguageRule::Rule>]
63
64
  # @return [Array<Array(Integer,Data::LanguageRule::Rule)>] an array of pairs
64
65
  # of 1) the position of a break, and 2) the rule that matched at that
data/lib/srx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Srx
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Madlon-Kay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri