ffast 0.1.7 → 0.1.8

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: d1ae41b9a66311eb3308fd3ca3f69f5a06943a337f9907d502f1a2ed27342a46
4
- data.tar.gz: 80e545ae2769ab27ba39d8338b57c60626ca3f79ec5e73139c12f3cb01dfd5fb
3
+ metadata.gz: d07f3e9f3161db325a672703937f6c25aeacf21f76e835fd1547d34437a62a13
4
+ data.tar.gz: 1faf3b9d8e3bbbc6ee9b859fc5ae5779bca6750b7e510667502359db779d0e46
5
5
  SHA512:
6
- metadata.gz: fbcb874fb1c2916d0fa89d687fd9e320f248c8cc64c5193244b8d007b39cffb86b23db2ff7c3134c4d43baba1d4d99b6526831a20b3c630867691d5076ae33bc
7
- data.tar.gz: de6c3a1e706f6a3e39791a413584dc227af3ee8810628145b0844d9b4d2ac1f9d7f631c9db859a7cb6d8c7f56313b3f0aff2be4b9868627c31ece3924e79379c
6
+ metadata.gz: 2945758fe9f1a818ec8154acb3585959c2b76c557d92ddcc14fc396b13394da8607924db5e3a84d579826e77951d5a41c8c003a2a055e653e1897475fa146ed0
7
+ data.tar.gz: 6637f8426a03b2ff25b4975a0887f6d11428155764029e94956d875d85625b7ee15d17eb5c5c30876c7e70cdd3f027e1228946084a18abd362935acf62352766
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [jonatas]
@@ -10,7 +10,7 @@ AllCops:
10
10
  - 'examples/*'
11
11
  TargetRubyVersion: 2.3
12
12
 
13
- Metrics/LineLength:
13
+ Layout/LineLength:
14
14
  Enabled: false
15
15
 
16
16
  Metrics/BlockLength:
@@ -46,3 +46,12 @@ RSpec/DescribedClass:
46
46
 
47
47
  RSpec/ImplicitSubject:
48
48
  Enabled: false
49
+
50
+ Style/HashEachMethods:
51
+ Enabled: true
52
+
53
+ Style/HashTransformKeys:
54
+ Enabled: true
55
+
56
+ Style/HashTransformValues:
57
+ Enabled: true
data/README.md CHANGED
@@ -253,25 +253,29 @@ This can be represented as the following AST:
253
253
 
254
254
  We can create a query that searches for such a method:
255
255
 
256
- Fast.match?(ast,'(def $_ ... (send (send nil _) \1))') # => [:name]
256
+ Fast.match?('(def $_ ... (send (send nil _) \1))', ast) # => [:name]
257
257
 
258
258
  ## Fast.search
259
259
 
260
260
  Search allows you to go search the entire AST, collecting nodes that matches given
261
261
  expression. Any matching node is then returned:
262
262
 
263
- Fast.search(Fast.ast('a = 1'), '(int _)') # => s(:int, 1)
263
+ Fast.search('(int _)', Fast.ast('a = 1')) # => s(:int, 1)
264
264
 
265
265
  If you use captures along with a search, both the matching nodes and the
266
266
  captures will be returned:
267
267
 
268
- Fast.search(Fast.ast('a = 1'), '(int $_)') # => [s(:int, 1), 1]
268
+ Fast.search('(int $_)', Fast.ast('a = 1')) # => [s(:int, 1), 1]
269
+
270
+ You can also bind external parameters from the search:
271
+
272
+ Fast.search('(int %1)', Fast.ast('a = 1'), 1) # => [s(:int, 1)]
269
273
 
270
274
  ## Fast.capture
271
275
 
272
276
  To only pick captures and ignore the nodes, use `Fast.capture`:
273
277
 
274
- Fast.capture(Fast.ast('a = 1'), '(int $_)') # => 1
278
+ Fast.capture('(int $_)', Fast.ast('a = 1')) # => 1
275
279
 
276
280
  ## Fast.replace
277
281
 
@@ -269,6 +269,11 @@ If you use captures, it returns the node and the captures respectively:
269
269
  Fast.search('(int $_)', Fast.ast('a = 1')) # => [s(:int, 1), 1]
270
270
  ```
271
271
 
272
+ You can also bind external parameters in the search using extra arguments:
273
+ ```ruby
274
+ Fast.search('(int %1)', Fast.ast('a = 1'), 1) # => [s(:int, 1)]
275
+ ```
276
+
272
277
  ## capture
273
278
 
274
279
  To pick just the captures and ignore the nodes, use `Fast.capture`:
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'guard'
35
35
  spec.add_development_dependency 'guard-livereload'
36
36
  spec.add_development_dependency 'guard-rspec'
37
- spec.add_development_dependency 'rake', '~> 10.0'
37
+ spec.add_development_dependency 'rake'
38
38
  spec.add_development_dependency 'rspec', '~> 3.0'
39
39
  spec.add_development_dependency 'rspec-its', '~> 1.2'
40
40
  spec.add_development_dependency 'rubocop'
@@ -50,7 +50,7 @@ module Fast
50
50
  |
51
51
  \? # maybe expression
52
52
  |
53
- [\d\w_]+[\\!\?]? # method names or numbers
53
+ [\d\w_]+[=\\!\?]? # method names or numbers
54
54
  |
55
55
  \(|\) # parens `(` and `)` for tuples
56
56
  |
@@ -168,13 +168,13 @@ module Fast
168
168
  # If the node matches with the pattern it returns the node,
169
169
  # otherwise it recursively collect possible children nodes
170
170
  # @yield node and capture if block given
171
- def search(pattern, node)
172
- if (match = match?(pattern, node))
171
+ def search(pattern, node, *args)
172
+ if (match = match?(pattern, node, *args))
173
173
  yield node, match if block_given?
174
174
  match != true ? [node, match] : [node]
175
175
  else
176
176
  node.each_child_node
177
- .flat_map { |child| search(pattern, child) }
177
+ .flat_map { |child| search(pattern, child, *args) }
178
178
  .compact.flatten
179
179
  end
180
180
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fast
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jônatas Davi Paganini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-16 00:00:00.000000000 Z
11
+ date: 2020-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: astrolabe
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '10.0'
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '10.0'
152
+ version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -243,6 +243,7 @@ executables:
243
243
  extensions: []
244
244
  extra_rdoc_files: []
245
245
  files:
246
+ - ".github/FUNDING.yml"
246
247
  - ".gitignore"
247
248
  - ".projections.json"
248
249
  - ".rspec"
@@ -308,8 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
309
  - !ruby/object:Gem::Version
309
310
  version: '0'
310
311
  requirements: []
311
- rubyforge_project:
312
- rubygems_version: 2.7.6.2
312
+ rubygems_version: 3.0.3
313
313
  signing_key:
314
314
  specification_version: 4
315
315
  summary: 'FAST: Find by AST.'