File: 20append_addins_ruby.nsc

package info (click to toggle)
ngraph-gtk 6.09.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,036 kB
  • sloc: ansic: 113,697; sh: 5,833; ruby: 1,824; makefile: 590; cpp: 373; xml: 208; sed: 39; awk: 11
file content (65 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! ngraph
if system::plugin_check ruby
then
    true
else
    exit
fi

if exist -q menu
then
    new regexp name=ADDIN
    regexp:ADDIN:@='^#\s*Description:\s*(.+)'

    new regexp name=COMMENT
    regexp:COMMENT:@='^#'

    new io name=ADDIN
    io:ADDIN:mode="r"

    new sarray name=ADDIN
    sarray::delimiter=","

    for addin in "${system::home_dir}"/*.rb "${system::data_dir}"/addin/*.rb
    do
	if [ -f "$addin" ]
	then
	    io:ADDIN:open "$addin"
	    while l=`get io -field gets`
	    do
		if regexp:COMMENT:match "$l"
		then
		    if regexp:ADDIN:match "$l"
		    then
			sarray:ADDIN:split "${regexp:ADDIN:get:'0 1'}"
			if [ ${sarray:ADDIN:num} -gt 3 ]
			then
			    new sarray name=TMP
			    sarray:TMP:push "${sarray:ADDIN:shift}"
			    sarray:TMP:push "${sarray:ADDIN:shift}"
			    sarray:TMP:push "${sarray:ADDIN:join:','}"
			    cpy sarray:TMP,ADDIN @
			    del sarray:TMP
			fi
			if [ ${sarray:ADDIN:num} -eq 3 ]
			then
			    sarray:ADDIN:put 2 "$addin ${sarray:ADDIN:get:2}"
			else
			    sarray:ADDIN:put 2 "$addin"
			fi
			sarray:ADDIN:unshift "ruby.nsc"
			menu::addin_list_append sarray:ADDIN
		    fi
		else
		    break
		fi
	    done
	    io:ADDIN:close
	fi
    done

    del regexp:ADDIN
    del regexp:COMMENT
    del io:ADDIN
    del sarray:ADDIN
fi