rscript 0.4.2 → 0.4.3

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
  SHA1:
3
- metadata.gz: fc3f40360bfcfaa7ccad1714ff106750a5b02a34
4
- data.tar.gz: 6c76f8853884bd8971ba0df510768146c97031b8
3
+ metadata.gz: 26b394eea73f4ae8bc13a0931a2b04486c95d444
4
+ data.tar.gz: 75326f182b1e231f64e435c92c45353bed50805c
5
5
  SHA512:
6
- metadata.gz: a478c2358ce674b43ddd48305f87fce6ac64c216c6f5658e3e745d88714709faf7414315e173e0571936d6d9397f143e545ed2bb465e1506ae60c72bfe2eb33d
7
- data.tar.gz: 4b943c128dab882f79dab27e390ac481b3f3f79612e385db6a8f0448ac4fbd682329478d36bee8933fd570ce2b41f84dbeca04299a2bf83c23ba23e0c3063ce4
6
+ metadata.gz: 1006ebf6b87ad01b3b9439f560ad8818fa75a2cab735ac18c00092e7e723ee794a3e0ec4c5fbb47549cb10b2abd248e38b440f0fa91648ac5eb3ed40bc9268d3
7
+ data.tar.gz: c66bf47997cc89e084c5eebfa0fc3d3509eb324e75614a40dd1f4ab720e6b6bf7fa04238198a068a87d2956eaf9b4583575dbfe4f9089190d2558eeb6e2616d4
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/rscript.rb CHANGED
@@ -46,37 +46,38 @@ require 'rexle'
46
46
 
47
47
  class RScript < RScriptBase
48
48
 
49
- def initialize(log: nil, pkg_src: '', cache: 5)
49
+ def initialize(log: nil, pkg_src: '', cache: 5, debug: false, type: 'job')
50
50
 
51
51
  @log = log
52
52
  @cache = cache
53
53
  @rsf_cache = HashCache.new({cache: cache}) if cache > 0
54
+ @debug = debug
55
+ @jobname = type
54
56
 
55
57
  end
56
58
 
57
- def read(args=[])
59
+ def read(raw_args=[])
58
60
 
61
+ args = raw_args.clone
59
62
  @log.info 'RScript/read: args: ' + args.inspect if @log
60
63
 
61
64
  threads = []
62
65
 
63
- if args.to_s[/\/\/job:/] then
64
-
65
- ajob = []
66
-
66
+ if args.to_s[/\/\/#{@jobname}:/] then
67
+ ajob = ''
67
68
  args.each_index do |i|
68
- if args[i].to_s[/\/\/job:/] then
69
- ajob << "@id='#{$'}'"; args[i] = nil
69
+ if args[i].to_s[/\/\/#{@jobname}:/] then
70
+ ajob = "@id='#{$'}'"; args[i] = nil
71
+ puts 'ajob: ' + ajob.inspect
70
72
  end
71
73
  end
72
74
 
73
75
  args.compact!
74
76
 
75
- out = read_rsf(args) do |doc|
76
- doc.root.xpath("//job[#{ajob.join(' or ')}]").map do |job|
77
- job.xpath('script').map {|s| read_script(s)}.join("\n")
78
- end.join("\n")
79
- end
77
+ out, attr = read_rsf(args) do |doc|
78
+ job = doc.root.element("//#{@jobname}[#{ajob}]")
79
+ [job.xpath('script').map {|s| read_script(s)}.join("\n"), job.attributes]
80
+ end
80
81
 
81
82
  raise "job not found" unless out.length > 0
82
83
  out
@@ -87,7 +88,7 @@ class RScript < RScriptBase
87
88
 
88
89
  @log.info 'RScript/read: code: ' + out.inspect if @log
89
90
 
90
- [out, args]
91
+ [out, args, attr]
91
92
  end
92
93
 
93
94
  def reset()
@@ -98,14 +99,15 @@ class RScript < RScriptBase
98
99
  def run(raw_args, params={}, rws=self)
99
100
 
100
101
  @log.info 'RScript/run: raw_args: ' + raw_args.inspect if @log
102
+ puts 'raw_args: ' + raw_args.inspect if @debug
101
103
 
102
- if params[:splat] then
104
+ if params and params[:splat] then
103
105
  params.each do |k,v|
104
106
  params.delete k unless k == :splat or k == :package or k == :job or k == :captures
105
107
  end
106
108
  end
107
109
 
108
- if params[:splat] and params[:splat].length > 0 then
110
+ if params and params[:splat] and params[:splat].length > 0 then
109
111
  h = params[:splat].first[1..-1].split('&').inject({}) do |r,x|
110
112
  k, v = x.split('=')
111
113
  v ? r.merge(k[/\w+$/].to_sym => v) : r
@@ -113,27 +115,13 @@ class RScript < RScriptBase
113
115
  params.merge! h
114
116
  end
115
117
 
116
- code2, args = self.read raw_args
117
-
118
+ code2, args, attr = self.read raw_args.clone
119
+ puts 'code2 : ' + code2.inspect if @debug
118
120
  @log.info 'RScript/run: code2: ' + code2 if @log
119
121
 
120
122
  begin
121
123
 
122
- =begin
123
- thread = Thread.new(code2) do |x|
124
-
125
- begin
126
- Thread.current['result'] = eval x
127
- rescue
128
- @logger.debug('RScript -> eval: ' + ($!).inspect) if @logger
129
- end
130
-
131
- end
132
- thread.join
133
- =end
134
- #puts 'code2 :' + code2.inspect
135
124
  r = eval code2
136
- #r = thread['result']
137
125
 
138
126
  params = {}
139
127
 
@@ -142,6 +130,7 @@ class RScript < RScriptBase
142
130
  rescue Exception => e
143
131
  params = {}
144
132
  err_label = e.message.to_s + " :: \n" + e.backtrace.join("\n")
133
+ @log.debug 'rscrcript/error: ' + err_label
145
134
  return err_label
146
135
  end
147
136
 
@@ -151,6 +140,7 @@ class RScript < RScriptBase
151
140
 
152
141
  def read_rsf(args=[])
153
142
 
143
+ puts 'args: ' + args.inspect if @debug
154
144
  rsfile = args[0]; args.shift
155
145
 
156
146
  $rsfile = rsfile[/[^\/]+(?=\.rsf)/]
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.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file