eac_ruby_utils 0.62.1 → 0.63.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: 76b0e92df72f0b6b552d62eda2aad5f2701409e7d8093aee4d30c5df70ee30a1
4
- data.tar.gz: b6450dc7143e3a1669df002394357c2209d51983111cefc2d8f25efbd8e5344a
3
+ metadata.gz: 988305393f16d7782424d4d46c3cfa88d805d1a06b813e87027a9f44ea2b5ce3
4
+ data.tar.gz: c8c55c9c290a618bcf090a9c7d59bd5a51055d91284ca2e8c411fdb6898f3ee0
5
5
  SHA512:
6
- metadata.gz: 7839203f7f9e9a8baa17167e4a5e0d9d812ff9028de3fb3c8298ce6bb584f6b77256b8afdfd49ff79f23d0614afcef74aa5f003ab00a0d3fc14d58816e695fce
7
- data.tar.gz: 9392bdfc10d5a2ba53de62a816c307e0d2f3e21b6731888cc0fe63a46853ed5c074d91fafc5f91194256fa33c6ddb39a930c75564db7aac3ff3967c9e4329eee
6
+ metadata.gz: c7c3cdfdef8b47a669ef14010c8a76399e4bd3febe7c860123a36a3b54dabce947ccbb5231031a11ea11540977930f10a6ca03079e8de86a47f7b4f048b4d0dc
7
+ data.tar.gz: b1ff9b89451e86ce8a76a05dff08b19b21a77c2c129f5390a2a9400b49bc5a9812eb44ec9591a323c5fb8f419d83da8321d4251cbd5ca0d07409277dabf8e82b
@@ -24,6 +24,12 @@ module EacRubyUtils
24
24
  ::File.read(content_path)
25
25
  end
26
26
 
27
+ def read_or_cache
28
+ write(yield) unless cached?
29
+
30
+ read
31
+ end
32
+
27
33
  def write(value)
28
34
  assert_directory_on_path
29
35
  ::File.write(content_path, value)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/regexp_parser'
4
+
5
+ class Regexp
6
+ # @return [::EacRubyUtils::RegexpParser]
7
+ def to_parser(&block)
8
+ ::EacRubyUtils::RegexpParser.new(self, &block)
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class RegexpParser
5
+ attr_reader :pattern, :builder_proc
6
+
7
+ def initialize(pattern, &builder_proc)
8
+ @pattern = pattern
9
+ @builder_proc = builder_proc
10
+ end
11
+
12
+ def parse(string)
13
+ internal_parse(string)[1]
14
+ end
15
+
16
+ def parse!(string)
17
+ match, result = internal_parse(string)
18
+ return result if match
19
+
20
+ raise ::ArgumentError, "String \"#{string}\" does not match pattern \"#{pattern}\""
21
+ end
22
+
23
+ private
24
+
25
+ def internal_parse(string)
26
+ m = pattern.match(string)
27
+ if m
28
+ [true, builder_proc ? builder_proc.call(m) : m]
29
+ else
30
+ [false, nil]
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.62.1'
4
+ VERSION = '0.63.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.62.1
4
+ version: 0.63.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-01 00:00:00.000000000 Z
11
+ date: 2021-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,20 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.1'
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 0.1.1
103
+ version: '0.2'
107
104
  type: :development
108
105
  prerelease: false
109
106
  version_requirements: !ruby/object:Gem::Requirement
110
107
  requirements:
111
108
  - - "~>"
112
109
  - !ruby/object:Gem::Version
113
- version: '0.1'
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: 0.1.1
110
+ version: '0.2'
117
111
  description:
118
112
  email:
119
113
  executables: []
@@ -241,6 +235,7 @@ files:
241
235
  - lib/eac_ruby_utils/patches/pathname/basename_sub.rb
242
236
  - lib/eac_ruby_utils/patches/regexp.rb
243
237
  - lib/eac_ruby_utils/patches/regexp/if_match.rb
238
+ - lib/eac_ruby_utils/patches/regexp/to_parser.rb
244
239
  - lib/eac_ruby_utils/patches/string.rb
245
240
  - lib/eac_ruby_utils/patches/string/inflector.rb
246
241
  - lib/eac_ruby_utils/patches/time.rb
@@ -249,6 +244,7 @@ files:
249
244
  - lib/eac_ruby_utils/paths_hash/entry_key_error.rb
250
245
  - lib/eac_ruby_utils/paths_hash/node.rb
251
246
  - lib/eac_ruby_utils/paths_hash/path_search.rb
247
+ - lib/eac_ruby_utils/regexp_parser.rb
252
248
  - lib/eac_ruby_utils/require_sub.rb
253
249
  - lib/eac_ruby_utils/rspec.rb
254
250
  - lib/eac_ruby_utils/rspec/conditional.rb