rpy 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/COPYING +18 -0
- data/LICENSE +18 -0
- data/README +55 -0
- data/Rakefile +55 -0
- data/doc/rdoc/classes/Py.html +117 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/COPYING.html +129 -0
- data/doc/rdoc/files/LICENSE.html +129 -0
- data/doc/rdoc/files/README.html +158 -0
- data/doc/rdoc/files/ext/rpy/pyyaml/ext/_yaml_h.html +101 -0
- data/doc/rdoc/files/ext/rpy/rpy_c.html +101 -0
- data/doc/rdoc/files/ext/rpy/rpy_config_h.html +101 -0
- data/doc/rdoc/files/ext/rpy/rpy_h.html +101 -0
- data/doc/rdoc/fr_class_index.html +27 -0
- data/doc/rdoc/fr_file_index.html +33 -0
- data/doc/rdoc/fr_method_index.html +26 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/ext/rpy/extconf.rb +28 -0
- data/ext/rpy/pyyaml/ext/_yaml.h +3 -0
- data/ext/rpy/rpy.c +91 -0
- data/ext/rpy/rpy.h +8 -0
- data/ext/rpy/rpy_config.h +20 -0
- data/ext/rpy/test.rb +65 -0
- data/setup.rb +1585 -0
- data/test/rpy_test.rb +66 -0
- data/tools/rakehelp.rb +113 -0
- metadata +85 -0
data/test/rpy_test.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'test/unit'
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
4
|
+
require 'rpy'
|
5
|
+
|
6
|
+
class TestPython < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_python_no_return
|
9
|
+
Py.start # starts the python interperter
|
10
|
+
|
11
|
+
output = "hello world"
|
12
|
+
|
13
|
+
Py.run( %Q(print "#{output}"), {} )
|
14
|
+
|
15
|
+
Py.stop # stops the interperter
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_python_yaml_return
|
19
|
+
Py.start
|
20
|
+
|
21
|
+
result = YAML.load( Py.run( %Q(_rpython_result = {'hello':1,'world':2}), :serialize => 'yaml') )
|
22
|
+
|
23
|
+
assert_equal 1, result['hello']
|
24
|
+
assert_equal 2, result['world']
|
25
|
+
|
26
|
+
Py.stop
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def test_benchmark
|
31
|
+
Py.start
|
32
|
+
|
33
|
+
py_result = ""
|
34
|
+
iterations = 100
|
35
|
+
real_times = []
|
36
|
+
|
37
|
+
iterations.times do
|
38
|
+
timer = Time.now
|
39
|
+
py_result = Py.run( %Q(_rpython_result = {'hello':1,'world':2}), :serialize => 'yaml')
|
40
|
+
real_times << Time.now - timer
|
41
|
+
end
|
42
|
+
total = 0
|
43
|
+
average = 0.0
|
44
|
+
n = 0
|
45
|
+
variance = 0.0
|
46
|
+
real_times.each do|time|
|
47
|
+
n = n + 1
|
48
|
+
delta = time - average
|
49
|
+
average = average + (delta/n)
|
50
|
+
variance = variance + delta * (time - average)
|
51
|
+
total += time
|
52
|
+
end
|
53
|
+
|
54
|
+
variance /= n
|
55
|
+
|
56
|
+
puts "total: #{total} seconds, average: #{average} seconds, variance: #{variance} seconds"
|
57
|
+
|
58
|
+
result = YAML.load( py_result )
|
59
|
+
assert_equal 1, result['hello']
|
60
|
+
assert_equal 2, result['world']
|
61
|
+
|
62
|
+
|
63
|
+
Py.stop
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/tools/rakehelp.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# This final came directly from mongrel 1.0.1 source
|
2
|
+
# with a few modifications to support some of my network tests
|
3
|
+
# Also, i have figured out yet if this should remain so much a clone of the mongrel tree
|
4
|
+
# or become a plugin, need to review more closely how that works
|
5
|
+
|
6
|
+
def make(makedir)
|
7
|
+
Dir.chdir(makedir) do
|
8
|
+
sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def extconf(dir)
|
13
|
+
Dir.chdir(dir) do ruby "extconf.rb" end
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup_tests
|
17
|
+
Rake::TestTask.new do |t|
|
18
|
+
t.test_files = FileList["test/*_test.rb"]
|
19
|
+
t.verbose = true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def setup_clean otherfiles
|
25
|
+
files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
|
26
|
+
CLEAN.include(files)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def setup_rdoc files
|
31
|
+
Rake::RDocTask.new do |rdoc|
|
32
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
33
|
+
rdoc.options << '--line-numbers'
|
34
|
+
rdoc.rdoc_files.add(files)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def setup_extension(dir, extension)
|
40
|
+
ext = "ext/#{dir}"
|
41
|
+
ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
|
42
|
+
ext_files = FileList[
|
43
|
+
"#{ext}/*.c",
|
44
|
+
"#{ext}/*.h",
|
45
|
+
"#{ext}/extconf.rb",
|
46
|
+
"#{ext}/Makefile",
|
47
|
+
"lib"
|
48
|
+
]
|
49
|
+
|
50
|
+
task "lib" do
|
51
|
+
directory "lib"
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Builds just the #{extension} extension"
|
55
|
+
task extension.to_sym => ["#{ext}/Makefile", ext_so ]
|
56
|
+
|
57
|
+
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
58
|
+
extconf "#{ext}"
|
59
|
+
end
|
60
|
+
|
61
|
+
file ext_so => ext_files do
|
62
|
+
make "#{ext}"
|
63
|
+
cp ext_so, "lib"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def base_gem_spec(pkg_name, pkg_version)
|
69
|
+
rm_rf "test/coverage"
|
70
|
+
pkg_version = pkg_version
|
71
|
+
pkg_name = pkg_name
|
72
|
+
pkg_file_name = "#{pkg_name}-#{pkg_version}"
|
73
|
+
Gem::Specification.new do |s|
|
74
|
+
s.name = pkg_name
|
75
|
+
s.version = pkg_version
|
76
|
+
s.platform = Gem::Platform::RUBY
|
77
|
+
s.has_rdoc = true
|
78
|
+
s.extra_rdoc_files = [ "README" ]
|
79
|
+
|
80
|
+
s.files = %w(COPYING LICENSE README Rakefile) +
|
81
|
+
Dir.glob("{bin,doc/rdoc,test}/**/*") +
|
82
|
+
Dir.glob("ext/**/*.{h,c,rb,rl}") +
|
83
|
+
Dir.glob("{examples,tools,lib}/**/*.rb")
|
84
|
+
|
85
|
+
s.require_path = "lib"
|
86
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
87
|
+
s.bindir = "bin"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def setup_gem(pkg_name, pkg_version)
|
92
|
+
spec = base_gem_spec(pkg_name, pkg_version)
|
93
|
+
yield spec if block_given?
|
94
|
+
|
95
|
+
Rake::GemPackageTask.new(spec) do |p|
|
96
|
+
p.gem_spec = spec
|
97
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Conditional require rcov/rcovtask if present
|
102
|
+
begin
|
103
|
+
require 'rcov/rcovtask'
|
104
|
+
|
105
|
+
Rcov::RcovTask.new do |t|
|
106
|
+
t.test_files = FileList['test/unit/*_test.rb'] + FileList["test/integration/*_test.rb"]
|
107
|
+
t.rcov_opts << "-x /usr"
|
108
|
+
t.output_dir = "test/coverage"
|
109
|
+
t.verbose = true
|
110
|
+
end
|
111
|
+
rescue Object => e
|
112
|
+
puts e.message
|
113
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rpy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Todd A. Fisher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-14 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Make it easy and fun to run Python within Ruby
|
17
|
+
email:
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/rpy/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- COPYING
|
26
|
+
- LICENSE
|
27
|
+
- README
|
28
|
+
- Rakefile
|
29
|
+
- doc/rdoc/index.html
|
30
|
+
- doc/rdoc/created.rid
|
31
|
+
- doc/rdoc/classes
|
32
|
+
- doc/rdoc/classes/Py.html
|
33
|
+
- doc/rdoc/rdoc-style.css
|
34
|
+
- doc/rdoc/fr_file_index.html
|
35
|
+
- doc/rdoc/fr_class_index.html
|
36
|
+
- doc/rdoc/files
|
37
|
+
- doc/rdoc/files/LICENSE.html
|
38
|
+
- doc/rdoc/files/COPYING.html
|
39
|
+
- doc/rdoc/files/ext
|
40
|
+
- doc/rdoc/files/ext/rpy
|
41
|
+
- doc/rdoc/files/ext/rpy/pyyaml
|
42
|
+
- doc/rdoc/files/ext/rpy/pyyaml/ext
|
43
|
+
- doc/rdoc/files/ext/rpy/pyyaml/ext/_yaml_h.html
|
44
|
+
- doc/rdoc/files/ext/rpy/rpy_c.html
|
45
|
+
- doc/rdoc/files/ext/rpy/rpy_h.html
|
46
|
+
- doc/rdoc/files/ext/rpy/rpy_config_h.html
|
47
|
+
- doc/rdoc/files/README.html
|
48
|
+
- doc/rdoc/fr_method_index.html
|
49
|
+
- test/rpy_test.rb
|
50
|
+
- ext/rpy/pyyaml/ext/_yaml.h
|
51
|
+
- ext/rpy/rpy_config.h
|
52
|
+
- ext/rpy/rpy.h
|
53
|
+
- ext/rpy/rpy.c
|
54
|
+
- ext/rpy/test.rb
|
55
|
+
- ext/rpy/extconf.rb
|
56
|
+
- tools/rakehelp.rb
|
57
|
+
- setup.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage:
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.5
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.0.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 2
|
83
|
+
summary: Make it easy and fun to run Python within Ruby
|
84
|
+
test_files: []
|
85
|
+
|