ruby-perl 0.99.15j
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.rspec +0 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +49 -0
- data/README.md +123 -0
- data/Rakefile +5 -0
- data/autotest/discover.rb +1 -0
- data/bin/rperl +23 -0
- data/examples/hello.pl +1 -0
- data/examples/hello.rb +9 -0
- data/examples/hello_block.rb +5 -0
- data/examples/hello_here.rb +5 -0
- data/examples/passenger/config.ru +3 -0
- data/examples/passenger/log/.keep +0 -0
- data/examples/passenger/public/.keep +0 -0
- data/examples/passenger/tmp/.keep +0 -0
- data/examples/passenger/webapp.psgi +16 -0
- data/examples/perl.ru +4 -0
- data/examples/webapp.psgi +16 -0
- data/lib/perl.rb +43 -0
- data/lib/perl/common.rb +64 -0
- data/lib/perl/ext/hash.rb +10 -0
- data/lib/perl/ext/object.rb +30 -0
- data/lib/perl/ext/string.rb +10 -0
- data/lib/perl/ffi_lib.rb +65 -0
- data/lib/perl/internal.rb +73 -0
- data/lib/perl/interpreter.rb +89 -0
- data/lib/perl/rack.rb +45 -0
- data/lib/perl/shell.rb +28 -0
- data/lib/perl/stack.rb +99 -0
- data/lib/perl/stack/function.rb +67 -0
- data/lib/perl/value.rb +4 -0
- data/lib/perl/value/array.rb +54 -0
- data/lib/perl/value/hash.rb +73 -0
- data/lib/perl/value/scalar.rb +130 -0
- data/spec/ext/hash_spec.rb +24 -0
- data/spec/ext/object_spec.rb +40 -0
- data/spec/ext/string_spec.rb +37 -0
- data/spec/hash_value_spec.rb +47 -0
- data/spec/interpreter_spec.rb +220 -0
- data/spec/scalar_value_spec.rb +82 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/support/perl_value_helpers.rb +13 -0
- metadata +109 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'perl/interpreter'
|
4
|
+
require 'perl/value/scalar'
|
5
|
+
|
6
|
+
describe Perl::Value::Scalar do
|
7
|
+
include PerlValueHelpers
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
@interpreter = Perl::Interpreter.new
|
11
|
+
end
|
12
|
+
after(:all) do
|
13
|
+
@interpreter.stop
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "class method" do
|
17
|
+
describe " #to_perl" do
|
18
|
+
it "should return the expected object when passed a String" do
|
19
|
+
input = "something"
|
20
|
+
|
21
|
+
sv = described_class.to_perl(input)
|
22
|
+
sv.should_not be_nil
|
23
|
+
|
24
|
+
ret = described_class.new(sv)
|
25
|
+
ret.should_not be_nil
|
26
|
+
ret.value.should eq(input)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return the expected object when passed a StringIO" do
|
30
|
+
input = StringIO.new("something")
|
31
|
+
|
32
|
+
sv = described_class.to_perl(input)
|
33
|
+
sv.should_not be_nil
|
34
|
+
|
35
|
+
ret = described_class.new(sv)
|
36
|
+
ret.should_not be_nil
|
37
|
+
ret.value.should eq(input.string)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should raise when passed a Fixnum" do
|
41
|
+
lambda { described_class.to_perl(42) }.should raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "built without arguments" do
|
47
|
+
its(:perl) { should_not be_nil }
|
48
|
+
its(:scalar) { should be_nil }
|
49
|
+
its(:sv) { should be_nil }
|
50
|
+
end
|
51
|
+
|
52
|
+
context "built from a Fixnum" do
|
53
|
+
let(:input) { 42 }
|
54
|
+
it do
|
55
|
+
lambda { described_class.new(input) }.should raise_error
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "built from a String" do
|
60
|
+
let(:input) { "something" }
|
61
|
+
subject { described_class.new(input) }
|
62
|
+
its(:perl) { should_not be_nil }
|
63
|
+
its(:scalar) { should_not be_nil }
|
64
|
+
its(:scalar) { should eq(input) }
|
65
|
+
its(:sv) { should be_nil }
|
66
|
+
|
67
|
+
describe "when #to_perl is called" do
|
68
|
+
it "should return the expected object" do
|
69
|
+
sv = subject.to_perl
|
70
|
+
sv.should_not be_nil
|
71
|
+
|
72
|
+
ret = described_class.new(sv)
|
73
|
+
ret.should_not be_nil
|
74
|
+
ret.value.should eq(input)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should cache the returned object" do
|
78
|
+
subject.to_perl.should == subject.sv
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# require 'cover_me'
|
2
|
+
require 'pathname'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
module SpecHelper
|
6
|
+
def root
|
7
|
+
@root_path ||= Pathname.new(File.expand_path('../../', __FILE__))
|
8
|
+
end
|
9
|
+
|
10
|
+
def support
|
11
|
+
root.join('spec', 'support')
|
12
|
+
end
|
13
|
+
|
14
|
+
module_function :root, :support
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir["#{SpecHelper.support}/**/*.rb"].each do |f|
|
18
|
+
require f
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.mock_with :rspec
|
23
|
+
end
|
24
|
+
|
25
|
+
module Kernel
|
26
|
+
def capture_stdout_descriptor
|
27
|
+
Tempfile.open("spec") do |file|
|
28
|
+
begin
|
29
|
+
out = $stdout.dup
|
30
|
+
$stdout.reopen(file)
|
31
|
+
yield
|
32
|
+
$stdout.flush
|
33
|
+
return File.read(file)
|
34
|
+
ensure
|
35
|
+
$stdout.reopen(out)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-perl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: 7
|
5
|
+
version: 0.99.15j
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrea Campi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-01 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: ffi
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.0.6
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: Run Perl code from any Ruby application, or run Perl web apps on Ruby.
|
28
|
+
email:
|
29
|
+
- andrea.campi@zephirworks.com
|
30
|
+
executables:
|
31
|
+
- rperl
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- .autotest
|
38
|
+
- .rspec
|
39
|
+
- Gemfile
|
40
|
+
- Gemfile.lock
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- autotest/discover.rb
|
44
|
+
- bin/rperl
|
45
|
+
- examples/hello.pl
|
46
|
+
- examples/hello.rb
|
47
|
+
- examples/hello_block.rb
|
48
|
+
- examples/hello_here.rb
|
49
|
+
- examples/passenger/config.ru
|
50
|
+
- examples/passenger/log/.keep
|
51
|
+
- examples/passenger/public/.keep
|
52
|
+
- examples/passenger/tmp/.keep
|
53
|
+
- examples/passenger/webapp.psgi
|
54
|
+
- examples/perl.ru
|
55
|
+
- examples/webapp.psgi
|
56
|
+
- lib/perl.rb
|
57
|
+
- lib/perl/common.rb
|
58
|
+
- lib/perl/ext/hash.rb
|
59
|
+
- lib/perl/ext/object.rb
|
60
|
+
- lib/perl/ext/string.rb
|
61
|
+
- lib/perl/ffi_lib.rb
|
62
|
+
- lib/perl/internal.rb
|
63
|
+
- lib/perl/interpreter.rb
|
64
|
+
- lib/perl/rack.rb
|
65
|
+
- lib/perl/shell.rb
|
66
|
+
- lib/perl/stack.rb
|
67
|
+
- lib/perl/stack/function.rb
|
68
|
+
- lib/perl/value.rb
|
69
|
+
- lib/perl/value/array.rb
|
70
|
+
- lib/perl/value/hash.rb
|
71
|
+
- lib/perl/value/scalar.rb
|
72
|
+
- spec/ext/hash_spec.rb
|
73
|
+
- spec/ext/object_spec.rb
|
74
|
+
- spec/ext/string_spec.rb
|
75
|
+
- spec/hash_value_spec.rb
|
76
|
+
- spec/interpreter_spec.rb
|
77
|
+
- spec/scalar_value_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/support/perl_value_helpers.rb
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/zephirworks/ruby-perl
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.3.6
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project: ruby-perl
|
104
|
+
rubygems_version: 1.6.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Run Perl code from any Ruby application.
|
108
|
+
test_files: []
|
109
|
+
|