Browse Source

merge converters into filters

Alois Mahdal 9 years ago
parent
commit
e3c8f75b93
1 changed files with 12 additions and 33 deletions
  1. 12
    33
      src/ffoo/saturnin_urimagic.sh

+ 12
- 33
src/ffoo/saturnin_urimagic.sh View File

@@ -12,7 +12,9 @@ __saturnin_urimagic__flt_exps() {
12 12
       | perl -ne '
13 13
             next unless m/\b([a-zA-Z]\w*\s*=\s*\w+)\b/;
14 14
             print "$1\n";
15
-        '
15
+        ' \
16
+      | sed -re 's/\s*=\s*/ /' \
17
+      | tr '[:upper:]' '[:lower:]'
16 18
 }
17 19
 
18 20
 
@@ -24,7 +26,8 @@ __saturnin_urimagic__flt_ids() {
24 26
       | perl -ne '
25 27
             next unless m/\b([a-zA-Z]\w*#\w+)\b/;
26 28
             print "$1\n";
27
-        '
29
+        ' \
30
+      | tr '#' ' '
28 31
 }
29 32
 
30 33
 
@@ -33,10 +36,10 @@ __saturnin_urimagic__flt_tags() {
33 36
     # Hack "tags" like bug123 out of the text
34 37
     #
35 38
     tr ' ' '\n' \
36
-      | grep -E '^[a-zA-Z]+[0-9]+$'
39
+      | grep -E '^[a-zA-Z]+[0-9]+$' \
40
+      | sed -r 's/([a-zA-Z]+)([0-9])/\1 \2/'
37 41
 }
38 42
 
39
-
40 43
 __saturnin_urimagic__flt_kws() {
41 44
     #
42 45
     # Hack out lines that look like kw expressions
@@ -85,11 +88,11 @@ saturnin_urimagic__scan() {
85 88
         ##
86 89
         # process each pipe *async* by different filter
87 90
         #
88
-        < maybe_uris ${p}flt_uris                            > uris &
89
-        < maybe_ids  ${p}flt_ids  | ${p}conv_id  | ${p}deref > uris_from_ids &
90
-        < maybe_exps ${p}flt_exps | ${p}conv_exp | ${p}deref > uris_from_exps &
91
-        < maybe_tags ${p}flt_tags | ${p}conv_tag | ${p}deref > uris_from_tags &
92
-        < maybe_kws  ${p}flt_kws  |                ${p}deref > uris_from_kws &
91
+        < maybe_uris ${p}flt_uris             > uris &
92
+        < maybe_ids  ${p}flt_ids  | ${p}deref > uris_from_ids &
93
+        < maybe_exps ${p}flt_exps | ${p}deref > uris_from_exps &
94
+        < maybe_tags ${p}flt_tags | ${p}deref > uris_from_tags &
95
+        < maybe_kws  ${p}flt_kws  | ${p}deref > uris_from_kws &
93 96
         ##
94 97
         # print result *sync* in correct order
95 98
         #
@@ -105,30 +108,6 @@ saturnin_urimagic__scan() {
105 108
 }
106 109
 
107 110
 
108
-__saturnin_urimagic__conv_id() {
109
-    #
110
-    # Convert doer-like ID to kw expression
111
-    #
112
-    tr '#' ' '
113
-}
114
-
115
-
116
-__saturnin_urimagic__conv_tag() {
117
-    #
118
-    # Convert tag to kw expression
119
-    #
120
-    sed -r 's/([a-zA-Z]+)([0-9])/\1 \2/'
121
-}
122
-
123
-
124
-__saturnin_urimagic__conv_exp() {
125
-    #
126
-    # Convert equal sign expression to kw expression
127
-    #
128
-    sed -re 's/\s*=\s*/ /' | tr '[:upper:]' '[:lower:]'
129
-}
130
-
131
-
132 111
 __saturnin_urimagic__deref() {
133 112
     #
134 113
     # Turn keyword or query (like "g hello" for google) to URI