scriptcrmod 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/scriptcrmod.rb +39 -7
  3. data/scriptcrmod.gemspec +3 -3
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/lib/scriptcrmod.rb CHANGED
@@ -10,7 +10,13 @@ class CodeRunner
10
10
  # here is how to use it from the command line
11
11
  # to submit a ruby script:
12
12
  # coderunner sub -W 60 -n 1x32 -C script -X '/usr/bin/env ruby' \
13
- # -p '{file_name: "my_script.rb", arguments: "my command line args"}'
13
+ # -p '{file_name: "my_script.rb", arguments: "my command line args", \
14
+ # replace_tokens: {"TOKEN" => "replace"}'
15
+ #
16
+ # The parameter replace_tokens takes a hash of {string => string}
17
+ # which will be used to modify the text in the script via
18
+ # text.gsub!(Regexp.new(Regexp.escape("TOKEN")), replace)
19
+ # Symbols may be used instead of strings
14
20
 
15
21
  class Script < Run
16
22
 
@@ -21,7 +27,9 @@ class CodeRunner
21
27
 
22
28
  # @code = 'cubecalc'
23
29
 
24
- @variables = [:file_name, :arguments]
30
+ @code_module_folder = File.expand_path(File.dirname(__FILE__))
31
+
32
+ @variables = [:file_name, :arguments, :preamble, :replace_tokens]
25
33
 
26
34
  @naming_pars = []
27
35
 
@@ -29,7 +37,7 @@ class CodeRunner
29
37
 
30
38
  # e.g. number of iterations
31
39
 
32
- @run_info = []
40
+ @run_info = [ :percent_complete]
33
41
 
34
42
  # @@executable_name = 'cubecalc'
35
43
 
@@ -45,27 +53,50 @@ class CodeRunner
45
53
 
46
54
  def process_directory_code_specific
47
55
  if @running
48
- @status = :Incomplete
56
+ @status ||= :Incomplete
49
57
  else
50
58
  @status = :Complete
51
59
  end
60
+ eval(File.read('script_outputs.rb')) if FileTest.exist? 'script_outputs.rb'
52
61
  end
53
62
 
54
63
  def print_out_line
55
- return sprintf("%d:%d %30s %10s", @id, @job_no, @run_name, @status)
64
+ line = sprintf("%d:%d %30s %10s %s", @id, @job_no, @run_name, @status, @nprocs.to_s)
65
+ line += sprintf(" %3.1f\%", @percent_complete) if @percent_complete
66
+ line += " -- #@comment" if @comment
67
+ return line
56
68
  end
57
69
 
58
70
  def parameter_string
59
- return sprintf("%s %s", @file_name, @arguments)
71
+ return sprintf("%s %s", @file_name.to_s, @arguments.to_s)
60
72
  end
61
73
 
62
74
  def generate_input_file
63
- FileUtils.cp(@file_name, @directory + File.basename(@directory))
75
+
76
+ if @file_name
77
+ ep ['Copying:', rcp.runner.root_folder + '/' + @file_name, @directory + '/' + File.basename(@file_name)]
78
+ #FileUtils.cp(rcp.runner.root_folder + '/' + @file_name, @directory + '/' + File.basename(@file_name))
79
+ text = File.read(rcp.runner.root_folder + '/' + @file_name)
80
+ if @replace_tokens
81
+ @replace_tokens.each do |token, replace_str|
82
+ text.gsub!(Regexp.new(Regexp.escape(token)), replace_str.to_s)
83
+ end
84
+ end
85
+ File.open(@directory + '/' + File.basename(@file_name), 'w'){|file| file.puts text}
86
+ else
87
+ eputs 'Running without a script file...'
88
+ end
64
89
  end
65
90
  # @run_class.variables.keys[0]
66
91
  def parameter_transition(run)
67
92
  end
68
93
 
94
+ # Override whatever is in the system module
95
+ def run_command
96
+ eputs "Warning: preamble does not end in a new line" unless !preamble or preamble =~ /\n\s*\Z/
97
+ "#{preamble} #{executable_location}/#{executable_name} #{parameter_string}"
98
+ end
99
+
69
100
  #def executable_location
70
101
 
71
102
  #end
@@ -76,6 +107,7 @@ end
76
107
 
77
108
  def graphkit(name, options)
78
109
  case name
110
+ when 'empty'
79
111
  else
80
112
  raise 'Unknown graph'
81
113
  end
data/scriptcrmod.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "scriptcrmod"
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edmund Highcock"]
12
- s.date = "2012-12-29"
12
+ s.date = "2012-12-30"
13
13
  s.description = "A module for CodeRunner to allow arbitrary scripts to be run. Installed automatically with the coderunner gem."
14
14
  s.email = "github@edmundhighcock.com"
15
15
  s.extra_rdoc_files = [
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.homepage = "http://github.com/edmundhighcock/scriptcrmod"
34
34
  s.licenses = ["GPLv3"]
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = "1.8.24"
36
+ s.rubygems_version = "1.8.23"
37
37
  s.summary = "A module for CodeRunner to allow arbitrary scripts to be run."
38
38
 
39
39
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scriptcrmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-29 00:00:00.000000000 Z
12
+ date: 2012-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: 3677990674877173425
114
+ hash: 3601816563671045039
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 1.8.24
123
+ rubygems_version: 1.8.23
124
124
  signing_key:
125
125
  specification_version: 3
126
126
  summary: A module for CodeRunner to allow arbitrary scripts to be run.