rscript 0.4.4 → 0.5.0

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: a3845b49bc53494d6bbc97f701d3d1ff39b9c121
4
- data.tar.gz: bad102556f34d806949de239f180a572809376d1
3
+ metadata.gz: 7eb9e42c934b67de1cb3ada17cd8904823e5c7ea
4
+ data.tar.gz: d2678d1666cd603dc582339246eeb9c8a1c7002c
5
5
  SHA512:
6
- metadata.gz: 3ed86f99bba8dfa88452e4c47beef7189b71788a3534b31fc76d3a075cfaa947204e0e7214a3afc878da746f6a20e55f79daabfd2db57a3434b202e7040c80c7
7
- data.tar.gz: 65a0a37b113a4fd3dea3b7f0b6a184d5dcac83706b40c0ba82e51107edd99b23b5fc2dd38b9863d47d82c5a0c89674115e7e16508b3b143206f74f56887fb690
6
+ metadata.gz: e446f1fb007aba23683f6f508ba934d3aae142b159f419c05914221737df3fa40b75b2bb7b2595d26c592ce9280dee8beb43e3267ae3abf6282d28082e7882d0
7
+ data.tar.gz: 50f96e09ef49dc13b55944d56139d99f370804fd1ea0457296677a5c0a6a1bba2358600a0b8fff78fcc60471f9b066615a0592996a66027d40e66631e065ee92
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -3,11 +3,12 @@
3
3
  # file: rscript.rb
4
4
 
5
5
  # created: 1-Jul-2009
6
- # updated: 13-Jul-2018
6
+ # updated: 28-Jul-2018
7
7
 
8
8
  # modification:
9
9
 
10
- # 13-Jul-2018@ bug fix: The use of a cache is now optional
10
+ # 28-Jul-2018: feature: Jobs are now looked up from a Hash object
11
+ # 13-Jul-2018: bug fix: The use of a cache is now optional
11
12
  # 10-Jul-2018: feature: Attributes can now be read from the job
12
13
  # 24-Mar-2018: Bug fix: Public method run() can now correctly
13
14
  # handle a param value of nil
@@ -68,23 +69,21 @@ class RScript < RScriptBase
68
69
  ajob = ''
69
70
  args.each_index do |i|
70
71
  if args[i].to_s[/\/\/#{@jobname}:/] then
71
- ajob = "@id='#{$'}'"; args[i] = nil
72
- puts 'ajob: ' + ajob.inspect
72
+ ajob = $'; args[i] = nil
73
73
  end
74
74
  end
75
75
 
76
76
  args.compact!
77
-
78
- out, attr = read_rsf(args) do |doc|
79
- job = doc.root.element("//#{@jobname}[#{ajob}]")
80
- [job.xpath('script').map {|s| read_script(s)}.join("\n"), job.attributes]
81
- end
77
+
78
+ a = read_rsfdoc(args)
79
+ job = a.assoc(ajob.to_sym)
80
+ out, attr = job[:code], job[:attributes]
82
81
 
83
82
  raise "job not found" unless out.length > 0
84
83
  out
85
84
 
86
85
  else
87
- out = read_rsf(args) {|doc| doc.root.xpath('//script').map {|s| read_script(s)}}.join("\n")
86
+ out = read_rsfdoc(args).map {|x| x.last[:code]}.join("\n")
88
87
  end
89
88
 
90
89
  @log.info 'RScript/read: code: ' + out.inspect if @log
@@ -138,26 +137,35 @@ class RScript < RScriptBase
138
137
  end
139
138
 
140
139
  private
141
-
142
- def read_rsf(args=[])
140
+
141
+ def build_a(rsfile)
142
+
143
+ buffer = read_sourcecode(rsfile)
144
+ doc = Rexle.new(buffer)
145
+
146
+ doc.root.xpath("//#{@jobname}").inject([]) do |r,x|
147
+ codeblock = x.xpath('//script')\
148
+ .map {|s| read_script(s)}.join("\n")
149
+ r << [x.attributes[:id].to_sym, {attributes: x.attributes,
150
+ code: codeblock}]
151
+ end
152
+
153
+ end
154
+
155
+ def read_rsfdoc(args=[])
143
156
 
144
157
  puts 'args: ' + args.inspect if @debug
145
158
  rsfile = args[0]; args.shift
146
159
 
147
160
  $rsfile = rsfile[/[^\/]+(?=\.rsf)/]
148
161
 
149
- buffer = if @cache then
150
- @rsf_cache.read(rsfile) {read_sourcecode(rsfile) }
151
- else
152
- read_sourcecode(rsfile)
153
- end
162
+ a = @cache ? @rsf_cache.read(rsfile) { build_a(rsfile) } : build_a(rsfile)
154
163
 
155
164
  @url_base = rsfile[/\w+:\/\/[^\/]+/]
165
+
166
+ return a
156
167
 
157
- doc = Rexle.new(buffer)
158
- yield(doc)
159
-
160
- end
168
+ end
161
169
 
162
170
  end
163
171
 
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.4
4
+ version: 0.5.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-07-13 00:00:00.000000000 Z
34
+ date: 2018-07-28 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.6'
62
+ version: '0.7'
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: 0.6.1
65
+ version: 0.7.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.6'
72
+ version: '0.7'
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.6.1
75
+ version: 0.7.0
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: rexle
78
78
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file