Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Commit 4c37073

Browse files
author
zouyi
committed
modify abtraction to PhpExtensionFormula
gsed -i 's/AbstractPhp[0-9]{2}Extension/PhpExtensionFormula/g' ./*
1 parent 0d6c610 commit 4c37073

File tree

110 files changed

+204
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+204
-109
lines changed

Abstract/abstract-php-extension.rb

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
require "formula"
2+
class PhpExtensionFormula < Formula
3+
def initialize(*)
4+
super
5+
active_spec.owner = php_parent.stable.owner
6+
end
7+
8+
def install
9+
cd "ext/#{extension}"
10+
system php_parent.bin/"phpize"
11+
system "./configure", *configure_args
12+
system "make"
13+
(lib/module_path).install "modules/#{extension}.so"
14+
end
15+
16+
def post_install
17+
ext_config_path = etc/"php"/php_parent.php_version/"conf.d"/"ext-#{extension}.ini"
18+
if ext_config_path.exist?
19+
inreplace ext_config_path,
20+
/#{extension_type}=.*$/, "#{extension_type}=#{opt_lib/module_path}/#{extension}.so"
21+
else
22+
ext_config_path.write <<~EOS
23+
[#{extension}]
24+
#{extension_type}=#{opt_lib/module_path}/#{extension}.so
25+
EOS
26+
end
27+
end
28+
29+
test do
30+
assert_match extension.downcase, shell_output("#{php_parent.opt_bin}/php -m").downcase,
31+
"failed to find extension in php -m output"
32+
end
33+
34+
private
35+
36+
def php_parent
37+
self.class.php_parent
38+
end
39+
40+
def extension
41+
self.class.extension
42+
end
43+
44+
def extension_type
45+
# extension or zend_extension
46+
"extension"
47+
end
48+
49+
def module_path
50+
extension_dir = Utils.popen_read("#{php_parent.opt_bin/"php-config"} --extension-dir").chomp
51+
php_basename = File.basename(extension_dir)
52+
"php/#{php_basename}"
53+
end
54+
55+
def configure_args
56+
self.class.configure_args
57+
end
58+
59+
class << self
60+
NAME_PATTERN = /^Php(?:AT([57])(\d+))?(.+)/
61+
attr_reader :configure_args, :php_parent, :extension
62+
63+
def configure_arg(args)
64+
@configure_args ||= []
65+
@configure_args.concat(Array(args))
66+
end
67+
68+
def extension_dsl
69+
class_name = name.split("::").last
70+
m = NAME_PATTERN.match(class_name)
71+
if m.nil?
72+
raise "Bad PHP Extension name for #{class_name}"
73+
elsif m[1].nil?
74+
parent_name = "php"
75+
else
76+
parent_name = "php@" + m.captures[0..1].join(".")
77+
end
78+
79+
@php_parent = Formula[parent_name]
80+
@extension = m[3].gsub(/([a-z])([A-Z])/) do
81+
Regexp.last_match(1) + "_" + Regexp.last_match(2)
82+
end.downcase
83+
@configure_args = %W[
84+
--with-php-config=#{php_parent.opt_bin/"php-config"}
85+
]
86+
87+
homepage php_parent.homepage + extension
88+
url php_parent.stable.url
89+
send php_parent.stable.checksum.hash_type, php_parent.stable.checksum.hexdigest
90+
91+
depends_on "autoconf" => :build
92+
depends_on parent_name
93+
end
94+
end
95+
end

Formula/php53-amqp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Amqp < AbstractPhp53Extension
3+
class Php53Amqp < PhpExtensionFormula
44
init
55
desc "Communicates with any AMQP 0-9-1 compatible server."
66
homepage "https://pecl.php.net/package/amqp"

Formula/php53-apc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Apc < AbstractPhp53Extension
3+
class Php53Apc < PhpExtensionFormula
44
init
55
desc "Alternative PHP cache"
66
homepage "https://pecl.php.net/package/apc"

Formula/php53-apcu.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Apcu < AbstractPhp53Extension
3+
class Php53Apcu < PhpExtensionFormula
44
init
55
desc "APC User Cache"
66
homepage "https://pecl.php.net/package/apcu"

Formula/php53-binpack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Binpack < AbstractPhp53Extension
3+
class Php53Binpack < PhpExtensionFormula
44
init
55
desc "The php implementation for BINPACK"
66
homepage "https://pecl.php.net/package/binpack"

Formula/php53-blitz.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Blitz < AbstractPhp53Extension
3+
class Php53Blitz < PhpExtensionFormula
44
init
55
desc "Blitz, the fasted template engine for PHP!"
66
homepage "http://alexeyrybak.com/blitz/blitz_en.html"

Formula/php53-boxwood.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Boxwood < AbstractPhp53Extension
3+
class Php53Boxwood < PhpExtensionFormula
44
init
55
desc "PHP extension for fast replacement of multiple words in a piece of text"
66
homepage "https://github.com/ning/boxwood"

Formula/php53-chdb.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Chdb < AbstractPhp53Extension
3+
class Php53Chdb < PhpExtensionFormula
44
init
55
desc "A fast database for constant data with memory sharing across processes"
66
homepage "https://pecl.php.net/package/chdb"

Formula/php53-couchbase.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Couchbase < AbstractPhp53Extension
3+
class Php53Couchbase < PhpExtensionFormula
44
init
55
desc "Provides fast access to documents stored in a Couchbase Server."
66
homepage "https://pecl.php.net/package/couchbase"

Formula/php53-crypto.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Crypto < AbstractPhp53Extension
3+
class Php53Crypto < PhpExtensionFormula
44
init
55
desc "Wrapper for OpenSSL Crypto Library"
66
homepage "https://pecl.php.net/package/crypto"

Formula/php53-dbase.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Dbase < AbstractPhp53Extension
3+
class Php53Dbase < PhpExtensionFormula
44
init
55
desc "dBase database file access functions"
66
homepage "https://pecl.php.net/package/dbase"

Formula/php53-dbus.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Dbus < AbstractPhp53Extension
3+
class Php53Dbus < PhpExtensionFormula
44
init
55
desc "Extension for interaction with DBUS busses"
66
homepage "https://pecl.php.net/package/dbus"

Formula/php53-dmtx.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Dmtx < AbstractPhp53Extension
3+
class Php53Dmtx < PhpExtensionFormula
44
init
55
desc "PHP bindings for the dmtx library"
66
homepage "http://www.libdmtx.org"

Formula/php53-eio.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Eio < AbstractPhp53Extension
3+
class Php53Eio < PhpExtensionFormula
44
init
55
desc "interface to the libeio library"
66
homepage "https://pecl.php.net/package/eio"

Formula/php53-gearman.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Gearman < AbstractPhp53Extension
3+
class Php53Gearman < PhpExtensionFormula
44
init
55
desc "PHP wrapper to libgearman"
66
homepage "https://pecl.php.net/package/gearman"

Formula/php53-geoip.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Geoip < AbstractPhp53Extension
3+
class Php53Geoip < PhpExtensionFormula
44
init
55
desc "Map IP address to geographic places"
66
homepage "https://pecl.php.net/package/geoip"

Formula/php53-geos.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Geos < AbstractPhp53Extension
3+
class Php53Geos < PhpExtensionFormula
44
init
55
desc "PHP bindings for GEOS"
66
homepage "https://git.osgeo.org/gogs/geos/php-geos"

Formula/php53-gmagick.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Gmagick < AbstractPhp53Extension
3+
class Php53Gmagick < PhpExtensionFormula
44
init
55
desc "Provides a wrapper to the GraphicsMagick library."
66
homepage "https://pecl.php.net/package/gmagick"

Formula/php53-gmp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Gmp < AbstractPhp53Extension
3+
class Php53Gmp < PhpExtensionFormula
44
init
55
desc "GMP core php extension"
66
homepage "http://php.net/manual/en/book.gmp.php"

Formula/php53-gnupg.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Gnupg < AbstractPhp53Extension
3+
class Php53Gnupg < PhpExtensionFormula
44
init
55
desc "Wrapper around the gpgme library"
66
homepage "https://pecl.php.net/package/gnupg"

Formula/php53-graphdat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Graphdat < AbstractPhp53Extension
3+
class Php53Graphdat < PhpExtensionFormula
44
init
55
desc "Troubleshoot application and server performance."
66
homepage "http://www.graphdat.com/"

Formula/php53-htscanner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Htscanner < AbstractPhp53Extension
3+
class Php53Htscanner < PhpExtensionFormula
44
init
55
desc "Fork of the htscanner project with additional settings to facilitate shared webhosting providers."
66
homepage "https://github.com/piannelli/htscanner-enhanced"

Formula/php53-http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Http < AbstractPhp53Extension
3+
class Php53Http < PhpExtensionFormula
44
init
55
desc "HTTP extension that provides a convenient set of functionality"
66
homepage "https://pecl.php.net/package/pecl_http"

Formula/php53-igbinary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Igbinary < AbstractPhp53Extension
3+
class Php53Igbinary < PhpExtensionFormula
44
init
55
desc "Drop in replacement for the standard php serializer"
66
homepage "https://pecl.php.net/package/igbinary"

Formula/php53-imagick.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Imagick < AbstractPhp53Extension
3+
class Php53Imagick < PhpExtensionFormula
44
init
55
desc "Provides a wrapper to the ImageMagick library."
66
homepage "https://pecl.php.net/package/imagick"

Formula/php53-intl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Intl < AbstractPhp53Extension
3+
class Php53Intl < PhpExtensionFormula
44
init
55
desc "A wrapper for the ICU library"
66
homepage "http://php.net/manual/en/book.intl.php"

Formula/php53-ioncubeloader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Ioncubeloader < AbstractPhp53Extension
3+
class Php53Ioncubeloader < PhpExtensionFormula
44
init
55
desc "Loader for ionCube Secured Files"
66
homepage "http://www.ioncube.com/loaders.php"

Formula/php53-jsmin.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Jsmin < AbstractPhp53Extension
3+
class Php53Jsmin < PhpExtensionFormula
44
init
55
desc "PHP extension for minifying JavaScript."
66
homepage "https://pecl.php.net/package/jsmin"

Formula/php53-kafka.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Kafka < AbstractPhp53Extension
3+
class Php53Kafka < PhpExtensionFormula
44
init
55
desc "PHP extension for Apache Kafka"
66
homepage "https://github.com/EVODelavega/phpkafka/"

Formula/php53-leveldb.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Leveldb < AbstractPhp53Extension
3+
class Php53Leveldb < PhpExtensionFormula
44
init
55
desc "This extension is a PHP binding for Google LevelDB"
66
homepage "https://pecl.php.net/package/leveldb"

Formula/php53-libevent.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Libevent < AbstractPhp53Extension
3+
class Php53Libevent < PhpExtensionFormula
44
init
55
desc "This extension is a wrapper for the libevent event notification library."
66
homepage "https://pecl.php.net/package/libevent"

Formula/php53-libsodium.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Libsodium < AbstractPhp53Extension
3+
class Php53Libsodium < PhpExtensionFormula
44
init
55
desc "Modern and easy-to-use crypto library"
66
homepage "https://github.com/jedisct1/libsodium-php"

Formula/php53-libvirt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Libvirt < AbstractPhp53Extension
3+
class Php53Libvirt < PhpExtensionFormula
44
init
55
desc "PHP bindings for libvirt virtualization toolkit"
66
homepage "http://libvirt.org/php"

Formula/php53-lz4.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Lz4 < AbstractPhp53Extension
3+
class Php53Lz4 < PhpExtensionFormula
44
init
55
desc "Extremely Fast Compression algorithm."
66
homepage "https://cyan4973.github.io/lz4/"

Formula/php53-lzf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Lzf < AbstractPhp53Extension
3+
class Php53Lzf < PhpExtensionFormula
44
init
55
desc "handles LZF de/compression"
66
homepage "https://pecl.php.net/package/lzf"

Formula/php53-magickwand.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Magickwand < AbstractPhp53Extension
3+
class Php53Magickwand < PhpExtensionFormula
44
init
55
desc "ImageMagick MagickWand API"
66
homepage "http://www.magickwand.org"

Formula/php53-mailparse.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Mailparse < AbstractPhp53Extension
3+
class Php53Mailparse < PhpExtensionFormula
44
init
55
desc "Mailparse is an extension for parsing and working with email messages."
66
homepage "https://pecl.php.net/package/mailparse"

Formula/php53-maxminddb.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Maxminddb < AbstractPhp53Extension
3+
class Php53Maxminddb < PhpExtensionFormula
44
init
55
desc "Extension for MaxMind DB file format"
66
homepage "https://github.com/maxmind/libmaxminddb"

Formula/php53-mcrypt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
22

3-
class Php53Mcrypt < AbstractPhp53Extension
3+
class Php53Mcrypt < PhpExtensionFormula
44
init
55
desc "An interface to the mcrypt library"
66
homepage "http://php.net/manual/en/book.mcrypt.php"

0 commit comments

Comments
 (0)