rscript 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rscript.rb +25 -124
- data/lib/rscript_base.rb +8 -12
- metadata +7 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bcf43718d97e71fe37bee3a62f1770d1a55254e59d892462f879864faf653688
|
4
|
+
data.tar.gz: ff8a1cf984cc885b90d119a47b9354185df2b16081f7547feb8b5e2ab1bb1fc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc56fc7b376efeeabf272a0f85d4512daf274b2203d1ede851abc05e37685e895e9bacf8b0a5b66741b6646f2b5ea45e4e880887af785aeaa585781ab964597b
|
7
|
+
data.tar.gz: 2d70b5ede964d1516e90c0a22887ccf714cf6bb7cccdd678b93ff2d07a9df767879397eaf4c2d172dbabeb2c81dc78c73de27064cfcbc80950d6e163160b2fc8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rscript.rb
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
# file: rscript.rb
|
4
4
|
|
5
5
|
# created: 1-Jul-2009
|
6
|
-
# updated:
|
6
|
+
# updated: 11-Aug-2018
|
7
7
|
|
8
8
|
# modification:
|
9
9
|
|
10
|
+
# 11-Aug-2018: Added the keyword auto: false to RxfHelper for clarity
|
10
11
|
# 30-Jul-2018: feature: A list of job ids can now be returned
|
11
12
|
# 28-Jul-2018: feature: Jobs are now looked up from a Hash object
|
12
13
|
# 13-Jul-2018: bug fix: The use of a cache is now optional
|
@@ -47,137 +48,37 @@ require 'hashcache'
|
|
47
48
|
require 'rexle'
|
48
49
|
|
49
50
|
|
50
|
-
class
|
51
|
-
|
52
|
-
def initialize(log: nil, pkg_src: '', cache: 5, debug: false, type: 'job')
|
53
|
-
|
54
|
-
@log = log
|
55
|
-
@cache = cache
|
56
|
-
@rsf_cache = HashCache.new({cache: cache}) if cache and cache > 0
|
57
|
-
@debug = debug
|
58
|
-
@jobname = type
|
59
|
-
|
60
|
-
end
|
51
|
+
class RScriptBase
|
61
52
|
|
62
|
-
def
|
63
|
-
|
64
|
-
a.map(&:first).uniq
|
53
|
+
def initialize(debug: false)
|
54
|
+
@debug = debug
|
65
55
|
end
|
66
56
|
|
67
|
-
def read(
|
68
|
-
|
69
|
-
args = raw_args.clone
|
70
|
-
@log.info 'RScript/read: args: ' + args.inspect if @log
|
71
|
-
|
72
|
-
threads = []
|
73
|
-
|
74
|
-
if args.to_s[/\/\/#{@jobname}:/] then
|
75
|
-
ajob = ''
|
76
|
-
args.each_index do |i|
|
77
|
-
if args[i].to_s[/\/\/#{@jobname}:/] then
|
78
|
-
ajob = $'; args[i] = nil
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
args.compact!
|
83
|
-
|
84
|
-
a = read_rsfdoc(args)
|
85
|
-
job = a.assoc(ajob.to_sym)
|
86
|
-
out, attr = job.last[:code], job.last[:attributes]
|
87
|
-
|
88
|
-
raise "job not found" unless out.length > 0
|
89
|
-
out
|
90
|
-
|
91
|
-
else
|
92
|
-
out = read_rsfdoc(args).map {|x| x.last[:code]}.join("\n")
|
93
|
-
end
|
94
|
-
|
95
|
-
@log.info 'RScript/read: code: ' + out.inspect if @log
|
96
|
-
|
97
|
-
[out, args, attr]
|
57
|
+
def read(doc)
|
58
|
+
doc.root.xpath('//script').map {|s| run_script(s)}.join(';')
|
98
59
|
end
|
99
|
-
|
100
|
-
def reset()
|
101
|
-
@rsf_cache.reset
|
102
|
-
end
|
103
|
-
|
104
|
-
# note: run() was copied from the development file rscript-wrapper.rb
|
105
|
-
def run(raw_args, params={}, rws=self)
|
106
|
-
|
107
|
-
@log.info 'RScript/run: raw_args: ' + raw_args.inspect if @log
|
108
|
-
puts 'raw_args: ' + raw_args.inspect if @debug
|
109
|
-
|
110
|
-
if params and params[:splat] then
|
111
|
-
params.each do |k,v|
|
112
|
-
params.delete k unless k == :splat or k == :package or k == :job or k == :captures
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
if params and params[:splat] and params[:splat].length > 0 then
|
117
|
-
h = params[:splat].first[1..-1].split('&').inject({}) do |r,x|
|
118
|
-
k, v = x.split('=')
|
119
|
-
v ? r.merge(k[/\w+$/].to_sym => v) : r
|
120
|
-
end
|
121
|
-
params.merge! h
|
122
|
-
end
|
123
|
-
|
124
|
-
code2, args, attr = self.read raw_args.clone
|
125
|
-
puts 'code2 : ' + code2.inspect if @debug
|
126
|
-
@log.info 'RScript/run: code2: ' + code2 if @log
|
127
|
-
|
128
|
-
begin
|
129
|
-
|
130
|
-
r = eval code2
|
131
|
-
|
132
|
-
params = {}
|
133
|
-
|
134
|
-
return r
|
135
|
-
|
136
|
-
rescue Exception => e
|
137
|
-
params = {}
|
138
|
-
err_label = e.message.to_s + " :: \n" + e.backtrace.join("\n")
|
139
|
-
@log.debug 'rscrcript/error: ' + err_label
|
140
|
-
return err_label
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
60
|
|
145
|
-
|
146
|
-
|
147
|
-
def build_a(rsfile)
|
148
|
-
|
149
|
-
buffer = read_sourcecode(rsfile)
|
150
|
-
doc = Rexle.new(buffer)
|
151
|
-
|
152
|
-
doc.root.xpath("//#{@jobname}").inject([]) do |r,x|
|
153
|
-
codeblock = x.xpath('//script')\
|
154
|
-
.map {|s| read_script(s)}.join("\n")
|
155
|
-
r << [x.attributes[:id].to_sym, {attributes: x.attributes,
|
156
|
-
code: codeblock}]
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
61
|
+
protected
|
160
62
|
|
161
|
-
def
|
162
|
-
|
163
|
-
|
164
|
-
rsfile = args[0]; args.shift
|
63
|
+
def read_script(script)
|
64
|
+
puts 'inside read_script' if @debug
|
65
|
+
out_buffer = ''
|
165
66
|
|
166
|
-
|
167
|
-
|
168
|
-
a = @cache ? @rsf_cache.read(rsfile) { build_a(rsfile) } : build_a(rsfile)
|
67
|
+
src = script.attributes[:src]
|
169
68
|
|
170
|
-
|
69
|
+
out_buffer = if src then
|
70
|
+
read_sourcecode(script.attributes[:src].to_s)
|
71
|
+
else
|
72
|
+
script.texts.join("\n")
|
73
|
+
end
|
171
74
|
|
172
|
-
|
173
|
-
|
174
|
-
|
75
|
+
out_buffer
|
76
|
+
end
|
77
|
+
|
78
|
+
def read_sourcecode(rsf)
|
79
|
+
puts 'inside read_sourcecode' if @debug
|
80
|
+
buffer, _ = RXFHelper.read rsf, auto: false
|
81
|
+
return buffer
|
82
|
+
end
|
175
83
|
|
176
84
|
end
|
177
|
-
|
178
|
-
if __FILE__ == $0 then
|
179
|
-
raw_args = ARGV
|
180
|
-
rs = RScript.new()
|
181
|
-
code, args = rs.read(raw_args)
|
182
|
-
puts eval(code).join("\n")
|
183
|
-
end
|
data/lib/rscript_base.rb
CHANGED
@@ -8,7 +8,8 @@ require 'rxfhelper'
|
|
8
8
|
|
9
9
|
class RScriptBase
|
10
10
|
|
11
|
-
def initialize()
|
11
|
+
def initialize(debug: false)
|
12
|
+
@debug = debug
|
12
13
|
end
|
13
14
|
|
14
15
|
def read(doc)
|
@@ -17,7 +18,8 @@ class RScriptBase
|
|
17
18
|
|
18
19
|
protected
|
19
20
|
|
20
|
-
def read_script(script)
|
21
|
+
def read_script(script)
|
22
|
+
puts 'inside read_script' if @debug
|
21
23
|
out_buffer = ''
|
22
24
|
|
23
25
|
src = script.attributes[:src]
|
@@ -32,15 +34,9 @@ class RScriptBase
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def read_sourcecode(rsf)
|
35
|
-
|
36
|
-
buffer,
|
37
|
-
|
38
|
-
case type
|
39
|
-
when :url, :file
|
40
|
-
buffer
|
41
|
-
when :relative_url
|
42
|
-
open(@url_base + rsf, "UserAgent" => "rscript"){|x| x.read}
|
43
|
-
end
|
37
|
+
puts 'inside read_sourcecode' if @debug
|
38
|
+
buffer, _ = RXFHelper.read rsf, auto: false
|
39
|
+
return buffer
|
44
40
|
end
|
45
41
|
|
46
|
-
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
TqGxWMRGelsOt2zNIFH+8d4Yz1dYsNbhK66Q8KRR2vHoT/9T3IJGBPHdsR6Kl6yB
|
32
32
|
e5SlxbsP/R/Leg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2018-
|
34
|
+
date: 2018-08-11 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hashcache
|
@@ -59,20 +59,20 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0.
|
62
|
+
version: '0.8'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.
|
65
|
+
version: 0.8.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '0.
|
72
|
+
version: '0.8'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.8.0
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: rexle
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.6
|
124
|
+
rubygems_version: 2.7.6
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Reads or executes a job contained within a package (XML document), whereby
|
metadata.gz.sig
CHANGED
Binary file
|