sexp_cli_tools 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -1
- data/lib/sexp_cli_tools/cli.rb +1 -1
- data/lib/sexp_cli_tools/version.rb +1 -1
- data/lib/sexp_cli_tools.rb +7 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfd7461cf33cec563afc13f39afaebceaa45dc09fa3eb45218bdc6972b95b306
|
4
|
+
data.tar.gz: 36ec4b06baabaf5948db2fc6a1f684de53d7cdab792c10374676163b4282d3f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ecf793511ac338cc9c5189b4bb29a99947072d2eb96a02ed1e5710714c4edc15376bf83708eeb802140f5e82d12e248c9329892124531af0733767bb87ef421
|
7
|
+
data.tar.gz: d0c51c4cef9bddba9582ff525ce3d699186b881775d619fb310235bce90123cb40db0d6a2b044a8a7c843af680875e6b34110ac0a728e152171c06ff8b065033
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Lets imagine a scenario where we have achieved total consensus in an organizatio
|
|
18
18
|
#### Goal
|
19
19
|
|
20
20
|
- Replace methods that call super with a hook method
|
21
|
-
- Modify parent
|
21
|
+
- Modify parent class' implementation of the supered method to call hook methods
|
22
22
|
|
23
23
|
#### Initial state
|
24
24
|
|
@@ -95,6 +95,11 @@ What isn't show in [the commit which added the `Sexp::Matcher`](https://github.c
|
|
95
95
|
|
96
96
|
Setting up a unit test can help close that iteration loop. [Consider the unit test for `SexpCliTools::Matchers::SuperCaller`](test/sexp_cli_tools/matchers/super_caller_test.rb)
|
97
97
|
|
98
|
+
Allowing users to experiment with s-expressions might enable exploration and discovery. The `sexp find` command also supports inline s-expressions. Try these in your projects:
|
99
|
+
|
100
|
+
- `sexp find '(class ___)'` to find class definitions
|
101
|
+
- `sexp find '[include (case ___)]'` to find case statements
|
102
|
+
|
98
103
|
#### Hook methods from super callers
|
99
104
|
|
100
105
|
#### Hook calls from super methods
|
data/lib/sexp_cli_tools/cli.rb
CHANGED
@@ -10,7 +10,7 @@ module SexpCliTools
|
|
10
10
|
|
11
11
|
desc "find sexp-matcher [**/*.rb]", "Finds Ruby files matching the s-expression matcher in the glob pattern. Defaults to search all Ruby files with the pattern **/*.rb"
|
12
12
|
def find(requested_sexp_matcher, glob="**/*.rb")
|
13
|
-
sexp_matcher = SexpCliTools::MATCHERS
|
13
|
+
sexp_matcher = SexpCliTools::MATCHERS[requested_sexp_matcher]
|
14
14
|
Pathname.glob(glob).each do |path|
|
15
15
|
puts path.to_s if sexp_matcher.satisfy?(RubyParser.new.parse(path.read))
|
16
16
|
end
|
data/lib/sexp_cli_tools.rb
CHANGED
@@ -8,9 +8,11 @@ require_relative "sexp_cli_tools/matchers/super_caller"
|
|
8
8
|
module SexpCliTools
|
9
9
|
class Error < StandardError; end
|
10
10
|
|
11
|
-
MATCHERS =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
MATCHERS = Hash
|
12
|
+
.new {|hash, key| hash[key] = Sexp::Matcher.parse(key) }
|
13
|
+
.merge({
|
14
|
+
"child-class" => Sexp::Matcher.parse('(class _ (const _) ___)'),
|
15
|
+
"parent-class" => Sexp::Matcher.parse('(class _ [not? (const _)] ___)'),
|
16
|
+
"super-caller" => Matchers::SuperCaller,
|
17
|
+
})
|
16
18
|
end
|