oration 0.0.1
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.
- data/LICENSE +39 -0
- data/bin/oration +56 -0
- data/bin/oration.rb +56 -0
- data/doc/Generator.html +558 -0
- data/doc/Object.html +232 -0
- data/doc/bin/oration.html +56 -0
- data/doc/bin/oration_rb.html +56 -0
- data/doc/created.rid +4 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +71 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/lib/generator_rb.html +56 -0
- data/lib/generator.rb +174 -0
- data/test/test_generator.rb +206 -0
- data/test/test_oration.rb +53 -0
- data/test/ts_all.rb +5 -0
- metadata +104 -0
@@ -0,0 +1,206 @@
|
|
1
|
+
# Programmer: Chris Bunch
|
2
|
+
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
|
+
require 'generator'
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
|
10
|
+
class DoNothingGenerator
|
11
|
+
def self.does_nothing(a, b, c)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
class GetPythonFunctionFakeFile
|
17
|
+
def self.open(filename)
|
18
|
+
case filename
|
19
|
+
when "test 1"
|
20
|
+
return TEST_PYTHON_FILE1
|
21
|
+
when "test 2"
|
22
|
+
return TEST_PYTHON_FILE2
|
23
|
+
when "test 3"
|
24
|
+
return TEST_PYTHON_FILE3
|
25
|
+
else
|
26
|
+
abort("filename was not an acceptable parameter")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
PY_FUNCTION = <<PY
|
33
|
+
def print_hello_world():
|
34
|
+
print "hello world!"
|
35
|
+
PY
|
36
|
+
|
37
|
+
TEST_PYTHON_FILE1 = <<PY
|
38
|
+
#{PY_FUNCTION}
|
39
|
+
PY
|
40
|
+
|
41
|
+
TEST_PYTHON_FILE2 = <<PY
|
42
|
+
def print_hello_world():
|
43
|
+
sleep(1)
|
44
|
+
for i in range(5):
|
45
|
+
print "hello world!"
|
46
|
+
PY
|
47
|
+
|
48
|
+
TEST_PYTHON_FILE3 = <<PY
|
49
|
+
import random
|
50
|
+
import sys
|
51
|
+
import os
|
52
|
+
|
53
|
+
#{PY_FUNCTION}
|
54
|
+
PY
|
55
|
+
|
56
|
+
|
57
|
+
class GetGoFunctionFakeFile
|
58
|
+
def self.open(filename)
|
59
|
+
case filename
|
60
|
+
when "test 1"
|
61
|
+
return TEST_GO_FILE1
|
62
|
+
when "test 2"
|
63
|
+
return TEST_GO_FILE2
|
64
|
+
when "test 3"
|
65
|
+
return TEST_GO_FILE3
|
66
|
+
else
|
67
|
+
abort("filename was not an acceptable parameter")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
GO_FUNCTION = <<GO
|
74
|
+
func PrintHelloWorld() string {
|
75
|
+
return "Hello world!"
|
76
|
+
}
|
77
|
+
GO
|
78
|
+
|
79
|
+
TEST_GO_FILE1 = <<GO
|
80
|
+
#{GO_FUNCTION}
|
81
|
+
GO
|
82
|
+
|
83
|
+
TEST_GO_FILE2 = <<GO
|
84
|
+
func PrintHelloWorld() string {
|
85
|
+
all := ""
|
86
|
+
for i := 0; i < 5; i++ {
|
87
|
+
all += "Hello world!\n"
|
88
|
+
}
|
89
|
+
return all
|
90
|
+
}
|
91
|
+
GO
|
92
|
+
|
93
|
+
GO_FUNCTION_3 = <<GO
|
94
|
+
func PrintHelloWorld() string {
|
95
|
+
return fmt.Sprintf("Hello world %d", 1)
|
96
|
+
}
|
97
|
+
GO
|
98
|
+
|
99
|
+
TEST_GO_FILE3 = <<GO
|
100
|
+
import fmt
|
101
|
+
|
102
|
+
#{GO_FUNCTION_3}
|
103
|
+
GO
|
104
|
+
|
105
|
+
|
106
|
+
class GeneratorFakeFile
|
107
|
+
def self.expand_path(path)
|
108
|
+
return path
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.open(location, mode=nil)
|
112
|
+
return ""
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
class TestGenerator < Test::Unit::TestCase
|
118
|
+
def test_generate_app
|
119
|
+
# Slip in a fake method that doesn't do anything since we only want to
|
120
|
+
# test the generate_app method, and not methods that actually create a
|
121
|
+
# Python or Go application.
|
122
|
+
function = "blarg"
|
123
|
+
output_dir = "output_dir"
|
124
|
+
do_nothing_method = DoNothingGenerator.method(:does_nothing)
|
125
|
+
|
126
|
+
# c files aren't supported, so this should fail
|
127
|
+
assert_raise(SystemExit) {
|
128
|
+
Generator.generate_app("boo.c", function, output_dir, do_nothing_method,
|
129
|
+
do_nothing_method)
|
130
|
+
}
|
131
|
+
|
132
|
+
# files with no extension aren't supported, so this should fail
|
133
|
+
assert_raise(SystemExit) {
|
134
|
+
Generator.generate_app("boo", function, output_dir, do_nothing_method,
|
135
|
+
do_nothing_method)
|
136
|
+
}
|
137
|
+
|
138
|
+
# python files are supported, so this should succeed
|
139
|
+
assert_nothing_raised(SystemExit) {
|
140
|
+
Generator.generate_app("boo.py", function, output_dir, do_nothing_method,
|
141
|
+
do_nothing_method)
|
142
|
+
}
|
143
|
+
|
144
|
+
# go files are supported, so this should succeed
|
145
|
+
assert_nothing_raised(SystemExit) {
|
146
|
+
Generator.generate_app("boo.go", function, output_dir, do_nothing_method,
|
147
|
+
do_nothing_method)
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_get_python_function
|
152
|
+
main_file1 = "test 1"
|
153
|
+
function_name = "print_hello_world"
|
154
|
+
assert_equal(PY_FUNCTION.strip, Generator.get_python_function(main_file1,
|
155
|
+
function_name, file=GetPythonFunctionFakeFile).strip)
|
156
|
+
|
157
|
+
main_file2 = "test 2"
|
158
|
+
assert_equal(TEST_PYTHON_FILE2.strip, Generator.get_python_function(
|
159
|
+
main_file2, function_name, file=GetPythonFunctionFakeFile).strip)
|
160
|
+
|
161
|
+
main_file3 = "test 3"
|
162
|
+
assert_equal(PY_FUNCTION.strip, Generator.get_python_function(main_file3,
|
163
|
+
function_name, file=GetPythonFunctionFakeFile).strip)
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_write_python_app_yaml
|
167
|
+
assert_nothing_raised(SystemExit) {
|
168
|
+
Generator.write_python_app_yaml_file("boo", "/tmp/boo", GeneratorFakeFile)
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_write_python_main_py
|
173
|
+
assert_nothing_raised(SystemExit) {
|
174
|
+
Generator.write_python_cicero_code("def boo():\n print 'hello world!'",
|
175
|
+
"boo", "/tmp/boo", GeneratorFakeFile)
|
176
|
+
}
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_get_go_function
|
180
|
+
main_file1 = "test 1"
|
181
|
+
function_name = "PrintHelloWorld"
|
182
|
+
assert_equal(GO_FUNCTION.strip, Generator.get_go_function(main_file1,
|
183
|
+
function_name, file=GetGoFunctionFakeFile).strip)
|
184
|
+
|
185
|
+
main_file2 = "test 2"
|
186
|
+
assert_equal(TEST_GO_FILE2.strip, Generator.get_go_function(main_file2,
|
187
|
+
function_name, file=GetGoFunctionFakeFile).strip)
|
188
|
+
|
189
|
+
main_file3 = "test 3"
|
190
|
+
assert_equal(GO_FUNCTION_3.strip, Generator.get_go_function(main_file3,
|
191
|
+
function_name, file=GetGoFunctionFakeFile).strip)
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_write_go_app_yaml
|
195
|
+
assert_nothing_raised(SystemExit) {
|
196
|
+
Generator.write_go_app_yaml_file("boo", "/tmp/boo", GeneratorFakeFile)
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_write_go_main_go
|
201
|
+
assert_nothing_raised(SystemExit) {
|
202
|
+
Generator.write_go_cicero_code("func Boo() string { return \"2\" }",
|
203
|
+
"boo", "/tmp/boo", GeneratorFakeFile)
|
204
|
+
}
|
205
|
+
end
|
206
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Programmer: Chris Bunch
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "bin")
|
4
|
+
require 'oration'
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
|
8
|
+
|
9
|
+
class FakeFile
|
10
|
+
def self.exists?(file_name)
|
11
|
+
if file_name.include?("good") or file_name.include?("exists")
|
12
|
+
return true
|
13
|
+
else
|
14
|
+
return false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.open(file_name)
|
19
|
+
return "def good-function-name():\n print 'hello world!'"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
class TestOration < Test::Unit::TestCase
|
25
|
+
def test_validate_arguments
|
26
|
+
# test when there are the wrong number of args
|
27
|
+
bad_args_1 = %w{}
|
28
|
+
bad_args_2 = %w{boo.go}
|
29
|
+
bad_args_3 = %w{boo.go boo}
|
30
|
+
bad_args_4 = %w{boo.go boo boo boo}
|
31
|
+
[bad_args_1, bad_args_2, bad_args_3, bad_args_4].each { |args|
|
32
|
+
assert_raise(SystemExit) { validate_arguments(args, FakeFile) }
|
33
|
+
}
|
34
|
+
|
35
|
+
# test when the file in question doesn't exist
|
36
|
+
bad_args_5 = %w{doesnt-exist.go boo output-dir}
|
37
|
+
assert_raise(SystemExit) { validate_arguments(bad_args_5, FakeFile) }
|
38
|
+
|
39
|
+
# test when the function to be used doesn't exist in that file
|
40
|
+
bad_args_6 = %w{good-file.go bad-function-name output-dir}
|
41
|
+
assert_raise(SystemExit) { validate_arguments(bad_args_6, FakeFile) }
|
42
|
+
|
43
|
+
# test when the output-dir specified already exists
|
44
|
+
bad_args_7 = %w{good-file.go good-function-name output-dir-exists}
|
45
|
+
assert_raise(SystemExit) { validate_arguments(bad_args_7, FakeFile) }
|
46
|
+
|
47
|
+
# test when the user gives us a file that exists with the named function
|
48
|
+
good_args = %w{good-file.go good-function-name output-dir}
|
49
|
+
assert_nothing_raised(SystemExit) {
|
50
|
+
validate_arguments(good_args, FakeFile)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
data/test/ts_all.rb
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oration
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Chris Bunch
|
14
|
+
autorequire: oration
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-12-01 00:00:00 -08:00
|
19
|
+
default_executable: oration
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: " Oration converts a function written in Python or Go into a Google App Engine\n application that conforms to the Cicero API, allowing the given function to\n be automatically executed over Google App Engine or AppScale in an\n embarrassingly parallel fashion.\n"
|
23
|
+
email: appscale_community@googlegroups.com
|
24
|
+
executables:
|
25
|
+
- oration
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- LICENSE
|
30
|
+
files:
|
31
|
+
- bin/oration
|
32
|
+
- bin/oration.rb
|
33
|
+
- doc/Object.html
|
34
|
+
- doc/js/jquery.js
|
35
|
+
- doc/js/darkfish.js
|
36
|
+
- doc/js/quicksearch.js
|
37
|
+
- doc/js/thickbox-compressed.js
|
38
|
+
- doc/lib/generator_rb.html
|
39
|
+
- doc/index.html
|
40
|
+
- doc/bin/oration_rb.html
|
41
|
+
- doc/bin/oration.html
|
42
|
+
- doc/Generator.html
|
43
|
+
- doc/images/wrench.png
|
44
|
+
- doc/images/loadingAnimation.gif
|
45
|
+
- doc/images/find.png
|
46
|
+
- doc/images/page_white_text.png
|
47
|
+
- doc/images/zoom.png
|
48
|
+
- doc/images/plugin.png
|
49
|
+
- doc/images/brick_link.png
|
50
|
+
- doc/images/page_green.png
|
51
|
+
- doc/images/brick.png
|
52
|
+
- doc/images/date.png
|
53
|
+
- doc/images/bug.png
|
54
|
+
- doc/images/bullet_black.png
|
55
|
+
- doc/images/page_white_width.png
|
56
|
+
- doc/images/tag_green.png
|
57
|
+
- doc/images/macFFBgHack.png
|
58
|
+
- doc/images/wrench_orange.png
|
59
|
+
- doc/images/ruby.png
|
60
|
+
- doc/images/bullet_toggle_plus.png
|
61
|
+
- doc/images/package.png
|
62
|
+
- doc/images/bullet_toggle_minus.png
|
63
|
+
- doc/created.rid
|
64
|
+
- lib/generator.rb
|
65
|
+
- test/test_generator.rb
|
66
|
+
- test/test_oration.rb
|
67
|
+
- test/ts_all.rb
|
68
|
+
- LICENSE
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://appscale.cs.ucsb.edu
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.4.2
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Generates Cicero-ready Google App Engine apps from regular code
|
103
|
+
test_files: []
|
104
|
+
|