php_process 0.0.5 → 0.0.6
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/VERSION +1 -1
- data/examples/example_phpexcel.rb +42 -0
- data/lib/php_process.rb +8 -1
- data/php_process.gemspec +3 -2
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#Remember to install 'php5-cli' like under Ubuntu: apt-get install php5-cli
|
4
|
+
#Load 'Php_process' through RubyGems.
|
5
|
+
require "rubygems"
|
6
|
+
require "php_process"
|
7
|
+
php = Php_process.new
|
8
|
+
|
9
|
+
#Load PHPExcel (can be downloaded here: 'http://phpexcel.codeplex.com/releases/view/45412')
|
10
|
+
php.func("require_once", "#{File.dirname(__FILE__)}/PHPExcel/PHPExcel.php")
|
11
|
+
|
12
|
+
#Create new PHPExcel object
|
13
|
+
print "#{Time.now} Create new PHPExcel object\n"
|
14
|
+
objPHPExcel = php.new("PHPExcel")
|
15
|
+
|
16
|
+
#Set properties
|
17
|
+
print "#{Time.now} Set properties\n"
|
18
|
+
objPHPExcel.getProperties.setCreator("Maarten Balliauw")
|
19
|
+
objPHPExcel.getProperties.setLastModifiedBy("Maarten Balliauw")
|
20
|
+
objPHPExcel.getProperties.setTitle("Office 2007 XLSX Test Document")
|
21
|
+
objPHPExcel.getProperties.setSubject("Office 2007 XLSX Test Document")
|
22
|
+
objPHPExcel.getProperties.setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
23
|
+
|
24
|
+
#Add some data
|
25
|
+
print "#{Time.now} Add some data\n"
|
26
|
+
objPHPExcel.setActiveSheetIndex(0);
|
27
|
+
objPHPExcel.getActiveSheet.SetCellValue('A1', 'Hello')
|
28
|
+
objPHPExcel.getActiveSheet.SetCellValue('B2', 'world!')
|
29
|
+
objPHPExcel.getActiveSheet.SetCellValue('C1', 'Hello')
|
30
|
+
objPHPExcel.getActiveSheet.SetCellValue('D2', 'world!')
|
31
|
+
|
32
|
+
#Rename sheet
|
33
|
+
print "#{Time.now} Rename sheet\n";
|
34
|
+
objPHPExcel.getActiveSheet.setTitle('Simple')
|
35
|
+
|
36
|
+
#Save Excel 2007 file
|
37
|
+
print "#{Time.now} Write to Excel2007 format\n"
|
38
|
+
objWriter = php.new("PHPExcel_Writer_Excel2007", objPHPExcel)
|
39
|
+
objWriter.save(__FILE__.gsub(".rb", ".xlsx"))
|
40
|
+
|
41
|
+
#Echo done
|
42
|
+
print "#{Time.now} Done writing file.\n"
|
data/lib/php_process.rb
CHANGED
@@ -2,6 +2,7 @@ require "knjrbfw"
|
|
2
2
|
require "knj/wref"
|
3
3
|
require "base64"
|
4
4
|
require "php-serialize4ruby"
|
5
|
+
require "open3"
|
5
6
|
|
6
7
|
#This class starts a PHP-process and proxies various calls to it. It also spawns proxy-objects, which can you can call like they were normal Ruby-objects.
|
7
8
|
#===Examples
|
@@ -41,7 +42,13 @@ class Php_process
|
|
41
42
|
@callbacks_count = 0
|
42
43
|
@callbacks_mutex = Mutex.new
|
43
44
|
|
44
|
-
|
45
|
+
if @args[:cmd_php]
|
46
|
+
cmd_str = "#{@args[:cmd_php]} "
|
47
|
+
else
|
48
|
+
cmd_str = "/usr/bin/env php5 "
|
49
|
+
end
|
50
|
+
|
51
|
+
cmd_str << "\"#{File.dirname(__FILE__)}/php_script.php\""
|
45
52
|
|
46
53
|
if RUBY_ENGINE == "jruby"
|
47
54
|
pid, @stdin, @stdout, @stderr = IO.popen4(cmd_str)
|
data/php_process.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{php_process}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kasper Johansen"]
|
12
|
-
s.date = %q{2012-05-
|
12
|
+
s.date = %q{2012-05-08}
|
13
13
|
s.description = %q{Spawns a PHP process and proxies calls to it, making it possible to proxy objects and more.}
|
14
14
|
s.email = %q{k@spernj.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
+
"examples/example_phpexcel.rb",
|
27
28
|
"lib/php_process.rb",
|
28
29
|
"lib/php_script.php",
|
29
30
|
"php_process.gemspec",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: php_process
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-08 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- README.rdoc
|
108
108
|
- Rakefile
|
109
109
|
- VERSION
|
110
|
+
- examples/example_phpexcel.rb
|
110
111
|
- lib/php_process.rb
|
111
112
|
- lib/php_script.php
|
112
113
|
- php_process.gemspec
|
@@ -126,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
127
|
requirements:
|
127
128
|
- - ">="
|
128
129
|
- !ruby/object:Gem::Version
|
129
|
-
hash: -
|
130
|
+
hash: -4239415254216203709
|
130
131
|
segments:
|
131
132
|
- 0
|
132
133
|
version: "0"
|