CombinedText stringlengths 4 3.42M |
|---|
# config valid only for current version of Capistrano
lock '3.8.1'
set :repo_url, "git@github.com:rubyforgood/diaper.git"
set :application, "diaper_base"
set :user, "deploy"
set :puma_threads, [4, 16]
set :puma_workers, 0
set :ssh_options, keys: ["config/deploy_id_rsa"] if File.exist?("config/deploy_id_rsa")
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord
## Defaults:
# set :scm, :git
# set :branch, :master
# set :format, :pretty
# set :log_level, :debug
# set :keep_releases, 5
## Linked Files & Directories (Default None):
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
# ps aux | grep puma # Get puma pid
# kill -s SIGUSR2 pid # Restart puma
# kill -s SIGTERM pid # Stop puma
Updating the capistrano deploy file.
# config valid only for current version of Capistrano
lock '3.8.1'
set :repo_url, "git@github.com:rubyforgood/diaper.git"
set :application, "diaper_base"
set :user, "deploy"
set :puma_threads, [4, 16]
set :puma_workers, 0
set :ssh_options, keys: ["config/deploy_id_rsa"] if File.exist?("config/deploy_id_rsa")
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord
## Defaults:
# set :scm, :git
# set :branch, :master
# set :format, :pretty
# set :log_level, :debug
# set :keep_releases, 5
## Linked Files & Directories (Default None):
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
end
# ps aux | grep puma # Get puma pid
# kill -s SIGUSR2 pid # Restart puma
# kill -s SIGTERM pid # Stop puma
|
class Mysql < Formula
desc "Open source relational database management system"
homepage "https://dev.mysql.com/doc/refman/5.7/en/"
url "https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.18.tar.gz"
sha256 "ae6f5e2cf7b936496cf60260cd7fd5a0862c21f48cd240448021c4ea067a0f0c"
bottle do
rebuild 1
sha256 "4c4ca41db24fca1a443bcae54e238d4b830aa4e8dd7fdc44ddb898490aa47b94" => :sierra
sha256 "2256b6ec4878266cb4b3ec22abd9d154e4ce5e5413648737c388ac48fc63fac0" => :el_capitan
sha256 "abc74fa6a0d7330761dd68572b5bccf063b9df57267a2a421eef24c270182bbe" => :yosemite
end
option "with-test", "Build with unit tests"
option "with-embedded", "Build the embedded server"
option "with-archive-storage-engine", "Compile with the ARCHIVE storage engine enabled"
option "with-blackhole-storage-engine", "Compile with the BLACKHOLE storage engine enabled"
option "with-local-infile", "Build with local infile loading support"
option "with-debug", "Build with debug support"
deprecated_option "enable-local-infile" => "with-local-infile"
deprecated_option "enable-debug" => "with-debug"
deprecated_option "with-tests" => "with-test"
depends_on "cmake" => :build
depends_on "pidof" unless MacOS.version >= :mountain_lion || !OS.mac?
depends_on "openssl"
# Fix error: Cannot find system editline libraries.
depends_on "libedit" unless OS.mac?
# https://github.com/Homebrew/homebrew-core/issues/1475
# Needs at least Clang 3.3, which shipped alongside Lion.
# Note: MySQL themselves don't support anything below El Capitan.
depends_on :macos => :lion
conflicts_with "mysql-cluster", "mariadb", "percona-server",
:because => "mysql, mariadb, and percona install the same binaries."
conflicts_with "mysql-connector-c",
:because => "both install MySQL client libraries"
conflicts_with "mariadb-connector-c",
:because => "both install plugins"
def datadir
var/"mysql"
end
def install
# Reduce memory usage below 4 GB for Circle CI.
ENV["MAKEFLAGS"] = "-j3" if ENV["CIRCLECI"]
# Don't hard-code the libtool path. See:
# https://github.com/Homebrew/legacy-homebrew/issues/20185
inreplace "cmake/libutils.cmake",
"COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}",
"COMMAND libtool -static -o ${TARGET_LOCATION}"
# -DINSTALL_* are relative to `CMAKE_INSTALL_PREFIX` (`prefix`)
args = %W[
-DMYSQL_DATADIR=#{datadir}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INFODIR=share/info
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DWITH_SSL=yes
-DWITH_SSL=system
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DSYSCONFDIR=#{etc}
-DCOMPILATION_COMMENT=Homebrew
-DWITH_EDITLINE=system
-DWITH_BOOST=boost
]
# To enable unit testing at build, we need to download the unit testing suite
if build.with? "test"
args << "-DENABLE_DOWNLOADS=ON"
else
args << "-DWITH_UNIT_TESTS=OFF"
end
# Build the embedded server
args << "-DWITH_EMBEDDED_SERVER=ON" if build.with? "embedded"
# Compile with ARCHIVE engine enabled if chosen
args << "-DWITH_ARCHIVE_STORAGE_ENGINE=1" if build.with? "archive-storage-engine"
# Compile with BLACKHOLE engine enabled if chosen
args << "-DWITH_BLACKHOLE_STORAGE_ENGINE=1" if build.with? "blackhole-storage-engine"
# Build with local infile loading support
args << "-DENABLED_LOCAL_INFILE=1" if build.with? "local-infile"
# Build with debug support
args << "-DWITH_DEBUG=1" if build.with? "debug"
system "cmake", ".", *std_cmake_args, *args
system "make"
system "make", "install"
# We don't want to keep a 240MB+ folder around most users won't need.
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{Dir.mktmpdir}"
end
rm_rf prefix/"mysql-test"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Perl script was removed in 5.7.9 so install C++ binary instead.
# Binary is deprecated & will be removed in future upstream
# update but is still required for mysql-test-run to pass in test.
(prefix/"scripts").install "client/mysql_install_db"
bin.install_symlink prefix/"scripts/mysql_install_db"
# Fix up the control script and link into bin.
inreplace "#{prefix}/support-files/mysql.server",
/^(PATH=".*)(")/,
"\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"
# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<-EOS.undent
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
etc.install "my.cnf"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<-EOS.undent
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
EOS
if my_cnf = ["/etc/my.cnf", "/etc/mysql/my.cnf"].find { |x| File.exist? x }
s += <<-EOS.undent
A "#{my_cnf}" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
begin
# Expects datadir to be a completely clean dir, which testpath isn't.
dir = Dir.mktmpdir
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{dir}", "--tmpdir=#{dir}"
pid = fork do
exec bin/"mysqld", "--bind-address=127.0.0.1", "--datadir=#{dir}"
end
sleep 2
output = shell_output("curl 127.0.0.1:3306")
output.force_encoding("ASCII-8BIT") if output.respond_to?(:force_encoding)
assert_match version.to_s, output
ensure
Process.kill(9, pid)
Process.wait(pid)
end
end
end
mysql: update 5.7.18 bottle for Linuxbrew.
Closes Linuxbrew/homebrew-core#2597.
Signed-off-by: Maxim Belkin <032baa6ccf1d4eaa4536fc4f9b83b9a1f593449a@gmail.com>
class Mysql < Formula
desc "Open source relational database management system"
homepage "https://dev.mysql.com/doc/refman/5.7/en/"
url "https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.18.tar.gz"
sha256 "ae6f5e2cf7b936496cf60260cd7fd5a0862c21f48cd240448021c4ea067a0f0c"
bottle do
rebuild 1
sha256 "4c4ca41db24fca1a443bcae54e238d4b830aa4e8dd7fdc44ddb898490aa47b94" => :sierra
sha256 "2256b6ec4878266cb4b3ec22abd9d154e4ce5e5413648737c388ac48fc63fac0" => :el_capitan
sha256 "abc74fa6a0d7330761dd68572b5bccf063b9df57267a2a421eef24c270182bbe" => :yosemite
sha256 "f9c9605fdb747e655afb1c9a39e317e2d07d5223bcbf96f972fca7efe864b4d7" => :x86_64_linux
end
option "with-test", "Build with unit tests"
option "with-embedded", "Build the embedded server"
option "with-archive-storage-engine", "Compile with the ARCHIVE storage engine enabled"
option "with-blackhole-storage-engine", "Compile with the BLACKHOLE storage engine enabled"
option "with-local-infile", "Build with local infile loading support"
option "with-debug", "Build with debug support"
deprecated_option "enable-local-infile" => "with-local-infile"
deprecated_option "enable-debug" => "with-debug"
deprecated_option "with-tests" => "with-test"
depends_on "cmake" => :build
depends_on "pidof" unless MacOS.version >= :mountain_lion || !OS.mac?
depends_on "openssl"
# Fix error: Cannot find system editline libraries.
depends_on "libedit" unless OS.mac?
# https://github.com/Homebrew/homebrew-core/issues/1475
# Needs at least Clang 3.3, which shipped alongside Lion.
# Note: MySQL themselves don't support anything below El Capitan.
depends_on :macos => :lion
conflicts_with "mysql-cluster", "mariadb", "percona-server",
:because => "mysql, mariadb, and percona install the same binaries."
conflicts_with "mysql-connector-c",
:because => "both install MySQL client libraries"
conflicts_with "mariadb-connector-c",
:because => "both install plugins"
def datadir
var/"mysql"
end
def install
# Reduce memory usage below 4 GB for Circle CI.
ENV["MAKEFLAGS"] = "-j3" if ENV["CIRCLECI"]
# Don't hard-code the libtool path. See:
# https://github.com/Homebrew/legacy-homebrew/issues/20185
inreplace "cmake/libutils.cmake",
"COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}",
"COMMAND libtool -static -o ${TARGET_LOCATION}"
# -DINSTALL_* are relative to `CMAKE_INSTALL_PREFIX` (`prefix`)
args = %W[
-DMYSQL_DATADIR=#{datadir}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INFODIR=share/info
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DWITH_SSL=yes
-DWITH_SSL=system
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DSYSCONFDIR=#{etc}
-DCOMPILATION_COMMENT=Homebrew
-DWITH_EDITLINE=system
-DWITH_BOOST=boost
]
# To enable unit testing at build, we need to download the unit testing suite
if build.with? "test"
args << "-DENABLE_DOWNLOADS=ON"
else
args << "-DWITH_UNIT_TESTS=OFF"
end
# Build the embedded server
args << "-DWITH_EMBEDDED_SERVER=ON" if build.with? "embedded"
# Compile with ARCHIVE engine enabled if chosen
args << "-DWITH_ARCHIVE_STORAGE_ENGINE=1" if build.with? "archive-storage-engine"
# Compile with BLACKHOLE engine enabled if chosen
args << "-DWITH_BLACKHOLE_STORAGE_ENGINE=1" if build.with? "blackhole-storage-engine"
# Build with local infile loading support
args << "-DENABLED_LOCAL_INFILE=1" if build.with? "local-infile"
# Build with debug support
args << "-DWITH_DEBUG=1" if build.with? "debug"
system "cmake", ".", *std_cmake_args, *args
system "make"
system "make", "install"
# We don't want to keep a 240MB+ folder around most users won't need.
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{Dir.mktmpdir}"
end
rm_rf prefix/"mysql-test"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Perl script was removed in 5.7.9 so install C++ binary instead.
# Binary is deprecated & will be removed in future upstream
# update but is still required for mysql-test-run to pass in test.
(prefix/"scripts").install "client/mysql_install_db"
bin.install_symlink prefix/"scripts/mysql_install_db"
# Fix up the control script and link into bin.
inreplace "#{prefix}/support-files/mysql.server",
/^(PATH=".*)(")/,
"\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"
# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<-EOS.undent
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
etc.install "my.cnf"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<-EOS.undent
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
EOS
if my_cnf = ["/etc/my.cnf", "/etc/mysql/my.cnf"].find { |x| File.exist? x }
s += <<-EOS.undent
A "#{my_cnf}" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
begin
# Expects datadir to be a completely clean dir, which testpath isn't.
dir = Dir.mktmpdir
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{dir}", "--tmpdir=#{dir}"
pid = fork do
exec bin/"mysqld", "--bind-address=127.0.0.1", "--datadir=#{dir}"
end
sleep 2
output = shell_output("curl 127.0.0.1:3306")
output.force_encoding("ASCII-8BIT") if output.respond_to?(:force_encoding)
assert_match version.to_s, output
ensure
Process.kill(9, pid)
Process.wait(pid)
end
end
end
|
set :application, 'promotego-org'
set :domain, 'webapps@promotego.org'
set :deploy_to, '/var/tmp/promotego-vlad'
set :repository, 'git://github.com/amikula/promotego-org.git'
set :app_command, "/usr/sbin/apache2ctl"
namespace :vlad do
desc 'Restart Passenger'
remote_task :start_app, :roles => :app do
run "touch #{current_release}/tmp/restart.txt"
end
desc 'Restarts the apache servers'
remote_task :start_web, :roles => :app do
run "sudo #{app_command} restart"
end
### Extending 'vlad:update' with 'gems:geminstaller'
desc "Install gems via geminstaller."
remote_task :update, :roles => :app do
Rake::Task['gems:geminstaller'].invoke
end
end
namespace :gems do
desc "Run geminstaller."
remote_task :geminstaller, :roles => :app do
run "sudo geminstaller"
end
end
Added cd statement to run geminstaller without arguments
set :application, 'promotego-org'
set :domain, 'webapps@promotego.org'
set :deploy_to, '/var/tmp/promotego-vlad'
set :repository, 'git://github.com/amikula/promotego-org.git'
set :app_command, "/usr/sbin/apache2ctl"
namespace :vlad do
desc 'Restart Passenger'
remote_task :start_app, :roles => :app do
run "touch #{current_release}/tmp/restart.txt"
end
desc 'Restarts the apache servers'
remote_task :start_web, :roles => :app do
run "sudo #{app_command} restart"
end
### Extending 'vlad:update' with 'gems:geminstaller'
desc "Install gems via geminstaller."
remote_task :update, :roles => :app do
Rake::Task['gems:geminstaller'].invoke
end
end
namespace :gems do
desc "Run geminstaller."
remote_task :geminstaller, :roles => :app do
run "cd #{current_path}; sudo geminstaller"
end
end
|
class Mysql < Formula
desc "Open source relational database management system"
homepage "https://dev.mysql.com/doc/refman/5.7/en/"
url "https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.10.tar.gz"
sha256 "1ea1644884d086a23eafd8ccb04d517fbd43da3a6a06036f23c5c3a111e25c74"
bottle do
sha256 "7ae8f867a55df376cf0d2e6de4d915271805077660f248a0cd1400645f586fe5" => :el_capitan
sha256 "d626277de0795dca5393d0b2fc223deaacd9541e67ac800eb8d001aa0e3bd952" => :yosemite
sha256 "29d34e35b680ac112abfae03e759147dafb3780b9760fd3a60333e2a2df9e817" => :mavericks
end
option :universal
option "with-test", "Build with unit tests"
option "with-embedded", "Build the embedded server"
option "with-archive-storage-engine", "Compile with the ARCHIVE storage engine enabled"
option "with-blackhole-storage-engine", "Compile with the BLACKHOLE storage engine enabled"
option "with-local-infile", "Build with local infile loading support"
option "with-memcached", "Enable innodb-memcached support"
option "with-debug", "Build with debug support"
deprecated_option "enable-local-infile" => "with-local-infile"
deprecated_option "enable-memcached" => "with-memcached"
deprecated_option "enable-debug" => "with-debug"
deprecated_option "with-tests" => "with-test"
depends_on "cmake" => :build
depends_on "pidof" unless MacOS.version >= :mountain_lion
depends_on "openssl"
depends_on "boost" => :build
conflicts_with "mysql-cluster", "mariadb", "percona-server",
:because => "mysql, mariadb, and percona install the same binaries."
conflicts_with "mysql-connector-c",
:because => "both install MySQL client libraries"
fails_with :llvm do
build 2326
cause "https://github.com/Homebrew/homebrew/issues/issue/144"
end
def datadir
var/"mysql"
end
def install
# Don't hard-code the libtool path. See:
# https://github.com/Homebrew/homebrew/issues/20185
inreplace "cmake/libutils.cmake",
"COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}",
"COMMAND libtool -static -o ${TARGET_LOCATION}"
# Build without compiler or CPU specific optimization flags to facilitate
# compilation of gems and other software that queries `mysql-config`.
ENV.minimal_optimization
# -DINSTALL_* are relative to `CMAKE_INSTALL_PREFIX` (`prefix`)
args = %W[
.
-DCMAKE_INSTALL_PREFIX=#{prefix}
-DCMAKE_FIND_FRAMEWORK=LAST
-DCMAKE_VERBOSE_MAKEFILE=ON
-DMYSQL_DATADIR=#{datadir}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INFODIR=share/info
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DWITH_SSL=yes
-DWITH_SSL=system
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DSYSCONFDIR=#{etc}
-DCOMPILATION_COMMENT=Homebrew
-DWITH_EDITLINE=system
]
# To enable unit testing at build, we need to download the unit testing suite
if build.with? "test"
args << "-DENABLE_DOWNLOADS=ON"
else
args << "-DWITH_UNIT_TESTS=OFF"
end
# Build the embedded server
args << "-DWITH_EMBEDDED_SERVER=ON" if build.with? "embedded"
# Compile with ARCHIVE engine enabled if chosen
args << "-DWITH_ARCHIVE_STORAGE_ENGINE=1" if build.with? "archive-storage-engine"
# Compile with BLACKHOLE engine enabled if chosen
args << "-DWITH_BLACKHOLE_STORAGE_ENGINE=1" if build.with? "blackhole-storage-engine"
# Make universal for binding to universal applications
if build.universal?
ENV.universal_binary
args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}"
end
# Build with local infile loading support
args << "-DENABLED_LOCAL_INFILE=1" if build.with? "local-infile"
# Build with memcached support
args << "-DWITH_INNODB_MEMCACHED=1" if build.with? "memcached"
# Build with debug support
args << "-DWITH_DEBUG=1" if build.with? "debug"
system "cmake", *args
system "make"
system "make", "install"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Perl script was removed in 5.7.9 so install C++ binary instead.
# Binary is deprecated & will be removed in future upstream
# update but is still required for mysql-test-run to pass in test.
(prefix/"scripts").install "client/mysql_install_db"
bin.install_symlink prefix/"scripts/mysql_install_db"
# Fix up the control script and link into bin
inreplace "#{prefix}/support-files/mysql.server" do |s|
s.gsub!(/^(PATH=".*)(")/, "\\1:#{HOMEBREW_PREFIX}/bin\\2")
# pidof can be replaced with pgrep from proctools on Mountain Lion
s.gsub!(/pidof/, "pgrep") if MacOS.version >= :mountain_lion
end
bin.install_symlink prefix/"support-files/mysql.server"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<-EOS.undent
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
To connect run:
mysql -uroot
EOS
if File.exist? "/etc/my.cnf"
s += <<-EOS.undent
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--bind-address=127.0.0.1</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
system "/bin/sh", "-n", "#{bin}/mysqld_safe"
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{testpath}"
end
end
end
mysql: update 5.7.10 bottle.
class Mysql < Formula
desc "Open source relational database management system"
homepage "https://dev.mysql.com/doc/refman/5.7/en/"
url "https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.10.tar.gz"
sha256 "1ea1644884d086a23eafd8ccb04d517fbd43da3a6a06036f23c5c3a111e25c74"
bottle do
revision 1
sha256 "866d0adbfe88f626452006bb50aa9489413a81a03cbef40c3175f7e7daaab879" => :el_capitan
sha256 "048629d5759e5aa7cabd934214a011c30c1f94c57ea47c8b853b338213572c77" => :yosemite
sha256 "84b963def9d2ff10bd21435ac2b9b87cce34a8e68bb9e82e3b2c6a0200970975" => :mavericks
end
option :universal
option "with-test", "Build with unit tests"
option "with-embedded", "Build the embedded server"
option "with-archive-storage-engine", "Compile with the ARCHIVE storage engine enabled"
option "with-blackhole-storage-engine", "Compile with the BLACKHOLE storage engine enabled"
option "with-local-infile", "Build with local infile loading support"
option "with-memcached", "Enable innodb-memcached support"
option "with-debug", "Build with debug support"
deprecated_option "enable-local-infile" => "with-local-infile"
deprecated_option "enable-memcached" => "with-memcached"
deprecated_option "enable-debug" => "with-debug"
deprecated_option "with-tests" => "with-test"
depends_on "cmake" => :build
depends_on "pidof" unless MacOS.version >= :mountain_lion
depends_on "openssl"
depends_on "boost" => :build
conflicts_with "mysql-cluster", "mariadb", "percona-server",
:because => "mysql, mariadb, and percona install the same binaries."
conflicts_with "mysql-connector-c",
:because => "both install MySQL client libraries"
fails_with :llvm do
build 2326
cause "https://github.com/Homebrew/homebrew/issues/issue/144"
end
def datadir
var/"mysql"
end
def install
# Don't hard-code the libtool path. See:
# https://github.com/Homebrew/homebrew/issues/20185
inreplace "cmake/libutils.cmake",
"COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}",
"COMMAND libtool -static -o ${TARGET_LOCATION}"
# Build without compiler or CPU specific optimization flags to facilitate
# compilation of gems and other software that queries `mysql-config`.
ENV.minimal_optimization
# -DINSTALL_* are relative to `CMAKE_INSTALL_PREFIX` (`prefix`)
args = %W[
.
-DCMAKE_INSTALL_PREFIX=#{prefix}
-DCMAKE_FIND_FRAMEWORK=LAST
-DCMAKE_VERBOSE_MAKEFILE=ON
-DMYSQL_DATADIR=#{datadir}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INFODIR=share/info
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DWITH_SSL=yes
-DWITH_SSL=system
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DSYSCONFDIR=#{etc}
-DCOMPILATION_COMMENT=Homebrew
-DWITH_EDITLINE=system
]
# To enable unit testing at build, we need to download the unit testing suite
if build.with? "test"
args << "-DENABLE_DOWNLOADS=ON"
else
args << "-DWITH_UNIT_TESTS=OFF"
end
# Build the embedded server
args << "-DWITH_EMBEDDED_SERVER=ON" if build.with? "embedded"
# Compile with ARCHIVE engine enabled if chosen
args << "-DWITH_ARCHIVE_STORAGE_ENGINE=1" if build.with? "archive-storage-engine"
# Compile with BLACKHOLE engine enabled if chosen
args << "-DWITH_BLACKHOLE_STORAGE_ENGINE=1" if build.with? "blackhole-storage-engine"
# Make universal for binding to universal applications
if build.universal?
ENV.universal_binary
args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}"
end
# Build with local infile loading support
args << "-DENABLED_LOCAL_INFILE=1" if build.with? "local-infile"
# Build with memcached support
args << "-DWITH_INNODB_MEMCACHED=1" if build.with? "memcached"
# Build with debug support
args << "-DWITH_DEBUG=1" if build.with? "debug"
system "cmake", *args
system "make"
system "make", "install"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Perl script was removed in 5.7.9 so install C++ binary instead.
# Binary is deprecated & will be removed in future upstream
# update but is still required for mysql-test-run to pass in test.
(prefix/"scripts").install "client/mysql_install_db"
bin.install_symlink prefix/"scripts/mysql_install_db"
# Fix up the control script and link into bin
inreplace "#{prefix}/support-files/mysql.server" do |s|
s.gsub!(/^(PATH=".*)(")/, "\\1:#{HOMEBREW_PREFIX}/bin\\2")
# pidof can be replaced with pgrep from proctools on Mountain Lion
s.gsub!(/pidof/, "pgrep") if MacOS.version >= :mountain_lion
end
bin.install_symlink prefix/"support-files/mysql.server"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<-EOS.undent
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
To connect run:
mysql -uroot
EOS
if File.exist? "/etc/my.cnf"
s += <<-EOS.undent
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--bind-address=127.0.0.1</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
system "/bin/sh", "-n", "#{bin}/mysqld_safe"
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{testpath}"
end
end
end
|
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
set :domain, 'foobar.com'
set :deploy_to, '/var/www/foobar.com'
set :repository, 'git://...'
set :branch, 'master'
# For system-wide RVM install.
# set :rvm_path, '/usr/local/rvm/bin/rvm'
# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']
# Optional settings:
# set :user, 'foobar' # Username in the server to SSH to.
# set :port, '30000' # SSH port number.
# set :forward_agent, true # SSH forward_agent.
# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
# invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
# invoke :'rvm:use[ruby-1.9.3-p125@default]'
end
# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"]
queue %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml' and 'secrets.yml'."]
queue %[
repo_host=`echo $repo | sed -e 's/.*@//g' -e 's/:.*//g'` &&
repo_port=`echo $repo | grep -o ':[0-9]*' | sed -e 's/://g'` &&
if [ -z "${repo_port}" ]; then repo_port=22; fi &&
ssh-keyscan -p $repo_port -H $repo_host >> ~/.ssh/known_hosts
]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
end
end
end
# For help in making your deploy script, see the Mina documentation:
#
# - http://nadarei.co/mina
# - http://nadarei.co/mina/tasks
# - http://nadarei.co/mina/settings
# - http://nadarei.co/mina/helpers
edit mina deploy file
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
set :domain, 'vertdeal.com'
set :deploy_to, '/home/ryan/project/Jobby'
set :repository, 'https://github.com/ryangoh/Jobby.git'
set :branch, 'master'
set :term_mode, nil
set :rails_env, 'production'
set :branch, 'master'
set :db_name, 'jobby_production2'
# For system-wide RVM install.
# set :rvm_path, '/usr/local/rvm/bin/rvm'
# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'log']
# Optional settings:
# set :user, 'foobar' # Username in the server to SSH to.
# set :port, '30000' # SSH port number.
# set :forward_agent, true # SSH forward_agent.
set :user, 'ryan'
set :port, '22'
set :forward_agent, true
# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
# invoke :'rvm:use[ruby-1.9.3-p125@default]'
end
# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
queue! %[touch "#{deploy_to}/.rbenv-vars"]
queue %[echo "-----> Be sure to add your ENV VAR in '#{deploy_to}/.rbenv-vars'."]
invoke :'setup:db:database_yml'
# invoke :'create:database'
# queue %[
# repo_host=`echo $repo | sed -e 's/.*@//g' -e 's/:.*//g'` &&
# repo_port=`echo $repo | grep -o ':[0-9]*' | sed -e 's/://g'` &&
# if [ -z "${repo_port}" ]; then repo_port=22; fi &&
# ssh-keyscan -p $repo_port -H $repo_host >> ~/.ssh/known_hosts
# ]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_create'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
invoke :restartng
to :launch do
queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
end
end
end
desc "Populate shared database.yml"
task :'setup:db:database_yml' => :environment do
database_yml = <<-DATABASE.dedent
#{rails_env}:
adapter: postgresql
encoding: unicode
database: #{db_name}
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASS'] %>
host: localhost
timeout: 5000
pool: 5
DATABASE
queue! %{
echo "-----> Populating shared database.yml"
echo "#{database_yml}" > #{deploy_to!}/shared/config/database.yml
echo "-----> Done"
}
end
#restart nginx server
task :restartng do
queue "sudo nginx -s reload"
end
task :logs do
queue 'sudo tail -f /var/log/nginx/error.log'
end
task :reboot do
queue "sudo reboot"
end
task :prodlog do
queue "tail -f #{deploy_to}/shared/log/production.log"
end
# For help in making your deploy script, see the Mina documentation:
#
# - http://nadarei.co/mina
# - http://nadarei.co/mina/tasks
# - http://nadarei.co/mina/settings
# - http://nadarei.co/mina/helpers
class String
def dedent
lines = split "\n"
return self if lines.empty?
indents = lines.map do |line|
line =~ /\S/ ? (line.start_with?(" ") ? line.match(/^ +/).offset(0)[1] : 0) : nil
end
min_indent = indents.compact.min
return self if min_indent.zero?
lines.map { |line| line =~ /\S/ ? line.gsub(/^ {#{min_indent}}/, "") : line }.join "\n"
end
end
|
require 'formula'
class Mysql <Formula
homepage 'http://dev.mysql.com/doc/refman/5.1/en/'
url 'http://mysql.llarian.net/Downloads/MySQL-5.1/mysql-5.1.48.tar.gz'
md5 'd04c54d1cfbd8c6c8650c8d078f885b2'
depends_on 'readline'
def options
[
['--with-tests', "Keep tests when installing."],
['--with-bench', "Keep benchmark app when installing."],
['--client-only', "Only install client tools, not the server."],
['--universal', "Make mysql a universal binary"]
]
end
def patches
DATA
end
def install
fails_with_llvm "http://github.com/mxcl/homebrew/issues/issue/144"
# See: http://dev.mysql.com/doc/refman/5.1/en/configure-options.html
# These flags may not apply to gcc 4+
ENV['CXXFLAGS'] = ENV['CXXFLAGS'].gsub "-fomit-frame-pointer", ""
ENV['CXXFLAGS'] += " -fno-omit-frame-pointer -felide-constructors"
# Make universal for bindings to universal applications
ENV.universal_binary if ARGV.include? '--universal'
configure_args = [
"--without-docs",
"--without-debug",
"--disable-dependency-tracking",
"--prefix=#{prefix}",
"--localstatedir=#{var}/mysql",
"--sysconfdir=#{etc}",
"--with-plugins=innobase,myisam",
"--with-extra-charsets=complex",
"--with-ssl",
"--with-readline",
"--enable-assembler",
"--enable-thread-safe-client",
"--enable-local-infile",
"--enable-shared"]
configure_args << "--without-server" if ARGV.include? '--client-only'
system "./configure", *configure_args
system "make install"
ln_s "#{libexec}/mysqld", "#{bin}/mysqld"
(prefix+'mysql-test').rmtree unless ARGV.include? '--with-tests' # save 66MB!
(prefix+'sql-bench').rmtree unless ARGV.include? '--with-bench'
(prefix+'com.mysql.mysqld.plist').write startup_plist
end
def caveats; <<-EOS.undent
Set up databases with:
mysql_install_db
If this is your first install, automatically load on login with:
cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
If this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
Note on upgrading:
We overwrite any existing com.mysql.mysqld.plist in ~/Library/LaunchAgents
if we are upgrading because previous versions of this brew created the
plist with a version specific program argument.
Or start manually with:
#{prefix}/share/mysql/mysql.server start
EOS
end
def startup_plist; <<-EOPLIST.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>#{bin}/mysqld_safe</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>#{`whoami`.chomp}</string>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
EOPLIST
end
end
__END__
--- old/scripts/mysqld_safe.sh 2009-09-02 04:10:39.000000000 -0400
+++ new/scripts/mysqld_safe.sh 2009-09-02 04:52:55.000000000 -0400
@@ -383,7 +383,7 @@
fi
USER_OPTION=""
-if test -w / -o "$USER" = "root"
+if test -w /sbin -o "$USER" = "root"
then
if test "$user" != "root" -o $SET_USER = 1
then
diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh
index efc8254..8964b70 100644
--- a/scripts/mysql_config.sh
+++ b/scripts/mysql_config.sh
@@ -132,7 +132,8 @@ for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
Xa xstrconst "xc99=none" AC99 \
- unroll2 ip mp restrict
+ unroll2 ip mp restrict \
+ mmmx 'msse[0-9.]*' 'mfpmath=sse' w pipe 'fomit-frame-pointer' 'mmacosx-version-min=10.[0-9]'
do
# The first option we might strip will always have a space before it because
# we set -I$pkgincludedir as the first option
mysql - fix weird readline option
require 'formula'
class Mysql <Formula
homepage 'http://dev.mysql.com/doc/refman/5.1/en/'
url 'http://mysql.llarian.net/Downloads/MySQL-5.1/mysql-5.1.48.tar.gz'
md5 'd04c54d1cfbd8c6c8650c8d078f885b2'
depends_on 'readline'
def options
[
['--with-tests', "Keep tests when installing."],
['--with-bench', "Keep benchmark app when installing."],
['--client-only', "Only install client tools, not the server."],
['--universal', "Make mysql a universal binary"]
]
end
def patches
DATA
end
def install
fails_with_llvm "http://github.com/mxcl/homebrew/issues/issue/144"
# See: http://dev.mysql.com/doc/refman/5.1/en/configure-options.html
# These flags may not apply to gcc 4+
ENV['CXXFLAGS'] = ENV['CXXFLAGS'].gsub "-fomit-frame-pointer", ""
ENV['CXXFLAGS'] += " -fno-omit-frame-pointer -felide-constructors"
# Make universal for bindings to universal applications
ENV.universal_binary if ARGV.include? '--universal'
configure_args = [
"--without-docs",
"--without-debug",
"--disable-dependency-tracking",
"--prefix=#{prefix}",
"--localstatedir=#{var}/mysql",
"--sysconfdir=#{etc}",
"--with-plugins=innobase,myisam",
"--with-extra-charsets=complex",
"--with-ssl",
"--without-readline", # Confusingly, means "use detected readline instead of included readline"
"--enable-assembler",
"--enable-thread-safe-client",
"--enable-local-infile",
"--enable-shared"]
configure_args << "--without-server" if ARGV.include? '--client-only'
system "./configure", *configure_args
system "make install"
ln_s "#{libexec}/mysqld", "#{bin}/mysqld"
(prefix+'mysql-test').rmtree unless ARGV.include? '--with-tests' # save 66MB!
(prefix+'sql-bench').rmtree unless ARGV.include? '--with-bench'
(prefix+'com.mysql.mysqld.plist').write startup_plist
end
def caveats; <<-EOS.undent
Set up databases with:
mysql_install_db
If this is your first install, automatically load on login with:
cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
If this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
Note on upgrading:
We overwrite any existing com.mysql.mysqld.plist in ~/Library/LaunchAgents
if we are upgrading because previous versions of this brew created the
plist with a version specific program argument.
Or start manually with:
#{prefix}/share/mysql/mysql.server start
EOS
end
def startup_plist; <<-EOPLIST.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>#{bin}/mysqld_safe</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>#{`whoami`.chomp}</string>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
EOPLIST
end
end
__END__
--- old/scripts/mysqld_safe.sh 2009-09-02 04:10:39.000000000 -0400
+++ new/scripts/mysqld_safe.sh 2009-09-02 04:52:55.000000000 -0400
@@ -383,7 +383,7 @@
fi
USER_OPTION=""
-if test -w / -o "$USER" = "root"
+if test -w /sbin -o "$USER" = "root"
then
if test "$user" != "root" -o $SET_USER = 1
then
diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh
index efc8254..8964b70 100644
--- a/scripts/mysql_config.sh
+++ b/scripts/mysql_config.sh
@@ -132,7 +132,8 @@ for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
Xa xstrconst "xc99=none" AC99 \
- unroll2 ip mp restrict
+ unroll2 ip mp restrict \
+ mmmx 'msse[0-9.]*' 'mfpmath=sse' w pipe 'fomit-frame-pointer' 'mmacosx-version-min=10.[0-9]'
do
# The first option we might strip will always have a space before it because
# we set -I$pkgincludedir as the first option
|
class CompetitionPolicy < ApplicationPolicy
# Can this user manage the lane assignments for the competition?
def manage_lane_assignments?
user.has_role?(:race_official, record) || super_admin?
end
def copy_judges?
record.unlocked? && (director?(record.event) || super_admin?)
end
def index?
director?(record.event) || super_admin?
end
def create?
competition_admin? || super_admin?
end
def update?
competition_admin? || super_admin?
end
def destroy?
competition_admin? || super_admin?
end
def show?
director?(record.event) || awards_admin? || data_entry_volunteer? || competition_admin? || super_admin?
end
def sort?
record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)
end
###### START State Machine transitions ############
def lock?
record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)
end
def unlock?
competition_admin? || super_admin?
end
def publish?
awards_admin? || super_admin?
end
def unpublish?
awards_admin? || super_admin?
end
def award?
awards_admin? || super_admin?
end
###### END State Machine transitions ############
def export_scores?
director?(record.event) || super_admin?
end
# printing/results
def results?
director?(record.event) || awards_admin? || super_admin?
end
def result?
director?(record.event) || super_admin?
end
def set_places?
competition_admin? || super_admin?
end
# PRINTING
def announcer?
return true # ?? Was "skip_authorization_check" before?
data_entry_volunteer? || director?(record.event)
end
def heat_recording?
data_entry_volunteer? || director?(record.event)
end
# DATA MANAGEMENT
def view_result_data?
director?(record.event) || super_admin?
end
def modify_result_data?
record.unlocked? && view_result_data?
end
def single_attempt_recording?
data_entry_volunteer? || director?(record.event)
end
def two_attempt_recording?
data_entry_volunteer? || director?(record.event)
end
def start_list?
true
end
# DATA ENTRY
def create_preliminary_result?
record.unlocked? && (data_entry_volunteer? || director?(record.event)|| super_admin?)
end
def manage_volunteers?
director?(record.event) || super_admin?
end
def publish_age_group_entry?
super_admin?
end
def set_age_group_places?
super_admin?
end
private
class Scope < Scope
def resolve
scope.none
end
end
end
allow super admin to view data entry forms
class CompetitionPolicy < ApplicationPolicy
# Can this user manage the lane assignments for the competition?
def manage_lane_assignments?
user.has_role?(:race_official, record) || super_admin?
end
def copy_judges?
record.unlocked? && (director?(record.event) || super_admin?)
end
def index?
director?(record.event) || super_admin?
end
def create?
competition_admin? || super_admin?
end
def update?
competition_admin? || super_admin?
end
def destroy?
competition_admin? || super_admin?
end
def show?
director?(record.event) || awards_admin? || data_entry_volunteer? || competition_admin? || super_admin?
end
def sort?
record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)
end
###### START State Machine transitions ############
def lock?
record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)
end
def unlock?
competition_admin? || super_admin?
end
def publish?
awards_admin? || super_admin?
end
def unpublish?
awards_admin? || super_admin?
end
def award?
awards_admin? || super_admin?
end
###### END State Machine transitions ############
def export_scores?
director?(record.event) || super_admin?
end
# printing/results
def results?
director?(record.event) || awards_admin? || super_admin?
end
def result?
director?(record.event) || super_admin?
end
def set_places?
competition_admin? || super_admin?
end
# PRINTING
def announcer?
return true # ?? Was "skip_authorization_check" before?
data_entry_volunteer? || director?(record.event) || super_admin?
end
def heat_recording?
data_entry_volunteer? || director?(record.event) || super_admin?
end
# DATA MANAGEMENT
def view_result_data?
director?(record.event) || super_admin?
end
def modify_result_data?
record.unlocked? && view_result_data?
end
def single_attempt_recording?
data_entry_volunteer? || director?(record.event) || super_admin?
end
def two_attempt_recording?
data_entry_volunteer? || director?(record.event) || super_admin?
end
def start_list?
true
end
# DATA ENTRY
def create_preliminary_result?
record.unlocked? && (data_entry_volunteer? || director?(record.event)|| super_admin?)
end
def manage_volunteers?
director?(record.event) || super_admin?
end
def publish_age_group_entry?
super_admin?
end
def set_age_group_places?
super_admin?
end
private
class Scope < Scope
def resolve
scope.none
end
end
end
|
class Mysql < Formula
desc "Open source relational database management system"
homepage "https://dev.mysql.com/doc/refman/8.0/en/"
url "https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-8.0.12.tar.gz"
sha256 "99abae6660b53a462cff7c9fefb56d17f52823e9a964831aee1ae5633d9a2982"
bottle do
rebuild 1
sha256 "b56609f349ecc52c1b0718b8882fe0c85774e02cd08dab68d4e749e95fac5289" => :mojave
sha256 "d9a08d2ec153a122b069cfe82f5ff8445fe108969d33985a697290a01844950e" => :high_sierra
sha256 "140885182eac70d95b65110534222a3e6cc4c64d31f8a44618af7f6f123c29ce" => :sierra
end
depends_on "cmake" => :build
# GCC is not supported either, so exclude for El Capitan.
depends_on :macos => :sierra if DevelopmentTools.clang_build_version == 800
# https://github.com/Homebrew/homebrew-core/issues/1475
# Needs at least Clang 3.6, which shipped alongside Yosemite.
# Note: MySQL themselves don't support anything below Sierra.
depends_on :macos => :yosemite
depends_on "openssl"
conflicts_with "mysql-cluster", "mariadb", "percona-server",
:because => "mysql, mariadb, and percona install the same binaries."
conflicts_with "mysql-connector-c",
:because => "both install MySQL client libraries"
conflicts_with "mariadb-connector-c",
:because => "both install plugins"
# https://bugs.mysql.com/bug.php?id=86711
# https://github.com/Homebrew/homebrew-core/pull/20538
fails_with :clang do
build 800
cause "Wrong inlining with Clang 8.0, see MySQL Bug #86711"
end
def datadir
var/"mysql"
end
def install
# -DINSTALL_* are relative to `CMAKE_INSTALL_PREFIX` (`prefix`)
args = %W[
-DCOMPILATION_COMMENT=Homebrew
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_INFODIR=share/info
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_PLUGINDIR=lib/plugin
-DMYSQL_DATADIR=#{datadir}
-DSYSCONFDIR=#{etc}
-DWITH_BOOST=boost
-DWITH_EDITLINE=system
-DWITH_SSL=yes
-DWITH_UNIT_TESTS=OFF
-DWITH_EMBEDDED_SERVER=ON
-DENABLED_LOCAL_INFILE=1
-DWITH_INNODB_MEMCACHED=ON
]
system "cmake", ".", *std_cmake_args, *args
system "make"
system "make", "install"
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{Dir.mktmpdir}"
end
# Remove the tests directory
rm_rf prefix/"mysql-test"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Fix up the control script and link into bin.
inreplace "#{prefix}/support-files/mysql.server",
/^(PATH=".*)(")/,
"\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"
# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
etc.install "my.cnf"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/general_log.CSM").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<~EOS
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
EOS
if my_cnf = ["/etc/my.cnf", "/etc/mysql/my.cnf"].find { |x| File.exist? x }
s += <<~EOS
A "#{my_cnf}" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
begin
# Expects datadir to be a completely clean dir, which testpath isn't.
dir = Dir.mktmpdir
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{dir}", "--tmpdir=#{dir}"
pid = fork do
exec bin/"mysqld", "--bind-address=127.0.0.1", "--datadir=#{dir}"
end
sleep 2
output = shell_output("curl 127.0.0.1:3306")
output.force_encoding("ASCII-8BIT") if output.respond_to?(:force_encoding)
assert_match version.to_s, output
ensure
Process.kill(9, pid)
Process.wait(pid)
end
end
end
mysql 8.0.13
Closes #35544.
Signed-off-by: Chongyu Zhu <042dc4512fa3d391c5170cf3aa61e6a638f84342@lembacon.com>
class Mysql < Formula
desc "Open source relational database management system"
homepage "https://dev.mysql.com/doc/refman/8.0/en/"
url "https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-8.0.13.tar.gz"
sha256 "61f97906050c2a0cc008be347f70c2c6612425c85342466f549088c570b35ff4"
bottle do
rebuild 1
sha256 "b56609f349ecc52c1b0718b8882fe0c85774e02cd08dab68d4e749e95fac5289" => :mojave
sha256 "d9a08d2ec153a122b069cfe82f5ff8445fe108969d33985a697290a01844950e" => :high_sierra
sha256 "140885182eac70d95b65110534222a3e6cc4c64d31f8a44618af7f6f123c29ce" => :sierra
end
depends_on "cmake" => :build
# GCC is not supported either, so exclude for El Capitan.
depends_on :macos => :sierra if DevelopmentTools.clang_build_version == 800
# https://github.com/Homebrew/homebrew-core/issues/1475
# Needs at least Clang 3.6, which shipped alongside Yosemite.
# Note: MySQL themselves don't support anything below Sierra.
depends_on :macos => :yosemite
depends_on "openssl"
conflicts_with "mysql-cluster", "mariadb", "percona-server",
:because => "mysql, mariadb, and percona install the same binaries."
conflicts_with "mysql-connector-c",
:because => "both install MySQL client libraries"
conflicts_with "mariadb-connector-c",
:because => "both install plugins"
# https://bugs.mysql.com/bug.php?id=86711
# https://github.com/Homebrew/homebrew-core/pull/20538
fails_with :clang do
build 800
cause "Wrong inlining with Clang 8.0, see MySQL Bug #86711"
end
def datadir
var/"mysql"
end
def install
# -DINSTALL_* are relative to `CMAKE_INSTALL_PREFIX` (`prefix`)
args = %W[
-DCOMPILATION_COMMENT=Homebrew
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_INFODIR=share/info
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_PLUGINDIR=lib/plugin
-DMYSQL_DATADIR=#{datadir}
-DSYSCONFDIR=#{etc}
-DWITH_BOOST=boost
-DWITH_EDITLINE=system
-DWITH_SSL=yes
-DWITH_UNIT_TESTS=OFF
-DWITH_EMBEDDED_SERVER=ON
-DENABLED_LOCAL_INFILE=1
-DWITH_INNODB_MEMCACHED=ON
]
system "cmake", ".", *std_cmake_args, *args
system "make"
system "make", "install"
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{Dir.mktmpdir}"
end
# Remove the tests directory
rm_rf prefix/"mysql-test"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Fix up the control script and link into bin.
inreplace "#{prefix}/support-files/mysql.server",
/^(PATH=".*)(")/,
"\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"
# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
etc.install "my.cnf"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/general_log.CSM").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<~EOS
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
EOS
if my_cnf = ["/etc/my.cnf", "/etc/mysql/my.cnf"].find { |x| File.exist? x }
s += <<~EOS
A "#{my_cnf}" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
begin
# Expects datadir to be a completely clean dir, which testpath isn't.
dir = Dir.mktmpdir
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{dir}", "--tmpdir=#{dir}"
pid = fork do
exec bin/"mysqld", "--bind-address=127.0.0.1", "--datadir=#{dir}"
end
sleep 2
output = shell_output("curl 127.0.0.1:3306")
output.force_encoding("ASCII-8BIT") if output.respond_to?(:force_encoding)
assert_match version.to_s, output
ensure
Process.kill(9, pid)
Process.wait(pid)
end
end
end
|
# frozen_string_literal: true
class SearchPresenter < BasePresenter
RESULT_AYAH = 'ayah'
attr_reader :query,
:navigational_results,
:pagination
def initialize(params, query)
super(params)
@query = query
end
def add_navigational_results(search)
@navigational_results = search.results
end
def add_search_results(search_response)
@search = search_response
@pagination = search_response.pagination
@results = @search.results
end
def no_results?
@search.nil? || @search.empty?
end
def next_page
pagination.next
end
def verses_results
verses = load_verses(@results.pluck("verse_id").uniq)
search_result = {
}
@results.map do |item|
if RESULT_AYAH == item['result_type']
search_result[item['verse_id']] ||= item
search_result[item['verse_id']][:words] = prepare_verse_words(item, verses)
else
search_result[item['verse_id']] ||= {
result_type: 'ayah',
verse_key: item['verse_key'],
verse_id: item['verse_id']
}
search_result[item['verse_id']][:words] ||= prepare_verse_words(item, verses)
search_result[item['verse_id']]['translations'] ||= []
search_result[item['verse_id']]['translations'].push({
text: item['text'],
id: item['id'],
resource_id: item['resource_id'],
resource_name: item['resource_name'],
language_name: item['language_name']
}
)
end
end
search_result.values
end
protected
def prepare_verse_words(item, verses)
verse = verses.detect { |v| v.id == item['verse_id'] }
highlighted_words = item['highlighted_words'] || []
verse.words.map do |w|
{
id: w.id,
position: w.position,
audio_url: w.audio_url,
char_type_name: "word",
text: w.qpc_uthmani_hafs,
highlight: highlighted_words.include?(w.id),
translation: {
text: w.word_translation&.text,
language_name: w.word_translation&.language_name
},
transliteration: {
text: w.en_transliteration,
language_name: 'english'
}
}
end
end
def load_verses(ids)
language = word_trans_language
verses = Verse.where(id: ids).select('verses.id')
words_with_default_translation = verses.where(word_translations: { language_id: Language.default.id })
if language
verses = verses
.where(word_translations: { language_id: language.id })
.or(words_with_default_translation)
.eager_load(words: :word_translation)
else
verses = words_with_default_translation
.eager_load(words: :word_translation)
end
verses.order("words.position ASC, word_translations.priority ASC")
end
def word_trans_language
if (lang = (params[:language] || params[:locale])).presence
Language.find_with_id_or_iso_code lang
end
end
end
text shouldn't be an array
# frozen_string_literal: true
class SearchPresenter < BasePresenter
RESULT_AYAH = 'ayah'
attr_reader :query,
:navigational_results,
:pagination
def initialize(params, query)
super(params)
@query = query
end
def add_navigational_results(search)
@navigational_results = search.results
end
def add_search_results(search_response)
@search = search_response
@pagination = search_response.pagination
@results = @search.results
end
def no_results?
@search.nil? || @search.empty?
end
def next_page
pagination.next
end
def verses_results
verses = load_verses(@results.pluck("verse_id").uniq)
search_result = {
}
@results.map do |item|
if RESULT_AYAH == item['result_type']
search_result[item['verse_id']] ||= item
search_result[item['verse_id']][:words] = prepare_verse_words(item, verses)
else
search_result[item['verse_id']] ||= {
result_type: 'ayah',
verse_key: item['verse_key'],
verse_id: item['verse_id']
}
search_result[item['verse_id']][:words] ||= prepare_verse_words(item, verses)
search_result[item['verse_id']]['translations'] ||= []
search_result[item['verse_id']]['translations'].push({
text: item['text'][0],
id: item['id'],
resource_id: item['resource_id'],
resource_name: item['resource_name'],
language_name: item['language_name']
}
)
end
end
search_result.values
end
protected
def prepare_verse_words(item, verses)
verse = verses.detect { |v| v.id == item['verse_id'] }
highlighted_words = item['highlighted_words'] || []
verse.words.map do |w|
{
id: w.id,
position: w.position,
audio_url: w.audio_url,
char_type_name: "word",
text: w.qpc_uthmani_hafs,
highlight: highlighted_words.include?(w.id),
translation: {
text: w.word_translation&.text,
language_name: w.word_translation&.language_name
},
transliteration: {
text: w.en_transliteration,
language_name: 'english'
}
}
end
end
def load_verses(ids)
language = word_trans_language
verses = Verse.where(id: ids).select('verses.id')
words_with_default_translation = verses.where(word_translations: { language_id: Language.default.id })
if language
verses = verses
.where(word_translations: { language_id: language.id })
.or(words_with_default_translation)
.eager_load(words: :word_translation)
else
verses = words_with_default_translation
.eager_load(words: :word_translation)
end
verses.order("words.position ASC, word_translations.priority ASC")
end
def word_trans_language
if (lang = (params[:language] || params[:locale])).presence
Language.find_with_id_or_iso_code lang
end
end
end
|
require "bundler/capistrano"
set :stages, %w(production staging testing vm)
set :default_stage, "testing"
require "capistrano/ext/multistage"
set :application, "canvas"
set :repository, "git://github.com/sfu/canvas-lms.git"
set :scm, :git
set :user, "canvasuser"
set :branch, "sfu-deploy"
set :deploy_via, :remote_cache
set :deploy_to, "/var/rails/canvas"
set :use_sudo, false
set :deploy_env, "production"
set :bundle_dir, "/opt/ruby-enterprise-1.8.7-2012.02/lib/ruby/gems/1.8"
set :bundle_without, []
default_run_options[:pty] = true
if (ENV.has_key?('gateway') && ENV['gateway'].downcase == "true")
set :gateway, "welcome.its.sfu.ca"
end
disable_log_formatters;
ssh_options[:forward_agent] = true
ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "id_rsa_canvas")]
namespace :deploy do
task :start do ; end
task :stop do ; end
desc 'Signal Passenger to restart the application.'
task :restart, :except => { :no_release => true } do
# run "touch #{release_path}/tmp/restart.txt"
run "sudo /etc/init.d/httpd restart"
end
namespace :web do
task :disable, :roles => :app do
on_rollback { rm "#{shared_path}/system/maintenance.html" }
run "cp /usr/local/canvas/maintenance.html #{shared_path}/system/maintenance.html && chmod 0644 #{shared_path}/system/maintenance.html"
end
task :enable, :roles => :app do
run "rm #{shared_path}/system/maintenance.html"
end
end
end
namespace :canvas do
desc "Create symlink for files folder to mount point"
task :symlink_canvasfiles do
target = "mnt/data"
run "mkdir -p #{latest_release}/mnt/data && ln -s /mnt/data/canvasfiles #{latest_release}/#{target}/canvasfiles"
end
desc "Copy config files from /mnt/data/canvasconfig/config"
task :copy_config do
run "sudo /etc/init.d/canvasconfig start"
end
desc "Clone QTIMigrationTool"
task :clone_qtimigrationtool do
run "cd #{latest_release}/vendor && git clone https://github.com/instructure/QTIMigrationTool.git QTIMigrationTool && chmod +x QTIMigrationTool/migrate.py"
end
desc "Compile static assets"
task :compile_assets, :on_error => :continue do
# On remote: bundle exec rake canvas:compile_assets
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} canvas:compile_assets --quiet"
run "cd #{latest_release} && chown -R canvasuser:canvasuser ."
end
desc "Load new notification types"
task :load_notifications, :roles => :db, :only => { :primary => true } do
# On remote: RAILS_ENV=production bundle exec rake db:load_notifications
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} db:load_notifications --quiet"
end
desc "Restart delayed jobs workers"
task :restart_jobs, :roles => :db, :only => { :primary => true } do
run "sudo /etc/init.d/canvas_init restart"
end
desc "Log the deploy to graphite"
task :log_deploy do
ts = Time.now.to_i
cmd = "echo 'stats.canvas.#{stage}.deploys 1 #{ts}' | nc stats.tier2.sfu.ca 2003"
puts cmd
puts run_locally cmd
end
desc "Post-update commands"
task :update_remote do
copy_config
clone_qtimigrationtool
deploy.migrate
load_notifications
restart_jobs
log_deploy
end
end
before(:deploy, "deploy:web:disable")
before("deploy:restart", "canvas:symlink_canvasfiles")
before("deploy:restart", "canvas:compile_assets")
before("deploy:restart", "canvas:update_remote")
after(:deploy, "deploy:cleanup")
after(:deploy, "deploy:web:enable")
Disable generate documentation task
require "bundler/capistrano"
set :stages, %w(production staging testing vm)
set :default_stage, "testing"
require "capistrano/ext/multistage"
set :application, "canvas"
set :repository, "git://github.com/sfu/canvas-lms.git"
set :scm, :git
set :user, "canvasuser"
set :branch, "sfu-deploy"
set :deploy_via, :remote_cache
set :deploy_to, "/var/rails/canvas"
set :use_sudo, false
set :deploy_env, "production"
set :bundle_dir, "/opt/ruby-enterprise-1.8.7-2012.02/lib/ruby/gems/1.8"
set :bundle_without, []
default_run_options[:pty] = true
if (ENV.has_key?('gateway') && ENV['gateway'].downcase == "true")
set :gateway, "welcome.its.sfu.ca"
end
disable_log_formatters;
ssh_options[:forward_agent] = true
ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "id_rsa_canvas")]
namespace :deploy do
task :start do ; end
task :stop do ; end
desc 'Signal Passenger to restart the application.'
task :restart, :except => { :no_release => true } do
# run "touch #{release_path}/tmp/restart.txt"
run "sudo /etc/init.d/httpd restart"
end
namespace :web do
task :disable, :roles => :app do
on_rollback { rm "#{shared_path}/system/maintenance.html" }
run "cp /usr/local/canvas/maintenance.html #{shared_path}/system/maintenance.html && chmod 0644 #{shared_path}/system/maintenance.html"
end
task :enable, :roles => :app do
run "rm #{shared_path}/system/maintenance.html"
end
end
end
namespace :canvas do
desc "Create symlink for files folder to mount point"
task :symlink_canvasfiles do
target = "mnt/data"
run "mkdir -p #{latest_release}/mnt/data && ln -s /mnt/data/canvasfiles #{latest_release}/#{target}/canvasfiles"
end
desc "Copy config files from /mnt/data/canvasconfig/config"
task :copy_config do
run "sudo /etc/init.d/canvasconfig start"
end
desc "Clone QTIMigrationTool"
task :clone_qtimigrationtool do
run "cd #{latest_release}/vendor && git clone https://github.com/instructure/QTIMigrationTool.git QTIMigrationTool && chmod +x QTIMigrationTool/migrate.py"
end
desc "Compile static assets"
task :compile_assets, :on_error => :continue do
# On remote: bundle exec rake canvas:compile_assets
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} canvas:compile_assets[false] --quiet"
run "cd #{latest_release} && chown -R canvasuser:canvasuser ."
end
desc "Load new notification types"
task :load_notifications, :roles => :db, :only => { :primary => true } do
# On remote: RAILS_ENV=production bundle exec rake db:load_notifications
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} db:load_notifications --quiet"
end
desc "Restart delayed jobs workers"
task :restart_jobs, :roles => :db, :only => { :primary => true } do
run "sudo /etc/init.d/canvas_init restart"
end
desc "Log the deploy to graphite"
task :log_deploy do
ts = Time.now.to_i
cmd = "echo 'stats.canvas.#{stage}.deploys 1 #{ts}' | nc stats.tier2.sfu.ca 2003"
puts cmd
puts run_locally cmd
end
desc "Post-update commands"
task :update_remote do
copy_config
clone_qtimigrationtool
deploy.migrate
load_notifications
restart_jobs
log_deploy
end
end
before(:deploy, "deploy:web:disable")
before("deploy:restart", "canvas:symlink_canvasfiles")
before("deploy:restart", "canvas:compile_assets")
before("deploy:restart", "canvas:update_remote")
after(:deploy, "deploy:cleanup")
after(:deploy, "deploy:web:enable")
|
class Ncmpc < Formula
desc "Curses Music Player Daemon (MPD) client"
homepage "https://www.musicpd.org/clients/ncmpc/"
url "https://www.musicpd.org/download/ncmpc/0/ncmpc-0.45.tar.xz"
sha256 "17ff446447e002f2ed4342b7324263a830df7d76bcf177dce928f7d3a6f1f785"
license "GPL-2.0-or-later"
livecheck do
url "https://www.musicpd.org/download/ncmpc/0/"
regex(/href=.*?ncmpc[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "982287b4dcffb2e5534640b77f22b5f73865f8c0a521089252001557f3fe402a"
sha256 cellar: :any, big_sur: "212ca11a9b74741334dca03a195c1d46898d6d7036708d48cf3ef704f29ddde6"
sha256 cellar: :any, catalina: "6df55c912cf6f466378b548d9752793a9d2b6eb42c55c7cf2c1bc156fd29743c"
sha256 cellar: :any, mojave: "972c8c9f233312353c16e416ecdd8c643fb5d805946c5ca7cdd1e9fae8c792a7"
end
depends_on "boost" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "gettext"
depends_on "libmpdclient"
depends_on "pcre"
def install
mkdir "build" do
system "meson", *std_meson_args, "-Dcolors=false", "-Dnls=disabled", ".."
system "ninja", "install"
end
end
test do
system bin/"ncmpc", "--help"
end
end
ncmpc: needs gcc on Linux
Fixes:
../src/util/IntrusiveList.hxx:110:61: error: expected string-literal before ')' token
../src/util/IntrusiveList.hxx: In static member function 'static constexpr const IntrusiveListHook& IntrusiveList<T>::ToHook(const T&)':
../src/util/IntrusiveList.hxx:115:61: error: expected ',' before ')' token
static_assert(std::is_base_of<IntrusiveListHook, T>::value);
^
../src/util/IntrusiveList.hxx:115:61: error: expected string-literal before ')' token
In file included from ../src/mpdclient.hxx:26:0,
from ../src/OutputsPage.cxx:29:
../src/event/FineTimerEvent.hxx: At global scope:
../src/event/FineTimerEvent.hxx:77:17: error: enclosing class of constexpr non-static member function 'auto FineTimerEvent::GetDue() const' is not a literal type
constexpr auto GetDue() const noexcept {
^
../src/event/FineTimerEvent.hxx:53:7: note: 'FineTimerEvent' is not literal because:
class FineTimerEvent final
^
../src/event/FineTimerEvent.hxx:53:7: note: 'FineTimerEvent' has a non-trivial destructor
ninja: build stopped: subcommand failed.
Closes #81887.
Signed-off-by: Daniel Nachun <67d4b1adb270d50ecb7ec053ff144a69f3054d28@users.noreply.github.com>
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
class Ncmpc < Formula
desc "Curses Music Player Daemon (MPD) client"
homepage "https://www.musicpd.org/clients/ncmpc/"
url "https://www.musicpd.org/download/ncmpc/0/ncmpc-0.45.tar.xz"
sha256 "17ff446447e002f2ed4342b7324263a830df7d76bcf177dce928f7d3a6f1f785"
license "GPL-2.0-or-later"
livecheck do
url "https://www.musicpd.org/download/ncmpc/0/"
regex(/href=.*?ncmpc[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "982287b4dcffb2e5534640b77f22b5f73865f8c0a521089252001557f3fe402a"
sha256 cellar: :any, big_sur: "212ca11a9b74741334dca03a195c1d46898d6d7036708d48cf3ef704f29ddde6"
sha256 cellar: :any, catalina: "6df55c912cf6f466378b548d9752793a9d2b6eb42c55c7cf2c1bc156fd29743c"
sha256 cellar: :any, mojave: "972c8c9f233312353c16e416ecdd8c643fb5d805946c5ca7cdd1e9fae8c792a7"
end
depends_on "boost" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "gettext"
depends_on "libmpdclient"
depends_on "pcre"
on_linux do
depends_on "gcc"
end
fails_with gcc: "5"
def install
mkdir "build" do
system "meson", *std_meson_args, "-Dcolors=false", "-Dnls=disabled", ".."
system "ninja", "install"
end
end
test do
system bin/"ncmpc", "--help"
end
end
|
class Neo4j < Formula
desc "Robust (fully ACID) transactional property graph database"
homepage "https://neo4j.com/"
url "https://neo4j.com/artifact.php?name=neo4j-community-4.4.8-unix.tar.gz"
sha256 "34c8ce7edc2ab9f63a204f74f37621cac3427f12b0aef4c6ef47eaf4c2b90d66"
license "GPL-3.0-or-later"
livecheck do
url "https://neo4j.com/download-center/"
regex(/href=.*?edition=community[^"' >]+release=v?(\d+(?:\.\d+)+)[&"' >]
|href=.*?release=v?(\d+(?:\.\d+)+)[^"' >]+edition=community/ix)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "9783f1a2efd47678571c95eb0f8ef094cdfd5f9e4c01ba215408e0e4bb6e815c"
end
depends_on "openjdk@11"
def install
env = {
JAVA_HOME: Formula["openjdk@11"].opt_prefix,
NEO4J_HOME: libexec,
}
# Remove windows files
rm_f Dir["bin/*.bat"]
# Install jars in libexec to avoid conflicts
libexec.install Dir["*"]
# Symlink binaries
bin.install Dir["#{libexec}/bin/neo4j{,-shell,-import,-shared.sh,-admin}", "#{libexec}/bin/cypher-shell"]
bin.env_script_all_files(libexec/"bin", env)
# Adjust UDC props
# Suppress the empty, focus-stealing java gui.
(libexec/"conf/neo4j.conf").append_lines <<~EOS
wrapper.java.additional=-Djava.awt.headless=true
wrapper.java.additional.4=-Dneo4j.ext.udc.source=homebrew
dbms.directories.data=#{var}/neo4j/data
dbms.directories.logs=#{var}/log/neo4j
EOS
end
def post_install
(var/"log/neo4j").mkpath
(var/"neo4j").mkpath
end
service do
run [opt_bin/"neo4j", "console"]
keep_alive false
working_dir var
log_path var/"log/neo4j.log"
error_log_path var/"log/neo4j.log"
end
test do
ENV["NEO4J_HOME"] = libexec
ENV["NEO4J_LOG"] = testpath/"libexec/data/log/neo4j.log"
ENV["NEO4J_PIDFILE"] = testpath/"libexec/data/neo4j-service.pid"
mkpath testpath/"libexec/data/log"
assert_match(/Neo4j .*is not running/i, shell_output("#{bin}/neo4j status", 3))
end
end
neo4j 4.4.9
Closes #106112.
Signed-off-by: Sean Molenaar <2b250e3fea88cfef248b497ad5fc17f7dc435154@users.noreply.github.com>
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
class Neo4j < Formula
desc "Robust (fully ACID) transactional property graph database"
homepage "https://neo4j.com/"
url "https://neo4j.com/artifact.php?name=neo4j-community-4.4.9-unix.tar.gz"
sha256 "4ee12a98d2dd819d6f08408429014b65264097a812ba5978c14836d6bbccb4a0"
license "GPL-3.0-or-later"
livecheck do
url "https://neo4j.com/download-center/"
regex(/href=.*?edition=community[^"' >]+release=v?(\d+(?:\.\d+)+)[&"' >]
|href=.*?release=v?(\d+(?:\.\d+)+)[^"' >]+edition=community/ix)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "9783f1a2efd47678571c95eb0f8ef094cdfd5f9e4c01ba215408e0e4bb6e815c"
end
depends_on "openjdk@11"
def install
env = {
JAVA_HOME: Formula["openjdk@11"].opt_prefix,
NEO4J_HOME: libexec,
}
# Remove windows files
rm_f Dir["bin/*.bat"]
# Install jars in libexec to avoid conflicts
libexec.install Dir["*"]
# Symlink binaries
bin.install Dir["#{libexec}/bin/neo4j{,-shell,-import,-shared.sh,-admin}", "#{libexec}/bin/cypher-shell"]
bin.env_script_all_files(libexec/"bin", env)
# Adjust UDC props
# Suppress the empty, focus-stealing java gui.
(libexec/"conf/neo4j.conf").append_lines <<~EOS
wrapper.java.additional=-Djava.awt.headless=true
wrapper.java.additional.4=-Dneo4j.ext.udc.source=homebrew
dbms.directories.data=#{var}/neo4j/data
dbms.directories.logs=#{var}/log/neo4j
EOS
end
def post_install
(var/"log/neo4j").mkpath
(var/"neo4j").mkpath
end
service do
run [opt_bin/"neo4j", "console"]
keep_alive false
working_dir var
log_path var/"log/neo4j.log"
error_log_path var/"log/neo4j.log"
end
test do
ENV["NEO4J_HOME"] = libexec
ENV["NEO4J_LOG"] = testpath/"libexec/data/log/neo4j.log"
ENV["NEO4J_PIDFILE"] = testpath/"libexec/data/neo4j-service.pid"
mkpath testpath/"libexec/data/log"
assert_match(/Neo4j .*is not running/i, shell_output("#{bin}/neo4j status", 3))
end
end
|
class ApiController < ApplicationController
before_action :doorkeeper_authorize!
respond_to :json
def find_course(id = nil)
return unless @course.nil?
@course = Course.find_by(id: id || params[:course_id])
head :not_found if @course.nil?
end
def require_admin_or_prof
admin_or_prof = current_user_site_admin? || current_user_prof_for?(@course)
head :forbidden unless admin_or_prof
end
def require_admin
head :forbidden unless current_user_site_admin?
end
def require_admin_or_prof_ever
admin_or_prof = current_user_site_admin? || current_user&.professor_ever?
head :forbidden unless admin_or_prof
end
def current_user
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end
def require_registered_user
find_course
return if current_user_site_admin?
@registration = current_user.registration_for(@course)
if @registration.nil?
head :forbidden
elsif @registration.dropped_date
head :forbidden
end
end
private
def serialize_user(user)
{
username: user.username,
display_name: user.display_name,
nuid: user.nuid,
email: user.email,
prof: user.professor_ever?,
image_url: user.profile
}
end
end
remove prof_ever from serialize_user
class ApiController < ApplicationController
before_action :doorkeeper_authorize!
respond_to :json
def find_course(id = nil)
return unless @course.nil?
@course = Course.find_by(id: id || params[:course_id])
head :not_found if @course.nil?
end
def require_admin_or_prof
admin_or_prof = current_user_site_admin? || current_user_prof_for?(@course)
head :forbidden unless admin_or_prof
end
def require_admin
head :forbidden unless current_user_site_admin?
end
def require_admin_or_prof_ever
admin_or_prof = current_user_site_admin? || current_user&.professor_ever?
head :forbidden unless admin_or_prof
end
def current_user
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end
def require_registered_user
find_course
return if current_user_site_admin?
@registration = current_user.registration_for(@course)
if @registration.nil?
head :forbidden
elsif @registration.dropped_date
head :forbidden
end
end
private
def serialize_user(user)
{
username: user.username,
display_name: user.display_name,
nuid: user.nuid,
email: user.email,
image_url: user.profile
}
end
end
|
require 'formula'
class Nginx < Formula
homepage 'http://nginx.org/'
url 'http://nginx.org/download/nginx-1.0.6.tar.gz'
head 'http://nginx.org/download/nginx-1.1.3.tar.gz'
if ARGV.build_head?
md5 '3aa027ee3aabf1a5ae6e4a3bbd09efda'
else
md5 'bc98bac3f0b85da1045bc02e6d8fc80d'
end
depends_on 'pcre'
skip_clean 'logs'
# Changes default port to 8080
# Tell configure to look for pcre in HOMEBREW_PREFIX
def patches
DATA
end
def options
[
['--with-passenger', "Compile with support for Phusion Passenger module"],
['--with-webdav', "Compile with support for WebDAV module"]
]
end
def passenger_config_args
passenger_root = `passenger-config --root`.chomp
if File.directory?(passenger_root)
return "--add-module=#{passenger_root}/ext/nginx"
end
puts "Unable to install nginx with passenger support. The passenger"
puts "gem must be installed and passenger-config must be in your path"
puts "in order to continue."
exit
end
def install
args = ["--prefix=#{prefix}",
"--with-http_ssl_module",
"--with-pcre",
"--conf-path=#{etc}/nginx/nginx.conf",
"--pid-path=#{var}/run/nginx.pid",
"--lock-path=#{var}/nginx/nginx.lock"]
args << passenger_config_args if ARGV.include? '--with-passenger'
args << "--with-http_dav_module" if ARGV.include? '--with-webdav'
system "./configure", *args
system "make install"
(prefix+'org.nginx.nginx.plist').write startup_plist
(prefix+'org.nginx.nginx.plist').chmod 0644
end
def caveats; <<-EOS.undent
In the interest of allowing you to run `nginx` without `sudo`, the default
port is set to localhost:8080.
If you want to host pages on your local machine to the public, you should
change that to localhost:80, and run `sudo nginx`. You'll need to turn off
any other web servers running port 80, of course.
You can start nginx automatically on login running as your user with:
mkdir -p ~/Library/LaunchAgents
cp #{prefix}/org.nginx.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.nginx.nginx.plist
Though note that if running as your user, the launch agent will fail if you
try to use a port below 1024 (such as http's default of 80.)
EOS
end
def startup_plist
return <<-EOPLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.nginx.nginx</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>UserName</key>
<string>#{`whoami`.chomp}</string>
<key>ProgramArguments</key>
<array>
<string>#{sbin}/nginx</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOPLIST
end
end
__END__
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -155,6 +155,22 @@ else
. auto/feature
fi
+ if [ $ngx_found = no ]; then
+
+ # Homebrew
+ HOMEBREW_PREFIX=${NGX_PREFIX%Cellar*}
+ ngx_feature="PCRE library in ${HOMEBREW_PREFIX}"
+ ngx_feature_path="${HOMEBREW_PREFIX}/include"
+
+ if [ $NGX_RPATH = YES ]; then
+ ngx_feature_libs="-R${HOMEBREW_PREFIX}/lib -L${HOMEBREW_PREFIX}/lib -lpcre"
+ else
+ ngx_feature_libs="-L${HOMEBREW_PREFIX}/lib -lpcre"
+ fi
+
+ . auto/feature
+ fi
+
if [ $ngx_found = yes ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -33,7 +33,7 @@
#gzip on;
server {
- listen 80;
+ listen 8080;
server_name localhost;
#charset koi8-r;
nginx: fix patch variable substitution
Closes Homebrew/homebrew#7718.
Signed-off-by: Jack Nagel <43386ce32af96f5c56f2a88e458cb94cebee3751@gmail.com>
require 'formula'
class Nginx < Formula
homepage 'http://nginx.org/'
url 'http://nginx.org/download/nginx-1.0.6.tar.gz'
head 'http://nginx.org/download/nginx-1.1.3.tar.gz'
if ARGV.build_head?
md5 '3aa027ee3aabf1a5ae6e4a3bbd09efda'
else
md5 'bc98bac3f0b85da1045bc02e6d8fc80d'
end
depends_on 'pcre'
skip_clean 'logs'
# Changes default port to 8080
# Tell configure to look for pcre in HOMEBREW_PREFIX
def patches
DATA
end
def options
[
['--with-passenger', "Compile with support for Phusion Passenger module"],
['--with-webdav', "Compile with support for WebDAV module"]
]
end
def passenger_config_args
passenger_root = `passenger-config --root`.chomp
if File.directory?(passenger_root)
return "--add-module=#{passenger_root}/ext/nginx"
end
puts "Unable to install nginx with passenger support. The passenger"
puts "gem must be installed and passenger-config must be in your path"
puts "in order to continue."
exit
end
def install
args = ["--prefix=#{prefix}",
"--with-http_ssl_module",
"--with-pcre",
"--conf-path=#{etc}/nginx/nginx.conf",
"--pid-path=#{var}/run/nginx.pid",
"--lock-path=#{var}/nginx/nginx.lock"]
args << passenger_config_args if ARGV.include? '--with-passenger'
args << "--with-http_dav_module" if ARGV.include? '--with-webdav'
system "./configure", *args
system "make install"
(prefix+'org.nginx.nginx.plist').write startup_plist
(prefix+'org.nginx.nginx.plist').chmod 0644
end
def caveats; <<-EOS.undent
In the interest of allowing you to run `nginx` without `sudo`, the default
port is set to localhost:8080.
If you want to host pages on your local machine to the public, you should
change that to localhost:80, and run `sudo nginx`. You'll need to turn off
any other web servers running port 80, of course.
You can start nginx automatically on login running as your user with:
mkdir -p ~/Library/LaunchAgents
cp #{prefix}/org.nginx.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.nginx.nginx.plist
Though note that if running as your user, the launch agent will fail if you
try to use a port below 1024 (such as http's default of 80.)
EOS
end
def startup_plist
return <<-EOPLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.nginx.nginx</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>UserName</key>
<string>#{`whoami`.chomp}</string>
<key>ProgramArguments</key>
<array>
<string>#{sbin}/nginx</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOPLIST
end
end
__END__
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -155,6 +155,21 @@ else
. auto/feature
fi
+ if [ $ngx_found = no ]; then
+
+ # Homebrew
+ ngx_feature="PCRE library in HOMEBREW_PREFIX"
+ ngx_feature_path="HOMEBREW_PREFIX/include"
+
+ if [ $NGX_RPATH = YES ]; then
+ ngx_feature_libs="-RHOMEBREW_PREFIX/lib -LHOMEBREW_PREFIX/lib -lpcre"
+ else
+ ngx_feature_libs="-LHOMEBREW_PREFIX/lib -lpcre"
+ fi
+
+ . auto/feature
+ fi
+
if [ $ngx_found = yes ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -33,7 +33,7 @@
#gzip on;
server {
- listen 80;
+ listen 8080;
server_name localhost;
#charset koi8-r;
|
class Nginx < Formula
desc "HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server"
homepage "https://nginx.org/"
# Use "mainline" releases only (odd minor version number), not "stable"
# See https://www.nginx.com/blog/nginx-1-12-1-13-released/ for why
url "https://nginx.org/download/nginx-1.15.2.tar.gz"
sha256 "eeba09aecfbe8277ac33a5a2486ec2d6731739f3c1c701b42a0c3784af67ad90"
head "https://hg.nginx.org/nginx/", :using => :hg
bottle do
sha256 "d5bf234af2cb08f928d2c4835102dbf690815e9a24e79c74967d6e2d96afa1ae" => :high_sierra
sha256 "91e82e12c69c861fd19e11c2f47d86b4c7fe0df5a94d1369cb105e81f88f7e9a" => :sierra
sha256 "6504e5bf7043b3f77e435aed6193bbda6995c19c6a7e95219ae508bbecb68ed2" => :el_capitan
end
option "with-passenger", "Compile with support for Phusion Passenger module"
depends_on "openssl" # don't switch to 1.1 until passenger is switched, too
depends_on "pcre"
depends_on "passenger" => :optional
def install
# Changes default port to 8080
inreplace "conf/nginx.conf" do |s|
s.gsub! "listen 80;", "listen 8080;"
s.gsub! " #}\n\n}", " #}\n include servers/*;\n}"
end
openssl = Formula["openssl"]
pcre = Formula["pcre"]
cc_opt = "-I#{pcre.opt_include} -I#{openssl.opt_include}"
ld_opt = "-L#{pcre.opt_lib} -L#{openssl.opt_lib}"
args = %W[
--prefix=#{prefix}
--sbin-path=#{bin}/nginx
--with-cc-opt=#{cc_opt}
--with-ld-opt=#{ld_opt}
--conf-path=#{etc}/nginx/nginx.conf
--pid-path=#{var}/run/nginx.pid
--lock-path=#{var}/run/nginx.lock
--http-client-body-temp-path=#{var}/run/nginx/client_body_temp
--http-proxy-temp-path=#{var}/run/nginx/proxy_temp
--http-fastcgi-temp-path=#{var}/run/nginx/fastcgi_temp
--http-uwsgi-temp-path=#{var}/run/nginx/uwsgi_temp
--http-scgi-temp-path=#{var}/run/nginx/scgi_temp
--http-log-path=#{var}/log/nginx/access.log
--error-log-path=#{var}/log/nginx/error.log
--with-debug
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_degradation_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-ipv6
--with-mail
--with-mail_ssl_module
--with-pcre
--with-pcre-jit
--with-stream
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
]
if build.with? "passenger"
nginx_ext = `#{Formula["passenger"].opt_bin}/passenger-config --nginx-addon-dir`.chomp
args << "--add-module=#{nginx_ext}"
end
if build.head?
system "./auto/configure", *args
else
system "./configure", *args
end
system "make", "install"
if build.head?
man8.install "docs/man/nginx.8"
else
man8.install "man/nginx.8"
end
end
def post_install
(etc/"nginx/servers").mkpath
(var/"run/nginx").mkpath
# nginx's docroot is #{prefix}/html, this isn't useful, so we symlink it
# to #{HOMEBREW_PREFIX}/var/www. The reason we symlink instead of patching
# is so the user can redirect it easily to something else if they choose.
html = prefix/"html"
dst = var/"www"
if dst.exist?
html.rmtree
dst.mkpath
else
dst.dirname.mkpath
html.rename(dst)
end
prefix.install_symlink dst => "html"
# for most of this formula's life the binary has been placed in sbin
# and Homebrew used to suggest the user copy the plist for nginx to their
# ~/Library/LaunchAgents directory. So we need to have a symlink there
# for such cases
if rack.subdirs.any? { |d| d.join("sbin").directory? }
sbin.install_symlink bin/"nginx"
end
end
def passenger_caveats; <<~EOS
To activate Phusion Passenger, add this to #{etc}/nginx/nginx.conf, inside the 'http' context:
passenger_root #{Formula["passenger"].opt_libexec}/src/ruby_supportlib/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
EOS
end
def caveats
s = <<~EOS
Docroot is: #{var}/www
The default port has been set in #{etc}/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in #{etc}/nginx/servers/.
EOS
s << "\n" << passenger_caveats if build.with? "passenger"
s
end
plist_options :manual => "nginx"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/nginx</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOS
end
test do
(testpath/"nginx.conf").write <<~EOS
worker_processes 4;
error_log #{testpath}/error.log;
pid #{testpath}/nginx.pid;
events {
worker_connections 1024;
}
http {
client_body_temp_path #{testpath}/client_body_temp;
fastcgi_temp_path #{testpath}/fastcgi_temp;
proxy_temp_path #{testpath}/proxy_temp;
scgi_temp_path #{testpath}/scgi_temp;
uwsgi_temp_path #{testpath}/uwsgi_temp;
server {
listen 8080;
root #{testpath};
access_log #{testpath}/access.log;
error_log #{testpath}/error.log;
}
}
EOS
system bin/"nginx", "-t", "-c", testpath/"nginx.conf"
end
end
nginx: update 1.15.2 bottle.
class Nginx < Formula
desc "HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server"
homepage "https://nginx.org/"
# Use "mainline" releases only (odd minor version number), not "stable"
# See https://www.nginx.com/blog/nginx-1-12-1-13-released/ for why
url "https://nginx.org/download/nginx-1.15.2.tar.gz"
sha256 "eeba09aecfbe8277ac33a5a2486ec2d6731739f3c1c701b42a0c3784af67ad90"
head "https://hg.nginx.org/nginx/", :using => :hg
bottle do
sha256 "140b7782c4c231aefa464bd95dfdec5b39932f7f365e6349a9490c4bbb10b5f8" => :mojave
sha256 "d5bf234af2cb08f928d2c4835102dbf690815e9a24e79c74967d6e2d96afa1ae" => :high_sierra
sha256 "91e82e12c69c861fd19e11c2f47d86b4c7fe0df5a94d1369cb105e81f88f7e9a" => :sierra
sha256 "6504e5bf7043b3f77e435aed6193bbda6995c19c6a7e95219ae508bbecb68ed2" => :el_capitan
end
option "with-passenger", "Compile with support for Phusion Passenger module"
depends_on "openssl" # don't switch to 1.1 until passenger is switched, too
depends_on "pcre"
depends_on "passenger" => :optional
def install
# Changes default port to 8080
inreplace "conf/nginx.conf" do |s|
s.gsub! "listen 80;", "listen 8080;"
s.gsub! " #}\n\n}", " #}\n include servers/*;\n}"
end
openssl = Formula["openssl"]
pcre = Formula["pcre"]
cc_opt = "-I#{pcre.opt_include} -I#{openssl.opt_include}"
ld_opt = "-L#{pcre.opt_lib} -L#{openssl.opt_lib}"
args = %W[
--prefix=#{prefix}
--sbin-path=#{bin}/nginx
--with-cc-opt=#{cc_opt}
--with-ld-opt=#{ld_opt}
--conf-path=#{etc}/nginx/nginx.conf
--pid-path=#{var}/run/nginx.pid
--lock-path=#{var}/run/nginx.lock
--http-client-body-temp-path=#{var}/run/nginx/client_body_temp
--http-proxy-temp-path=#{var}/run/nginx/proxy_temp
--http-fastcgi-temp-path=#{var}/run/nginx/fastcgi_temp
--http-uwsgi-temp-path=#{var}/run/nginx/uwsgi_temp
--http-scgi-temp-path=#{var}/run/nginx/scgi_temp
--http-log-path=#{var}/log/nginx/access.log
--error-log-path=#{var}/log/nginx/error.log
--with-debug
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_degradation_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-ipv6
--with-mail
--with-mail_ssl_module
--with-pcre
--with-pcre-jit
--with-stream
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
]
if build.with? "passenger"
nginx_ext = `#{Formula["passenger"].opt_bin}/passenger-config --nginx-addon-dir`.chomp
args << "--add-module=#{nginx_ext}"
end
if build.head?
system "./auto/configure", *args
else
system "./configure", *args
end
system "make", "install"
if build.head?
man8.install "docs/man/nginx.8"
else
man8.install "man/nginx.8"
end
end
def post_install
(etc/"nginx/servers").mkpath
(var/"run/nginx").mkpath
# nginx's docroot is #{prefix}/html, this isn't useful, so we symlink it
# to #{HOMEBREW_PREFIX}/var/www. The reason we symlink instead of patching
# is so the user can redirect it easily to something else if they choose.
html = prefix/"html"
dst = var/"www"
if dst.exist?
html.rmtree
dst.mkpath
else
dst.dirname.mkpath
html.rename(dst)
end
prefix.install_symlink dst => "html"
# for most of this formula's life the binary has been placed in sbin
# and Homebrew used to suggest the user copy the plist for nginx to their
# ~/Library/LaunchAgents directory. So we need to have a symlink there
# for such cases
if rack.subdirs.any? { |d| d.join("sbin").directory? }
sbin.install_symlink bin/"nginx"
end
end
def passenger_caveats; <<~EOS
To activate Phusion Passenger, add this to #{etc}/nginx/nginx.conf, inside the 'http' context:
passenger_root #{Formula["passenger"].opt_libexec}/src/ruby_supportlib/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
EOS
end
def caveats
s = <<~EOS
Docroot is: #{var}/www
The default port has been set in #{etc}/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in #{etc}/nginx/servers/.
EOS
s << "\n" << passenger_caveats if build.with? "passenger"
s
end
plist_options :manual => "nginx"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/nginx</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOS
end
test do
(testpath/"nginx.conf").write <<~EOS
worker_processes 4;
error_log #{testpath}/error.log;
pid #{testpath}/nginx.pid;
events {
worker_connections 1024;
}
http {
client_body_temp_path #{testpath}/client_body_temp;
fastcgi_temp_path #{testpath}/fastcgi_temp;
proxy_temp_path #{testpath}/proxy_temp;
scgi_temp_path #{testpath}/scgi_temp;
uwsgi_temp_path #{testpath}/uwsgi_temp;
server {
listen 8080;
root #{testpath};
access_log #{testpath}/access.log;
error_log #{testpath}/error.log;
}
}
EOS
system bin/"nginx", "-t", "-c", testpath/"nginx.conf"
end
end
|
class ApiController < ApplicationController
before_action :doorkeeper_authorize!
respond_to :json
def find_course(id = nil)
return unless @course.nil?
@course = Course.find_by(id: id || params[:course_id])
head :not_found if @course.nil?
end
def require_admin_or_prof
admin_or_prof = current_user_site_admin? || current_user_prof_for?(@course)
head :forbidden unless admin_or_prof
end
def require_admin
head :forbidden unless current_user_site_admin?
end
def require_admin_or_prof_ever
admin_or_prof = current_user_site_admin? || current_user&.professor_ever?
head :forbidden unless admin_or_prof
end
def current_user
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end
def require_registered_user
find_course
return if current_user_site_admin?
@registration = current_user.registration_for(@course)
if @registration.nil?
head :forbidden
elsif @registration.dropped_date
head :forbidden
end
end
private
def serialize_user(user)
{
username: user.username,
display_name: user.display_name,
nuid: user.nuid,
email: user.email,
image_url: Upload.upload_path_for(user.profile)
}
end
end
need to disable CSRF protection here for inbound connections from Hourglass
class ApiController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :doorkeeper_authorize!
respond_to :json
def find_course(id = nil)
return unless @course.nil?
@course = Course.find_by(id: id || params[:course_id])
head :not_found if @course.nil?
end
def require_admin_or_prof
admin_or_prof = current_user_site_admin? || current_user_prof_for?(@course)
head :forbidden unless admin_or_prof
end
def require_admin
head :forbidden unless current_user_site_admin?
end
def require_admin_or_prof_ever
admin_or_prof = current_user_site_admin? || current_user&.professor_ever?
head :forbidden unless admin_or_prof
end
def current_user
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end
def require_registered_user
find_course
return if current_user_site_admin?
@registration = current_user.registration_for(@course)
if @registration.nil?
head :forbidden
elsif @registration.dropped_date
head :forbidden
end
end
private
def serialize_user(user)
{
username: user.username,
display_name: user.display_name,
nuid: user.nuid,
email: user.email,
image_url: Upload.upload_path_for(user.profile)
}
end
end
|
require "formula"
class Ninja < Formula
homepage "https://martine.github.io/ninja/"
url "https://github.com/martine/ninja/archive/v1.5.3.tar.gz"
sha1 "b3ff794461ff5e4e1e73fe6bd11e653bbe509e63"
head "https://github.com/martine/ninja.git"
bottle do
cellar :any
sha1 "e82dc5e952531ce5a586275c1078e3c35a15246b" => :yosemite
sha1 "04e4fc5a7ee416e248fd42eab9fe04a26f79fc96" => :mavericks
sha1 "553fca852991a02ed526d4a37f79aa60c50f23ee" => :mountain_lion
end
option "without-tests", "Run build-time tests"
resource "gtest" do
url "https://googletest.googlecode.com/files/gtest-1.7.0.zip"
sha1 "f85f6d2481e2c6c4a18539e391aa4ea8ab0394af"
end
def install
system "python", "configure.py", "--bootstrap"
if build.with? "tests"
(buildpath/"gtest").install resource("gtest")
system buildpath/"configure.py", "--with-gtest=gtest"
system buildpath/"ninja", "ninja_test"
system buildpath/"ninja_test", "--gtest_filter=-SubprocessTest.SetWithLots"
end
bin.install "ninja"
bash_completion.install "misc/bash-completion" => "ninja-completion.sh"
zsh_completion.install "misc/zsh-completion" => "_ninja"
end
end
ninja: add test
Closes Homebrew/homebrew#38057.
Signed-off-by: Xu Cheng <9a05244150b861e40c78843b801eed71bca54eac@me.com>
class Ninja < Formula
homepage "https://martine.github.io/ninja/"
url "https://github.com/martine/ninja/archive/v1.5.3.tar.gz"
sha256 "7c953b5a7c26cfcd082882e3f3e2cd08fee8848ad228bb47223b18ea18777ec0"
head "https://github.com/martine/ninja.git"
bottle do
cellar :any
sha1 "e82dc5e952531ce5a586275c1078e3c35a15246b" => :yosemite
sha1 "04e4fc5a7ee416e248fd42eab9fe04a26f79fc96" => :mavericks
sha1 "553fca852991a02ed526d4a37f79aa60c50f23ee" => :mountain_lion
end
option "without-tests", "Run build-time tests"
resource "gtest" do
url "https://googletest.googlecode.com/files/gtest-1.7.0.zip"
sha256 "247ca18dd83f53deb1328be17e4b1be31514cedfc1e3424f672bf11fd7e0d60d"
end
def install
system "python", "configure.py", "--bootstrap"
if build.with? "tests"
(buildpath/"gtest").install resource("gtest")
system buildpath/"configure.py", "--with-gtest=gtest"
system buildpath/"ninja", "ninja_test"
system buildpath/"ninja_test", "--gtest_filter=-SubprocessTest.SetWithLots"
end
bin.install "ninja"
bash_completion.install "misc/bash-completion" => "ninja-completion.sh"
zsh_completion.install "misc/zsh-completion" => "_ninja"
end
test do
(testpath/"build.ninja").write <<-EOS.undent
cflags = -Wall
rule cc
command = gcc $cflags -c $in -o $out
build foo.o: cc foo.c
EOS
system bin/"ninja", "-t", "targets"
end
end
|
class ApiController < ApplicationController
before_action :verify_key, :except => [:filter_generator, :api_docs]
before_action :set_pagesize, :except => [:filter_generator, :api_docs]
before_action :verify_write_token, :only => [:create_feedback, :report_post]
skip_before_action :verify_authenticity_token, :only => [:create_feedback, :report_post]
# Yes, this looks bad, but it actually works as a cache - we only have to calculate the bitstring for each filter once.
@@filters = Hash.new { |h, k| h[k] = k.chars.map { |c| c.ord.to_s(2).rjust(8, '0') }.join('') }
# Public routes
def api_docs
redirect_to "https://github.com/Charcoal-SE/metasmoke/wiki/API-Documentation"
end
# Routes for developer use
def filter_generator
end
# Read routes: Posts
def posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.where(:id => params[:ids].split(";")).select(select_fields(filter)).order(:id => :desc).left_joins(:feedbacks).left_joins(:deletion_logs).includes(:flag_logs => [:user])
@results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
@more = has_more?(params[:page], @results.count)
@results = @results.group(:id)
render :formats => :json
end
def posts_by_feedback
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.all.joins(:feedbacks).where(:feedbacks => { :feedback_type => params[:type] }).select(select_fields(filter)).order(:id => :desc).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_url
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xA5\xC2\x83\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.where(:link => params[:urls].split(";")).select(select_fields(filter)).order(:id => :desc).includes(:feedbacks => [:user]).includes(:deletion_logs).includes(:flag_logs => [:user])
@results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
@more = has_more?(params[:page], @results.count)
render 'posts.json.jbuilder'
end
def posts_by_site
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.joins(:site).where(:sites => { :site_url => params[:site] }).select(select_fields(filter)).order(:id => :desc).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_daterange
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.where(:created_at => DateTime.strptime(params[:from_date], '%s')..DateTime.strptime(params[:to_date], '%s')).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.select(select_fields(filter)).order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def undeleted_posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.left_outer_joins(:deletion_logs).where(:deletion_logs => { :id => nil }).select(select_fields(filter)).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def post_feedback
filter = "\x00\x00\x00\x00\xc2\xbd\x19\xc2\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@feedbacks = Feedback.where(:post_id => params[:id]).select(select_fields(filter)).order(:id => :desc)
results = @feedbacks.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def post_reasons
filter = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00"
@reasons = Reason.joins(:posts_reasons).where(:posts_reasons => { :post_id => params[:id] }).select(select_fields(filter)).order(:id => :desc)
results = @reasons.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def post_valid_feedback
@post = Post.find params[:id]
render :formats => :json
end
def search_posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.all
if params[:feedback_type].present?
@posts = @posts.includes(:feedbacks).where(:feedbacks => { :feedback_type => params[:feedback_type] })
end
if params[:site].present?
@posts = @posts.joins(:site).where(:sites => { :site_domain => params[:site] })
end
if params[:from_date].present?
@posts = @posts.where('`posts`.`created_at` > ?', DateTime.strptime(params[:from_date], '%s'))
end
if params[:to_date].present?
@posts = @posts.where('`posts`.`created_at` < ?', DateTime.strptime(params[:to_date], '%s'))
end
results = @posts.select(select_fields(filter)).order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
# Read routes: Reasons
def reasons
filter = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00"
@reasons = Reason.where(:id => params[:ids].split(";")).select(select_fields(filter)).order(:id => :desc)
results = @reasons.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def reason_posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.joins(:posts_reasons).where(:posts_reasons => { :reason_id => params[:id] }).select(select_fields(filter)).order(:id => :desc)
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
# Read routes: BlacklistedWebsites
def blacklisted_websites
@websites = BlacklistedWebsite.active
results = @websites.order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
# Read routes: Users
def users_with_code_privs
chat_ids = User.code_admins.pluck(:stackexchange_chat_id, :stackoverflow_chat_id, :meta_stackexchange_chat_id)
items = {}
["stackexchange_chat_ids", "stackoverflow_chat_ids", "meta_stackexchange_chat_ids"].each_with_index do |name, index|
items[name] = chat_ids.map { |a| a[index] }.select { |n| n.present? }
end
render :json => { :items => items }
end
# Read routes: Status
def current_status
render :json => { :last_ping => SmokeDetector.where.not(:location => params[:except]).maximum(:last_ping) }
end
# Write routes
def create_feedback
@post = Post.find params[:id]
@feedback = Feedback.new(:user => @user, :post => @post, :api_key => @key)
@feedback.feedback_type = params[:type]
if @feedback.save
if @feedback.is_positive?
begin
ActionCable.server.broadcast "smokedetector_messages", { blacklist: { uid: @post.stack_exchange_user.user_id.to_s, site: URI.parse(@post.stack_exchange_user.site.site_url).host, post: @post.link } }
rescue
end
elsif @feedback.is_naa?
begin
ActionCable.server.broadcast "smokedetector_messages", { naa: { post_link: @post.link } }
rescue
end
elsif @feedback.is_negative?
begin
ActionCable.server.broadcast "smokedetector_messages", { fp: { post_link: @post.link } }
rescue
end
end
unless Feedback.where(:post_id => @post.id, :feedback_type => @feedback.feedback_type).where.not(:id => @feedback.id).exists?
ActionCable.server.broadcast "smokedetector_messages", { message: "#{@feedback.feedback_type} by #{@user.username}" + (@post.id == Post.last.id ? "" : " on [#{@post.title}](#{@post.link}) \\[[MS](#{url_for(:controller => :posts, :action => :show, :id => @post.id)})]") }
end
render :json => @post.feedbacks, :status => 201
else
render :status => 500, :json => { :error_name => "failed", :error_code => 500, :error_message => "Feedback object failed to save." }
end
end
def report_post
# We don't create any posts here, just send them on to Smokey to do all the processing
ActionCable.server.broadcast "smokedetector_messages", { report: { :user => @user.username, :post_link => params[:post_link] } }
render :plain => "OK", :status => 201
end
private
def verify_key
@key = ApiKey.find_by_key(params[:key])
unless params[:key].present? && @key.present?
smokey = SmokeDetector.find_by_access_token(params[:key])
unless smokey.present?
render :status => 403, :json => { :error_name => "unauthenticated", :error_code => 403, :error_message => "No key was passed or the passed key is invalid." } and return
end
end
end
def set_pagesize
@pagesize = [(params[:per_page] || 10).to_i, 100].min
end
def has_more?(page, result_count)
(page || 1).to_i * @pagesize < result_count
end
def verify_write_token
# This method deliberately doesn't check expiry: tokens are valid for authorization forever, but can only be fetched using the code in the first 10 minutes.
@token = ApiToken.where(:token => params[:token], :api_key => @key)
if @token.any?
@token = @token.first
@user = @token.user
else
render :status => 401, :json => { :error_name => 'unauthorized', :error_code => 401, :error_message => "The token provided does not supply authorization to perform this action." } and return
end
end
def select_fields(default="")
filter = params[:filter] || default
bitstring = @@filters[filter]
bits = bitstring.chars.map { |c| c.to_i }
AppConfig['api_field_mappings'].zip(bits).map { |k, v| k if v == 1 }.compact
end
end
Move group clause to the actual query
class ApiController < ApplicationController
before_action :verify_key, :except => [:filter_generator, :api_docs]
before_action :set_pagesize, :except => [:filter_generator, :api_docs]
before_action :verify_write_token, :only => [:create_feedback, :report_post]
skip_before_action :verify_authenticity_token, :only => [:create_feedback, :report_post]
# Yes, this looks bad, but it actually works as a cache - we only have to calculate the bitstring for each filter once.
@@filters = Hash.new { |h, k| h[k] = k.chars.map { |c| c.ord.to_s(2).rjust(8, '0') }.join('') }
# Public routes
def api_docs
redirect_to "https://github.com/Charcoal-SE/metasmoke/wiki/API-Documentation"
end
# Routes for developer use
def filter_generator
end
# Read routes: Posts
def posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.where(:id => params[:ids].split(";")).select(select_fields(filter)).order(:id => :desc).left_joins(:feedbacks).left_joins(:deletion_logs).includes(:flag_logs => [:user]).group(:id)
@results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
@more = has_more?(params[:page], @results.count)
render :formats => :json
end
def posts_by_feedback
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.all.joins(:feedbacks).where(:feedbacks => { :feedback_type => params[:type] }).select(select_fields(filter)).order(:id => :desc).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_url
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xA5\xC2\x83\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.where(:link => params[:urls].split(";")).select(select_fields(filter)).order(:id => :desc).includes(:feedbacks => [:user]).includes(:deletion_logs).includes(:flag_logs => [:user])
@results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
@more = has_more?(params[:page], @results.count)
render 'posts.json.jbuilder'
end
def posts_by_site
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.joins(:site).where(:sites => { :site_url => params[:site] }).select(select_fields(filter)).order(:id => :desc).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_daterange
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.where(:created_at => DateTime.strptime(params[:from_date], '%s')..DateTime.strptime(params[:to_date], '%s')).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.select(select_fields(filter)).order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def undeleted_posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.left_outer_joins(:deletion_logs).where(:deletion_logs => { :id => nil }).select(select_fields(filter)).includes(:feedbacks).includes(:flag_logs => [:user])
results = @posts.order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def post_feedback
filter = "\x00\x00\x00\x00\xc2\xbd\x19\xc2\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@feedbacks = Feedback.where(:post_id => params[:id]).select(select_fields(filter)).order(:id => :desc)
results = @feedbacks.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def post_reasons
filter = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00"
@reasons = Reason.joins(:posts_reasons).where(:posts_reasons => { :post_id => params[:id] }).select(select_fields(filter)).order(:id => :desc)
results = @reasons.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def post_valid_feedback
@post = Post.find params[:id]
render :formats => :json
end
def search_posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.all
if params[:feedback_type].present?
@posts = @posts.includes(:feedbacks).where(:feedbacks => { :feedback_type => params[:feedback_type] })
end
if params[:site].present?
@posts = @posts.joins(:site).where(:sites => { :site_domain => params[:site] })
end
if params[:from_date].present?
@posts = @posts.where('`posts`.`created_at` > ?', DateTime.strptime(params[:from_date], '%s'))
end
if params[:to_date].present?
@posts = @posts.where('`posts`.`created_at` < ?', DateTime.strptime(params[:to_date], '%s'))
end
results = @posts.select(select_fields(filter)).order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
# Read routes: Reasons
def reasons
filter = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00"
@reasons = Reason.where(:id => params[:ids].split(";")).select(select_fields(filter)).order(:id => :desc)
results = @reasons.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def reason_posts
filter = "\x00\x00\x00\x00\x00\x00\x00\x03\xC3\xBF\xC3\xBF\xC2\x80\x00\x00\x00\x00\x01"
@posts = Post.joins(:posts_reasons).where(:posts_reasons => { :reason_id => params[:id] }).select(select_fields(filter)).order(:id => :desc)
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
# Read routes: BlacklistedWebsites
def blacklisted_websites
@websites = BlacklistedWebsite.active
results = @websites.order(:id => :desc).paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
# Read routes: Users
def users_with_code_privs
chat_ids = User.code_admins.pluck(:stackexchange_chat_id, :stackoverflow_chat_id, :meta_stackexchange_chat_id)
items = {}
["stackexchange_chat_ids", "stackoverflow_chat_ids", "meta_stackexchange_chat_ids"].each_with_index do |name, index|
items[name] = chat_ids.map { |a| a[index] }.select { |n| n.present? }
end
render :json => { :items => items }
end
# Read routes: Status
def current_status
render :json => { :last_ping => SmokeDetector.where.not(:location => params[:except]).maximum(:last_ping) }
end
# Write routes
def create_feedback
@post = Post.find params[:id]
@feedback = Feedback.new(:user => @user, :post => @post, :api_key => @key)
@feedback.feedback_type = params[:type]
if @feedback.save
if @feedback.is_positive?
begin
ActionCable.server.broadcast "smokedetector_messages", { blacklist: { uid: @post.stack_exchange_user.user_id.to_s, site: URI.parse(@post.stack_exchange_user.site.site_url).host, post: @post.link } }
rescue
end
elsif @feedback.is_naa?
begin
ActionCable.server.broadcast "smokedetector_messages", { naa: { post_link: @post.link } }
rescue
end
elsif @feedback.is_negative?
begin
ActionCable.server.broadcast "smokedetector_messages", { fp: { post_link: @post.link } }
rescue
end
end
unless Feedback.where(:post_id => @post.id, :feedback_type => @feedback.feedback_type).where.not(:id => @feedback.id).exists?
ActionCable.server.broadcast "smokedetector_messages", { message: "#{@feedback.feedback_type} by #{@user.username}" + (@post.id == Post.last.id ? "" : " on [#{@post.title}](#{@post.link}) \\[[MS](#{url_for(:controller => :posts, :action => :show, :id => @post.id)})]") }
end
render :json => @post.feedbacks, :status => 201
else
render :status => 500, :json => { :error_name => "failed", :error_code => 500, :error_message => "Feedback object failed to save." }
end
end
def report_post
# We don't create any posts here, just send them on to Smokey to do all the processing
ActionCable.server.broadcast "smokedetector_messages", { report: { :user => @user.username, :post_link => params[:post_link] } }
render :plain => "OK", :status => 201
end
private
def verify_key
@key = ApiKey.find_by_key(params[:key])
unless params[:key].present? && @key.present?
smokey = SmokeDetector.find_by_access_token(params[:key])
unless smokey.present?
render :status => 403, :json => { :error_name => "unauthenticated", :error_code => 403, :error_message => "No key was passed or the passed key is invalid." } and return
end
end
end
def set_pagesize
@pagesize = [(params[:per_page] || 10).to_i, 100].min
end
def has_more?(page, result_count)
(page || 1).to_i * @pagesize < result_count
end
def verify_write_token
# This method deliberately doesn't check expiry: tokens are valid for authorization forever, but can only be fetched using the code in the first 10 minutes.
@token = ApiToken.where(:token => params[:token], :api_key => @key)
if @token.any?
@token = @token.first
@user = @token.user
else
render :status => 401, :json => { :error_name => 'unauthorized', :error_code => 401, :error_message => "The token provided does not supply authorization to perform this action." } and return
end
end
def select_fields(default="")
filter = params[:filter] || default
bitstring = @@filters[filter]
bits = bitstring.chars.map { |c| c.to_i }
AppConfig['api_field_mappings'].zip(bits).map { |k, v| k if v == 1 }.compact
end
end
|
require "formula"
class Nitro < Formula
homepage "https://github.com/hobu/nitro"
# TODO: request a tagged release
url "https://github.com/hobu/nitro.git", :revision => "c0c3fbba2638a68d3300191cd0a204542b78fc78"
version "1.0-c0c3fbb"
sha1 "c0c3fbba2638a68d3300191cd0a204542b78fc78"
head "https://github.com/hobu/nitro.git", :branch => "master"
depends_on "cmake" => :build
def install
mkdir "build" do
system "cmake", "..", *std_cmake_args
system "make"
system "make", "install"
end
end
test do
# installs just a lib
end
end
Upgrade to latest Nitro HEAD
require "formula"
class Nitro < Formula
homepage "https://github.com/hobu/nitro"
# TODO: request a tagged release
url "https://github.com/hobu/nitro.git", :revision => "a3539c63128d9190fbd0043c1652d1b9397f8fcd"
version "1.0-a3539c6"
sha1 "a3539c63128d9190fbd0043c1652d1b9397f8fcd"
head "https://github.com/hobu/nitro.git", :branch => "master"
depends_on "cmake" => :build
def install
mkdir "build" do
system "cmake", "..", *std_cmake_args
system "make"
system "make", "install"
end
end
test do
# installs just a lib
end
end
|
Adhearsion::Events.draw do
shutdown do |event|
User.shutdown!
Adhearsion.active_calls.values.each { |call| call.hangup }
AmqpManager.shutdown!
end
after_initialized do |event|
User.fetch_all_agents
Call.clear_all_redis_calls
Thread.new { AgentCollector.start }
Thread.new { CallScheduler.start }
end
ami name: 'BridgeExec' do |event|
if event.headers['Response'] == 'Success'
Call.update_state_for(event)
end
AmqpManager.numbers_publish(event)
end
# See adhearsion-xmpp for agent availability-states
# Has no Rayo-pendant:
#
ami name: 'PeerStatus' do |event|
agent = Agent.find_for(event)
new_state = event.headers['PeerStatus'].downcase.to_sym
if agent
old_state = agent.agent_state
if old_state != :talking
agent.update_state_to(new_state) &&
AmqpManager.numbers_publish(event)
end
end
end
ami name: 'Newstate' do |event|
agent_state = nil
if ['4', '5', '6'].include?(event.headers['ChannelState'])
Call.update_state_for(event)
agent_state = :talking
elsif event.headers['ChannelState'] == '0'
agent_state = :registered
end
if agent_state && (agent = Agent.find_for event)
agent.update_state_to(agent_state) &&
AmqpManager.numbers_publish(event)
end
end
ami name: 'Hangup' do |event|
Call.close_state_for(event)
if (agent = Agent.find_for event)
agent.update_state_to(:registered) &&
AmqpManager.numbers_publish(event)
end
end
# ! This emits Rayo-Events
#
# punchblock(Punchblock::Event::End) do |event|
# puts event
# end
# ami name: 'Bridge' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'NewCallerid' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'OriginateResponse' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'Newchannel' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'SoftHangupRequest' do |event|
# AmqpManager.numbers_publish(event)
# end
end
dont propagate BridgeExec events
Adhearsion::Events.draw do
shutdown do |event|
User.shutdown!
Adhearsion.active_calls.values.each { |call| call.hangup }
AmqpManager.shutdown!
end
after_initialized do |event|
User.fetch_all_agents
Call.clear_all_redis_calls
Thread.new { AgentCollector.start }
Thread.new { CallScheduler.start }
end
ami name: 'BridgeExec' do |event|
if event.headers['Response'] == 'Success'
Call.update_state_for(event)
end
end
# See adhearsion-xmpp for agent availability-states
# Has no Rayo-pendant:
#
ami name: 'PeerStatus' do |event|
agent = Agent.find_for(event)
new_state = event.headers['PeerStatus'].downcase.to_sym
if agent
old_state = agent.agent_state
if old_state != :talking
agent.update_state_to(new_state) &&
AmqpManager.numbers_publish(event)
end
end
end
ami name: 'Newstate' do |event|
agent_state = nil
if ['4', '5', '6'].include?(event.headers['ChannelState'])
Call.update_state_for(event)
agent_state = :talking
elsif event.headers['ChannelState'] == '0'
agent_state = :registered
end
if agent_state && (agent = Agent.find_for event)
agent.update_state_to(agent_state)
AmqpManager.numbers_publish(event)
end
end
ami name: 'Hangup' do |event|
Call.close_state_for(event)
if (agent = Agent.find_for event)
agent.update_state_to(:registered) &&
AmqpManager.numbers_publish(event)
end
end
# ! This emits Rayo-Events
#
# punchblock(Punchblock::Event::End) do |event|
# puts event
# end
# ami name: 'Bridge' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'NewCallerid' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'OriginateResponse' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'Newchannel' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'SoftHangupRequest' do |event|
# AmqpManager.numbers_publish(event)
# end
end
|
# Run API used by the morph command-line client
class ApiController < ApplicationController
include ActionController::Live
# The run_remote method will be secured with a key so shouldn't need csrf
# token authentication
skip_before_filter :verify_authenticity_token, only: [:run_remote]
before_filter :authenticate_api_key, only: :run_remote
before_filter :can_run, only: :run_remote
# Receive code from a remote client, run it and return the result.
# This will be a long running request
# TODO: Document this API
def run_remote
response.headers['Content-Type'] = 'text/event-stream'
run = Run.create(queued_at: Time.now, auto: false, owner: current_user)
# TODO: Shouldn't need to untar here because it just gets retarred
Archive::Tar::Minitar.unpack(params[:code].tempfile, run.repo_path)
runner = Morph::Runner.new(run)
runner.go { |timestamp, s, text| stream_message(s, text) }
ensure
# Cleanup run
response.stream.close
# Don't want to leave any containers hanging around
container = runner.container_for_run
if container
container.kill
container.delete
end
FileUtils.rm_rf(run.data_path)
FileUtils.rm_rf(run.repo_path)
end
def data
@scraper = Scraper.friendly.find(params[:id])
#response.stream.write('Hello!')
# Check authentication
# We're still allowing authentication via header so that old users
# of the api don't have to change anything
api_key = request.headers['HTTP_X_API_KEY'] || params[:key]
if api_key.nil?
render_error 'API key is missing'
return
else
owner = Owner.find_by_api_key(api_key)
if owner.nil?
render_error 'API key is not valid'
return
end
end
begin
respond_to do |format|
format.sqlite { data_sqlite(owner) }
format.json { data_json(owner) }
format.csv { data_csv(owner) }
format.atom { data_atom(owner) }
end
rescue SQLite3::Exception => e
render_error e.to_s
end
ensure
response.stream.close
end
private
def data_sqlite(owner)
bench = Benchmark.measure do
# Not just using send_file because we need to follow the pattern of the
# rest of the controller
File.open(@scraper.database.sqlite_db_path, 'rb') do |file|
while buff = file.read(16384)
response.stream.write(buff)
end
end
# For some reason the code below just copied across one 16k block
#IO.copy_stream(@scraper.database.sqlite_db_path, response.stream)
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: @scraper.database.sqlite_db_size,
type: 'database',
format: 'sqlite'
)
end
def data_json(owner)
# When calculating the size here we're ignoring a few bytes at the front and end
size = 0
bench = Benchmark.measure do
mime_type = params[:callback] ? 'application/javascript': 'application/json'
response.headers['Content-Type'] = "#{mime_type}; charset=utf-8"
response.stream.write("/**/#{params[:callback]}(") if params[:callback]
response.stream.write("[\n")
i = 0
@scraper.database.sql_query_streaming(params[:query]) do |row|
response.stream.write("\n,") unless i == 0
s = row.to_json
size += s.size
response.stream.write(s)
i += 1
end
response.stream.write("\n]")
response.stream.write(")\n") if params[:callback]
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: size,
type: 'sql',
format: 'json'
)
end
def data_csv(owner)
size = 0
bench = Benchmark.measure do
response.headers["Content-Disposition"] = "attachment; filename=#{@scraper.name}.csv"
displayed_header = false
@scraper.database.sql_query_streaming(params[:query]) do |row|
# only show the header once at the beginning
unless displayed_header
s = row.keys.to_csv
size += s.size
response.stream.write(s)
displayed_header = true
end
s = row.values.to_csv
size += s.size
response.stream.write(s)
end
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: size,
type: 'sql',
format: 'csv'
)
end
def data_atom(owner)
# Only measuring the size of the entry blocks. We're ignoring the header.
size = 0
bench = Benchmark.measure do
response.stream.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
response.stream.write("<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n")
response.stream.write(" <title>morph.io: #{@scraper.full_name}</title>\n")
response.stream.write(" <subtitle>#{@scraper.description}</subtitle>\n")
response.stream.write(" <updated>#{DateTime.parse(@scraper.updated_at.to_s).rfc3339}</updated>\n")
response.stream.write(" <author>\n")
response.stream.write(" <name>#{@scraper.owner.name || @scraper.owner.nickname}</name>\n")
response.stream.write(" </author>\n")
response.stream.write(" <id>#{request.protocol}#{request.host_with_port}#{request.fullpath}</id>\n")
response.stream.write(" <link href=\"#{scraper_url(@scraper)}\"/>\n")
response.stream.write(" <link href=\"#{request.protocol}#{request.host_with_port}#{request.fullpath}\" rel=\"self\"/>\n")
@scraper.database.sql_query_streaming(params[:query]) do |row|
s = ""
s << " <entry>\n"
s << " <title>#{row['title']}</title>\n"
s << " <content>#{row['content']}</content>\n"
s << " <link href=\"#{row['link']}\"/>\n"
s << " <id>#{row['link']}</id>\n"
s << " <updated>#{DateTime.parse(row['date']).rfc3339 rescue nil}</updated>\n"
s << " </entry>\n"
size += s.size
response.stream.write(s)
end
response.stream.write("</feed>\n")
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: size,
type: 'sql',
format: 'atom'
)
end
def render_error(message)
respond_to do |format|
format.sqlite { render text: message, status: 401, content_type: :text }
format.json { render json: { error: message }, status: 401 }
format.csv { render text: message, status: 401, content_type: :text }
format.atom { render text: message, status: 401, content_type: :text }
end
end
def can_run
return if current_user.ability.can? :create, Run
render json: {
stream: 'internalerr',
text: "You currently can't start a scraper run." \
' See https://morph.io for more details'
}
end
def stream_message(stream, text)
response.stream.write({ stream: stream, text: text }.to_json + "\n")
end
def authenticate_api_key
render(text: 'API key is not valid', status: 401) if current_user.nil?
end
def current_user
@current_user ||= User.find_by_api_key(params[:api_key])
end
end
Tell nginx and passenger not to buffer data api responses
# Run API used by the morph command-line client
class ApiController < ApplicationController
include ActionController::Live
# The run_remote method will be secured with a key so shouldn't need csrf
# token authentication
skip_before_filter :verify_authenticity_token, only: [:run_remote]
before_filter :authenticate_api_key, only: :run_remote
before_filter :can_run, only: :run_remote
# Receive code from a remote client, run it and return the result.
# This will be a long running request
# TODO: Document this API
def run_remote
response.headers['Content-Type'] = 'text/event-stream'
run = Run.create(queued_at: Time.now, auto: false, owner: current_user)
# TODO: Shouldn't need to untar here because it just gets retarred
Archive::Tar::Minitar.unpack(params[:code].tempfile, run.repo_path)
runner = Morph::Runner.new(run)
runner.go { |timestamp, s, text| stream_message(s, text) }
ensure
# Cleanup run
response.stream.close
# Don't want to leave any containers hanging around
container = runner.container_for_run
if container
container.kill
container.delete
end
FileUtils.rm_rf(run.data_path)
FileUtils.rm_rf(run.repo_path)
end
def data
@scraper = Scraper.friendly.find(params[:id])
#response.stream.write('Hello!')
# Check authentication
# We're still allowing authentication via header so that old users
# of the api don't have to change anything
api_key = request.headers['HTTP_X_API_KEY'] || params[:key]
if api_key.nil?
render_error 'API key is missing'
return
else
owner = Owner.find_by_api_key(api_key)
if owner.nil?
render_error 'API key is not valid'
return
end
end
begin
respond_to do |format|
format.sqlite { data_sqlite(owner) }
format.json { data_json(owner) }
format.csv { data_csv(owner) }
format.atom { data_atom(owner) }
end
rescue SQLite3::Exception => e
render_error e.to_s
end
ensure
response.stream.close
end
private
def data_sqlite(owner)
bench = Benchmark.measure do
# Not just using send_file because we need to follow the pattern of the
# rest of the controller
File.open(@scraper.database.sqlite_db_path, 'rb') do |file|
while buff = file.read(16384)
response.stream.write(buff)
end
end
# For some reason the code below just copied across one 16k block
#IO.copy_stream(@scraper.database.sqlite_db_path, response.stream)
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: @scraper.database.sqlite_db_size,
type: 'database',
format: 'sqlite'
)
end
def data_json(owner)
# When calculating the size here we're ignoring a few bytes at the front and end
size = 0
bench = Benchmark.measure do
# Tell nginx and passenger not to buffer this
response.headers['X-Accel-Buffering'] = 'no'
mime_type = params[:callback] ? 'application/javascript': 'application/json'
response.headers['Content-Type'] = "#{mime_type}; charset=utf-8"
response.stream.write("/**/#{params[:callback]}(") if params[:callback]
response.stream.write("[\n")
i = 0
@scraper.database.sql_query_streaming(params[:query]) do |row|
response.stream.write("\n,") unless i == 0
s = row.to_json
size += s.size
response.stream.write(s)
i += 1
end
response.stream.write("\n]")
response.stream.write(")\n") if params[:callback]
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: size,
type: 'sql',
format: 'json'
)
end
def data_csv(owner)
size = 0
bench = Benchmark.measure do
# Tell nginx and passenger not to buffer this
response.headers['X-Accel-Buffering'] = 'no'
response.headers["Content-Disposition"] = "attachment; filename=#{@scraper.name}.csv"
displayed_header = false
@scraper.database.sql_query_streaming(params[:query]) do |row|
# only show the header once at the beginning
unless displayed_header
s = row.keys.to_csv
size += s.size
response.stream.write(s)
displayed_header = true
end
s = row.values.to_csv
size += s.size
response.stream.write(s)
end
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: size,
type: 'sql',
format: 'csv'
)
end
def data_atom(owner)
# Only measuring the size of the entry blocks. We're ignoring the header.
size = 0
bench = Benchmark.measure do
# Tell nginx and passenger not to buffer this
response.headers['X-Accel-Buffering'] = 'no'
response.stream.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
response.stream.write("<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n")
response.stream.write(" <title>morph.io: #{@scraper.full_name}</title>\n")
response.stream.write(" <subtitle>#{@scraper.description}</subtitle>\n")
response.stream.write(" <updated>#{DateTime.parse(@scraper.updated_at.to_s).rfc3339}</updated>\n")
response.stream.write(" <author>\n")
response.stream.write(" <name>#{@scraper.owner.name || @scraper.owner.nickname}</name>\n")
response.stream.write(" </author>\n")
response.stream.write(" <id>#{request.protocol}#{request.host_with_port}#{request.fullpath}</id>\n")
response.stream.write(" <link href=\"#{scraper_url(@scraper)}\"/>\n")
response.stream.write(" <link href=\"#{request.protocol}#{request.host_with_port}#{request.fullpath}\" rel=\"self\"/>\n")
@scraper.database.sql_query_streaming(params[:query]) do |row|
s = ""
s << " <entry>\n"
s << " <title>#{row['title']}</title>\n"
s << " <content>#{row['content']}</content>\n"
s << " <link href=\"#{row['link']}\"/>\n"
s << " <id>#{row['link']}</id>\n"
s << " <updated>#{DateTime.parse(row['date']).rfc3339 rescue nil}</updated>\n"
s << " </entry>\n"
size += s.size
response.stream.write(s)
end
response.stream.write("</feed>\n")
end
ApiQuery.log!(
query: params[:query],
scraper: @scraper,
owner: owner,
benchmark: bench,
size: size,
type: 'sql',
format: 'atom'
)
end
def render_error(message)
respond_to do |format|
format.sqlite { render text: message, status: 401, content_type: :text }
format.json { render json: { error: message }, status: 401 }
format.csv { render text: message, status: 401, content_type: :text }
format.atom { render text: message, status: 401, content_type: :text }
end
end
def can_run
return if current_user.ability.can? :create, Run
render json: {
stream: 'internalerr',
text: "You currently can't start a scraper run." \
' See https://morph.io for more details'
}
end
def stream_message(stream, text)
response.stream.write({ stream: stream, text: text }.to_json + "\n")
end
def authenticate_api_key
render(text: 'API key is not valid', status: 401) if current_user.nil?
end
def current_user
@current_user ||= User.find_by_api_key(params[:api_key])
end
end
|
class Numpy < Formula
desc "Package for scientific computing with Python"
homepage "https://www.numpy.org/"
url "https://files.pythonhosted.org/packages/fb/48/b0708ebd7718a8933f0d3937513ef8ef2f4f04529f1f66ca86d873043921/numpy-1.21.4.zip"
sha256 "e6c76a87633aa3fa16614b61ccedfae45b91df2767cf097aa9c933932a7ed1e0"
license "BSD-3-Clause"
head "https://github.com/numpy/numpy.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_big_sur: "b0553e85982be6edaf90a71dc7561ab64f096188fcc7142dc535602732dc0cfc"
sha256 cellar: :any, monterey: "14dc6f3429ade704765c7f23553b7b7b60ad389ae8348224eb16683408530783"
sha256 cellar: :any, big_sur: "599eac2a70e5c48c9f4fdcf5960eb5165a929f6028cdf641ee1b2f3df019faf2"
sha256 cellar: :any, catalina: "3281f550910f6b4d1b3accf5b1fbd2f08bb1d1eb42b2a424f286d09f8d8ee694"
sha256 x86_64_linux: "1787c0a7ce1c2f89550d9a97b9cbea0f305915e93884f6978b36686ada4c7a60"
end
depends_on "cython" => :build
depends_on "gcc" => :build # for gfortran
depends_on "openblas"
depends_on "python@3.9"
fails_with gcc: "5"
def install
openblas = Formula["openblas"].opt_prefix
ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework
ENV["BLAS"] = ENV["LAPACK"] = "#{openblas}/lib/#{shared_library("libopenblas")}"
config = <<~EOS
[openblas]
libraries = openblas
library_dirs = #{openblas}/lib
include_dirs = #{openblas}/include
EOS
Pathname("site.cfg").write config
xy = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3"
ENV.prepend_create_path "PYTHONPATH", Formula["cython"].opt_libexec/"lib/python#{xy}/site-packages"
system Formula["python@3.9"].opt_bin/"python3", "setup.py", "build",
"--fcompiler=gfortran", "--parallel=#{ENV.make_jobs}"
system Formula["python@3.9"].opt_bin/"python3", *Language::Python.setup_install_args(prefix)
end
test do
system Formula["python@3.9"].opt_bin/"python3", "-c", <<~EOS
import numpy as np
t = np.ones((3,3), int)
assert t.sum() == 9
assert np.dot(t, t).sum() == 27
EOS
end
end
numpy: update 1.21.4 bottle.
class Numpy < Formula
desc "Package for scientific computing with Python"
homepage "https://www.numpy.org/"
url "https://files.pythonhosted.org/packages/fb/48/b0708ebd7718a8933f0d3937513ef8ef2f4f04529f1f66ca86d873043921/numpy-1.21.4.zip"
sha256 "e6c76a87633aa3fa16614b61ccedfae45b91df2767cf097aa9c933932a7ed1e0"
license "BSD-3-Clause"
head "https://github.com/numpy/numpy.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_monterey: "899171d279a5082950b9d7177c055df740008f9b5f86b4481e0b7cf9c8b0ba2f"
sha256 cellar: :any, arm64_big_sur: "b0553e85982be6edaf90a71dc7561ab64f096188fcc7142dc535602732dc0cfc"
sha256 cellar: :any, monterey: "14dc6f3429ade704765c7f23553b7b7b60ad389ae8348224eb16683408530783"
sha256 cellar: :any, big_sur: "599eac2a70e5c48c9f4fdcf5960eb5165a929f6028cdf641ee1b2f3df019faf2"
sha256 cellar: :any, catalina: "3281f550910f6b4d1b3accf5b1fbd2f08bb1d1eb42b2a424f286d09f8d8ee694"
sha256 x86_64_linux: "1787c0a7ce1c2f89550d9a97b9cbea0f305915e93884f6978b36686ada4c7a60"
end
depends_on "cython" => :build
depends_on "gcc" => :build # for gfortran
depends_on "openblas"
depends_on "python@3.9"
fails_with gcc: "5"
def install
openblas = Formula["openblas"].opt_prefix
ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework
ENV["BLAS"] = ENV["LAPACK"] = "#{openblas}/lib/#{shared_library("libopenblas")}"
config = <<~EOS
[openblas]
libraries = openblas
library_dirs = #{openblas}/lib
include_dirs = #{openblas}/include
EOS
Pathname("site.cfg").write config
xy = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3"
ENV.prepend_create_path "PYTHONPATH", Formula["cython"].opt_libexec/"lib/python#{xy}/site-packages"
system Formula["python@3.9"].opt_bin/"python3", "setup.py", "build",
"--fcompiler=gfortran", "--parallel=#{ENV.make_jobs}"
system Formula["python@3.9"].opt_bin/"python3", *Language::Python.setup_install_args(prefix)
end
test do
system Formula["python@3.9"].opt_bin/"python3", "-c", <<~EOS
import numpy as np
t = np.ones((3,3), int)
assert t.sum() == 9
assert np.dot(t, t).sum() == 27
EOS
end
end
|
Adhearsion::Events.draw do
shutdown do |event|
User.shutdown!
Adhearsion.active_calls.values.each { |call| call.hangup }
AmqpManager.shutdown!
end
after_initialized do |event|
User.fetch_all_agents
Call.clear_all_redis_calls
Thread.new { AgentCollector.start }
Thread.new { CallScheduler.start }
end
ami name: 'BridgeExec' do |event|
if event.headers['Response'] == 'Success'
Call.update_state_for(event)
end
AmqpManager.numbers_publish(event)
end
# See adhearsion-xmpp for agent availability-states
# Has no Rayo-pendant:
#
ami name: 'PeerStatus' do |event|
agent = Agent.find_for(event)
new_state = event.headers['PeerStatus'].downcase.to_sym
if agent
old_state = agent.agent_state
if old_state != :talking
agent.update_state_to(new_state) &&
AmqpManager.numbers_publish(event)
end
end
end
ami name: 'Newstate' do |event|
agent_state = nil
if ['4', '5', '6'].include?(event.headers['ChannelState'])
Call.update_state_for(event)
agent_state = :talking
elsif event.headers['ChannelState'] == '0'
agent_state = :registered
end
if agent_state && (agent = Agent.find_for event)
agent.update_state_to(agent_state) &&
AmqpManager.numbers_publish(event)
end
end
ami name: 'Hangup' do |event|
Call.close_state_for(event)
if (agent = Agent.find_for event)
agent.update_state_to(:registered) &&
AmqpManager.numbers_publish(event)
end
end
# ! This emits Rayo-Events
#
# punchblock(Punchblock::Event::End) do |event|
# puts event
# end
# ami name: 'Bridge' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'NewCallerid' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'OriginateResponse' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'Newchannel' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'SoftHangupRequest' do |event|
# AmqpManager.numbers_publish(event)
# end
end
Squashed commit of the following:
commit ba6010dd1fa46f1d090703502381a5114d8c88f0
Author: Frank Wöckener <fwoeck@gmail.com>
Date: Fri Aug 1 12:42:14 2014 +0200
dont propagate BridgeExec events
Adhearsion::Events.draw do
shutdown do |event|
User.shutdown!
Adhearsion.active_calls.values.each { |call| call.hangup }
AmqpManager.shutdown!
end
after_initialized do |event|
User.fetch_all_agents
Call.clear_all_redis_calls
Thread.new { AgentCollector.start }
Thread.new { CallScheduler.start }
end
ami name: 'BridgeExec' do |event|
if event.headers['Response'] == 'Success'
Call.update_state_for(event)
end
end
# See adhearsion-xmpp for agent availability-states
# Has no Rayo-pendant:
#
ami name: 'PeerStatus' do |event|
agent = Agent.find_for(event)
new_state = event.headers['PeerStatus'].downcase.to_sym
if agent
old_state = agent.agent_state
if old_state != :talking
agent.update_state_to(new_state) &&
AmqpManager.numbers_publish(event)
end
end
end
ami name: 'Newstate' do |event|
agent_state = nil
if ['4', '5', '6'].include?(event.headers['ChannelState'])
Call.update_state_for(event)
agent_state = :talking
elsif event.headers['ChannelState'] == '0'
agent_state = :registered
end
if agent_state && (agent = Agent.find_for event)
agent.update_state_to(agent_state)
AmqpManager.numbers_publish(event)
end
end
ami name: 'Hangup' do |event|
Call.close_state_for(event)
if (agent = Agent.find_for event)
agent.update_state_to(:registered) &&
AmqpManager.numbers_publish(event)
end
end
# ! This emits Rayo-Events
#
# punchblock(Punchblock::Event::End) do |event|
# puts event
# end
# ami name: 'Bridge' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'NewCallerid' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'OriginateResponse' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'Newchannel' do |event|
# AmqpManager.numbers_publish(event)
# end
# ami name: 'SoftHangupRequest' do |event|
# AmqpManager.numbers_publish(event)
# end
end
|
class ApiController < ApplicationController
before_action :verify_key
before_action :set_pagesize
before_action :verify_auth, :only => [:create_feedback]
skip_before_action :verify_authenticity_token, :only => [:create_feedback]
def posts
@posts = Post.where(:id => params[:ids].split(";"))
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_feedback
@posts = Post.all.joins(:feedbacks).where(:feedbacks => { :feedback_type => params[:type] })
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_url
@post = Post.where(:link => params[:url])
render :json => @post
end
def post_feedback
@post = Post.find params[:id]
render :json => @post.feedbacks
end
def post_reasons
@post = Post.find params[:id]
render :json => @post.reasons
end
def reasons
@reasons = Reason.where(:id => params[:ids].split(";"))
results = @reasons.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def reason_posts
@reason = Reason.find params[:id]
results = @reason.posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def create_feedback
@post = Post.find params[:id]
@feedback = Feedback.new(:user => current_user, :post => @post, :api_key => @key)
@feedback.feedback_type = params[:type]
if @feedback.save
if @feedback.is_positive?
ActionCable.server.broadcast "smokedetector_messages", { blacklist: { uid: @post.stack_exchange_user.user_id, site: @post.stack_exchange_user.site.site_url, post: @post.link } }
end
render :json => @post.feedbacks, :status => 201
else
render :status => 500, :json => { :error_name => "failed", :error_code => 500, :error_message => "Feedback object failed to save." }
end
end
private
def verify_key
@key = ApiKey.find_by_key(params[:key])
unless params[:key].present? && @key.present?
render :status => 403, :json => { :error_name => "unauthenticated", :error_code => 403, :error_message => "No key was passed or the passed key is invalid." } and return
end
end
def verify_auth
unless user_signed_in?
render :status => 401, :json => { :error_name => "unauthorized", :error_code => 401, :error_message => "There must be a metasmoke user logged in to use this route." } and return
end
end
def set_pagesize
@pagesize = [params[:per_page] || 10, 100].min
end
def has_more?(page, result_count)
(page || 1) * @pagesize < result_count
end
end
Attempt at quick fix for failing tests
class ApiController < ApplicationController
before_action :verify_key
before_action :set_pagesize
before_action :verify_auth, :only => [:create_feedback]
skip_before_action :verify_authenticity_token, :only => [:create_feedback]
def posts
@posts = Post.where(:id => params[:ids].split(";"))
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_feedback
@posts = Post.all.joins(:feedbacks).where(:feedbacks => { :feedback_type => params[:type] })
results = @posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def posts_by_url
@post = Post.where(:link => params[:url])
render :json => @post
end
def post_feedback
@post = Post.find params[:id]
render :json => @post.feedbacks
end
def post_reasons
@post = Post.find params[:id]
render :json => @post.reasons
end
def reasons
@reasons = Reason.where(:id => params[:ids].split(";"))
results = @reasons.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def reason_posts
@reason = Reason.find params[:id]
results = @reason.posts.paginate(:page => params[:page], :per_page => @pagesize)
render :json => { :items => results, :has_more => has_more?(params[:page], results.count) }
end
def create_feedback
@post = Post.find params[:id]
@feedback = Feedback.new(:user => current_user, :post => @post, :api_key => @key)
@feedback.feedback_type = params[:type]
if @feedback.save
if @feedback.is_positive?
ActionCable.server.broadcast "smokedetector_messages", { blacklist: { uid: @post.stack_exchange_user.try(:user_id), site: @post.stack_exchange_user.try(:site).try(:site_url), post: @post.link } }
end
render :json => @post.feedbacks, :status => 201
else
render :status => 500, :json => { :error_name => "failed", :error_code => 500, :error_message => "Feedback object failed to save." }
end
end
private
def verify_key
@key = ApiKey.find_by_key(params[:key])
unless params[:key].present? && @key.present?
render :status => 403, :json => { :error_name => "unauthenticated", :error_code => 403, :error_message => "No key was passed or the passed key is invalid." } and return
end
end
def verify_auth
unless user_signed_in?
render :status => 401, :json => { :error_name => "unauthorized", :error_code => 401, :error_message => "There must be a metasmoke user logged in to use this route." } and return
end
end
def set_pagesize
@pagesize = [params[:per_page] || 10, 100].min
end
def has_more?(page, result_count)
(page || 1) * @pagesize < result_count
end
end
|
class Ocrad < Formula
desc "Optical character recognition (OCR) program"
homepage "https://www.gnu.org/software/ocrad/"
url "http://ftpmirror.gnu.org/ocrad/ocrad-0.25.tar.lz"
mirror "https://ftp.gnu.org/gnu/ocrad/ocrad-0.25.tar.lz"
sha256 "e710be9c030fbcbce2315077326c8268feb422c0bc39fa744644cbbd1f5d4dd4"
bottle do
cellar :any
sha256 "99dba4fcc35dcea80dcf70e783832a57578f36406aa9a465398cf511ff2bae6e" => :yosemite
sha256 "ee28a84a3c13a281f601f92920201a00af54509201f62ffb9d84d0e554001c7d" => :mavericks
sha256 "2e338636210625c15a91389b2d53b7464c05c38017d0fba37076e100794668e1" => :mountain_lion
end
def install
system "./configure", "--prefix=#{prefix}"
system "make", "install", "CXXFLAGS=#{ENV.cxxflags}"
end
test do
(testpath/"test.pbm").write <<-EOS.undent
P1
# This is an example bitmap of the letter "J"
6 10
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
1 0 0 0 1 0
0 1 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
EOS
assert_equal "J", `#{bin}/ocrad #{testpath}/test.pbm`.strip
end
end
ocrad: update 0.25 bottle.
class Ocrad < Formula
desc "Optical character recognition (OCR) program"
homepage "https://www.gnu.org/software/ocrad/"
url "http://ftpmirror.gnu.org/ocrad/ocrad-0.25.tar.lz"
mirror "https://ftp.gnu.org/gnu/ocrad/ocrad-0.25.tar.lz"
sha256 "e710be9c030fbcbce2315077326c8268feb422c0bc39fa744644cbbd1f5d4dd4"
bottle do
cellar :any_skip_relocation
sha256 "9acb5576ee58fe3d968649659c9f374277d145a2050ce62ecd70d6d675645efb" => :el_capitan
sha256 "99dba4fcc35dcea80dcf70e783832a57578f36406aa9a465398cf511ff2bae6e" => :yosemite
sha256 "ee28a84a3c13a281f601f92920201a00af54509201f62ffb9d84d0e554001c7d" => :mavericks
sha256 "2e338636210625c15a91389b2d53b7464c05c38017d0fba37076e100794668e1" => :mountain_lion
end
def install
system "./configure", "--prefix=#{prefix}"
system "make", "install", "CXXFLAGS=#{ENV.cxxflags}"
end
test do
(testpath/"test.pbm").write <<-EOS.undent
P1
# This is an example bitmap of the letter "J"
6 10
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
1 0 0 0 1 0
0 1 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
EOS
assert_equal "J", `#{bin}/ocrad #{testpath}/test.pbm`.strip
end
end
|
class ApacheArchiva < Formula
desc "The Build Artifact Repository Manager"
homepage "https://archiva.apache.org/"
url "https://www.apache.org/dyn/closer.cgi?path=archiva/2.2.1/binaries/apache-archiva-2.2.1-bin.tar.gz"
sha256 "e56653e219b76c8c3afdfc424a05e46664958c126ba1d29246e4fd4734c87ba3"
bottle :unneeded
depends_on :java => "1.7+"
def install
libexec.install Dir["*"]
bin.install_symlink libexec/"bin/archiva"
end
def post_install
(var/"archiva/logs").mkpath
(var/"archiva/data").mkpath
(var/"archiva/temp").mkpath
cp_r libexec/"conf", var/"archiva"
end
plist_options :manual => "ARCHIVA_BASE=#{HOMEBREW_PREFIX}/var/archiva #{HOMEBREW_PREFIX}/opt/apache-archiva/bin/archiva console"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/archiva</string>
<string>console</string>
</array>
<key>Disabled</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>archiva</string>
<key>StandardOutPath</key>
<string>#{var}/archiva/logs/launchd.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>ARCHIVA_BASE</key>
<string>#{var}/archiva</string>
</dict>
</dict>
</plist>
EOS
end
test do
assert_match "was not running.", shell_output("#{bin}/archiva stop")
end
end
apache-archiva 2.2.3 (#13767)
class ApacheArchiva < Formula
desc "The Build Artifact Repository Manager"
homepage "https://archiva.apache.org/"
url "https://www.apache.org/dyn/closer.cgi?path=archiva/2.2.3/binaries/apache-archiva-2.2.3-bin.tar.gz"
sha256 "cf90d097e7c2763f6ff8df458b64be0348b35847de8b238c3e1e28e006da8bad"
bottle :unneeded
depends_on :java => "1.7+"
def install
libexec.install Dir["*"]
bin.install_symlink libexec/"bin/archiva"
end
def post_install
(var/"archiva/logs").mkpath
(var/"archiva/data").mkpath
(var/"archiva/temp").mkpath
cp_r libexec/"conf", var/"archiva"
end
plist_options :manual => "ARCHIVA_BASE=#{HOMEBREW_PREFIX}/var/archiva #{HOMEBREW_PREFIX}/opt/apache-archiva/bin/archiva console"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/archiva</string>
<string>console</string>
</array>
<key>Disabled</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>archiva</string>
<key>StandardOutPath</key>
<string>#{var}/archiva/logs/launchd.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>ARCHIVA_BASE</key>
<string>#{var}/archiva</string>
</dict>
</dict>
</plist>
EOS
end
test do
assert_match "was not running.", shell_output("#{bin}/archiva stop")
end
end
|
require 'formula'
class Ocrad < Formula
homepage 'http://www.gnu.org/software/ocrad/'
url 'http://ftpmirror.gnu.org/ocrad/ocrad-0.23.tar.lz'
mirror 'http://ftp.gnu.org/gnu/ocrad/ocrad-0.23.tar.lz'
sha1 '8f539613ce6eb816c691f37ef0977adfcdab5e92'
bottle do
cellar :any
sha1 "a3714c9fe1685bf247ba7ff127a098eb1ac0b9d9" => :mavericks
sha1 "fbc42888aa3700c6420eedb6aa3c7aea27d2e80d" => :mountain_lion
sha1 "3bc70ab2c0df8e0368990d146c03c34ed29d1e9a" => :lion
end
def install
system "./configure", "--prefix=#{prefix}"
system "make", "install", "CXXFLAGS=#{ENV.cxxflags}"
end
test do
system "#{bin}/ocrad", "-h"
end
end
ocrad 0.24
Update to latest stable release, use HTTPS on homepage and mirror,
change single quotes to double.
require "formula"
class Ocrad < Formula
homepage "https://www.gnu.org/software/ocrad/"
url "http://ftpmirror.gnu.org/ocrad/ocrad-0.24.tar.lz"
mirror "https://ftp.gnu.org/gnu/ocrad/ocrad-0.24.tar.lz"
sha1 "b46bbb4b57a3bf2d544cedca47b40f24d8aa811a"
bottle do
cellar :any
sha1 "a3714c9fe1685bf247ba7ff127a098eb1ac0b9d9" => :mavericks
sha1 "fbc42888aa3700c6420eedb6aa3c7aea27d2e80d" => :mountain_lion
sha1 "3bc70ab2c0df8e0368990d146c03c34ed29d1e9a" => :lion
end
def install
system "./configure", "--prefix=#{prefix}"
system "make", "install", "CXXFLAGS=#{ENV.cxxflags}"
end
test do
system "#{bin}/ocrad", "-h"
end
end
|
class AstrometryNet < Formula
include Language::Python::Virtualenv
desc "Automatic identification of astronomical images"
homepage "https://github.com/dstndstn/astrometry.net"
url "https://github.com/dstndstn/astrometry.net/releases/download/0.78/astrometry.net-0.78.tar.gz"
sha256 "9eda1b6cab5269b0a0e5d610aec86866cb8b08fb8f56254dc12f1690d69bc649"
revision 2
bottle do
cellar :any
sha256 "1779cbaea8541ee9987f50d252566a84a145d4beb582d5022318305050879b59" => :mojave
sha256 "5a1414ff53bf48bc14b18462f15da0f6ee49c16f5ef363f90ba5c6d3805e8b86" => :high_sierra
sha256 "b1015bcaf96e66f01d2a7b9b00d54a3d476e5f166cb7f587611811f62c5c2fa9" => :sierra
end
depends_on "pkg-config" => :build
depends_on "swig" => :build
depends_on "cairo"
depends_on "cfitsio"
depends_on "gsl"
depends_on "jpeg"
depends_on "libpng"
depends_on "netpbm"
depends_on "numpy"
depends_on "python"
depends_on "wcslib"
resource "fitsio" do
url "https://files.pythonhosted.org/packages/87/c1/be76515a52004b261febf2c2074f0c2fd730b71b331e2cc69480952e1ed3/fitsio-1.0.5.tar.gz"
sha256 "db5ac8d8216733f492007f1511dc0f77a8b6c0047aca35eb2148adc4a63a4d5a"
end
def install
ENV["NETPBM_INC"] = "-I#{Formula["netpbm"].opt_include}/netpbm"
ENV["NETPBM_LIB"] = "-L#{Formula["netpbm"].opt_lib} -lnetpbm"
ENV["SYSTEM_GSL"] = "yes"
ENV["PYTHON_SCRIPT"] = "#{libexec}/bin/python3"
ENV["PYTHON"] = "python3"
venv = virtualenv_create(libexec, "python3")
venv.pip_install resources
ENV["INSTALL_DIR"] = prefix
xy = Language::Python.major_minor_version "python3"
ENV["PY_BASE_INSTALL_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
ENV["PY_BASE_LINK_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
system "make"
system "make", "py"
system "make", "install"
end
test do
system "#{bin}/build-astrometry-index", "-d", "3", "-o", "index-9918.fits",
"-P", "18", "-S", "mag", "-B", "0.1",
"-s", "0", "-r", "1", "-I", "9918", "-M",
"-i", "#{prefix}/examples/tycho2-mag6.fits"
(testpath/"99.cfg").write <<~EOS
add_path .
inparallel
index index-9918.fits
EOS
system "#{bin}/solve-field", "--config", "99.cfg", "#{prefix}/examples/apod4.jpg",
"--continue", "--dir", "."
assert_predicate testpath/"apod4.solved", :exist?
assert_predicate testpath/"apod4.wcs", :exist?
end
end
astrometry-net: revision bump for gsl
class AstrometryNet < Formula
include Language::Python::Virtualenv
desc "Automatic identification of astronomical images"
homepage "https://github.com/dstndstn/astrometry.net"
url "https://github.com/dstndstn/astrometry.net/releases/download/0.78/astrometry.net-0.78.tar.gz"
sha256 "9eda1b6cab5269b0a0e5d610aec86866cb8b08fb8f56254dc12f1690d69bc649"
revision 3
bottle do
cellar :any
sha256 "1779cbaea8541ee9987f50d252566a84a145d4beb582d5022318305050879b59" => :mojave
sha256 "5a1414ff53bf48bc14b18462f15da0f6ee49c16f5ef363f90ba5c6d3805e8b86" => :high_sierra
sha256 "b1015bcaf96e66f01d2a7b9b00d54a3d476e5f166cb7f587611811f62c5c2fa9" => :sierra
end
depends_on "pkg-config" => :build
depends_on "swig" => :build
depends_on "cairo"
depends_on "cfitsio"
depends_on "gsl"
depends_on "jpeg"
depends_on "libpng"
depends_on "netpbm"
depends_on "numpy"
depends_on "python"
depends_on "wcslib"
resource "fitsio" do
url "https://files.pythonhosted.org/packages/87/c1/be76515a52004b261febf2c2074f0c2fd730b71b331e2cc69480952e1ed3/fitsio-1.0.5.tar.gz"
sha256 "db5ac8d8216733f492007f1511dc0f77a8b6c0047aca35eb2148adc4a63a4d5a"
end
def install
ENV["NETPBM_INC"] = "-I#{Formula["netpbm"].opt_include}/netpbm"
ENV["NETPBM_LIB"] = "-L#{Formula["netpbm"].opt_lib} -lnetpbm"
ENV["SYSTEM_GSL"] = "yes"
ENV["PYTHON_SCRIPT"] = "#{libexec}/bin/python3"
ENV["PYTHON"] = "python3"
venv = virtualenv_create(libexec, "python3")
venv.pip_install resources
ENV["INSTALL_DIR"] = prefix
xy = Language::Python.major_minor_version "python3"
ENV["PY_BASE_INSTALL_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
ENV["PY_BASE_LINK_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
system "make"
system "make", "py"
system "make", "install"
end
test do
system "#{bin}/build-astrometry-index", "-d", "3", "-o", "index-9918.fits",
"-P", "18", "-S", "mag", "-B", "0.1",
"-s", "0", "-r", "1", "-I", "9918", "-M",
"-i", "#{prefix}/examples/tycho2-mag6.fits"
(testpath/"99.cfg").write <<~EOS
add_path .
inparallel
index index-9918.fits
EOS
system "#{bin}/solve-field", "--config", "99.cfg", "#{prefix}/examples/apod4.jpg",
"--continue", "--dir", "."
assert_predicate testpath/"apod4.solved", :exist?
assert_predicate testpath/"apod4.wcs", :exist?
end
end
|
class Orbit < Formula
desc "CORBA 2.4-compliant object request broker (ORB)"
homepage "https://web.archive.org/web/20191222075841/projects-old.gnome.org/ORBit2/"
url "https://download.gnome.org/sources/ORBit2/2.14/ORBit2-2.14.19.tar.bz2"
sha256 "55c900a905482992730f575f3eef34d50bda717c197c97c08fa5a6eafd857550"
license all_of: ["GPL-2.0-or-later", "LGPL-2.0-only"]
revision 1
head "https://gitlab.gnome.org/Archive/orbit2.git"
livecheck do
url :stable
end
bottle do
rebuild 3
sha256 "d39f55257c7d7eff2ecb9bb03c596a23d53abf2c081b87bf06f1b93415dda0b4" => :big_sur
sha256 "42435b23e00c8227cd80af182e39c4f24ea2bd6e50b01c0df0cd171a92ba4c02" => :arm64_big_sur
sha256 "3108db04a65e53b067b29f700b1360e90badde53e891555f341fabe7c5dd5fe4" => :catalina
sha256 "638d7bc192d39014137dfe3508e935b0b129b78e1f6971c1342e8ed1a52b2900" => :mojave
end
# GNOME 2.19 deprecated Orbit2 in 2007; now even their webpage for it is gone as of 2020
deprecate! date: "2020-12-25", because: :deprecated_upstream
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "libidl"
# per MacPorts, re-enable use of deprecated glib functions
patch :p0 do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/6b7eaf2b/orbit/patch-linc2-src-Makefile.in.diff"
sha256 "572771ea59f841d74ac361d51f487cc3bcb2d75dacc9c20a8bd6cbbaeae8f856"
end
patch :p0 do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/6b7eaf2b/orbit/patch-configure.diff"
sha256 "34d068df8fc9482cf70b291032de911f0e75a30994562d4cf56b0cc2a8e28e42"
end
def install
ENV.deparallelize
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "install"
end
test do
assert_match /#{version}/, shell_output("#{bin}/orbit2-config --prefix --version")
end
end
orbit: update 2.14.19_1 bottle.
class Orbit < Formula
desc "CORBA 2.4-compliant object request broker (ORB)"
homepage "https://web.archive.org/web/20191222075841/projects-old.gnome.org/ORBit2/"
url "https://download.gnome.org/sources/ORBit2/2.14/ORBit2-2.14.19.tar.bz2"
sha256 "55c900a905482992730f575f3eef34d50bda717c197c97c08fa5a6eafd857550"
license all_of: ["GPL-2.0-or-later", "LGPL-2.0-only"]
revision 1
head "https://gitlab.gnome.org/Archive/orbit2.git"
livecheck do
url :stable
end
bottle do
rebuild 3
sha256 "d39f55257c7d7eff2ecb9bb03c596a23d53abf2c081b87bf06f1b93415dda0b4" => :big_sur
sha256 "42435b23e00c8227cd80af182e39c4f24ea2bd6e50b01c0df0cd171a92ba4c02" => :arm64_big_sur
sha256 "3108db04a65e53b067b29f700b1360e90badde53e891555f341fabe7c5dd5fe4" => :catalina
sha256 "638d7bc192d39014137dfe3508e935b0b129b78e1f6971c1342e8ed1a52b2900" => :mojave
sha256 "9e052f8285a5f0020ad16c746f206a3f60dd5a4a94cf410ab62758d59990aa44" => :x86_64_linux
end
# GNOME 2.19 deprecated Orbit2 in 2007; now even their webpage for it is gone as of 2020
deprecate! date: "2020-12-25", because: :deprecated_upstream
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "libidl"
# per MacPorts, re-enable use of deprecated glib functions
patch :p0 do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/6b7eaf2b/orbit/patch-linc2-src-Makefile.in.diff"
sha256 "572771ea59f841d74ac361d51f487cc3bcb2d75dacc9c20a8bd6cbbaeae8f856"
end
patch :p0 do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/6b7eaf2b/orbit/patch-configure.diff"
sha256 "34d068df8fc9482cf70b291032de911f0e75a30994562d4cf56b0cc2a8e28e42"
end
def install
ENV.deparallelize
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "install"
end
test do
assert_match /#{version}/, shell_output("#{bin}/orbit2-config --prefix --version")
end
end
|
class AstrometryNet < Formula
include Language::Python::Virtualenv
desc "Automatic identification of astronomical images"
homepage "https://github.com/dstndstn/astrometry.net"
url "https://github.com/dstndstn/astrometry.net/releases/download/0.80/astrometry.net-0.80.tar.gz"
sha256 "6eb73c2371df30324d6532955c46d5f324f2aad87f1af67c12f9354cfd4a7864"
revision 3
bottle do
cellar :any
sha256 "46a03003e70530c829daa38af5ca0768041a13aff07445dc5b3147d1ce406748" => :catalina
sha256 "1974bbd293175be81985447fc6dcd3a2756cc5b8e07b2cc43a75e650baa79792" => :mojave
sha256 "0a18f2feb70bc86a5a591b6255f530667239ee89126cc6e6e2509539babb29dd" => :high_sierra
end
depends_on "pkg-config" => :build
depends_on "swig" => :build
depends_on "cairo"
depends_on "cfitsio"
depends_on "gsl"
depends_on "jpeg"
depends_on "libpng"
depends_on "netpbm"
depends_on "numpy"
depends_on "python@3.8"
depends_on "wcslib"
resource "fitsio" do
url "https://files.pythonhosted.org/packages/5e/d7/58ef112ec42a23a866351b09f802e1b1fa6967ac01df0c9f3ea5ee8223ce/fitsio-1.1.2.tar.gz"
sha256 "20e689bdbb8cbf5fc6c4a1f7154e7407ed1aa68e2d045e3e2cd814f57d85002f"
end
def install
ENV["NETPBM_INC"] = "-I#{Formula["netpbm"].opt_include}/netpbm"
ENV["NETPBM_LIB"] = "-L#{Formula["netpbm"].opt_lib} -lnetpbm"
ENV["SYSTEM_GSL"] = "yes"
ENV["PYTHON"] = Formula["python@3.8"].opt_bin/"python3"
venv = virtualenv_create(libexec, Formula["python@3.8"].opt_bin/"python3")
venv.pip_install resources
ENV["INSTALL_DIR"] = prefix
xy = Language::Python.major_minor_version Formula["python@3.8"].opt_bin/"python3"
ENV["PY_BASE_INSTALL_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
ENV["PY_BASE_LINK_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
ENV["PYTHON_SCRIPT"] = libexec/"bin/python3"
system "make"
system "make", "py"
system "make", "install"
rm prefix/"doc/report.txt"
end
test do
system "#{bin}/image2pnm", "-h"
system "#{bin}/build-astrometry-index", "-d", "3", "-o", "index-9918.fits",
"-P", "18", "-S", "mag", "-B", "0.1",
"-s", "0", "-r", "1", "-I", "9918", "-M",
"-i", "#{prefix}/examples/tycho2-mag6.fits"
(testpath/"99.cfg").write <<~EOS
add_path .
inparallel
index index-9918.fits
EOS
system "#{bin}/solve-field", "--config", "99.cfg", "#{prefix}/examples/apod4.jpg",
"--continue", "--dir", "."
assert_predicate testpath/"apod4.solved", :exist?
assert_predicate testpath/"apod4.wcs", :exist?
end
end
astrometry-net: update 0.80_3 bottle.
class AstrometryNet < Formula
include Language::Python::Virtualenv
desc "Automatic identification of astronomical images"
homepage "https://github.com/dstndstn/astrometry.net"
url "https://github.com/dstndstn/astrometry.net/releases/download/0.80/astrometry.net-0.80.tar.gz"
sha256 "6eb73c2371df30324d6532955c46d5f324f2aad87f1af67c12f9354cfd4a7864"
revision 3
bottle do
cellar :any
sha256 "570d6f95597ff292819943648ce9fe2c23b93cb48b6cb91546269a50e0a8456e" => :catalina
sha256 "c1bb1942e65902e00ba2cf4ecc155bdc822efe3fd14f3c7ec1067c599af1236e" => :mojave
sha256 "214f90c3dba8b41f7a947c3386d97a9d09d751f1f3bf34595f1cfb0660a300ad" => :high_sierra
end
depends_on "pkg-config" => :build
depends_on "swig" => :build
depends_on "cairo"
depends_on "cfitsio"
depends_on "gsl"
depends_on "jpeg"
depends_on "libpng"
depends_on "netpbm"
depends_on "numpy"
depends_on "python@3.8"
depends_on "wcslib"
resource "fitsio" do
url "https://files.pythonhosted.org/packages/5e/d7/58ef112ec42a23a866351b09f802e1b1fa6967ac01df0c9f3ea5ee8223ce/fitsio-1.1.2.tar.gz"
sha256 "20e689bdbb8cbf5fc6c4a1f7154e7407ed1aa68e2d045e3e2cd814f57d85002f"
end
def install
ENV["NETPBM_INC"] = "-I#{Formula["netpbm"].opt_include}/netpbm"
ENV["NETPBM_LIB"] = "-L#{Formula["netpbm"].opt_lib} -lnetpbm"
ENV["SYSTEM_GSL"] = "yes"
ENV["PYTHON"] = Formula["python@3.8"].opt_bin/"python3"
venv = virtualenv_create(libexec, Formula["python@3.8"].opt_bin/"python3")
venv.pip_install resources
ENV["INSTALL_DIR"] = prefix
xy = Language::Python.major_minor_version Formula["python@3.8"].opt_bin/"python3"
ENV["PY_BASE_INSTALL_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
ENV["PY_BASE_LINK_DIR"] = libexec/"lib/python#{xy}/site-packages/astrometry"
ENV["PYTHON_SCRIPT"] = libexec/"bin/python3"
system "make"
system "make", "py"
system "make", "install"
rm prefix/"doc/report.txt"
end
test do
system "#{bin}/image2pnm", "-h"
system "#{bin}/build-astrometry-index", "-d", "3", "-o", "index-9918.fits",
"-P", "18", "-S", "mag", "-B", "0.1",
"-s", "0", "-r", "1", "-I", "9918", "-M",
"-i", "#{prefix}/examples/tycho2-mag6.fits"
(testpath/"99.cfg").write <<~EOS
add_path .
inparallel
index index-9918.fits
EOS
system "#{bin}/solve-field", "--config", "99.cfg", "#{prefix}/examples/apod4.jpg",
"--continue", "--dir", "."
assert_predicate testpath/"apod4.solved", :exist?
assert_predicate testpath/"apod4.wcs", :exist?
end
end
|
class P7zip < Formula
desc "7-Zip (high compression file archiver) implementation"
homepage "https://p7zip.sourceforge.io/"
url "https://downloads.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2"
sha256 "5eb20ac0e2944f6cb9c2d51dd6c4518941c185347d4089ea89087ffdd6e2341f"
revision 2
bottle do
cellar :any_skip_relocation
sha256 "bb715042a9067df735cd7d032a15988da430fbf5a297d9624b9a4a021af6fea2" => :mojave
sha256 "fb52fc214eb4ecd032666997976a514212adcb3c33ca23f15547310d5dc14a6e" => :high_sierra
sha256 "a2b914eebce9108f278e33b53ca798999eb81397c370bd1eaa7f63ddc5e51867" => :sierra
sha256 "229fc3a0badd5325e69b93121c9d55e7860110093e57ef46af063daccb2af372" => :el_capitan
end
patch do
url "https://deb.debian.org/debian/pool/main/p/p7zip/p7zip_16.02+dfsg-6.debian.tar.xz"
sha256 "fab0be1764efdbde1804072f1daa833de4e11ea65f718ad141a592404162643c"
apply "patches/12-CVE-2016-9296.patch",
"patches/13-CVE-2017-17969.patch"
end
patch :p4 do
url "https://github.com/aonez/Keka/files/2940620/15-Enhanced-encryption-strength.patch.zip"
sha256 "838dd2175c3112dc34193e99b8414d1dc1b2b20b861bdde0df2b32dbf59d1ce4"
end
def install
mv "makefile.macosx_llvm_64bits", "makefile.machine"
system "make", "all3",
"CC=#{ENV.cc} $(ALLFLAGS)",
"CXX=#{ENV.cxx} $(ALLFLAGS)"
system "make", "DEST_HOME=#{prefix}",
"DEST_MAN=#{man}",
"install"
end
test do
(testpath/"foo.txt").write("hello world!\n")
system bin/"7z", "a", "-t7z", "foo.7z", "foo.txt"
system bin/"7z", "e", "foo.7z", "-oout"
assert_equal "hello world!\n", File.read(testpath/"out/foo.txt")
end
end
p7zip: update 16.02_2 bottle.
class P7zip < Formula
desc "7-Zip (high compression file archiver) implementation"
homepage "https://p7zip.sourceforge.io/"
url "https://downloads.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2"
sha256 "5eb20ac0e2944f6cb9c2d51dd6c4518941c185347d4089ea89087ffdd6e2341f"
revision 2
bottle do
cellar :any_skip_relocation
sha256 "0de20c4bd05dc5652ca5f188895bf74e52eb701aaed502a0d1271eb58236f898" => :mojave
sha256 "5951a42bd864da7dba5ef5781a2efba206daba8b6f75c60c0cfd910dae218482" => :high_sierra
sha256 "73fe6276e906f67cd28adc0f5a22c914d57fd3cfdd54134ad64e5330f710235a" => :sierra
end
patch do
url "https://deb.debian.org/debian/pool/main/p/p7zip/p7zip_16.02+dfsg-6.debian.tar.xz"
sha256 "fab0be1764efdbde1804072f1daa833de4e11ea65f718ad141a592404162643c"
apply "patches/12-CVE-2016-9296.patch",
"patches/13-CVE-2017-17969.patch"
end
patch :p4 do
url "https://github.com/aonez/Keka/files/2940620/15-Enhanced-encryption-strength.patch.zip"
sha256 "838dd2175c3112dc34193e99b8414d1dc1b2b20b861bdde0df2b32dbf59d1ce4"
end
def install
mv "makefile.macosx_llvm_64bits", "makefile.machine"
system "make", "all3",
"CC=#{ENV.cc} $(ALLFLAGS)",
"CXX=#{ENV.cxx} $(ALLFLAGS)"
system "make", "DEST_HOME=#{prefix}",
"DEST_MAN=#{man}",
"install"
end
test do
(testpath/"foo.txt").write("hello world!\n")
system bin/"7z", "a", "-t7z", "foo.7z", "foo.txt"
system bin/"7z", "e", "foo.7z", "-oout"
assert_equal "hello world!\n", File.read(testpath/"out/foo.txt")
end
end
|
class BzrFastimport < Formula
desc "Bazaar plugin for fast loading of revision control"
homepage "https://launchpad.net/bzr-fastimport"
url "https://launchpad.net/bzr-fastimport/trunk/0.13.0/+download/bzr-fastimport-0.13.0.tar.gz"
sha256 "5e296dc4ff8e9bf1b6447e81fef41e1217656b43368ee4056a1f024221e009eb"
bottle do
cellar :any
sha256 "d72b41c0aad53a702677d75810369da2ad14a8006bfe46750de3ed2d98ddccbd" => :yosemite
sha256 "74e3a541a5e6436475d886a0a438540c31249b9c5d4c48a9111239227a0f8b85" => :mavericks
sha256 "e214595d2db088abe607c92f163eec3cf10118c52e00fbc5cf28c4440b33919c" => :mountain_lion
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "bazaar"
resource "python-fastimport" do
url "https://launchpad.net/python-fastimport/trunk/0.9.0/+download/python-fastimport-0.9.0.tar.gz"
sha256 "07d1d3800b1cfaa820b62c5a88c40cc7e32be9b14d9c6d3298721f32df8e1dec"
end
def install
resource("python-fastimport").stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
libexec.install Dir["*"]
# The plugin must be symlinked in bazaar/plugins to work
target = var/"bazaar/plugins/fastimport"
# we need to remove the target before symlinking it because if we don't and
# the symlink exists from a previous installation the new symlink will be
# created inside libexec instead of overriding the previous one because ln
# itself follows symlinks.
rm_rf target if target.exist?
ln_s libexec, target
end
def caveats; <<-EOS.undent
In order to use this plugin you must set your PYTHONPATH in your ~/.bashrc:
export PYTHONPATH="#{libexec}/vendor/lib/python2.7/site-packages:$PYTHONPATH"
EOS
end
test do
bazaar = Formula["bazaar"]
assert File.exist?(bazaar.libexec/"bzrlib/plugins/fastimport/__init__.py"),
"The fastimport plugin must have been symlinked under bzrlib/plugins/"
bzr = bazaar.bin/"bzr"
ENV.prepend_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
system bzr, "init"
assert_match(/fastimport #{version}/,
shell_output("#{bzr} plugins --verbose"))
system bzr, "fast-export", "--plain", "."
end
end
bzr-fastimport: install into Homebrew's bzr plugin path
Closes Homebrew/homebrew#42573.
Signed-off-by: Mike McQuaid <a17fed27eaa842282862ff7c1b9c8395a26ac320@mikemcquaid.com>
class BzrFastimport < Formula
desc "Bazaar plugin for fast loading of revision control"
homepage "https://launchpad.net/bzr-fastimport"
url "https://launchpad.net/bzr-fastimport/trunk/0.13.0/+download/bzr-fastimport-0.13.0.tar.gz"
sha256 "5e296dc4ff8e9bf1b6447e81fef41e1217656b43368ee4056a1f024221e009eb"
revision 1
bottle do
cellar :any
sha256 "d72b41c0aad53a702677d75810369da2ad14a8006bfe46750de3ed2d98ddccbd" => :yosemite
sha256 "74e3a541a5e6436475d886a0a438540c31249b9c5d4c48a9111239227a0f8b85" => :mavericks
sha256 "e214595d2db088abe607c92f163eec3cf10118c52e00fbc5cf28c4440b33919c" => :mountain_lion
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "bazaar"
resource "python-fastimport" do
url "https://launchpad.net/python-fastimport/trunk/0.9.2/+download/python-fastimport-0.9.2.tar.gz"
sha256 "fd60f1173e64a5da7c5d783f17402f795721b7548ea3a75e29c39d89a60f261e"
end
def install
resource("python-fastimport").stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
(share/"bazaar/plugins/fastimport").install Dir["*"]
end
def caveats; <<-EOS.undent
In order to use this plugin you must set your PYTHONPATH in your ~/.bashrc:
export PYTHONPATH="#{opt_libexec}/vendor/lib/python2.7/site-packages:$PYTHONPATH"
EOS
end
test do
ENV.prepend_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
bzr = Formula["bazaar"].bin/"bzr"
system bzr, "init"
assert_match(/fastimport #{version}/,
shell_output("#{bzr} plugins --verbose"))
system bzr, "fast-export", "--plain", "."
end
end
|
class P7zip < Formula
desc "7-Zip (high compression file archiver) implementation"
homepage "http://p7zip.sourceforge.net/"
url "https://downloads.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2"
sha256 "5eb20ac0e2944f6cb9c2d51dd6c4518941c185347d4089ea89087ffdd6e2341f"
bottle do
cellar :any_skip_relocation
sha256 "434d44f856b99cb91d764fa7d33381fa99b6dada32414cc389448c43d894d958" => :el_capitan
sha256 "9600ee488e04666b807ecbb0df5bafbb36428ca31e649a0a5d754991cc8c41dd" => :yosemite
sha256 "f6d30782b659590984cff65fd9bb8e53a7ea32ee3eb0b3c43d623e7eeacdbd12" => :mavericks
end
def install
mv "makefile.macosx_llvm_64bits", "makefile.machine"
system "make", "all3",
"CC=#{ENV.cc} $(ALLFLAGS)",
"CXX=#{ENV.cxx} $(ALLFLAGS)"
system "make", "DEST_HOME=#{prefix}",
"DEST_MAN=#{man}",
"install"
end
test do
(testpath/"foo.txt").write("hello world!\n")
system bin/"7z", "a", "-t7z", "foo.7z", "foo.txt"
system bin/"7z", "e", "foo.7z", "-oout"
assert_equal "hello world!\n", File.read(testpath/"out/foo.txt")
end
end
p7zip: update 16.02 bottle.
class P7zip < Formula
desc "7-Zip (high compression file archiver) implementation"
homepage "http://p7zip.sourceforge.net/"
url "https://downloads.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2"
sha256 "5eb20ac0e2944f6cb9c2d51dd6c4518941c185347d4089ea89087ffdd6e2341f"
bottle do
cellar :any_skip_relocation
sha256 "7c43699b4c1c186d1dfccb2246ed8c8a9175c5c57ba211b0774395335edce2c8" => :el_capitan
sha256 "1b3a075e34531a09c8714e92499726d4df8c082c29b43e2b11b35d6d20934627" => :yosemite
sha256 "78981de13a763ab595e073360e2848ca0ad65d9a13b7f7728e0c255945cdd00e" => :mavericks
end
def install
mv "makefile.macosx_llvm_64bits", "makefile.machine"
system "make", "all3",
"CC=#{ENV.cc} $(ALLFLAGS)",
"CXX=#{ENV.cxx} $(ALLFLAGS)"
system "make", "DEST_HOME=#{prefix}",
"DEST_MAN=#{man}",
"install"
end
test do
(testpath/"foo.txt").write("hello world!\n")
system bin/"7z", "a", "-t7z", "foo.7z", "foo.txt"
system bin/"7z", "e", "foo.7z", "-oout"
assert_equal "hello world!\n", File.read(testpath/"out/foo.txt")
end
end
|
# frozen_string_literal: true
class IcsController < ApplicationV6Controller
def show
@user = User.only_kept.find_by!(username: params[:username])
I18n.with_locale(@user.locale) do
@slots = UserSlotsQuery.new(
@user,
Slot.only_kept.with_works(@user.works_on(:wanna_watch, :watching).only_kept),
watched: false
).call
.where("started_at >= ?", Date.today.beginning_of_day)
.where("started_at <= ?", 7.days.since.end_of_day)
.where.not(episode_id: nil)
@works = @user
.works_on(:wanna_watch, :watching)
.only_kept
.where.not(started_on: nil)
render formats: :html, layout: false
end
end
end
Googleカレンダーに意図しないチャンネルの放送予定が表示されないように修正
# frozen_string_literal: true
class IcsController < ApplicationV6Controller
def show
@user = User.only_kept.find_by!(username: params[:username])
library_entries = @user.library_entries.wanna_watch_and_watching.where.not(program_id: nil)
I18n.with_locale(@user.locale) do
@slots = Slot
.only_kept
.where(program_id: library_entries.pluck(:program_id))
.where("started_at >= ?", Date.today.beginning_of_day)
.where("started_at <= ?", 7.days.since.end_of_day)
.where.not(episode_id: nil)
.where.not(episode_id: library_entries.pluck(:watched_episode_ids).flatten)
@works = @user
.works_on(:wanna_watch, :watching)
.only_kept
.where.not(started_on: nil)
render formats: :html, layout: false
end
end
end
|
class CfrDecompiler < Formula
desc "Yet Another Java Decompiler"
homepage "http://www.benf.org/other/cfr/"
url "http://www.benf.org/other/cfr/cfr_0_132.jar"
sha256 "e10b1667835cf5b73f09cf37eb122192ce29583c29f5c3a4e134a43e7669f5ba"
bottle :unneeded
depends_on :java => "1.6+"
def install
jar_version = version.to_s.tr(".", "_")
libexec.install "cfr_#{jar_version}.jar"
bin.write_jar_script libexec/"cfr_#{jar_version}.jar", "cfr-decompiler"
end
test do
fixture = <<~EOS
import java.io.PrintStream;
class T {
T() {
}
public static void main(String[] arrstring) {
System.out.println("Hello brew!");
}
}
EOS
(testpath/"T.java").write fixture
system "javac", "T.java"
output = pipe_output("#{bin}/cfr-decompiler T.class")
assert_match fixture, output
end
end
cfr-decompiler: secure url(s)
class CfrDecompiler < Formula
desc "Yet Another Java Decompiler"
homepage "https://www.benf.org/other/cfr/"
url "https://www.benf.org/other/cfr/cfr_0_132.jar"
sha256 "e10b1667835cf5b73f09cf37eb122192ce29583c29f5c3a4e134a43e7669f5ba"
bottle :unneeded
depends_on :java => "1.6+"
def install
jar_version = version.to_s.tr(".", "_")
libexec.install "cfr_#{jar_version}.jar"
bin.write_jar_script libexec/"cfr_#{jar_version}.jar", "cfr-decompiler"
end
test do
fixture = <<~EOS
import java.io.PrintStream;
class T {
T() {
}
public static void main(String[] arrstring) {
System.out.println("Hello brew!");
}
}
EOS
(testpath/"T.java").write fixture
system "javac", "T.java"
output = pipe_output("#{bin}/cfr-decompiler T.class")
assert_match fixture, output
end
end
|
class Paket < Formula
desc "Dependency manager for .NET with support for NuGet and Git repositories"
homepage "https://fsprojects.github.io/Paket/"
url "https://github.com/fsprojects/Paket/releases/download/5.245.0/paket.exe"
sha256 "42e11e7e43d8660da0bda9487a921328f3f249f3114152883d55483b43d0b6bb"
bottle :unneeded
depends_on "mono"
def install
libexec.install "paket.exe"
(bin/"paket").write <<~EOS
#!/bin/bash
mono #{libexec}/paket.exe "$@"
EOS
end
test do
test_package_id = "Paket.Test"
test_package_version = "1.2.3"
touch testpath/"paket.dependencies"
touch testpath/"testfile.txt"
system bin/"paket", "install"
assert_predicate testpath/"paket.lock", :exist?
(testpath/"paket.template").write <<~EOS
type file
id #{test_package_id}
version #{test_package_version}
authors Test package author
description
Description of this test package
files
testfile.txt ==> lib
EOS
system bin/"paket", "pack", "output", testpath
assert_predicate testpath/"#{test_package_id}.#{test_package_version}.nupkg", :exist?
end
end
paket 5.245.1
Closes #54354.
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
class Paket < Formula
desc "Dependency manager for .NET with support for NuGet and Git repositories"
homepage "https://fsprojects.github.io/Paket/"
url "https://github.com/fsprojects/Paket/releases/download/5.245.1/paket.exe"
sha256 "26ed11edc01ce407c4fe26d202deabbb9871c129f617309fc6ac5d4dd79fd20a"
bottle :unneeded
depends_on "mono"
def install
libexec.install "paket.exe"
(bin/"paket").write <<~EOS
#!/bin/bash
mono #{libexec}/paket.exe "$@"
EOS
end
test do
test_package_id = "Paket.Test"
test_package_version = "1.2.3"
touch testpath/"paket.dependencies"
touch testpath/"testfile.txt"
system bin/"paket", "install"
assert_predicate testpath/"paket.lock", :exist?
(testpath/"paket.template").write <<~EOS
type file
id #{test_package_id}
version #{test_package_version}
authors Test package author
description
Description of this test package
files
testfile.txt ==> lib
EOS
system bin/"paket", "pack", "output", testpath
assert_predicate testpath/"#{test_package_id}.#{test_package_version}.nupkg", :exist?
end
end
|
class JwtController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token
SERVICES = {
'container_registry' => ::Gitlab::JWT::ContainerRegistryAuthenticationService,
}
def auth
@authenticated = authenticate_with_http_basic do |login, password|
# if it's possible we first try to authenticate project with login and password
@project = authenticate_project(login, password)
@user = authenticate_user(login, password) unless @project
end
unless @authenticated
head :forbidden if ActionController::HttpAuthentication::Basic.has_basic_credentials?(request)
end
service = SERVICES[params[:service]]
head :not_found unless service
result = service.new(@project, @user, auth_params).execute
return head result[:http_status] if result[:http_status]
render json: result
end
private
def auth_params
params.permit(:service, :scope, :offline_token, :account, :client_id)
end
def authenticate_project(login, password)
matched_login = /(?<s>^[a-zA-Z]*-ci)-token$/.match(login)
if matched_login.present?
underscored_service = matched_login['s'].underscore
if underscored_service == 'gitlab_ci'
Project.find_by(builds_enabled: true, runners_token: password)
end
end
end
def authenticate_user(login, password)
user = Gitlab::Auth.new.find(login, password)
# If the user authenticated successfully, we reset the auth failure count
# from Rack::Attack for that IP. A client may attempt to authenticate
# with a username and blank password first, and only after it receives
# a 401 error does it present a password. Resetting the count prevents
# false positives from occurring.
#
# Otherwise, we let Rack::Attack know there was a failed authentication
# attempt from this IP. This information is stored in the Rails cache
# (Redis) and will be used by the Rack::Attack middleware to decide
# whether to block requests from this IP.
config = Gitlab.config.rack_attack.git_basic_auth
if config.enabled
if user
# A successful login will reset the auth failure count from this IP
Rack::Attack::Allow2Ban.reset(request.ip, config)
else
banned = Rack::Attack::Allow2Ban.filter(request.ip, config) do
# Unless the IP is whitelisted, return true so that Allow2Ban
# increments the counter (stored in Rails.cache) for the IP
if config.ip_whitelist.include?(request.ip)
false
else
true
end
end
if banned
Rails.logger.info "IP #{request.ip} failed to login " \
"as #{login} but has been temporarily banned from Git auth"
end
end
end
user
end
end
Improve JwtController code
class JwtController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token
before_action :authenticate_project_or_user
SERVICES = {
'container_registry' => ::Gitlab::JWT::ContainerRegistryAuthenticationService,
}
def auth
service = SERVICES[params[:service]]
head :not_found unless service
result = service.new(@project, @user, auth_params).execute
return head result[:http_status] if result[:http_status]
render json: result
end
private
def authenticate_project_or_user
authenticate_with_http_basic do |login, password|
# if it's possible we first try to authenticate project with login and password
@project = authenticate_project(login, password)
return if @project
@user = authenticate_user(login, password)
return if @user
end
if ActionController::HttpAuthentication::Basic.has_basic_credentials?(request)
head :forbidden
end
end
def auth_params
params.permit(:service, :scope, :offline_token, :account, :client_id)
end
def authenticate_project(login, password)
if login == 'gitlab_ci_token'
Project.find_by(builds_enabled: true, runners_token: password)
end
end
def authenticate_user(login, password)
user = Gitlab::Auth.new.find(login, password)
# If the user authenticated successfully, we reset the auth failure count
# from Rack::Attack for that IP. A client may attempt to authenticate
# with a username and blank password first, and only after it receives
# a 401 error does it present a password. Resetting the count prevents
# false positives from occurring.
#
# Otherwise, we let Rack::Attack know there was a failed authentication
# attempt from this IP. This information is stored in the Rails cache
# (Redis) and will be used by the Rack::Attack middleware to decide
# whether to block requests from this IP.
config = Gitlab.config.rack_attack.git_basic_auth
if config.enabled
if user
# A successful login will reset the auth failure count from this IP
Rack::Attack::Allow2Ban.reset(request.ip, config)
else
banned = Rack::Attack::Allow2Ban.filter(request.ip, config) do
# Unless the IP is whitelisted, return true so that Allow2Ban
# increments the counter (stored in Rails.cache) for the IP
if config.ip_whitelist.include?(request.ip)
false
else
true
end
end
if banned
Rails.logger.info "IP #{request.ip} failed to login " \
"as #{login} but has been temporarily banned from Git auth"
return
end
end
end
user
end
end
|
class ClickhouseCpp < Formula
desc "C++ client library for ClickHouse"
homepage "https://github.com/ClickHouse/clickhouse-cpp#readme"
url "https://github.com/ClickHouse/clickhouse-cpp/archive/refs/tags/v2.3.0.tar.gz"
sha256 "8eb8b49044247ccc57db73fdf41807a187d8a376d3469f255bab5c0eb0a64359"
license "Apache-2.0"
head "https://github.com/ClickHouse/clickhouse-cpp.git", branch: "master"
bottle do
sha256 cellar: :any, arm64_ventura: "5c65acfac0a5aa7d5b1efb3e8ed34479c80a4afd718c54a2d1f2fb661f9c7949"
sha256 cellar: :any, arm64_monterey: "26e39ddc384145868d46d4ce393da2743e2835ea5bfc9d8ea0b7eb9820200336"
sha256 cellar: :any, arm64_big_sur: "36ae89dde556bb4f92e180735c505a7f07ee42e9ee6398a7ec3cedf6aa2d19f6"
sha256 cellar: :any, ventura: "ca1718bf6713eed39c3fb9f1c8537b92b5ee08a4a462b7822642b68984300e1e"
sha256 cellar: :any, monterey: "525f287703a698aeef5daaeeeaf9bf3da115a3bb0019ccd3949edff1ed1c5326"
sha256 cellar: :any, big_sur: "c4bbc0a458466f26d915f0d88f08aa18146283dd3a70394b4bc2664e4548476b"
sha256 cellar: :any, catalina: "a682490a810ab9b36f1ff3206ebad0e8c232eccd5e878994bd9644dbd487e0d1"
sha256 cellar: :any_skip_relocation, x86_64_linux: "b1751f82002ec0dcc111aa9ce87a38c2b0db23ff14c545563e5558d86839ea79"
end
depends_on "cmake" => [:build, :test]
depends_on "abseil"
depends_on "openssl@3"
fails_with gcc: "5"
fails_with gcc: "6"
def install
system "cmake", "-S", ".", "-B", "build",
"-DWITH_OPENSSL=ON",
"-DOPENSSL_ROOT_DIR=#{Formula["openssl@3"].opt_prefix}",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
(testpath/"main.cpp").write <<~EOS
#include <clickhouse/client.h>
#include <exception>
#include <cstdio>
#include <cstdlib>
int main(int argc, char* argv[])
{
int exit_code = EXIT_SUCCESS;
try
{
// Expecting a typical "failed to connect" error.
clickhouse::Client client(
clickhouse::ClientOptions()
.SetHost("example.com")
.SetSendRetries(1)
.SetRetryTimeout(std::chrono::seconds(1))
.SetTcpKeepAliveCount(1)
.SetTcpKeepAliveInterval(std::chrono::seconds(1))
);
}
catch (const std::exception& ex)
{
std::fprintf(stdout, "Exception: %s\\n", ex.what());
exit_code = EXIT_FAILURE;
}
catch (...)
{
std::fprintf(stdout, "Exception: unknown\\n");
exit_code = EXIT_FAILURE;
}
return exit_code;
}
EOS
(testpath/"CMakeLists.txt").write <<~EOS
project (clickhouse-cpp-test-client LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CLICKHOUSE_CPP_INCLUDE "#{include}")
find_library (CLICKHOUSE_CPP_LIB NAMES clickhouse-cpp-lib PATHS "#{lib}" REQUIRED NO_DEFAULT_PATH)
add_executable (test-client main.cpp)
target_include_directories (test-client PRIVATE ${CLICKHOUSE_CPP_INCLUDE})
target_link_libraries (test-client PRIVATE ${CLICKHOUSE_CPP_LIB})
target_compile_definitions (test-client PUBLIC WITH_OPENSSL)
EOS
system "cmake", "-S", testpath, "-B", (testpath/"build"), *std_cmake_args
system "cmake", "--build", (testpath/"build")
assert_match "Exception: fail to connect: ", shell_output(testpath/"build"/"test-client", 1)
end
end
clickhouse-cpp: update 2.3.0 bottle.
class ClickhouseCpp < Formula
desc "C++ client library for ClickHouse"
homepage "https://github.com/ClickHouse/clickhouse-cpp#readme"
url "https://github.com/ClickHouse/clickhouse-cpp/archive/refs/tags/v2.3.0.tar.gz"
sha256 "8eb8b49044247ccc57db73fdf41807a187d8a376d3469f255bab5c0eb0a64359"
license "Apache-2.0"
head "https://github.com/ClickHouse/clickhouse-cpp.git", branch: "master"
bottle do
sha256 cellar: :any, arm64_ventura: "d416b409e0b3ea994d1862f98423903676b157bcb394b17b3ebbbd955f720620"
sha256 cellar: :any, arm64_monterey: "ad860cfc340915f420ac3a0f9f43a4ededae2af88f1f9d82d325ee78b59b7a81"
sha256 cellar: :any, arm64_big_sur: "c1c3be5c26eba1691038d78ae71872f9b05674bde112b59f8f829045a82808a4"
sha256 cellar: :any, monterey: "1c76150b5684c38b6cafc40fdf26a4eec68f664fab64b5cf672d9bd3623e50b0"
sha256 cellar: :any, big_sur: "55b7fde1c2ac15a34defc526a4ccb12107c757263f5202ac7fc72d81d91ef572"
sha256 cellar: :any, catalina: "b1a57158ed078088f38ce5da4207b4c10544e9268c35a17dd867e5788807ae7b"
sha256 cellar: :any_skip_relocation, x86_64_linux: "59b4a9754fd3934831f20c2efe2398c4a56b4e7fb0de43aff7a50642e80b4bf6"
end
depends_on "cmake" => [:build, :test]
depends_on "abseil"
depends_on "openssl@3"
fails_with gcc: "5"
fails_with gcc: "6"
def install
system "cmake", "-S", ".", "-B", "build",
"-DWITH_OPENSSL=ON",
"-DOPENSSL_ROOT_DIR=#{Formula["openssl@3"].opt_prefix}",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
(testpath/"main.cpp").write <<~EOS
#include <clickhouse/client.h>
#include <exception>
#include <cstdio>
#include <cstdlib>
int main(int argc, char* argv[])
{
int exit_code = EXIT_SUCCESS;
try
{
// Expecting a typical "failed to connect" error.
clickhouse::Client client(
clickhouse::ClientOptions()
.SetHost("example.com")
.SetSendRetries(1)
.SetRetryTimeout(std::chrono::seconds(1))
.SetTcpKeepAliveCount(1)
.SetTcpKeepAliveInterval(std::chrono::seconds(1))
);
}
catch (const std::exception& ex)
{
std::fprintf(stdout, "Exception: %s\\n", ex.what());
exit_code = EXIT_FAILURE;
}
catch (...)
{
std::fprintf(stdout, "Exception: unknown\\n");
exit_code = EXIT_FAILURE;
}
return exit_code;
}
EOS
(testpath/"CMakeLists.txt").write <<~EOS
project (clickhouse-cpp-test-client LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CLICKHOUSE_CPP_INCLUDE "#{include}")
find_library (CLICKHOUSE_CPP_LIB NAMES clickhouse-cpp-lib PATHS "#{lib}" REQUIRED NO_DEFAULT_PATH)
add_executable (test-client main.cpp)
target_include_directories (test-client PRIVATE ${CLICKHOUSE_CPP_INCLUDE})
target_link_libraries (test-client PRIVATE ${CLICKHOUSE_CPP_LIB})
target_compile_definitions (test-client PUBLIC WITH_OPENSSL)
EOS
system "cmake", "-S", testpath, "-B", (testpath/"build"), *std_cmake_args
system "cmake", "--build", (testpath/"build")
assert_match "Exception: fail to connect: ", shell_output(testpath/"build"/"test-client", 1)
end
end
|
class Paket < Formula
desc "Dependency manager for .NET with support for NuGet and Git repositories"
homepage "https://fsprojects.github.io/Paket/"
url "https://github.com/fsprojects/Paket/releases/download/5.4.8/paket.exe"
sha256 "b277f2efa4bfa0bb7f3e1b5b4384c170e0865d08f9b9dfeef44c7f010f1aa032"
bottle :unneeded
depends_on "mono" => :recommended
def install
libexec.install "paket.exe"
(bin/"paket").write <<-EOS.undent
#!/bin/bash
mono #{libexec}/paket.exe "$@"
EOS
end
test do
test_package_id = "Paket.Test"
test_package_version = "1.2.3"
touch testpath/"paket.dependencies"
touch testpath/"testfile.txt"
system bin/"paket", "install"
assert (testpath/"paket.lock").exist?
(testpath/"paket.template").write <<-EOS.undent
type file
id #{test_package_id}
version #{test_package_version}
authors Test package author
description
Description of this test package
files
testfile.txt ==> lib
EOS
system bin/"paket", "pack", "output", testpath
assert (testpath/"#{test_package_id}.#{test_package_version}.nupkg").exist?
end
end
paket 5.5.1 (#15383)
class Paket < Formula
desc "Dependency manager for .NET with support for NuGet and Git repositories"
homepage "https://fsprojects.github.io/Paket/"
url "https://github.com/fsprojects/Paket/releases/download/5.5.1/paket.exe"
sha256 "ce0b6a433e5a8812b5163f2e72af7ebd32f17000a0928bad1f004a1370056e29"
bottle :unneeded
depends_on "mono" => :recommended
def install
libexec.install "paket.exe"
(bin/"paket").write <<-EOS.undent
#!/bin/bash
mono #{libexec}/paket.exe "$@"
EOS
end
test do
test_package_id = "Paket.Test"
test_package_version = "1.2.3"
touch testpath/"paket.dependencies"
touch testpath/"testfile.txt"
system bin/"paket", "install"
assert (testpath/"paket.lock").exist?
(testpath/"paket.template").write <<-EOS.undent
type file
id #{test_package_id}
version #{test_package_version}
authors Test package author
description
Description of this test package
files
testfile.txt ==> lib
EOS
system bin/"paket", "pack", "output", testpath
assert (testpath/"#{test_package_id}.#{test_package_version}.nupkg").exist?
end
end
|
# frozen_string_literal: true
class OrderFeesHandler
attr_reader :order, :distributor, :order_cycle
def initialize(order)
@order = order
@distributor = order.distributor
@order_cycle = order.order_cycle
end
def recreate_all_fees!
# `with_lock` acquires an exclusive row lock on order so no other
# requests can update it until the transaction is commited.
# See https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/locking/pessimistic.rb#L69
# and https://www.postgresql.org/docs/current/static/sql-select.html#SQL-FOR-UPDATE-SHARE
order.with_lock do
EnterpriseFee.clear_all_adjustments order
create_line_item_fees!
create_order_fees!
order.updater.update_totals
order.updater.persist_totals
end
order.update_order!
end
def create_line_item_fees!
order.line_items.includes(variant: :product).each do |line_item|
if provided_by_order_cycle? line_item
calculator.create_line_item_adjustments_for line_item
end
end
end
def create_order_fees!
return unless order_cycle
calculator.create_order_adjustments_for order
end
def update_line_item_fees!(line_item)
line_item.adjustments.enterprise_fee.each do |fee|
fee.update_adjustment!(line_item, force: true)
end
end
def update_order_fees!
order.adjustments.enterprise_fee.where(adjustable_type: 'Spree::Order').each do |fee|
fee.update_adjustment!(order, force: true)
end
end
private
def calculator
@calculator ||= OpenFoodNetwork::EnterpriseFeeCalculator.new(distributor, order_cycle)
end
def provided_by_order_cycle?(line_item)
@order_cycle_variant_ids ||= order_cycle&.variants&.map(&:id) || []
@order_cycle_variant_ids.include? line_item.variant_id
end
end
Remove superfluous updates in OrderFeesHandler
# frozen_string_literal: true
class OrderFeesHandler
attr_reader :order, :distributor, :order_cycle
def initialize(order)
@order = order
@distributor = order.distributor
@order_cycle = order.order_cycle
end
def recreate_all_fees!
# `with_lock` acquires an exclusive row lock on order so no other
# requests can update it until the transaction is commited.
# See https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/locking/pessimistic.rb#L69
# and https://www.postgresql.org/docs/current/static/sql-select.html#SQL-FOR-UPDATE-SHARE
order.with_lock do
EnterpriseFee.clear_all_adjustments order
create_line_item_fees!
create_order_fees!
end
order.update_order!
end
def create_line_item_fees!
order.line_items.includes(variant: :product).each do |line_item|
if provided_by_order_cycle? line_item
calculator.create_line_item_adjustments_for line_item
end
end
end
def create_order_fees!
return unless order_cycle
calculator.create_order_adjustments_for order
end
def update_line_item_fees!(line_item)
line_item.adjustments.enterprise_fee.each do |fee|
fee.update_adjustment!(line_item, force: true)
end
end
def update_order_fees!
order.adjustments.enterprise_fee.where(adjustable_type: 'Spree::Order').each do |fee|
fee.update_adjustment!(order, force: true)
end
end
private
def calculator
@calculator ||= OpenFoodNetwork::EnterpriseFeeCalculator.new(distributor, order_cycle)
end
def provided_by_order_cycle?(line_item)
@order_cycle_variant_ids ||= order_cycle&.variants&.map(&:id) || []
@order_cycle_variant_ids.include? line_item.variant_id
end
end
|
require 'nokogiri'
require 'open-uri'
require 'wunderground'
class TFS
include HTTParty
base_uri 'http://ags1.dtsgis.com/ArcGIS/rest/services/v3scfa'
def self.get_token()
response = get('https://agstx.dtsagile.com/ArcGIS/Tokens',
:query => {
:request => "gettoken",
:username => ENV['TXWRAP_USER'],
:password => ENV['TXWRAP_PASS'],
:clientId => "ref.http://www.prepared.ly",
:expiration => "1440"
}
)
if response != nil
return response.body
else
return nil
end
end
def self.risk_assessment(latlon)
token = self.get_token()
response = get('/RiskAssessment/MapServer/identify',
:headers => {
"Referer" => "http://www.prepared.ly"
},
:query => {
:geometryType => "esriGeometryPoint",
:geometry => "{x: " + latlon.x.to_s + ", y: " + latlon.y.to_s + "}",
:sr => 4326,
:layers => 'all',
:tolerance => 3,
:mapExtent => '-98,30,-97,31',
:imageDisplay => '572,740,96',
:returnGeometry => true,
:f => 'pjson',
:token => token
}
)
if response != nil
json_response = JSON.parse(response.body)
if json_response['results'].length > 0
return json_response['results'][0]['attributes']['Pixel Value'].to_i
else
return nil
end
end
end
end
class MapController < ApplicationController
#after_filter :post, only => [:post, :nws_warnings]
def post
setupMapInfo()
@address_str = params[:q]
respond_to do |format|
#format.html
format.js
end
end
def setupMapInfo
@address_str = params[:q]
#to get only the lat lon, use line below and remove following five lines
#@coordinates = Geocoder.coordinates(@address_str)
@geocode = Geocoder.search(@address_str).to_json
@geocode_response = JSON.parse(@geocode)
# google's geocoder doesn't always put county in the same place in the returned data structure, find administrative_area_level_2 which is what they call counties
@address_components = @geocode_response[0]['data']['address_components']
@county_item = @address_components.select { |e| e['types'][0] === "administrative_area_level_2" }
@county = @county_item[0]["long_name"]
# make sure you're getting back what you want from the geocoder. for example, the yahoo geocoder returns the county every time unlike above:
# @county = @geocode_response[0]['data']['county'].gsub(' County', '').upcase
@coordinates = [@geocode_response[0]['data']['geometry']['location']['lat'], @coordinates = @geocode_response[0]['data']['geometry']['location']['lng']]
# get coordinates from yahoo geocoder response instead:
# @coordinates = [@geocode_response[0]['data']['latitude'], @geocode_response[0]['data']['longitude']]
logger.debug "coordinates:" + @coordinates[1].to_s + ' ' + @coordinates[0].to_s
if @coordinates
@address = Address.find_or_create_by_address(:address => @address_str,
:latlon => 'POINT(' + @coordinates[1].to_s + ' ' + @coordinates[0].to_s + ')')
session[:last_address_id] = @address.id
# Fire Station
@fs = FireStation.all() #order("ST_Distance(latlon, '" + @address.latlon.to_s + "') LIMIT 1")[0]
# d_meters = @address.latlon.distance(@cfs.latlon)
# @distance = "%.02f" % (d_meters/1609.344)
# Weather Conditions
w_api = Wunderground.new(ENV['WUNDERGROUND_API_KEY'])
w_response = w_api.get_conditions_for(@address.latlon.y.to_s + "," + @address.latlon.x.to_s)
@wind_conditions = w_response['current_observation']['wind_string']
@relative_humidity = w_response['current_observation']['relative_humidity']
# Counties with a Burn Ban
rss = Nokogiri::XML(open('http://tfsfrp.tamu.edu/wildfires/BurnBan.xml'))
rss.encoding = 'utf-8'
counties_text = rss.css('rss channel item description').text
counties_array = counties_text.strip.split(', ')
@counties_list = '\'' + counties_array.join("\', \'") + '\''
#use single call to geocoder above and get county back instead of using CartoDB class and API call to get *nearest* county (which sometimes matched 'yes' for a non-TX county)
if @county.nil?
@inside_burnban = 'unavailable'
@inside_nws = 'Please use a street address.'
elsif (counties_array.include?(@county.upcase))
@inside_burnban = 'yes'
else
@inside_burnban = 'no'
end
@burnban_updated = rss.css('rss channel item title').text.split('-')[1]
# Counties with a National Weather Service warning
unless @county.nil?
doc = Nokogiri::XML(open('http://alerts.weather.gov/cap/tx.php?x=0'))
doc.remove_namespaces!
@warnings = []
@inside_nws = 'no'
doc.css('entry').each do |node|
each_county_array = node.css('areaDesc').text.strip.split('; ')
if each_county_array.include?(@county.capitalize)
@inside_nws = 'yes'
@warnings.push(node)
end
end
end
# Risk Assessment Level
if TFS.risk_assessment(@address.latlon) == nil
@risk_text = "Not available at this time"
else
@risk_level = TFS.risk_assessment(@address.latlon)
risk_text_mapping = Hash.new {0}
risk_text_mapping[0] = "Very Low"
risk_text_mapping[1] = "Very Low"
risk_text_mapping[2] = "Low"
risk_text_mapping[3] = "Low"
risk_text_mapping[4] = "Moderate"
risk_text_mapping[5] = "Moderate"
risk_text_mapping[6] = "High"
risk_text_mapping[7] = "High"
risk_text_mapping[8] = "Very High"
risk_text_mapping[9] = "Very High"
@risk_text = risk_text_mapping[@risk_level]
end
end
end
def mapinfo
setupMapInfo()
render :json => {:risk_level => @risk_level,
:risk_text => @risk_text,
:address => @address_str,
:warnings => @warnings,
:inside_nws => @inside_nws,
:location => {:lat => @address.latlon.y, :lon => @address.latlon.x},
:wind_conditions => @wind_conditions,
:relative_humidity => @relative_humidity,
:inside_burnban => @inside_burnban}
#render :partial => 'map/mapinfo'
end
end
corrected POINT() syntax
require 'nokogiri'
require 'open-uri'
require 'wunderground'
class TFS
include HTTParty
base_uri 'http://ags1.dtsgis.com/ArcGIS/rest/services/v3scfa'
def self.get_token()
response = get('https://agstx.dtsagile.com/ArcGIS/Tokens',
:query => {
:request => "gettoken",
:username => ENV['TXWRAP_USER'],
:password => ENV['TXWRAP_PASS'],
:clientId => "ref.http://www.prepared.ly",
:expiration => "1440"
}
)
if response != nil
return response.body
else
return nil
end
end
def self.risk_assessment(latlon)
token = self.get_token()
response = get('/RiskAssessment/MapServer/identify',
:headers => {
"Referer" => "http://www.prepared.ly"
},
:query => {
:geometryType => "esriGeometryPoint",
:geometry => "{x: " + latlon.x.to_s + ", y: " + latlon.y.to_s + "}",
:sr => 4326,
:layers => 'all',
:tolerance => 3,
:mapExtent => '-98,30,-97,31',
:imageDisplay => '572,740,96',
:returnGeometry => true,
:f => 'pjson',
:token => token
}
)
if response != nil
json_response = JSON.parse(response.body)
if json_response['results'].length > 0
return json_response['results'][0]['attributes']['Pixel Value'].to_i
else
return nil
end
end
end
end
class MapController < ApplicationController
#after_filter :post, only => [:post, :nws_warnings]
def post
setupMapInfo()
@address_str = params[:q]
respond_to do |format|
#format.html
format.js
end
end
def setupMapInfo
@address_str = params[:q]
#to get only the lat lon, use line below and remove following five lines
#@coordinates = Geocoder.coordinates(@address_str)
@geocode = Geocoder.search(@address_str).to_json
@geocode_response = JSON.parse(@geocode)
# google's geocoder doesn't always put county in the same place in the returned data structure, find administrative_area_level_2 which is what they call counties
@address_components = @geocode_response[0]['data']['address_components']
@county_item = @address_components.select { |e| e['types'][0] === "administrative_area_level_2" }
@county = @county_item[0]["long_name"]
# make sure you're getting back what you want from the geocoder. for example, the yahoo geocoder returns the county every time unlike above:
# @county = @geocode_response[0]['data']['county'].gsub(' County', '').upcase
@coordinates = [@geocode_response[0]['data']['geometry']['location']['lat'], @coordinates = @geocode_response[0]['data']['geometry']['location']['lng']]
# get coordinates from yahoo geocoder response instead:
# @coordinates = [@geocode_response[0]['data']['latitude'], @geocode_response[0]['data']['longitude']]
logger.debug "coordinates:" + @coordinates[1].to_s + ' ' + @coordinates[0].to_s
if @coordinates
@address = Address.find_or_create_by_address(:address => @address_str,
:latlon => 'POINT(' + @coordinates[1].to_s + ',' + @coordinates[0].to_s + ')')
session[:last_address_id] = @address.id
# Fire Station
@fs = FireStation.all() #order("ST_Distance(latlon, '" + @address.latlon.to_s + "') LIMIT 1")[0]
# d_meters = @address.latlon.distance(@cfs.latlon)
# @distance = "%.02f" % (d_meters/1609.344)
# Weather Conditions
w_api = Wunderground.new(ENV['WUNDERGROUND_API_KEY'])
w_response = w_api.get_conditions_for(@address.latlon.y.to_s + "," + @address.latlon.x.to_s)
@wind_conditions = w_response['current_observation']['wind_string']
@relative_humidity = w_response['current_observation']['relative_humidity']
# Counties with a Burn Ban
rss = Nokogiri::XML(open('http://tfsfrp.tamu.edu/wildfires/BurnBan.xml'))
rss.encoding = 'utf-8'
counties_text = rss.css('rss channel item description').text
counties_array = counties_text.strip.split(', ')
@counties_list = '\'' + counties_array.join("\', \'") + '\''
#use single call to geocoder above and get county back instead of using CartoDB class and API call to get *nearest* county (which sometimes matched 'yes' for a non-TX county)
if @county.nil?
@inside_burnban = 'unavailable'
@inside_nws = 'Please use a street address.'
elsif (counties_array.include?(@county.upcase))
@inside_burnban = 'yes'
else
@inside_burnban = 'no'
end
@burnban_updated = rss.css('rss channel item title').text.split('-')[1]
# Counties with a National Weather Service warning
unless @county.nil?
doc = Nokogiri::XML(open('http://alerts.weather.gov/cap/tx.php?x=0'))
doc.remove_namespaces!
@warnings = []
@inside_nws = 'no'
doc.css('entry').each do |node|
each_county_array = node.css('areaDesc').text.strip.split('; ')
if each_county_array.include?(@county.capitalize)
@inside_nws = 'yes'
@warnings.push(node)
end
end
end
# Risk Assessment Level
if TFS.risk_assessment(@address.latlon) == nil
@risk_text = "Not available at this time"
else
@risk_level = TFS.risk_assessment(@address.latlon)
risk_text_mapping = Hash.new {0}
risk_text_mapping[0] = "Very Low"
risk_text_mapping[1] = "Very Low"
risk_text_mapping[2] = "Low"
risk_text_mapping[3] = "Low"
risk_text_mapping[4] = "Moderate"
risk_text_mapping[5] = "Moderate"
risk_text_mapping[6] = "High"
risk_text_mapping[7] = "High"
risk_text_mapping[8] = "Very High"
risk_text_mapping[9] = "Very High"
@risk_text = risk_text_mapping[@risk_level]
end
end
end
def mapinfo
setupMapInfo()
render :json => {:risk_level => @risk_level,
:risk_text => @risk_text,
:address => @address_str,
:warnings => @warnings,
:inside_nws => @inside_nws,
:location => {:lat => @address.latlon.y, :lon => @address.latlon.x},
:wind_conditions => @wind_conditions,
:relative_humidity => @relative_humidity,
:inside_burnban => @inside_burnban}
#render :partial => 'map/mapinfo'
end
end
|
class Concurrencykit < Formula
desc "Aid design and implementation of concurrent systems"
homepage "http://concurrencykit.org"
url "http://concurrencykit.org/releases/ck-0.6.0.tar.gz"
mirror "https://github.com/concurrencykit/ck/archive/0.6.0.tar.gz"
sha256 "d7e27dd0a679e45632951e672f8288228f32310dfed2d5855e9573a9cf0d62df"
head "https://github.com/concurrencykit/ck.git"
bottle do
cellar :any
sha256 "4bb00e2cc25ebe7e103ca8923c3376e86b3b7b360fc73beb8078d15af1239571" => :high_sierra
sha256 "1597c3fde162ccc3c8c729003da472f3f414509b18a2e64a1fade268ee8798e0" => :sierra
sha256 "897667302b03467c291ff141082b21ec2f31fc82ef5940f791196a14cec24909" => :el_capitan
sha256 "914d6e5afd3412f8892770f73233e1cca915b2a2315c811fc6a8d6fa5ab811ce" => :yosemite
end
def install
system "./configure", "--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <ck_spinlock.h>
int main()
{
return 0;
}
EOS
system ENV.cc, "-I#{include}", "-L#{lib}", "-lck",
testpath/"test.c", "-o", testpath/"test"
system "./test"
end
end
concurrencykit: update 0.6.0 bottle.
class Concurrencykit < Formula
desc "Aid design and implementation of concurrent systems"
homepage "http://concurrencykit.org"
url "http://concurrencykit.org/releases/ck-0.6.0.tar.gz"
mirror "https://github.com/concurrencykit/ck/archive/0.6.0.tar.gz"
sha256 "d7e27dd0a679e45632951e672f8288228f32310dfed2d5855e9573a9cf0d62df"
head "https://github.com/concurrencykit/ck.git"
bottle do
cellar :any
sha256 "d219f60638ce9501978e8494b64eef8861685f78c9e3eeefa295043a05ba75a2" => :mojave
sha256 "4bb00e2cc25ebe7e103ca8923c3376e86b3b7b360fc73beb8078d15af1239571" => :high_sierra
sha256 "1597c3fde162ccc3c8c729003da472f3f414509b18a2e64a1fade268ee8798e0" => :sierra
sha256 "897667302b03467c291ff141082b21ec2f31fc82ef5940f791196a14cec24909" => :el_capitan
sha256 "914d6e5afd3412f8892770f73233e1cca915b2a2315c811fc6a8d6fa5ab811ce" => :yosemite
end
def install
system "./configure", "--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <ck_spinlock.h>
int main()
{
return 0;
}
EOS
system ENV.cc, "-I#{include}", "-L#{lib}", "-lck",
testpath/"test.c", "-o", testpath/"test"
system "./test"
end
end
|
class Pango < Formula
desc "Framework for layout and rendering of i18n text"
homepage "http://www.pango.org/"
url "https://download.gnome.org/sources/pango/1.40/pango-1.40.3.tar.xz"
sha256 "abba8b5ce728520c3a0f1535eab19eac3c14aeef7faa5aded90017ceac2711d3"
bottle do
sha256 "e64fe3eacf55ceb1dbd50d1eb597fd42abed140b9d527aa3be9aa43f9a668b9c" => :sierra
sha256 "3139d621454aaaaedd9ed42dd7fc1b40124152d7db750873448aeb839ca6d59d" => :el_capitan
sha256 "380fff999d7a0e3931aa3c08f365071b90acb55a2d85f998aa5c9fa38cfacdfc" => :yosemite
sha256 "0a914c5cd46cdcf2c2b52ce1f4eda1a6820c77fbb333f5e789b26582356902a9" => :mavericks
end
head do
url "https://git.gnome.org/browse/pango.git"
depends_on "automake" => :build
depends_on "autoconf" => :build
depends_on "libtool" => :build
depends_on "gtk-doc" => :build
end
option :universal
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "cairo"
depends_on "harfbuzz"
depends_on "fontconfig"
depends_on "gobject-introspection"
if OS.mac?
depends_on :x11 => :optional
else
depends_on :x11
end
fails_with :llvm do
build 2326
cause "Undefined symbols when linking"
end
def install
ENV.universal_binary if build.universal?
args = %W[
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--enable-man
--with-html-dir=#{share}/doc
--enable-introspection=yes
--enable-static
]
if build.with? "x11"
args << "--with-xft"
else
args << "--without-xft"
end
system "./autogen.sh" if build.head?
system "./configure", *args
system "make"
system "make", "install"
end
test do
system "#{bin}/pango-view", "--version"
(testpath/"test.c").write <<-EOS.undent
#include <pango/pangocairo.h>
int main(int argc, char *argv[]) {
PangoFontMap *fontmap;
int n_families;
PangoFontFamily **families;
fontmap = pango_cairo_font_map_get_default();
pango_font_map_list_families (fontmap, &families, &n_families);
g_free(families);
return 0;
}
EOS
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
freetype = Formula["freetype"]
gettext = Formula["gettext"]
glib = Formula["glib"]
libpng = Formula["libpng"]
pixman = Formula["pixman"]
flags = %W[
-I#{cairo.opt_include}/cairo
-I#{fontconfig.opt_include}
-I#{freetype.opt_include}/freetype2
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{include}/pango-1.0
-I#{libpng.opt_include}/libpng16
-I#{pixman.opt_include}/pixman-1
-D_REENTRANT
-L#{cairo.opt_lib}
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{lib}
-lcairo
-lglib-2.0
-lgobject-2.0
-lpango-1.0
-lpangocairo-1.0
]
flags << "-lintl" if OS.mac?
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end
pango: update 1.40.3 bottle for Linuxbrew.
Closes Linuxbrew/homebrew-core#980.
Signed-off-by: Shaun Jackman <b580dab3251a9622aba3803114310c23fdb42900@gmail.com>
class Pango < Formula
desc "Framework for layout and rendering of i18n text"
homepage "http://www.pango.org/"
url "https://download.gnome.org/sources/pango/1.40/pango-1.40.3.tar.xz"
sha256 "abba8b5ce728520c3a0f1535eab19eac3c14aeef7faa5aded90017ceac2711d3"
bottle do
sha256 "e64fe3eacf55ceb1dbd50d1eb597fd42abed140b9d527aa3be9aa43f9a668b9c" => :sierra
sha256 "3139d621454aaaaedd9ed42dd7fc1b40124152d7db750873448aeb839ca6d59d" => :el_capitan
sha256 "380fff999d7a0e3931aa3c08f365071b90acb55a2d85f998aa5c9fa38cfacdfc" => :yosemite
sha256 "0a914c5cd46cdcf2c2b52ce1f4eda1a6820c77fbb333f5e789b26582356902a9" => :mavericks
sha256 "6622011cbf8e83d31b676ef437435f568e48e1835189af292a367ffe3cada4a9" => :x86_64_linux
end
head do
url "https://git.gnome.org/browse/pango.git"
depends_on "automake" => :build
depends_on "autoconf" => :build
depends_on "libtool" => :build
depends_on "gtk-doc" => :build
end
option :universal
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "cairo"
depends_on "harfbuzz"
depends_on "fontconfig"
depends_on "gobject-introspection"
if OS.mac?
depends_on :x11 => :optional
else
depends_on :x11
end
fails_with :llvm do
build 2326
cause "Undefined symbols when linking"
end
def install
ENV.universal_binary if build.universal?
args = %W[
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--enable-man
--with-html-dir=#{share}/doc
--enable-introspection=yes
--enable-static
]
if build.with? "x11"
args << "--with-xft"
else
args << "--without-xft"
end
system "./autogen.sh" if build.head?
system "./configure", *args
system "make"
system "make", "install"
end
test do
system "#{bin}/pango-view", "--version"
(testpath/"test.c").write <<-EOS.undent
#include <pango/pangocairo.h>
int main(int argc, char *argv[]) {
PangoFontMap *fontmap;
int n_families;
PangoFontFamily **families;
fontmap = pango_cairo_font_map_get_default();
pango_font_map_list_families (fontmap, &families, &n_families);
g_free(families);
return 0;
}
EOS
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
freetype = Formula["freetype"]
gettext = Formula["gettext"]
glib = Formula["glib"]
libpng = Formula["libpng"]
pixman = Formula["pixman"]
flags = %W[
-I#{cairo.opt_include}/cairo
-I#{fontconfig.opt_include}
-I#{freetype.opt_include}/freetype2
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{include}/pango-1.0
-I#{libpng.opt_include}/libpng16
-I#{pixman.opt_include}/pixman-1
-D_REENTRANT
-L#{cairo.opt_lib}
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{lib}
-lcairo
-lglib-2.0
-lgobject-2.0
-lpango-1.0
-lpangocairo-1.0
]
flags << "-lintl" if OS.mac?
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end
|
class SpreadsheetParser
# Based on file's extension opens file (used for importing)
def self.open_spreadsheet(file)
filename = file.original_filename
file_path = file.path
case File.extname(filename)
when '.csv'
Roo::CSV.new(file_path, extension: :csv)
when '.tsv'
Roo::CSV.new(file_path, csv_options: { col_sep: "\t" })
when '.txt'
# This assumption is based purely on biologist's habits
Roo::CSV.new(file_path, csv_options: { col_sep: "\t" })
when '.xlsx'
# Roo Excel parcel was replaced with Creek, but it can be enabled back,
# just swap lines below. But only one can be enabled at the same time.
Roo::Excelx.new(file_path)
# Creek::Book.new(file_path).sheets[0]
else
raise TypeError
end
end
def self.spreadsheet_enumerator(sheet)
if sheet.is_a?(Roo::CSV)
sheet
elsif sheet.is_a?(Roo::Excelx)
sheet.each_row_streaming
else
sheet.rows
end
end
def self.first_two_rows(sheet)
rows = spreadsheet_enumerator(sheet)
header = []
columns = []
i = 1
rows.each do |row_values|
# Creek XLSX parser returns Hash of the row, Roo - Array
row = parse_row(row_values, sheet)
header = row if i == 1 && row
columns = row if i == 2 && row
i += 1
break if i > 2
end
return header, columns
end
def self.parse_row(row, sheet)
# Creek XLSX parser returns Hash of the row, Roo - Array
if row.is_a?(Hash)
row.values.map(&:to_s)
elsif sheet.is_a?(Roo::Excelx)
row.map { |cell| cell.value.to_s }
else
row.map(&:to_s)
end
end
end
Fix import items to inventory (#2019)
# frozen_string_literal: true
class SpreadsheetParser
# Based on file's extension opens file (used for importing)
def self.open_spreadsheet(file)
if file.class == ActionDispatch::Http::UploadedFile
filename = file.original_filename
file_path = file.path
else
filename = file.filename.to_s
file_path = file.service_url
end
case File.extname(filename)
when '.csv'
Roo::CSV.new(file_path, extension: :csv)
when '.tsv'
Roo::CSV.new(file_path, csv_options: { col_sep: "\t" })
when '.txt'
# This assumption is based purely on biologist's habits
Roo::CSV.new(file_path, csv_options: { col_sep: "\t" })
when '.xlsx'
# Roo Excel parcel was replaced with Creek, but it can be enabled back,
# just swap lines below. But only one can be enabled at the same time.
Roo::Excelx.new(file_path)
# Creek::Book.new(file_path).sheets[0]
else
raise TypeError
end
end
def self.spreadsheet_enumerator(sheet)
if sheet.is_a?(Roo::CSV)
sheet
elsif sheet.is_a?(Roo::Excelx)
sheet.each_row_streaming
else
sheet.rows
end
end
def self.first_two_rows(sheet)
rows = spreadsheet_enumerator(sheet)
header = []
columns = []
i = 1
rows.each do |row_values|
# Creek XLSX parser returns Hash of the row, Roo - Array
row = parse_row(row_values, sheet)
header = row if i == 1 && row
columns = row if i == 2 && row
i += 1
break if i > 2
end
return header, columns
end
def self.parse_row(row, sheet)
# Creek XLSX parser returns Hash of the row, Roo - Array
if row.is_a?(Hash)
row.values.map(&:to_s)
elsif sheet.is_a?(Roo::Excelx)
row.map { |cell| cell.value.to_s }
else
row.map(&:to_s)
end
end
end
|
class MapController < ApplicationController
def index
@current_trends = Trend.most_recent
@mapped_trend = @current_trends.shift
end
def show
render :nothing => true
end
end
change mapped trend instance variable to first from array
class MapController < ApplicationController
def index
@current_trends = Trend.most_recent
@mapped_trend = @current_trends[0]
end
def show
render :nothing => true
end
end
|
class ConsoleBridge < Formula
desc "Robot Operating System-independent package for logging"
homepage "https://wiki.ros.org/console_bridge/"
url "https://github.com/ros/console_bridge/archive/0.5.1.tar.gz"
sha256 "c4ad60c82cd510d4078273a9e210faed572bef6014322456afd14999d2daf130"
bottle do
cellar :any
sha256 "e98131216958db0f3933e7fee94f37d5e356e599802e828f06423930fae66412" => :catalina
sha256 "f79326ff43c19d1fe5cb51af9728a52dd74953ab69c24712fcd8c7c1cc0586f0" => :mojave
sha256 "f1bc8a6b2fd18aa320dec8239f0a2f2082518289fe29da765600e728fa9e2765" => :high_sierra
end
depends_on "cmake" => :build
def install
ENV.cxx11
system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <console_bridge/console.h>
int main() {
CONSOLE_BRIDGE_logDebug("Testing Log");
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-L#{lib}", "-lconsole_bridge", "-std=c++11",
"-o", "test"
system "./test"
end
end
console_bridge: update 0.5.1 bottle.
class ConsoleBridge < Formula
desc "Robot Operating System-independent package for logging"
homepage "https://wiki.ros.org/console_bridge/"
url "https://github.com/ros/console_bridge/archive/0.5.1.tar.gz"
sha256 "c4ad60c82cd510d4078273a9e210faed572bef6014322456afd14999d2daf130"
bottle do
cellar :any
sha256 "e98131216958db0f3933e7fee94f37d5e356e599802e828f06423930fae66412" => :catalina
sha256 "f79326ff43c19d1fe5cb51af9728a52dd74953ab69c24712fcd8c7c1cc0586f0" => :mojave
sha256 "f1bc8a6b2fd18aa320dec8239f0a2f2082518289fe29da765600e728fa9e2765" => :high_sierra
sha256 "14411c3ecb48a3c8f73cede0c235458938100dbde51a7340ee591029300cba1a" => :x86_64_linux
end
depends_on "cmake" => :build
def install
ENV.cxx11
system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <console_bridge/console.h>
int main() {
CONSOLE_BRIDGE_logDebug("Testing Log");
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-L#{lib}", "-lconsole_bridge", "-std=c++11",
"-o", "test"
system "./test"
end
end
|
class Pcre2 < Formula
desc "Perl compatible regular expressions library with a new API"
homepage "https://www.pcre.org/"
url "https://ftp.pcre.org/pub/pcre/pcre2-10.36.tar.bz2"
sha256 "a9ef39278113542968c7c73a31cfcb81aca1faa64690f400b907e8ab6b4a665c"
license "BSD-3-Clause"
head "svn://vcs.exim.org/pcre2/code/trunk"
livecheck do
url "https://ftp.pcre.org/pub/pcre/"
regex(/href=.*?pcre2[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
cellar :any
sha256 "5f9d32224189298d99a994c7844daad4802b28c0f6f521d5b73cd8ca4a96ed1d" => :arm64_big_sur
sha256 "b2edbffaf229fc490843e83b43c4e12feab906fc34270d928c59cac74c6f4536" => :big_sur
sha256 "d14484c7e5d4a74112474288bb2b2edff55be51a42fd65dd02d046d24ebb6cd7" => :catalina
sha256 "2b16cf051af3ba797d12818e209ddbcafcd007e9af6474c0a642d388e299be90" => :mojave
end
uses_from_macos "bzip2"
uses_from_macos "zlib"
def install
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--enable-pcre2-16
--enable-pcre2-32
--enable-pcre2grep-libz
--enable-pcre2grep-libbz2
]
args << "--enable-jit" if Hardware::CPU.arch == :x86_64
system "./configure", *args
system "make"
system "make", "install"
end
test do
system bin/"pcre2grep", "regular expression", prefix/"README"
end
end
pcre2: fix bottle ordering
class Pcre2 < Formula
desc "Perl compatible regular expressions library with a new API"
homepage "https://www.pcre.org/"
url "https://ftp.pcre.org/pub/pcre/pcre2-10.36.tar.bz2"
sha256 "a9ef39278113542968c7c73a31cfcb81aca1faa64690f400b907e8ab6b4a665c"
license "BSD-3-Clause"
head "svn://vcs.exim.org/pcre2/code/trunk"
livecheck do
url "https://ftp.pcre.org/pub/pcre/"
regex(/href=.*?pcre2[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
cellar :any
sha256 "b2edbffaf229fc490843e83b43c4e12feab906fc34270d928c59cac74c6f4536" => :big_sur
sha256 "5f9d32224189298d99a994c7844daad4802b28c0f6f521d5b73cd8ca4a96ed1d" => :arm64_big_sur
sha256 "d14484c7e5d4a74112474288bb2b2edff55be51a42fd65dd02d046d24ebb6cd7" => :catalina
sha256 "2b16cf051af3ba797d12818e209ddbcafcd007e9af6474c0a642d388e299be90" => :mojave
end
uses_from_macos "bzip2"
uses_from_macos "zlib"
def install
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--enable-pcre2-16
--enable-pcre2-32
--enable-pcre2grep-libz
--enable-pcre2grep-libbz2
]
args << "--enable-jit" if Hardware::CPU.arch == :x86_64
system "./configure", *args
system "make"
system "make", "install"
end
test do
system bin/"pcre2grep", "regular expression", prefix/"README"
end
end
|
class RssController < ApplicationController
def index
@branch = Branch.find_by!(name: params[:branch])
@srpms = @branch.srpms.where('srpms.created_at > ?', Time.now - 2.day).order('srpms.created_at DESC')
render layout: nil
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
end
end
Fix rss
class RssController < ApplicationController
def index
@branch = Branch.find_by!(name: params[:branch])
@srpms = @branch.srpms.where('srpms.created_at > ?', Time.now - 2.day).order('srpms.created_at DESC').decorate
render layout: nil
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
end
end
|
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.8.20.tgz"
sha256 "857f353743e58db8d2e8168ee3b75ad005f737102cdbca41214d5efd95409290"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "10a22196223c3d9a204cb24818cc6ef0c71fd06d8bfa2e8662754489bfccce2b"
sha256 cellar: :any_skip_relocation, big_sur: "e5d86dae12dad761c948de60e2bfebadde625f9054dfbc206bb080faa428a4cd"
sha256 cellar: :any_skip_relocation, catalina: "e5d86dae12dad761c948de60e2bfebadde625f9054dfbc206bb080faa428a4cd"
sha256 cellar: :any_skip_relocation, mojave: "e5d86dae12dad761c948de60e2bfebadde625f9054dfbc206bb080faa428a4cd"
sha256 cellar: :any_skip_relocation, x86_64_linux: "774d52cbafc55d030b7ef22b88b3efe3be8ad4721844265002b20c37ddd662bb"
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a management token via --management-token argument", output
end
end
contentful-cli: update 1.8.20 bottle.
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.8.20.tgz"
sha256 "857f353743e58db8d2e8168ee3b75ad005f737102cdbca41214d5efd95409290"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "4765a6bf58c944bbfccbd35f355654ec1b182fbb7963be60de145e4590f4881e"
sha256 cellar: :any_skip_relocation, big_sur: "20849d4f80fd6fc4b488707baa21f83530ca8157a3d00796e72d02effe0775e0"
sha256 cellar: :any_skip_relocation, catalina: "20849d4f80fd6fc4b488707baa21f83530ca8157a3d00796e72d02effe0775e0"
sha256 cellar: :any_skip_relocation, mojave: "20849d4f80fd6fc4b488707baa21f83530ca8157a3d00796e72d02effe0775e0"
sha256 cellar: :any_skip_relocation, x86_64_linux: "ec6fa72ddf52c370b4ba063e8ca50268362430d559b534ebf11a6ac188b67e65"
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a management token via --management-token argument", output
end
end
|
class Petsc < Formula
desc "Portable, Extensible Toolkit for Scientific Computation"
homepage "https://www.mcs.anl.gov/petsc/"
url "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.9.0.tar.gz"
sha256 "a233e0d7f69c98504a1c3548162c6024f7797dde5556b83b0f98ce7326251ca1"
depends_on "hdf5"
depends_on "hwloc"
depends_on "metis"
depends_on "netcdf"
depends_on "open-mpi"
depends_on "scalapack"
depends_on "suite-sparse"
def install
ENV["CC"] = "mpicc"
ENV["CXX"] = "mpicxx"
ENV["F77"] = "mpif77"
ENV["FC"] = "mpif90"
system "./configure", "--prefix=#{prefix}",
"--with-debugging=0",
"--with-scalar-type=real",
"--with-x=0"
system "make", "all"
system "make", "install"
end
test do
test_case = "#{pkgshare}/examples/src/ksp/ksp/examples/tutorials/ex1.c"
system "mpicc", test_case, "-I#{include}", "-L#{lib}", "-lpetsc", "-o", "test"
output = shell_output("./test")
# This PETSc example prints several lines of output. The last line contains
# an error norm, expected to be small.
line = output.lines.last
assert_match /^Norm of error .+, Iterations/, line, "Unexpected output format"
error = line.split[3].to_f
assert (error >= 0.0 && error < 1.0e-13), "Error norm too large"
end
end
petsc: add 3.9.0 bottle.
class Petsc < Formula
desc "Portable, Extensible Toolkit for Scientific Computation"
homepage "https://www.mcs.anl.gov/petsc/"
url "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.9.0.tar.gz"
sha256 "a233e0d7f69c98504a1c3548162c6024f7797dde5556b83b0f98ce7326251ca1"
bottle do
sha256 "504bab16d879f2738e1568880c9d40cc68cad49ed8c0d0bdaa165e0a102f8465" => :high_sierra
sha256 "6ac3fdff619cecf97dd34ec49358c3004d4b610b7d062d5cb9b06fd135d55f04" => :sierra
sha256 "6e1b61304f92067de7ab36d5da2696b4132e79488cbf6bd729dea17908ca3bd4" => :el_capitan
end
depends_on "hdf5"
depends_on "hwloc"
depends_on "metis"
depends_on "netcdf"
depends_on "open-mpi"
depends_on "scalapack"
depends_on "suite-sparse"
def install
ENV["CC"] = "mpicc"
ENV["CXX"] = "mpicxx"
ENV["F77"] = "mpif77"
ENV["FC"] = "mpif90"
system "./configure", "--prefix=#{prefix}",
"--with-debugging=0",
"--with-scalar-type=real",
"--with-x=0"
system "make", "all"
system "make", "install"
end
test do
test_case = "#{pkgshare}/examples/src/ksp/ksp/examples/tutorials/ex1.c"
system "mpicc", test_case, "-I#{include}", "-L#{lib}", "-lpetsc", "-o", "test"
output = shell_output("./test")
# This PETSc example prints several lines of output. The last line contains
# an error norm, expected to be small.
line = output.lines.last
assert_match /^Norm of error .+, Iterations/, line, "Unexpected output format"
error = line.split[3].to_f
assert (error >= 0.0 && error < 1.0e-13), "Error norm too large"
end
end
|
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.4.26.tgz"
sha256 "ff9948f565785ace310fe8a1edf13abb72584dfb59da4c0ccff354a7be3d90d8"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
cellar :any_skip_relocation
sha256 "95a9b15e7c85ca5624ce717bfe9a43f437aaf6e1146fec905f05082d5d2797eb" => :catalina
sha256 "75c14c0a8c426b9cf1960602dd5b04f75ec055c0586f5f362e08304df73c0dc6" => :mojave
sha256 "ab95fde89b75baf09d05a75a19dcd7836ba19b5c53b9e9e54890c0924a4fef1c" => :high_sierra
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a managementToken via --management-Token argument", output
end
end
contentful-cli 1.4.27
Closes #60156.
Signed-off-by: Sean Molenaar <2b250e3fea88cfef248b497ad5fc17f7dc435154@users.noreply.github.com>
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.4.27.tgz"
sha256 "a81ff005f9fe0ba7140b277e73c9b22cf9f720f56d0a47bef2204409c8e4de06"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
cellar :any_skip_relocation
sha256 "95a9b15e7c85ca5624ce717bfe9a43f437aaf6e1146fec905f05082d5d2797eb" => :catalina
sha256 "75c14c0a8c426b9cf1960602dd5b04f75ec055c0586f5f362e08304df73c0dc6" => :mojave
sha256 "ab95fde89b75baf09d05a75a19dcd7836ba19b5c53b9e9e54890c0924a4fef1c" => :high_sierra
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a managementToken via --management-Token argument", output
end
end
|
class Pgcli < Formula
desc "CLI for Postgres with auto-completion and syntax highlighting"
homepage "https://pgcli.com/"
url "https://files.pythonhosted.org/packages/ee/d3/653864b55a857aa6c8c7741dd0ff7bd11423b379e3c84f5152641285cc39/pgcli-1.8.0.tar.gz"
sha256 "9cea027fed2e86d2a6552a962f6817a391560c080f98e5f2977b9385b3315664"
bottle do
cellar :any
rebuild 1
sha256 "da4f10b245a826c9226f20dba9f6f02bb30a725ceedc624e40dc43f05f7f14dd" => :high_sierra
sha256 "0c1113e26e84b844905197005b1731a4211d393d1fed2077e40223f6dc2a5082" => :sierra
sha256 "678d9fdc717c0198804bb497fe042ccf685237385bc00eb3e410add8c7fa2d58" => :el_capitan
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "libpq"
depends_on "openssl"
resource "backports.csv" do
url "https://files.pythonhosted.org/packages/6a/0b/2071ad285e87dd26f5c02147ba13abf7ec777ff20416a60eb15ea204ca76/backports.csv-1.0.5.tar.gz"
sha256 "8c421385cbc6042ba90c68c871c5afc13672acaf91e1508546d6cda6725ebfc6"
end
resource "cli-helpers" do
url "https://files.pythonhosted.org/packages/03/65/9a5b81f879131076e47fa7f0e633a2e6524cdae7d14ef66a58bb810c100e/cli_helpers-0.2.3.tar.gz"
sha256 "eaa887b46ef448c8864ba460cce4fa26866e45e337dc32a2b4741ccb033c42f1"
end
resource "click" do
url "https://files.pythonhosted.org/packages/95/d9/c3336b6b5711c3ab9d1d3a80f1a3e2afeb9d8c02a7166462f6cc96570897/click-6.7.tar.gz"
sha256 "f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
end
resource "configobj" do
url "https://files.pythonhosted.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz"
sha256 "a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"
end
resource "humanize" do
url "https://files.pythonhosted.org/packages/8c/e0/e512e4ac6d091fc990bbe13f9e0378f34cf6eecd1c6c268c9e598dcf5bb9/humanize-0.5.1.tar.gz"
sha256 "a43f57115831ac7c70de098e6ac46ac13be00d69abbf60bdcac251344785bb19"
end
resource "pgspecial" do
url "https://files.pythonhosted.org/packages/bd/61/b35b4622813d6659653290bf6c001b22dc0c5d0b88c0948db47d15d1c42d/pgspecial-1.8.0.tar.gz"
sha256 "89f524909e97554bb3eeceb186a834e86cb71e34afef3a95fe645049ead894b7"
end
resource "prompt_toolkit" do
url "https://files.pythonhosted.org/packages/55/56/8c39509b614bda53e638b7500f12577d663ac1b868aef53426fc6a26c3f5/prompt_toolkit-1.0.14.tar.gz"
sha256 "cc66413b1b4b17021675d9f2d15d57e640b06ddfd99bb724c73484126d22622f"
end
resource "psycopg2" do
url "https://files.pythonhosted.org/packages/f8/e9/5793369ce8a41bf5467623ded8d59a434dfef9c136351aca4e70c2657ba0/psycopg2-2.7.1.tar.gz"
sha256 "86c9355f5374b008c8479bc00023b295c07d508f7c3b91dbd2e74f8925b1d9c6"
end
resource "Pygments" do
url "https://files.pythonhosted.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz"
sha256 "dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
end
resource "setproctitle" do
url "https://files.pythonhosted.org/packages/5a/0d/dc0d2234aacba6cf1a729964383e3452c52096dc695581248b548786f2b3/setproctitle-1.1.10.tar.gz"
sha256 "6283b7a58477dd8478fbb9e76defb37968ee4ba47b05ec1c053cb39638bd7398"
end
resource "six" do
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
end
resource "sqlparse" do
url "https://files.pythonhosted.org/packages/45/67/14bdaeff492e6d03a055fe80502bae10b679891c25a0dc59be2fe51002f8/sqlparse-0.2.3.tar.gz"
sha256 "becd7cc7cebbdf311de8ceedfcf2bd2403297024418801947f8c953025beeff8"
end
resource "terminaltables" do
url "https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz"
sha256 "f3eb0eb92e3833972ac36796293ca0906e998dc3be91fbe1f8615b331b853b81"
end
resource "wcwidth" do
url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz"
sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e"
end
def install
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
resources.each do |r|
r.stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
end
# backports is a namespace package
touch libexec/"vendor/lib/python2.7/site-packages/backports/__init__.py"
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages"
system "python", *Language::Python.setup_install_args(libexec)
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system bin/"pgcli", "--help"
end
end
pgcli 1.8.1
Closes #18368.
Signed-off-by: ilovezfs <fbd54dbbcf9e596abad4ccdc4dfc17f80ebeaee2@icloud.com>
class Pgcli < Formula
desc "CLI for Postgres with auto-completion and syntax highlighting"
homepage "https://pgcli.com/"
url "https://files.pythonhosted.org/packages/d6/22/b31b930ab33ed23db9443f082f4aced2c81be97bcf3a2e1b2ec2e091cb09/pgcli-1.8.1.tar.gz"
sha256 "9a29b4082987760ea336697d3d4a4ecf9c126d7d6b56001d6d897d438bd91ce7"
bottle do
cellar :any
rebuild 1
sha256 "da4f10b245a826c9226f20dba9f6f02bb30a725ceedc624e40dc43f05f7f14dd" => :high_sierra
sha256 "0c1113e26e84b844905197005b1731a4211d393d1fed2077e40223f6dc2a5082" => :sierra
sha256 "678d9fdc717c0198804bb497fe042ccf685237385bc00eb3e410add8c7fa2d58" => :el_capitan
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "libpq"
depends_on "openssl"
resource "backports.csv" do
url "https://files.pythonhosted.org/packages/6a/0b/2071ad285e87dd26f5c02147ba13abf7ec777ff20416a60eb15ea204ca76/backports.csv-1.0.5.tar.gz"
sha256 "8c421385cbc6042ba90c68c871c5afc13672acaf91e1508546d6cda6725ebfc6"
end
resource "cli-helpers" do
url "https://files.pythonhosted.org/packages/03/65/9a5b81f879131076e47fa7f0e633a2e6524cdae7d14ef66a58bb810c100e/cli_helpers-0.2.3.tar.gz"
sha256 "eaa887b46ef448c8864ba460cce4fa26866e45e337dc32a2b4741ccb033c42f1"
end
resource "click" do
url "https://files.pythonhosted.org/packages/95/d9/c3336b6b5711c3ab9d1d3a80f1a3e2afeb9d8c02a7166462f6cc96570897/click-6.7.tar.gz"
sha256 "f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
end
resource "configobj" do
url "https://files.pythonhosted.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz"
sha256 "a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"
end
resource "humanize" do
url "https://files.pythonhosted.org/packages/8c/e0/e512e4ac6d091fc990bbe13f9e0378f34cf6eecd1c6c268c9e598dcf5bb9/humanize-0.5.1.tar.gz"
sha256 "a43f57115831ac7c70de098e6ac46ac13be00d69abbf60bdcac251344785bb19"
end
resource "pgspecial" do
url "https://files.pythonhosted.org/packages/bd/61/b35b4622813d6659653290bf6c001b22dc0c5d0b88c0948db47d15d1c42d/pgspecial-1.8.0.tar.gz"
sha256 "89f524909e97554bb3eeceb186a834e86cb71e34afef3a95fe645049ead894b7"
end
resource "prompt_toolkit" do
url "https://files.pythonhosted.org/packages/8a/ad/cf6b128866e78ad6d7f1dc5b7f99885fb813393d9860778b2984582e81b5/prompt_toolkit-1.0.15.tar.gz"
sha256 "858588f1983ca497f1cf4ffde01d978a3ea02b01c8a26a8bbc5cd2e66d816917"
end
resource "psycopg2" do
url "https://files.pythonhosted.org/packages/6b/fb/15c687eda2f925f0ff59373063fdb408471b4284714a7761daaa65c01f15/psycopg2-2.7.3.1.tar.gz"
sha256 "9b7b16e26448b43cf167f785d8b5345007731ebf153a510e12dae826800caa65"
end
resource "Pygments" do
url "https://files.pythonhosted.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz"
sha256 "dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
end
resource "setproctitle" do
url "https://files.pythonhosted.org/packages/5a/0d/dc0d2234aacba6cf1a729964383e3452c52096dc695581248b548786f2b3/setproctitle-1.1.10.tar.gz"
sha256 "6283b7a58477dd8478fbb9e76defb37968ee4ba47b05ec1c053cb39638bd7398"
end
resource "six" do
url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz"
sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
end
resource "sqlparse" do
url "https://files.pythonhosted.org/packages/45/67/14bdaeff492e6d03a055fe80502bae10b679891c25a0dc59be2fe51002f8/sqlparse-0.2.3.tar.gz"
sha256 "becd7cc7cebbdf311de8ceedfcf2bd2403297024418801947f8c953025beeff8"
end
resource "terminaltables" do
url "https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz"
sha256 "f3eb0eb92e3833972ac36796293ca0906e998dc3be91fbe1f8615b331b853b81"
end
resource "wcwidth" do
url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz"
sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e"
end
def install
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
resources.each do |r|
r.stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
end
# backports is a namespace package
touch libexec/"vendor/lib/python2.7/site-packages/backports/__init__.py"
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages"
system "python", *Language::Python.setup_install_args(libexec)
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system bin/"pgcli", "--help"
end
end
|
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.5.35.tgz"
sha256 "b62c4b67ed38e7d0bca79290c57c16a0787d76796f2a08276c545ea2ef02b710"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "79c006b3e1080c0c3ab656ddbee763c396cf51c8bbe92f501c2fd27b6f582746"
sha256 cellar: :any_skip_relocation, big_sur: "8a18ff7059abaea9c2e2891ea068cc3d383fbf1c10364497155448fe1c495f00"
sha256 cellar: :any_skip_relocation, catalina: "bd78afc86bebf0552969959876d84f27a8517932ad01d0446402d5cba66688da"
sha256 cellar: :any_skip_relocation, mojave: "b6bd46afc3a16e6d04679c0ded378b582efe8168f367f2bd955e499f619d468d"
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a management token via --management-token argument", output
end
end
contentful-cli 1.5.40
Closes #74793.
Signed-off-by: Sean Molenaar <2b250e3fea88cfef248b497ad5fc17f7dc435154@users.noreply.github.com>
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.5.40.tgz"
sha256 "a60b6829ee683a07e89d23e6e2dea208653e41041e2b405776bb954c4c972da8"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "79c006b3e1080c0c3ab656ddbee763c396cf51c8bbe92f501c2fd27b6f582746"
sha256 cellar: :any_skip_relocation, big_sur: "8a18ff7059abaea9c2e2891ea068cc3d383fbf1c10364497155448fe1c495f00"
sha256 cellar: :any_skip_relocation, catalina: "bd78afc86bebf0552969959876d84f27a8517932ad01d0446402d5cba66688da"
sha256 cellar: :any_skip_relocation, mojave: "b6bd46afc3a16e6d04679c0ded378b582efe8168f367f2bd955e499f619d468d"
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a management token via --management-token argument", output
end
end
|
class Pgcli < Formula
desc "CLI for Postgres with auto-completion and syntax highlighting"
homepage "https://pgcli.com/"
url "https://files.pythonhosted.org/packages/d2/71/59473625a4df68df7593b3fb86ac5a81bc5e29e2f9247acdfa4be08d3e43/pgcli-1.7.0.tar.gz"
sha256 "fd8ef5011a354063dd53c95e9b39125c601f8bd406f973a74601f919aafb1181"
revision 2
bottle do
sha256 "1574ae0f26253987feda503b74c0a4bdcb5e6bdfaba55c8cbe304555d8dabd3f" => :sierra
sha256 "6aafb608eabec0b673849edde41555334e4570f32714f6b117f00dd491507d1f" => :el_capitan
sha256 "0b4f03a74c1dbfbe5daf2d515315852a5a585e59ec84dd6092b232490b9537e5" => :yosemite
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "libpq"
depends_on "openssl"
resource "backports.csv" do
url "https://files.pythonhosted.org/packages/6a/0b/2071ad285e87dd26f5c02147ba13abf7ec777ff20416a60eb15ea204ca76/backports.csv-1.0.5.tar.gz"
sha256 "8c421385cbc6042ba90c68c871c5afc13672acaf91e1508546d6cda6725ebfc6"
end
resource "cli-helpers" do
url "https://files.pythonhosted.org/packages/2b/7e/307131c2c3f3abef2d1e68b7088882c078da6ce5bb57cbe79bac12718c72/cli_helpers-0.2.1.tar.gz"
sha256 "a868e69e780c1fd5091c83e784e8b18e2005cab921f1dfda4ffd376271ee85ac"
end
resource "click" do
url "https://files.pythonhosted.org/packages/95/d9/c3336b6b5711c3ab9d1d3a80f1a3e2afeb9d8c02a7166462f6cc96570897/click-6.7.tar.gz"
sha256 "f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
end
resource "configobj" do
url "https://files.pythonhosted.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz"
sha256 "a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"
end
resource "humanize" do
url "https://files.pythonhosted.org/packages/8c/e0/e512e4ac6d091fc990bbe13f9e0378f34cf6eecd1c6c268c9e598dcf5bb9/humanize-0.5.1.tar.gz"
sha256 "a43f57115831ac7c70de098e6ac46ac13be00d69abbf60bdcac251344785bb19"
end
resource "pgspecial" do
url "https://files.pythonhosted.org/packages/bd/61/b35b4622813d6659653290bf6c001b22dc0c5d0b88c0948db47d15d1c42d/pgspecial-1.8.0.tar.gz"
sha256 "89f524909e97554bb3eeceb186a834e86cb71e34afef3a95fe645049ead894b7"
end
resource "prompt_toolkit" do
url "https://files.pythonhosted.org/packages/55/56/8c39509b614bda53e638b7500f12577d663ac1b868aef53426fc6a26c3f5/prompt_toolkit-1.0.14.tar.gz"
sha256 "cc66413b1b4b17021675d9f2d15d57e640b06ddfd99bb724c73484126d22622f"
end
resource "psycopg2" do
url "https://files.pythonhosted.org/packages/f8/e9/5793369ce8a41bf5467623ded8d59a434dfef9c136351aca4e70c2657ba0/psycopg2-2.7.1.tar.gz"
sha256 "86c9355f5374b008c8479bc00023b295c07d508f7c3b91dbd2e74f8925b1d9c6"
end
resource "Pygments" do
url "https://files.pythonhosted.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz"
sha256 "dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
end
resource "setproctitle" do
url "https://files.pythonhosted.org/packages/5a/0d/dc0d2234aacba6cf1a729964383e3452c52096dc695581248b548786f2b3/setproctitle-1.1.10.tar.gz"
sha256 "6283b7a58477dd8478fbb9e76defb37968ee4ba47b05ec1c053cb39638bd7398"
end
resource "six" do
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
end
resource "sqlparse" do
url "https://files.pythonhosted.org/packages/45/67/14bdaeff492e6d03a055fe80502bae10b679891c25a0dc59be2fe51002f8/sqlparse-0.2.3.tar.gz"
sha256 "becd7cc7cebbdf311de8ceedfcf2bd2403297024418801947f8c953025beeff8"
end
resource "terminaltables" do
url "https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz"
sha256 "f3eb0eb92e3833972ac36796293ca0906e998dc3be91fbe1f8615b331b853b81"
end
resource "wcwidth" do
url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz"
sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e"
end
def install
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
resources.each do |r|
r.stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
end
# backports is a namespace package
touch libexec/"vendor/lib/python2.7/site-packages/backports/__init__.py"
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages"
system "python", *Language::Python.setup_install_args(libexec)
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system bin/"pgcli", "--help"
end
end
pgcli: update 1.7.0_2 bottle.
class Pgcli < Formula
desc "CLI for Postgres with auto-completion and syntax highlighting"
homepage "https://pgcli.com/"
url "https://files.pythonhosted.org/packages/d2/71/59473625a4df68df7593b3fb86ac5a81bc5e29e2f9247acdfa4be08d3e43/pgcli-1.7.0.tar.gz"
sha256 "fd8ef5011a354063dd53c95e9b39125c601f8bd406f973a74601f919aafb1181"
revision 2
bottle do
cellar :any
sha256 "91656947500c8f0a5d3aeb39312c6d2a3bd650a3e5641d36c276c39239fed63f" => :sierra
sha256 "a62aa538354e2a750093c46c88c7ad1e8815ace1df8371f1ffc5efe08cd215f9" => :el_capitan
sha256 "c08450475d1b959c5f298ad525466a7c2c66714961daf1acad821a52c85eaca4" => :yosemite
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "libpq"
depends_on "openssl"
resource "backports.csv" do
url "https://files.pythonhosted.org/packages/6a/0b/2071ad285e87dd26f5c02147ba13abf7ec777ff20416a60eb15ea204ca76/backports.csv-1.0.5.tar.gz"
sha256 "8c421385cbc6042ba90c68c871c5afc13672acaf91e1508546d6cda6725ebfc6"
end
resource "cli-helpers" do
url "https://files.pythonhosted.org/packages/2b/7e/307131c2c3f3abef2d1e68b7088882c078da6ce5bb57cbe79bac12718c72/cli_helpers-0.2.1.tar.gz"
sha256 "a868e69e780c1fd5091c83e784e8b18e2005cab921f1dfda4ffd376271ee85ac"
end
resource "click" do
url "https://files.pythonhosted.org/packages/95/d9/c3336b6b5711c3ab9d1d3a80f1a3e2afeb9d8c02a7166462f6cc96570897/click-6.7.tar.gz"
sha256 "f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
end
resource "configobj" do
url "https://files.pythonhosted.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz"
sha256 "a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"
end
resource "humanize" do
url "https://files.pythonhosted.org/packages/8c/e0/e512e4ac6d091fc990bbe13f9e0378f34cf6eecd1c6c268c9e598dcf5bb9/humanize-0.5.1.tar.gz"
sha256 "a43f57115831ac7c70de098e6ac46ac13be00d69abbf60bdcac251344785bb19"
end
resource "pgspecial" do
url "https://files.pythonhosted.org/packages/bd/61/b35b4622813d6659653290bf6c001b22dc0c5d0b88c0948db47d15d1c42d/pgspecial-1.8.0.tar.gz"
sha256 "89f524909e97554bb3eeceb186a834e86cb71e34afef3a95fe645049ead894b7"
end
resource "prompt_toolkit" do
url "https://files.pythonhosted.org/packages/55/56/8c39509b614bda53e638b7500f12577d663ac1b868aef53426fc6a26c3f5/prompt_toolkit-1.0.14.tar.gz"
sha256 "cc66413b1b4b17021675d9f2d15d57e640b06ddfd99bb724c73484126d22622f"
end
resource "psycopg2" do
url "https://files.pythonhosted.org/packages/f8/e9/5793369ce8a41bf5467623ded8d59a434dfef9c136351aca4e70c2657ba0/psycopg2-2.7.1.tar.gz"
sha256 "86c9355f5374b008c8479bc00023b295c07d508f7c3b91dbd2e74f8925b1d9c6"
end
resource "Pygments" do
url "https://files.pythonhosted.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz"
sha256 "dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
end
resource "setproctitle" do
url "https://files.pythonhosted.org/packages/5a/0d/dc0d2234aacba6cf1a729964383e3452c52096dc695581248b548786f2b3/setproctitle-1.1.10.tar.gz"
sha256 "6283b7a58477dd8478fbb9e76defb37968ee4ba47b05ec1c053cb39638bd7398"
end
resource "six" do
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
end
resource "sqlparse" do
url "https://files.pythonhosted.org/packages/45/67/14bdaeff492e6d03a055fe80502bae10b679891c25a0dc59be2fe51002f8/sqlparse-0.2.3.tar.gz"
sha256 "becd7cc7cebbdf311de8ceedfcf2bd2403297024418801947f8c953025beeff8"
end
resource "terminaltables" do
url "https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz"
sha256 "f3eb0eb92e3833972ac36796293ca0906e998dc3be91fbe1f8615b331b853b81"
end
resource "wcwidth" do
url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz"
sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e"
end
def install
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
resources.each do |r|
r.stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
end
# backports is a namespace package
touch libexec/"vendor/lib/python2.7/site-packages/backports/__init__.py"
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages"
system "python", *Language::Python.setup_install_args(libexec)
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system bin/"pgcli", "--help"
end
end
|
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.4.21.tgz"
sha256 "8c51f88cf6b00d2e2a0499ad887afcecc2c86f302d959b1b50678f6205894d10"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
cellar :any_skip_relocation
sha256 "98df49d0b27a1da4f6ff3d6c74099ee4d2de1cdb95b3d3f9534cfed69d3de858" => :catalina
sha256 "55ac0b016e8ac78736b62e6029b03dac0770061ecddf1d5a241b08fd2f216b4e" => :mojave
sha256 "3d6d7539d83ed92e9cfaee08b15aa85b44aed06451cf522b48b4ee6bb0d7941f" => :high_sierra
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a managementToken via --management-Token argument", output
end
end
contentful-cli: update 1.4.21 bottle.
require "language/node"
class ContentfulCli < Formula
desc "Contentful command-line tools"
homepage "https://github.com/contentful/contentful-cli"
url "https://registry.npmjs.org/contentful-cli/-/contentful-cli-1.4.21.tgz"
sha256 "8c51f88cf6b00d2e2a0499ad887afcecc2c86f302d959b1b50678f6205894d10"
license "MIT"
head "https://github.com/contentful/contentful-cli.git"
bottle do
cellar :any_skip_relocation
sha256 "4e3c0f5d07154ede5ac18c3e3edf355a53df29d94cc453fc27caa719254b407d" => :catalina
sha256 "3dbab387bb486599fcf2ee9c52027122c58dce1a4a4032d05c576f928ecd4733" => :mojave
sha256 "8f72eca8462285efb739179f65e709644c9c019360bc704db8652767f51db6fe" => :high_sierra
end
depends_on "node"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]
end
test do
output = shell_output("#{bin}/contentful space list 2>&1", 1)
assert_match "🚨 Error: You have to be logged in to do this.", output
assert_match "You can log in via contentful login", output
assert_match "Or provide a managementToken via --management-Token argument", output
end
end
|
class IssueDecorator < Draper::Decorator
delegate :votes,
:title,
:to_json,
:description,
:vote_connections,
:accountability,
:published?,
:cache_key,
# move to decorator?
:status_text,
:editor_name,
:last_updated_by_name,
:stats,
:downcased_title
def explanation
h.t('app.issues.explanation', count: votes.size, url: h.votes_issue_path(model)).html_safe
end
def published_at
h.l model.published_at.localtime, format: :text
end
def updated_at
h.l model.updated_at.localtime, format: :text
end
def time_since_updated
h.distance_of_time_in_words_to_now model.updated_at.localtime
end
def position_groups
grouped = Party.order(:name).group_by do |p|
model.stats.key_for(model.stats.score_for(p))
end
[:for, :for_and_against, :against].map do |key|
label = OpenStruct.new(:icon => "taxonomy-icons/issue_#{key}.png", :text => h.t("app.#{key}"))
parties = grouped[key] || []
[label, parties]
end
end
def promises_by_party
# {
# 'A' => { 'Partiprogram' => promises, 'Regjeringserklæring' => promises },
# 'FrP' => { 'Partiprogram' => promises },
# }
@promises_by_party ||= (
result = {}
model.promises.includes(:parties).each do |promise|
promise.parties.each do |party|
data = result[party] ||= {}
(data[promise.source.downcase] ||= []) << promise
end
end
result
)
end
def party_groups
government = Party.in_government.to_a
opposition = Party.order(:name).to_a - government
gov = IssuePartyDecorator.decorate_collection government, context: self
opp = IssuePartyDecorator.decorate_collection opposition, context: self
groups = []
if government.any?
groups << PartyGroup.new(h.t('app.parties.group.governing'), gov)
groups << PartyGroup.new(h.t('app.parties.group.opposition'), opp)
else
# if no-one's in government, we only need a single group with no name.
groups << PartyGroup.new('', opp)
end
groups
end
class PartyGroup < Struct.new(:name, :parties)
end
class IssuePartyDecorator < Draper::Decorator
alias_method :issue, :context
delegate :external_id, :image_with_fallback, :name
def link(opts = {}, &blk)
h.link_to h.party_path(model), opts, &blk
end
def logo(opts = {})
size = opts.delete(:size) || '96x96'
h.image_tag model.image_with_fallback.thumb(size).url, opts.merge(alt: "#{model.name}s logo")
end
def position_logo
key = issue.stats.key_for(score) # FIXME: take the party, not the score
if key.nil? || key == :not_participated
# could add taxonomy-icons/issue_not_participated.png
else
h.image_tag "taxonomy-icons/issue_#{key}.png"
end
end
def promise_logo
key = issue.accountability.key_for(model)
h.image_tag "taxonomy-icons/promise_#{key}.png"
end
def has_promises?
promise_groups && promise_groups.values.any?
end
def promise_groups
@promise_groups ||= issue.promises_by_party[model]
end
def score
issue.stats.score_for(model)
end
def position_text
[
issue.stats.text_for(model, html: true),
h.t('app.lang.infinitive_particle'),
issue.downcased_title
].join(' ').html_safe
end
def accountability_text
issue.accountability.text_for(model)
end
def votes
votes = issue.vote_connections.map { |vc| PartyVote.new(model, vc) }
votes.select { |e| e.participated? }
end
end
class PartyVote < Struct.new(:party, :vote_connection)
def participated?
stats.party_participated? party
end
def direction
@direction ||= stats.party_for?(party) ? 'for' : 'against'
end
def title
@title ||= (
title = vote_connection.title || ''
"#{I18n.t('app.lang.infinitive_particle')} #{UnicodeUtils.downcase title[0]}#{title[1..-1]}".strip
)
end
def time
I18n.l vote_connection.vote.time, format: :short
end
def anchor
vote_connection.to_param
end
def label
direction == 'for' ? 'For' : 'Mot'
end
def stats
@stats ||= vote_connection.vote.stats
end
end
end
Fix error if vote_connection.title was nil
class IssueDecorator < Draper::Decorator
delegate :votes,
:title,
:to_json,
:description,
:vote_connections,
:accountability,
:published?,
:cache_key,
# move to decorator?
:status_text,
:editor_name,
:last_updated_by_name,
:stats,
:downcased_title
def explanation
h.t('app.issues.explanation', count: votes.size, url: h.votes_issue_path(model)).html_safe
end
def published_at
h.l model.published_at.localtime, format: :text
end
def updated_at
h.l model.updated_at.localtime, format: :text
end
def time_since_updated
h.distance_of_time_in_words_to_now model.updated_at.localtime
end
def position_groups
grouped = Party.order(:name).group_by do |p|
model.stats.key_for(model.stats.score_for(p))
end
[:for, :for_and_against, :against].map do |key|
label = OpenStruct.new(:icon => "taxonomy-icons/issue_#{key}.png", :text => h.t("app.#{key}"))
parties = grouped[key] || []
[label, parties]
end
end
def promises_by_party
# {
# 'A' => { 'Partiprogram' => promises, 'Regjeringserklæring' => promises },
# 'FrP' => { 'Partiprogram' => promises },
# }
@promises_by_party ||= (
result = {}
model.promises.includes(:parties).each do |promise|
promise.parties.each do |party|
data = result[party] ||= {}
(data[promise.source.downcase] ||= []) << promise
end
end
result
)
end
def party_groups
government = Party.in_government.to_a
opposition = Party.order(:name).to_a - government
gov = IssuePartyDecorator.decorate_collection government, context: self
opp = IssuePartyDecorator.decorate_collection opposition, context: self
groups = []
if government.any?
groups << PartyGroup.new(h.t('app.parties.group.governing'), gov)
groups << PartyGroup.new(h.t('app.parties.group.opposition'), opp)
else
# if no-one's in government, we only need a single group with no name.
groups << PartyGroup.new('', opp)
end
groups
end
class PartyGroup < Struct.new(:name, :parties)
end
class IssuePartyDecorator < Draper::Decorator
alias_method :issue, :context
delegate :external_id, :image_with_fallback, :name
def link(opts = {}, &blk)
h.link_to h.party_path(model), opts, &blk
end
def logo(opts = {})
size = opts.delete(:size) || '96x96'
h.image_tag model.image_with_fallback.thumb(size).url, opts.merge(alt: "#{model.name}s logo")
end
def position_logo
key = issue.stats.key_for(score) # FIXME: take the party, not the score
if key.nil? || key == :not_participated
# could add taxonomy-icons/issue_not_participated.png
else
h.image_tag "taxonomy-icons/issue_#{key}.png"
end
end
def promise_logo
key = issue.accountability.key_for(model)
h.image_tag "taxonomy-icons/promise_#{key}.png"
end
def has_promises?
promise_groups && promise_groups.values.any?
end
def promise_groups
@promise_groups ||= issue.promises_by_party[model]
end
def score
issue.stats.score_for(model)
end
def position_text
[
issue.stats.text_for(model, html: true),
h.t('app.lang.infinitive_particle'),
issue.downcased_title
].join(' ').html_safe
end
def accountability_text
issue.accountability.text_for(model)
end
def votes
votes = issue.vote_connections.map { |vc| PartyVote.new(model, vc) }
votes.select { |e| e.participated? }
end
end
class PartyVote < Struct.new(:party, :vote_connection)
def participated?
stats.party_participated? party
end
def direction
@direction ||= stats.party_for?(party) ? 'for' : 'against'
end
def title
@title ||= (
title = vote_connection.title or return ''
"#{I18n.t('app.lang.infinitive_particle')} #{UnicodeUtils.downcase title[0]}#{title[1..-1]}".strip
)
end
def time
I18n.l vote_connection.vote.time, format: :short
end
def anchor
vote_connection.to_param
end
def label
direction == 'for' ? 'For' : 'Mot'
end
def stats
@stats ||= vote_connection.vote.stats
end
end
end
|
class Pgcli < Formula
desc "CLI for Postgres with auto-completion and syntax highlighting"
homepage "http://pgcli.com/"
url "https://files.pythonhosted.org/packages/44/c7/a3a1df56b7eefdbf2aaf833d2856262f075ece87530d98936d4147d3e32e/pgcli-1.5.1.tar.gz"
sha256 "10d7334a9a90c8eec107dca89f8bde0a5dbfa10bfc5f187402c3f1adffee36d7"
bottle do
cellar :any
sha256 "35a4ff3b9518553243f79ed230e0da38a1318fc0cab59003da3e347741499183" => :sierra
sha256 "12eabe80aafb6a9be527cee2d39295c706539f2ed0f8c59293398dc2eabe7e11" => :el_capitan
sha256 "0173793349867ee9fcefe023862f9b8cb1dff2f99858bddf8f2b26ee454661d2" => :yosemite
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "openssl"
depends_on :postgresql
resource "click" do
url "https://files.pythonhosted.org/packages/95/d9/c3336b6b5711c3ab9d1d3a80f1a3e2afeb9d8c02a7166462f6cc96570897/click-6.7.tar.gz"
sha256 "f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
end
resource "configobj" do
url "https://files.pythonhosted.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz"
sha256 "a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"
end
resource "humanize" do
url "https://files.pythonhosted.org/packages/8c/e0/e512e4ac6d091fc990bbe13f9e0378f34cf6eecd1c6c268c9e598dcf5bb9/humanize-0.5.1.tar.gz"
sha256 "a43f57115831ac7c70de098e6ac46ac13be00d69abbf60bdcac251344785bb19"
end
resource "pgspecial" do
url "https://files.pythonhosted.org/packages/71/cc/93ee525a00e5ad6306945529d6f9c7ea0058d2f7a72ad25759c21e558780/pgspecial-1.7.0.tar.gz"
sha256 "297e231caf77e129c4d0b71f97ca022be8d32684928af5959050de727245db4a"
end
resource "prompt_toolkit" do
url "https://files.pythonhosted.org/packages/23/be/4876b52d5cc159cbd4b0ff6e7aa419a26470849a43a8f647857a4a24467b/prompt_toolkit-1.0.13.tar.gz"
sha256 "33d68ca09f76cd73287fde7df5748ffacf26a8238dd61ee81ac50860ea7c6776"
end
resource "psycopg2" do
url "https://files.pythonhosted.org/packages/f8/e9/5793369ce8a41bf5467623ded8d59a434dfef9c136351aca4e70c2657ba0/psycopg2-2.7.1.tar.gz"
sha256 "86c9355f5374b008c8479bc00023b295c07d508f7c3b91dbd2e74f8925b1d9c6"
end
resource "Pygments" do
url "https://files.pythonhosted.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz"
sha256 "dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
end
resource "setproctitle" do
url "https://files.pythonhosted.org/packages/5a/0d/dc0d2234aacba6cf1a729964383e3452c52096dc695581248b548786f2b3/setproctitle-1.1.10.tar.gz"
sha256 "6283b7a58477dd8478fbb9e76defb37968ee4ba47b05ec1c053cb39638bd7398"
end
resource "six" do
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
end
resource "sqlparse" do
url "https://files.pythonhosted.org/packages/45/67/14bdaeff492e6d03a055fe80502bae10b679891c25a0dc59be2fe51002f8/sqlparse-0.2.3.tar.gz"
sha256 "becd7cc7cebbdf311de8ceedfcf2bd2403297024418801947f8c953025beeff8"
end
resource "wcwidth" do
url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz"
sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e"
end
def install
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
resources.each do |r|
r.stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
end
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages"
system "python", *Language::Python.setup_install_args(libexec)
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system bin/"pgcli", "--help"
end
end
pgcli: secure url(s)
class Pgcli < Formula
desc "CLI for Postgres with auto-completion and syntax highlighting"
homepage "https://pgcli.com/"
url "https://files.pythonhosted.org/packages/44/c7/a3a1df56b7eefdbf2aaf833d2856262f075ece87530d98936d4147d3e32e/pgcli-1.5.1.tar.gz"
sha256 "10d7334a9a90c8eec107dca89f8bde0a5dbfa10bfc5f187402c3f1adffee36d7"
bottle do
cellar :any
sha256 "35a4ff3b9518553243f79ed230e0da38a1318fc0cab59003da3e347741499183" => :sierra
sha256 "12eabe80aafb6a9be527cee2d39295c706539f2ed0f8c59293398dc2eabe7e11" => :el_capitan
sha256 "0173793349867ee9fcefe023862f9b8cb1dff2f99858bddf8f2b26ee454661d2" => :yosemite
end
depends_on :python if MacOS.version <= :snow_leopard
depends_on "openssl"
depends_on :postgresql
resource "click" do
url "https://files.pythonhosted.org/packages/95/d9/c3336b6b5711c3ab9d1d3a80f1a3e2afeb9d8c02a7166462f6cc96570897/click-6.7.tar.gz"
sha256 "f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
end
resource "configobj" do
url "https://files.pythonhosted.org/packages/64/61/079eb60459c44929e684fa7d9e2fdca403f67d64dd9dbac27296be2e0fab/configobj-5.0.6.tar.gz"
sha256 "a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"
end
resource "humanize" do
url "https://files.pythonhosted.org/packages/8c/e0/e512e4ac6d091fc990bbe13f9e0378f34cf6eecd1c6c268c9e598dcf5bb9/humanize-0.5.1.tar.gz"
sha256 "a43f57115831ac7c70de098e6ac46ac13be00d69abbf60bdcac251344785bb19"
end
resource "pgspecial" do
url "https://files.pythonhosted.org/packages/71/cc/93ee525a00e5ad6306945529d6f9c7ea0058d2f7a72ad25759c21e558780/pgspecial-1.7.0.tar.gz"
sha256 "297e231caf77e129c4d0b71f97ca022be8d32684928af5959050de727245db4a"
end
resource "prompt_toolkit" do
url "https://files.pythonhosted.org/packages/23/be/4876b52d5cc159cbd4b0ff6e7aa419a26470849a43a8f647857a4a24467b/prompt_toolkit-1.0.13.tar.gz"
sha256 "33d68ca09f76cd73287fde7df5748ffacf26a8238dd61ee81ac50860ea7c6776"
end
resource "psycopg2" do
url "https://files.pythonhosted.org/packages/f8/e9/5793369ce8a41bf5467623ded8d59a434dfef9c136351aca4e70c2657ba0/psycopg2-2.7.1.tar.gz"
sha256 "86c9355f5374b008c8479bc00023b295c07d508f7c3b91dbd2e74f8925b1d9c6"
end
resource "Pygments" do
url "https://files.pythonhosted.org/packages/71/2a/2e4e77803a8bd6408a2903340ac498cb0a2181811af7c9ec92cb70b0308a/Pygments-2.2.0.tar.gz"
sha256 "dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
end
resource "setproctitle" do
url "https://files.pythonhosted.org/packages/5a/0d/dc0d2234aacba6cf1a729964383e3452c52096dc695581248b548786f2b3/setproctitle-1.1.10.tar.gz"
sha256 "6283b7a58477dd8478fbb9e76defb37968ee4ba47b05ec1c053cb39638bd7398"
end
resource "six" do
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
end
resource "sqlparse" do
url "https://files.pythonhosted.org/packages/45/67/14bdaeff492e6d03a055fe80502bae10b679891c25a0dc59be2fe51002f8/sqlparse-0.2.3.tar.gz"
sha256 "becd7cc7cebbdf311de8ceedfcf2bd2403297024418801947f8c953025beeff8"
end
resource "wcwidth" do
url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz"
sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e"
end
def install
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
resources.each do |r|
r.stage do
system "python", *Language::Python.setup_install_args(libexec/"vendor")
end
end
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages"
system "python", *Language::Python.setup_install_args(libexec)
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system bin/"pgcli", "--help"
end
end
|
class CouchdbLucene < Formula
desc "Full-text search of CouchDB documents using Lucene"
homepage "https://github.com/rnewson/couchdb-lucene"
url "https://github.com/rnewson/couchdb-lucene/archive/v2.1.0.tar.gz"
sha256 "8297f786ab9ddd86239565702eb7ae8e117236781144529ed7b72a967224b700"
license "Apache-2.0"
revision 2
bottle do
sha256 cellar: :any_skip_relocation, big_sur: "8c75a95f3c1909e99602f51ed4c55fc2eb495910d8772b9b693347c633141715"
sha256 cellar: :any_skip_relocation, catalina: "5888b91cbf5c0fe4744ee9f1cf0ca204f9dd89e125a06fc928375b1d2770ae87"
sha256 cellar: :any_skip_relocation, mojave: "d7e8191c66bc938d7c8e15c10c13612be41ef601f5f6ab78b9ef5275c04bf89d"
end
depends_on "maven" => :build
depends_on "couchdb"
depends_on "openjdk"
def install
system "mvn"
system "tar", "-xzf", "target/couchdb-lucene-#{version}-dist.tar.gz", "--strip", "1"
prefix.install_metafiles
rm_rf Dir["bin/*.bat"]
libexec.install Dir["*"]
env = Language::Java.overridable_java_home_env
env["CL_BASEDIR"] = libexec/"bin"
Dir.glob("#{libexec}/bin/*") do |path|
bin_name = File.basename(path)
cmd = "cl_#{bin_name}"
(bin/cmd).write_env_script libexec/"bin/#{bin_name}", env
(libexec/"clbin").install_symlink bin/cmd => bin_name
end
ini_path.write(ini_file) unless ini_path.exist?
end
def ini_path
etc/"couchdb/local.d/couchdb-lucene.ini"
end
def ini_file
<<~EOS
[httpd_global_handlers]
_fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}
EOS
end
def caveats
<<~EOS
All commands have been installed with the prefix 'cl_'.
If you really need to use these commands with their normal names, you
can add a "clbin" directory to your PATH from your bashrc like:
PATH="#{opt_libexec}/clbin:$PATH"
EOS
end
service do
run opt_bin/"cl_run"
environment_variables HOME: "~"
run_type :immediate
keep_alive true
end
test do
# This seems to be the easiest way to make the test play nicely in our
# sandbox. If it works here, it'll work in the normal location though.
cp_r Dir[opt_prefix/"*"], testpath
inreplace "bin/cl_run", "CL_BASEDIR=\"#{libexec}/bin\"",
"CL_BASEDIR=\"#{testpath}/libexec/bin\""
port = free_port
inreplace "libexec/conf/couchdb-lucene.ini", "port=5985", "port=#{port}"
fork do
exec "#{testpath}/bin/cl_run"
end
sleep 5
output = JSON.parse shell_output("curl --silent localhost:#{port}")
assert_equal "Welcome", output["couchdb-lucene"]
assert_equal version, output["version"]
end
end
couchdb-lucene: update 2.1.0_2 bottle.
class CouchdbLucene < Formula
desc "Full-text search of CouchDB documents using Lucene"
homepage "https://github.com/rnewson/couchdb-lucene"
url "https://github.com/rnewson/couchdb-lucene/archive/v2.1.0.tar.gz"
sha256 "8297f786ab9ddd86239565702eb7ae8e117236781144529ed7b72a967224b700"
license "Apache-2.0"
revision 2
bottle do
sha256 cellar: :any_skip_relocation, big_sur: "8c75a95f3c1909e99602f51ed4c55fc2eb495910d8772b9b693347c633141715"
sha256 cellar: :any_skip_relocation, catalina: "5888b91cbf5c0fe4744ee9f1cf0ca204f9dd89e125a06fc928375b1d2770ae87"
sha256 cellar: :any_skip_relocation, mojave: "d7e8191c66bc938d7c8e15c10c13612be41ef601f5f6ab78b9ef5275c04bf89d"
sha256 cellar: :any_skip_relocation, x86_64_linux: "0d08b00d0ef852160eb6f5fef96f8cc9387b2fa4c29a792cfe9a13ccdf2d690b"
end
depends_on "maven" => :build
depends_on "couchdb"
depends_on "openjdk"
def install
system "mvn"
system "tar", "-xzf", "target/couchdb-lucene-#{version}-dist.tar.gz", "--strip", "1"
prefix.install_metafiles
rm_rf Dir["bin/*.bat"]
libexec.install Dir["*"]
env = Language::Java.overridable_java_home_env
env["CL_BASEDIR"] = libexec/"bin"
Dir.glob("#{libexec}/bin/*") do |path|
bin_name = File.basename(path)
cmd = "cl_#{bin_name}"
(bin/cmd).write_env_script libexec/"bin/#{bin_name}", env
(libexec/"clbin").install_symlink bin/cmd => bin_name
end
ini_path.write(ini_file) unless ini_path.exist?
end
def ini_path
etc/"couchdb/local.d/couchdb-lucene.ini"
end
def ini_file
<<~EOS
[httpd_global_handlers]
_fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}
EOS
end
def caveats
<<~EOS
All commands have been installed with the prefix 'cl_'.
If you really need to use these commands with their normal names, you
can add a "clbin" directory to your PATH from your bashrc like:
PATH="#{opt_libexec}/clbin:$PATH"
EOS
end
service do
run opt_bin/"cl_run"
environment_variables HOME: "~"
run_type :immediate
keep_alive true
end
test do
# This seems to be the easiest way to make the test play nicely in our
# sandbox. If it works here, it'll work in the normal location though.
cp_r Dir[opt_prefix/"*"], testpath
inreplace "bin/cl_run", "CL_BASEDIR=\"#{libexec}/bin\"",
"CL_BASEDIR=\"#{testpath}/libexec/bin\""
port = free_port
inreplace "libexec/conf/couchdb-lucene.ini", "port=5985", "port=#{port}"
fork do
exec "#{testpath}/bin/cl_run"
end
sleep 5
output = JSON.parse shell_output("curl --silent localhost:#{port}")
assert_equal "Welcome", output["couchdb-lucene"]
assert_equal version, output["version"]
end
end
|
class IssueDecorator < Draper::Decorator
delegate :votes,
:title,
:to_json,
:description,
:vote_connections,
:accountability,
:published?,
:cache_key,
:party_comments,
:tags,
:valence_issue?,
:valence_issue_explanations,
# move to decorator?
:status_text,
:editor_name,
:last_updated_by_name,
:stats,
:downcased_title
def explanation
h.t('app.issues.explanation', count: votes.size, url: h.votes_issue_path(model)).html_safe
end
def published_at
h.l model.published_at.localtime, format: :text
end
def updated_at
h.l model.updated_at.localtime, format: :text
end
def time_since_updated
h.distance_of_time_in_words_to_now model.updated_at.localtime
end
def position_groups
grouped = Party.order(:name).group_by do |p|
model.stats.key_for(model.stats.score_for(p))
end
[:for, :for_and_against, :against].map do |key|
label = OpenStruct.new(icon: "taxonomy-icons/issue_#{key}.png", text: h.t("app.#{key}"), key: key)
parties = grouped[key] || []
[label, parties]
end
end
def promises_by_party
@promises_by_party ||= (
result = Hash.new { |hash, key| hash[key] = [] }
model.promises.includes(:parties).each do |promise|
promise.parties.each do |party|
result[party] << promise
end
end
result
)
end
def party_groups
government = Party.in_government.order(:name).to_a
opposition = Party.order(:name).to_a - government
gov = IssuePartyDecorator.decorate_collection government, context: self
opp = IssuePartyDecorator.decorate_collection opposition, context: self
groups = []
if government.any?
groups << PartyGroup.new(h.t('app.parties.group.governing'), gov)
groups << PartyGroup.new(h.t('app.parties.group.opposition'), opp)
else
# if no-one's in government, we only need a single group with no name.
groups << PartyGroup.new('', opp)
end
groups
end
class PartyGroup < Struct.new(:name, :parties)
end
class IssuePartyDecorator < Draper::Decorator
alias_method :issue, :context
delegate :external_id,
:image_with_fallback,
:name,
:slug
def link(opts = {}, &blk)
h.link_to h.party_path(model), opts, &blk
end
def logo(opts = {})
h.image_tag model.logo.versions[:medium], opts.merge(alt: "#{model.name}s logo", width: '96', height: '96')
end
def position_logo
return '' if issue.valence_issue?
key = issue.stats.key_for(score) # FIXME: take the party, not the score
if key.nil? || key == :not_participated
# could add taxonomy-icons/issue_not_participated.png
else
h.image_tag "taxonomy-icons/issue_#{key}.png", alt: position_caption
end
end
def position_caption
return '' if issue.valence_issue?
key = issue.stats.key_for(score) # FIXME: take the party, not the score
if key && key != :not_participated
h.t("app.#{key}")
end
end
def has_comment?
!!comment
end
def comment
issue.party_comments.where(party_id: model.id).first
end
def promise_logo
return '' if issue.valence_issue?
key = issue.accountability.key_for(model)
if key == :unknown
return ''
end
# FIXME: missing icon for partially_kept
if key == :partially_kept
key = :kept
end
h.image_tag "taxonomy-icons/promise_#{key}.png", alt: promise_caption
end
def promise_caption
return '' if issue.valence_issue?
key = issue.accountability.key_for(model)
h.t("app.promises.scores.caption.#{key}")
end
def promise_groups
@promise_groups ||= (
# TODO: clean this up
result = {}
promises_by_source = issue.promises_by_party[model].group_by { |promise| [promise.source.downcase, promise.parliament_period_name] }
result['partiprogram 2009-2013'] = promises_by_source[['partiprogram', '2009-2013']] || []
result['regjeringserklæring 2009-2013'] = promises_by_source[['regjeringserklæring', '2009-2013']] if promises_by_source[['regjeringserklæring', '2009-2013']]
result['partiprogram 2013-2017'] = promises_by_source[['partiprogram', '2013-2017']] if promises_by_source[['partiprogram', '2013-2017']]
result
)
end
def score
issue.stats.score_for(model)
end
def position_text
return '' if issue.valence_issue?
[
issue.stats.text_for(model, html: true),
h.t('app.lang.infinitive_particle'),
"#{issue.downcased_title}."
].join(' ').html_safe
end
def accountability_text
acc = issue.accountability
if issue.valence_issue?
if acc.score_for(model)
acc.text_for(model, name: model.name)
else
''
end
else
acc.text_for(model, name: 'De')
end
end
def votes
votes = issue.vote_connections.includes(:vote).sort_by { |e| e.vote.time }.reverse
votes.map { |vc| PartyVote.new(model, vc) }.reject(&:ignored?)
end
end
class PartyVote < Struct.new(:party, :vote_connection)
def ignored?
!participated? || against_alternate_budget?
end
def against_alternate_budget?
vote_connection.proposition_type == 'alternate_national_budget' &&
direction == 'against'
end
def participated?
stats.party_participated? party
end
def direction
@direction ||= stats.party_for?(party) ? 'for' : 'against'
end
def title
@title ||= (
if vote_connection.title.blank?
''
else
title = vote_connection.title
"#{I18n.t('app.lang.infinitive_particle')} #{UnicodeUtils.downcase title[0]}#{title[1..-1]}".strip
end
)
end
def time
I18n.l vote_connection.vote.time, format: :short
end
def month_and_year
I18n.l(vote_connection.vote.time, format: :month_year).capitalize
end
def anchor
"vote-#{vote_connection.to_param}"
end
def label
direction == 'for' ? 'For' : 'Mot'
end
def stats
@stats ||= vote_connection.vote.stats
end
end
end
Add encoding comment
# encoding: utf-8
class IssueDecorator < Draper::Decorator
delegate :votes,
:title,
:to_json,
:description,
:vote_connections,
:accountability,
:published?,
:cache_key,
:party_comments,
:tags,
:valence_issue?,
:valence_issue_explanations,
# move to decorator?
:status_text,
:editor_name,
:last_updated_by_name,
:stats,
:downcased_title
def explanation
h.t('app.issues.explanation', count: votes.size, url: h.votes_issue_path(model)).html_safe
end
def published_at
h.l model.published_at.localtime, format: :text
end
def updated_at
h.l model.updated_at.localtime, format: :text
end
def time_since_updated
h.distance_of_time_in_words_to_now model.updated_at.localtime
end
def position_groups
grouped = Party.order(:name).group_by do |p|
model.stats.key_for(model.stats.score_for(p))
end
[:for, :for_and_against, :against].map do |key|
label = OpenStruct.new(icon: "taxonomy-icons/issue_#{key}.png", text: h.t("app.#{key}"), key: key)
parties = grouped[key] || []
[label, parties]
end
end
def promises_by_party
@promises_by_party ||= (
result = Hash.new { |hash, key| hash[key] = [] }
model.promises.includes(:parties).each do |promise|
promise.parties.each do |party|
result[party] << promise
end
end
result
)
end
def party_groups
government = Party.in_government.order(:name).to_a
opposition = Party.order(:name).to_a - government
gov = IssuePartyDecorator.decorate_collection government, context: self
opp = IssuePartyDecorator.decorate_collection opposition, context: self
groups = []
if government.any?
groups << PartyGroup.new(h.t('app.parties.group.governing'), gov)
groups << PartyGroup.new(h.t('app.parties.group.opposition'), opp)
else
# if no-one's in government, we only need a single group with no name.
groups << PartyGroup.new('', opp)
end
groups
end
class PartyGroup < Struct.new(:name, :parties)
end
class IssuePartyDecorator < Draper::Decorator
alias_method :issue, :context
delegate :external_id,
:image_with_fallback,
:name,
:slug
def link(opts = {}, &blk)
h.link_to h.party_path(model), opts, &blk
end
def logo(opts = {})
h.image_tag model.logo.versions[:medium], opts.merge(alt: "#{model.name}s logo", width: '96', height: '96')
end
def position_logo
return '' if issue.valence_issue?
key = issue.stats.key_for(score) # FIXME: take the party, not the score
if key.nil? || key == :not_participated
# could add taxonomy-icons/issue_not_participated.png
else
h.image_tag "taxonomy-icons/issue_#{key}.png", alt: position_caption
end
end
def position_caption
return '' if issue.valence_issue?
key = issue.stats.key_for(score) # FIXME: take the party, not the score
if key && key != :not_participated
h.t("app.#{key}")
end
end
def has_comment?
!!comment
end
def comment
issue.party_comments.where(party_id: model.id).first
end
def promise_logo
return '' if issue.valence_issue?
key = issue.accountability.key_for(model)
if key == :unknown
return ''
end
# FIXME: missing icon for partially_kept
if key == :partially_kept
key = :kept
end
h.image_tag "taxonomy-icons/promise_#{key}.png", alt: promise_caption
end
def promise_caption
return '' if issue.valence_issue?
key = issue.accountability.key_for(model)
h.t("app.promises.scores.caption.#{key}")
end
def promise_groups
@promise_groups ||= (
# TODO: clean this up
result = {}
promises_by_source = issue.promises_by_party[model].group_by { |promise| [promise.source.downcase, promise.parliament_period_name] }
result['partiprogram 2009-2013'] = promises_by_source[['partiprogram', '2009-2013']] || []
result['regjeringserklæring 2009-2013'] = promises_by_source[['regjeringserklæring', '2009-2013']] if promises_by_source[['regjeringserklæring', '2009-2013']]
result['partiprogram 2013-2017'] = promises_by_source[['partiprogram', '2013-2017']] if promises_by_source[['partiprogram', '2013-2017']]
result
)
end
def score
issue.stats.score_for(model)
end
def position_text
return '' if issue.valence_issue?
[
issue.stats.text_for(model, html: true),
h.t('app.lang.infinitive_particle'),
"#{issue.downcased_title}."
].join(' ').html_safe
end
def accountability_text
acc = issue.accountability
if issue.valence_issue?
if acc.score_for(model)
acc.text_for(model, name: model.name)
else
''
end
else
acc.text_for(model, name: 'De')
end
end
def votes
votes = issue.vote_connections.includes(:vote).sort_by { |e| e.vote.time }.reverse
votes.map { |vc| PartyVote.new(model, vc) }.reject(&:ignored?)
end
end
class PartyVote < Struct.new(:party, :vote_connection)
def ignored?
!participated? || against_alternate_budget?
end
def against_alternate_budget?
vote_connection.proposition_type == 'alternate_national_budget' &&
direction == 'against'
end
def participated?
stats.party_participated? party
end
def direction
@direction ||= stats.party_for?(party) ? 'for' : 'against'
end
def title
@title ||= (
if vote_connection.title.blank?
''
else
title = vote_connection.title
"#{I18n.t('app.lang.infinitive_particle')} #{UnicodeUtils.downcase title[0]}#{title[1..-1]}".strip
end
)
end
def time
I18n.l vote_connection.vote.time, format: :short
end
def month_and_year
I18n.l(vote_connection.vote.time, format: :month_year).capitalize
end
def anchor
"vote-#{vote_connection.to_param}"
end
def label
direction == 'for' ? 'For' : 'Mot'
end
def stats
@stats ||= vote_connection.vote.stats
end
end
end
|
require File.join(File.dirname(__FILE__), 'abstract-php')
class Php54 < AbstractPhp
init
url 'http://www.php.net/get/php-5.4.14.tar.bz2/from/this/mirror'
md5 '68e90795071f769b8fda22af7d71092d09f42dea'
version '5.4.14'
head 'https://github.com/php/php-src.git', :branch => 'PHP-5.4'
# Leopard requires Hombrew OpenSSL to build correctly
depends_on 'openssl' if MacOS.version == :leopard
def install_args
args = super
args << "--with-homebrew-openssl" if MacOS.version == :leopard
args + [
"--enable-zend-signals",
"--enable-dtrace",
]
end
def php_version
5.4
end
def php_version_path
54
end
end
Use sha1, not md5, for php54 package hash
require File.join(File.dirname(__FILE__), 'abstract-php')
class Php54 < AbstractPhp
init
url 'http://www.php.net/get/php-5.4.14.tar.bz2/from/this/mirror'
sha1 '68e90795071f769b8fda22af7d71092d09f42dea'
version '5.4.14'
head 'https://github.com/php/php-src.git', :branch => 'PHP-5.4'
# Leopard requires Hombrew OpenSSL to build correctly
depends_on 'openssl' if MacOS.version == :leopard
def install_args
args = super
args << "--with-homebrew-openssl" if MacOS.version == :leopard
args + [
"--enable-zend-signals",
"--enable-dtrace",
]
end
def php_version
5.4
end
def php_version_path
54
end
end
|
class DockerCompose < Formula
include Language::Python::Virtualenv
desc "Isolated development environments using Docker"
homepage "https://docs.docker.com/compose/"
url "https://files.pythonhosted.org/packages/92/29/303a71a1bf4522d6e36baa14d48f286d75da545777d8510b9f4085686ee3/docker-compose-1.28.5.tar.gz"
sha256 "b3ff8f0352eb4055c4c483cb498aeff7c90195fa679f3caf7098a2d6fa6030e5"
license "Apache-2.0"
head "https://github.com/docker/compose.git"
bottle do
sha256 cellar: :any, arm64_big_sur: "403a8c562cd2a9795b426602951a65076e75a93b4b38d69ee90cf036f889bc2c"
sha256 cellar: :any, big_sur: "7ce78bfe6c5ad7865592e147929ed98f59538ad026a6da497fb4f9856ca9aba7"
sha256 cellar: :any, catalina: "f6c2bedcc7d1c5966df7755f9df5b84f403dabb414c762b8c8209048e50cda8b"
sha256 cellar: :any, mojave: "7a70c69e013372a6ba2fc2b604e99dd80333ed3a38cbced99b47fc68f37b2397"
end
depends_on "rust" => :build
depends_on "libyaml"
depends_on "python@3.9"
uses_from_macos "libffi"
resource "attrs" do
url "https://files.pythonhosted.org/packages/f0/cb/80a4a274df7da7b8baf083249b0890a0579374c3d74b5ac0ee9291f912dc/attrs-20.3.0.tar.gz"
sha256 "832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700"
end
resource "bcrypt" do
url "https://files.pythonhosted.org/packages/d8/ba/21c475ead997ee21502d30f76fd93ad8d5858d19a3fad7cd153de698c4dd/bcrypt-3.2.0.tar.gz"
sha256 "5b93c1726e50a93a033c36e5ca7fdcd29a5c7395af50a6892f5d9e7c6cfbfb29"
end
resource "cached-property" do
url "https://files.pythonhosted.org/packages/61/2c/d21c1c23c2895c091fa7a91a54b6872098fea913526932d21902088a7c41/cached-property-1.5.2.tar.gz"
sha256 "9fa5755838eecbb2d234c3aa390bd80fbd3ac6b6869109bfc1b499f7bd89a130"
end
resource "certifi" do
url "https://files.pythonhosted.org/packages/06/a9/cd1fd8ee13f73a4d4f491ee219deeeae20afefa914dfb4c130cfc9dc397a/certifi-2020.12.5.tar.gz"
sha256 "1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"
end
resource "cffi" do
url "https://files.pythonhosted.org/packages/a8/20/025f59f929bbcaa579704f443a438135918484fffaacfaddba776b374563/cffi-1.14.5.tar.gz"
sha256 "fd78e5fee591709f32ef6edb9a015b4aa1a5022598e36227500c8f4e02328d9c"
end
resource "chardet" do
url "https://files.pythonhosted.org/packages/ee/2d/9cdc2b527e127b4c9db64b86647d567985940ac3698eeabc7ffaccb4ea61/chardet-4.0.0.tar.gz"
sha256 "0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"
end
resource "cryptography" do
url "https://files.pythonhosted.org/packages/fa/2d/2154d8cb773064570f48ec0b60258a4522490fcb115a6c7c9423482ca993/cryptography-3.4.6.tar.gz"
sha256 "2d32223e5b0ee02943f32b19245b61a62db83a882f0e76cc564e1cec60d48f87"
end
resource "distro" do
url "https://files.pythonhosted.org/packages/a6/a4/75064c334d8ae433445a20816b788700db1651f21bdb0af33db2aab142fe/distro-1.5.0.tar.gz"
sha256 "0e58756ae38fbd8fc3020d54badb8eae17c5b9dcbed388b17bb55b8a5928df92"
end
resource "docker" do
url "https://files.pythonhosted.org/packages/fd/46/6f6116c30cb859a0cdb95444140e9fe0be0de455c9c83748ee421aec8274/docker-4.4.4.tar.gz"
sha256 "d3393c878f575d3a9ca3b94471a3c89a6d960b35feb92f033c0de36cc9d934db"
end
resource "dockerpty" do
url "https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz"
sha256 "69a9d69d573a0daa31bcd1c0774eeed5c15c295fe719c61aca550ed1393156ce"
end
resource "docopt" do
url "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz"
sha256 "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491"
end
resource "idna" do
url "https://files.pythonhosted.org/packages/ea/b7/e0e3c1c467636186c39925827be42f16fee389dc404ac29e930e9136be70/idna-2.10.tar.gz"
sha256 "b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"
end
resource "jsonschema" do
url "https://files.pythonhosted.org/packages/69/11/a69e2a3c01b324a77d3a7c0570faa372e8448b666300c4117a516f8b1212/jsonschema-3.2.0.tar.gz"
sha256 "c8a85b28d377cc7737e46e2d9f2b4f44ee3c0e1deac6bf46ddefc7187d30797a"
end
resource "paramiko" do
url "https://files.pythonhosted.org/packages/cf/a1/20d00ce559a692911f11cadb7f94737aca3ede1c51de16e002c7d3a888e0/paramiko-2.7.2.tar.gz"
sha256 "7f36f4ba2c0d81d219f4595e35f70d56cc94f9ac40a6acdf51d6ca210ce65035"
end
resource "pycparser" do
url "https://files.pythonhosted.org/packages/0f/86/e19659527668d70be91d0369aeaa055b4eb396b0f387a4f92293a20035bd/pycparser-2.20.tar.gz"
sha256 "2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"
end
resource "PyNaCl" do
url "https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz"
sha256 "54e9a2c849c742006516ad56a88f5c74bf2ce92c9f67435187c3c5953b346505"
end
resource "pyrsistent" do
url "https://files.pythonhosted.org/packages/4d/70/fd441df751ba8b620e03fd2d2d9ca902103119616f0f6cc42e6405035062/pyrsistent-0.17.3.tar.gz"
sha256 "2e636185d9eb976a18a8a8e96efce62f2905fea90041958d8cc2a189756ebf3e"
end
resource "python-dotenv" do
url "https://files.pythonhosted.org/packages/53/04/1a8126516c8febfeb2015844edee977c9b783bdff9b3bcd89b1cc2e1f372/python-dotenv-0.15.0.tar.gz"
sha256 "587825ed60b1711daea4832cf37524dfd404325b7db5e25ebe88c495c9f807a0"
end
resource "PyYAML" do
url "https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz"
sha256 "607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"
end
resource "requests" do
url "https://files.pythonhosted.org/packages/6b/47/c14abc08432ab22dc18b9892252efaf005ab44066de871e72a38d6af464b/requests-2.25.1.tar.gz"
sha256 "27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"
end
resource "six" do
url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
end
resource "texttable" do
url "https://files.pythonhosted.org/packages/f5/be/716342325d6d6e05608e3a10e15f192f3723e454a25ce14bc9b9d1332772/texttable-1.6.3.tar.gz"
sha256 "ce0faf21aa77d806bbff22b107cc22cce68dc9438f97a2df32c93e9afa4ce436"
end
resource "urllib3" do
url "https://files.pythonhosted.org/packages/d7/8d/7ee68c6b48e1ec8d41198f694ecdc15f7596356f2ff8e6b1420300cf5db3/urllib3-1.26.3.tar.gz"
sha256 "de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73"
end
resource "websocket_client" do
url "https://files.pythonhosted.org/packages/8b/0f/52de51b9b450ed52694208ab952d5af6ebbcbce7f166a48784095d930d8c/websocket_client-0.57.0.tar.gz"
sha256 "d735b91d6d1692a6a181f2a8c9e0238e5f6373356f561bb9dc4c7af36f452010"
end
def install
virtualenv_install_with_resources
bash_completion.install "contrib/completion/bash/docker-compose"
zsh_completion.install "contrib/completion/zsh/_docker-compose"
end
test do
system bin/"docker-compose", "--help"
end
end
docker-compose: update 1.28.5 bottle.
class DockerCompose < Formula
include Language::Python::Virtualenv
desc "Isolated development environments using Docker"
homepage "https://docs.docker.com/compose/"
url "https://files.pythonhosted.org/packages/92/29/303a71a1bf4522d6e36baa14d48f286d75da545777d8510b9f4085686ee3/docker-compose-1.28.5.tar.gz"
sha256 "b3ff8f0352eb4055c4c483cb498aeff7c90195fa679f3caf7098a2d6fa6030e5"
license "Apache-2.0"
head "https://github.com/docker/compose.git"
bottle do
sha256 cellar: :any, arm64_big_sur: "b2aa9493fda75a1044fee7c321394b4d884fe72e6658c7523712659a0549d583"
sha256 cellar: :any, big_sur: "da80757f384997366c44221500a223cd169bbe002fc2676727b43056eca26ca8"
sha256 cellar: :any, catalina: "ff772da8c719b4f7c0ad0aae4ddf625c6eee12a8bc5c56bf864dde3ee435752f"
sha256 cellar: :any, mojave: "dd017cc11c4ac1242835aed3dd7da723244fb86f10e1c88e3a2ee319c674ab97"
end
depends_on "rust" => :build
depends_on "libyaml"
depends_on "python@3.9"
uses_from_macos "libffi"
resource "attrs" do
url "https://files.pythonhosted.org/packages/f0/cb/80a4a274df7da7b8baf083249b0890a0579374c3d74b5ac0ee9291f912dc/attrs-20.3.0.tar.gz"
sha256 "832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700"
end
resource "bcrypt" do
url "https://files.pythonhosted.org/packages/d8/ba/21c475ead997ee21502d30f76fd93ad8d5858d19a3fad7cd153de698c4dd/bcrypt-3.2.0.tar.gz"
sha256 "5b93c1726e50a93a033c36e5ca7fdcd29a5c7395af50a6892f5d9e7c6cfbfb29"
end
resource "cached-property" do
url "https://files.pythonhosted.org/packages/61/2c/d21c1c23c2895c091fa7a91a54b6872098fea913526932d21902088a7c41/cached-property-1.5.2.tar.gz"
sha256 "9fa5755838eecbb2d234c3aa390bd80fbd3ac6b6869109bfc1b499f7bd89a130"
end
resource "certifi" do
url "https://files.pythonhosted.org/packages/06/a9/cd1fd8ee13f73a4d4f491ee219deeeae20afefa914dfb4c130cfc9dc397a/certifi-2020.12.5.tar.gz"
sha256 "1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"
end
resource "cffi" do
url "https://files.pythonhosted.org/packages/a8/20/025f59f929bbcaa579704f443a438135918484fffaacfaddba776b374563/cffi-1.14.5.tar.gz"
sha256 "fd78e5fee591709f32ef6edb9a015b4aa1a5022598e36227500c8f4e02328d9c"
end
resource "chardet" do
url "https://files.pythonhosted.org/packages/ee/2d/9cdc2b527e127b4c9db64b86647d567985940ac3698eeabc7ffaccb4ea61/chardet-4.0.0.tar.gz"
sha256 "0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"
end
resource "cryptography" do
url "https://files.pythonhosted.org/packages/fa/2d/2154d8cb773064570f48ec0b60258a4522490fcb115a6c7c9423482ca993/cryptography-3.4.6.tar.gz"
sha256 "2d32223e5b0ee02943f32b19245b61a62db83a882f0e76cc564e1cec60d48f87"
end
resource "distro" do
url "https://files.pythonhosted.org/packages/a6/a4/75064c334d8ae433445a20816b788700db1651f21bdb0af33db2aab142fe/distro-1.5.0.tar.gz"
sha256 "0e58756ae38fbd8fc3020d54badb8eae17c5b9dcbed388b17bb55b8a5928df92"
end
resource "docker" do
url "https://files.pythonhosted.org/packages/fd/46/6f6116c30cb859a0cdb95444140e9fe0be0de455c9c83748ee421aec8274/docker-4.4.4.tar.gz"
sha256 "d3393c878f575d3a9ca3b94471a3c89a6d960b35feb92f033c0de36cc9d934db"
end
resource "dockerpty" do
url "https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz"
sha256 "69a9d69d573a0daa31bcd1c0774eeed5c15c295fe719c61aca550ed1393156ce"
end
resource "docopt" do
url "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz"
sha256 "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491"
end
resource "idna" do
url "https://files.pythonhosted.org/packages/ea/b7/e0e3c1c467636186c39925827be42f16fee389dc404ac29e930e9136be70/idna-2.10.tar.gz"
sha256 "b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"
end
resource "jsonschema" do
url "https://files.pythonhosted.org/packages/69/11/a69e2a3c01b324a77d3a7c0570faa372e8448b666300c4117a516f8b1212/jsonschema-3.2.0.tar.gz"
sha256 "c8a85b28d377cc7737e46e2d9f2b4f44ee3c0e1deac6bf46ddefc7187d30797a"
end
resource "paramiko" do
url "https://files.pythonhosted.org/packages/cf/a1/20d00ce559a692911f11cadb7f94737aca3ede1c51de16e002c7d3a888e0/paramiko-2.7.2.tar.gz"
sha256 "7f36f4ba2c0d81d219f4595e35f70d56cc94f9ac40a6acdf51d6ca210ce65035"
end
resource "pycparser" do
url "https://files.pythonhosted.org/packages/0f/86/e19659527668d70be91d0369aeaa055b4eb396b0f387a4f92293a20035bd/pycparser-2.20.tar.gz"
sha256 "2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"
end
resource "PyNaCl" do
url "https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz"
sha256 "54e9a2c849c742006516ad56a88f5c74bf2ce92c9f67435187c3c5953b346505"
end
resource "pyrsistent" do
url "https://files.pythonhosted.org/packages/4d/70/fd441df751ba8b620e03fd2d2d9ca902103119616f0f6cc42e6405035062/pyrsistent-0.17.3.tar.gz"
sha256 "2e636185d9eb976a18a8a8e96efce62f2905fea90041958d8cc2a189756ebf3e"
end
resource "python-dotenv" do
url "https://files.pythonhosted.org/packages/53/04/1a8126516c8febfeb2015844edee977c9b783bdff9b3bcd89b1cc2e1f372/python-dotenv-0.15.0.tar.gz"
sha256 "587825ed60b1711daea4832cf37524dfd404325b7db5e25ebe88c495c9f807a0"
end
resource "PyYAML" do
url "https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz"
sha256 "607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"
end
resource "requests" do
url "https://files.pythonhosted.org/packages/6b/47/c14abc08432ab22dc18b9892252efaf005ab44066de871e72a38d6af464b/requests-2.25.1.tar.gz"
sha256 "27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"
end
resource "six" do
url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
end
resource "texttable" do
url "https://files.pythonhosted.org/packages/f5/be/716342325d6d6e05608e3a10e15f192f3723e454a25ce14bc9b9d1332772/texttable-1.6.3.tar.gz"
sha256 "ce0faf21aa77d806bbff22b107cc22cce68dc9438f97a2df32c93e9afa4ce436"
end
resource "urllib3" do
url "https://files.pythonhosted.org/packages/d7/8d/7ee68c6b48e1ec8d41198f694ecdc15f7596356f2ff8e6b1420300cf5db3/urllib3-1.26.3.tar.gz"
sha256 "de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73"
end
resource "websocket_client" do
url "https://files.pythonhosted.org/packages/8b/0f/52de51b9b450ed52694208ab952d5af6ebbcbce7f166a48784095d930d8c/websocket_client-0.57.0.tar.gz"
sha256 "d735b91d6d1692a6a181f2a8c9e0238e5f6373356f561bb9dc4c7af36f452010"
end
def install
virtualenv_install_with_resources
bash_completion.install "contrib/completion/bash/docker-compose"
zsh_completion.install "contrib/completion/zsh/_docker-compose"
end
test do
system bin/"docker-compose", "--help"
end
end
|
require File.expand_path("../../Abstract/abstract-php", __FILE__)
class Php55 < AbstractPhp
init
include AbstractPhpVersion::Php55Defs
include AbstractPhpVersion::PhpdbgDefs
url PHP_SRC_TARBALL
sha256 PHP_CHECKSUM[:sha256]
version PHP_VERSION
revision 3
head PHP_GITHUB_URL, :branch => PHP_BRANCH
bottle do
sha256 "567d2e706eb241f1c52def4adc1e34d5da982caaa238238de714a21af9a3d5e4" => :el_capitan
sha256 "23e91e4f37275300e25a9ab404d24c57a61ac11b7d62ab411d8f288adb587eb9" => :yosemite
sha256 "0decf8177cf97100b6c867f272668e02ec16b4f79e2ba6d001d078505737f079" => :mavericks
end
if build.with? "phpdbg"
# needed to regenerate the configure script
depends_on "autoconf" => :build
depends_on "re2c" => :build
depends_on "flex" => :build
resource "phpdbg" do
url PHPDBG_SRC_TARBAL
sha256 PHPDBG_CHECKSUM[:sha256]
end
end
def install_args
args = super
# dtrace is not compatible with phpdbg: https://github.com/krakjoe/phpdbg/issues/38
args << "--enable-dtrace" if build.without? "phpdbg"
args << "--enable-zend-signals"
end
def _install
if build.with? "phpdbg"
resource("phpdbg").stage buildpath/"sapi/phpdbg"
# force the configure file to be rebuilt (needed to support phpdbg)
File.delete("configure")
system "./buildconf", "--force"
end
super
end
def php_version
"5.5"
end
def php_version_path
"55"
end
end
Removed old bottles hashes
require File.expand_path("../../Abstract/abstract-php", __FILE__)
class Php55 < AbstractPhp
init
include AbstractPhpVersion::Php55Defs
include AbstractPhpVersion::PhpdbgDefs
url PHP_SRC_TARBALL
sha256 PHP_CHECKSUM[:sha256]
version PHP_VERSION
revision 3
head PHP_GITHUB_URL, :branch => PHP_BRANCH
bottle do
end
if build.with? "phpdbg"
# needed to regenerate the configure script
depends_on "autoconf" => :build
depends_on "re2c" => :build
depends_on "flex" => :build
resource "phpdbg" do
url PHPDBG_SRC_TARBAL
sha256 PHPDBG_CHECKSUM[:sha256]
end
end
def install_args
args = super
# dtrace is not compatible with phpdbg: https://github.com/krakjoe/phpdbg/issues/38
args << "--enable-dtrace" if build.without? "phpdbg"
args << "--enable-zend-signals"
end
def _install
if build.with? "phpdbg"
resource("phpdbg").stage buildpath/"sapi/phpdbg"
# force the configure file to be rebuilt (needed to support phpdbg)
File.delete("configure")
system "./buildconf", "--force"
end
super
end
def php_version
"5.5"
end
def php_version_path
"55"
end
end
|
class DockerMachine < Formula
desc "Create Docker hosts locally and on cloud providers"
homepage "https://docs.docker.com/machine"
url "https://github.com/docker/machine.git",
tag: "v0.16.2",
revision: "bd45ab13d88c32a3dd701485983354514abc41fa"
license "Apache-2.0"
head "https://github.com/docker/machine.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8ed6a73a1d30c911811e8f6fb0e61e41bc3be4aea62bc2b77f7b6dca50b517a9"
sha256 cellar: :any_skip_relocation, big_sur: "720ea8bbbfdc6b9d0701f02014e09f6a46e6785bcbdb36ebe3e95bddd0849dfa"
sha256 cellar: :any_skip_relocation, catalina: "e27501077ccc67fc468ca8e2881366a9fc23260296ed93a3f436b4d12f41ec43"
sha256 cellar: :any_skip_relocation, mojave: "0cfe7d344bd6c2b3bc0d1c1de472c430162a45dd54454b268e82750094b9cf9f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "f08e7ba29eb793a79b8126631485ee4100cf07b9e1e5654a7c4db8c2d229d5af"
end
deprecate! date: "2021-09-30", because: :repo_archived
depends_on "automake" => :build
depends_on "go" => :build
conflicts_with "docker-machine-completion", because: "docker-machine already includes completion scripts"
def install
ENV["GOPATH"] = buildpath
ENV["GO111MODULE"] = "auto"
(buildpath/"src/github.com/docker/machine").install buildpath.children
cd "src/github.com/docker/machine" do
system "make", "build"
bin.install Dir["bin/*"]
bash_completion.install Dir["contrib/completion/bash/*.bash"]
zsh_completion.install "contrib/completion/zsh/_docker-machine"
prefix.install_metafiles
end
end
plist_options manual: "docker-machine start"
service do
run [opt_bin/"docker-machine", "start", "default"]
environment_variables PATH: std_service_path_env
run_type :immediate
working_dir HOMEBREW_PREFIX
end
test do
assert_match version.to_s, shell_output(bin/"docker-machine --version")
end
end
docker-machine: update 0.16.2 bottle.
class DockerMachine < Formula
desc "Create Docker hosts locally and on cloud providers"
homepage "https://docs.docker.com/machine"
url "https://github.com/docker/machine.git",
tag: "v0.16.2",
revision: "bd45ab13d88c32a3dd701485983354514abc41fa"
license "Apache-2.0"
head "https://github.com/docker/machine.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "c941d688b50d6eae302320aa5e702d5da26e4e38ceac2f925a24b6efe6c589db"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "8ed6a73a1d30c911811e8f6fb0e61e41bc3be4aea62bc2b77f7b6dca50b517a9"
sha256 cellar: :any_skip_relocation, big_sur: "720ea8bbbfdc6b9d0701f02014e09f6a46e6785bcbdb36ebe3e95bddd0849dfa"
sha256 cellar: :any_skip_relocation, catalina: "e27501077ccc67fc468ca8e2881366a9fc23260296ed93a3f436b4d12f41ec43"
sha256 cellar: :any_skip_relocation, mojave: "0cfe7d344bd6c2b3bc0d1c1de472c430162a45dd54454b268e82750094b9cf9f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "f08e7ba29eb793a79b8126631485ee4100cf07b9e1e5654a7c4db8c2d229d5af"
end
deprecate! date: "2021-09-30", because: :repo_archived
depends_on "automake" => :build
depends_on "go" => :build
conflicts_with "docker-machine-completion", because: "docker-machine already includes completion scripts"
def install
ENV["GOPATH"] = buildpath
ENV["GO111MODULE"] = "auto"
(buildpath/"src/github.com/docker/machine").install buildpath.children
cd "src/github.com/docker/machine" do
system "make", "build"
bin.install Dir["bin/*"]
bash_completion.install Dir["contrib/completion/bash/*.bash"]
zsh_completion.install "contrib/completion/zsh/_docker-machine"
prefix.install_metafiles
end
end
plist_options manual: "docker-machine start"
service do
run [opt_bin/"docker-machine", "start", "default"]
environment_variables PATH: std_service_path_env
run_type :immediate
working_dir HOMEBREW_PREFIX
end
test do
assert_match version.to_s, shell_output(bin/"docker-machine --version")
end
end
|
class Picat < Formula
desc "Simple, and yet powerful, logic-based multi-paradigm programming language"
homepage "http://picat-lang.org"
url "http://picat-lang.org/download/picat24_src.tar.gz"
version "2.4.8"
sha256 "72b452a8ba94d6187d837dcdb46aab0d7dc724651bac99a8cf2ada5c0a3543dd"
depends_on "gcc" => :build
def install
inreplace "emu/Makefile.picat.mac64", "/usr/local/bin/gcc", HOMEBREW_PREFIX/"bin/gcc-8"
system "make", "-C", "emu", "-f", "Makefile.picat.mac64"
prefix.install Dir["doc", "emu", "exs", "lib"]
end
def post_install
ln_sf prefix/"emu/picat_macx", HOMEBREW_PREFIX/"bin/picat"
end
test do
system "picat", "#{prefix}/exs/euler/p1.pi"
end
end
Update according to homebrew dev
class Picat < Formula
desc "Simple, and yet powerful, logic-based multi-paradigm programming language"
homepage "http://picat-lang.org"
url "http://picat-lang.org/download/picat24_src.tar.gz"
version "2.4.8"
sha256 "72b452a8ba94d6187d837dcdb46aab0d7dc724651bac99a8cf2ada5c0a3543dd"
depends_on "gcc"
def install
inreplace "emu/Makefile.picat.mac64", "/usr/local/bin/gcc", HOMEBREW_PREFIX/"bin/gcc-8"
system "make", "-C", "emu", "-f", "Makefile.picat.mac64"
mv "lib", "pi_lib"
prefix.install Dir["doc", "emu", "exs", "pi_lib"]
bin.install_symlink prefix/"emu/picat_macx" => "picat"
end
test do
system "#{HOMEBREW_PREFIX}/bin/picat", "#{prefix}/exs/euler/p1.pi"
end
end |
class EfmLangserver < Formula
desc "General purpose Language Server"
homepage "https://github.com/mattn/efm-langserver"
url "https://github.com/mattn/efm-langserver.git",
tag: "v0.0.28",
revision: "b997190cf70bbd3fef78ca12ef296cbe14daaf7d"
license "MIT"
head "https://github.com/mattn/efm-langserver.git"
bottle do
rebuild 1
sha256 cellar: :any_skip_relocation, arm64_big_sur: "de91d8053b75c1268fb683b94cd74a873af5395595208788a51fdf2c885f9b5c"
sha256 cellar: :any_skip_relocation, big_sur: "d363409ef73963e427e1af1df473993c40fa1ee57fd471eb5e726b5ab9f31bc5"
sha256 cellar: :any_skip_relocation, catalina: "15cde7a009c074ded83f8293fdbeb0b21e61dc44776e3907b5c9ba924ff45ca3"
sha256 cellar: :any_skip_relocation, mojave: "3386a4a8e1cd2952e08454483f4611b16589e7829ac1ba0a76e1fe6e715cdc8f"
end
depends_on "go" => :build
def install
system "go", "build", *std_go_args
end
test do
(testpath/"config.yml").write <<~EOS
version: 2
root-markers:
- ".git/"
languages:
python:
- lint-command: "flake8 --stdin-display-name ${INPUT} -"
lint-stdin: true
EOS
output = shell_output("#{bin}/efm-langserver -c #{testpath/"config.yml"} -d")
assert_match "version: 2", output
assert_match "lint-command: flake8 --stdin-display-name ${INPUT} -", output
end
end
efm-langserver: update 0.0.28 bottle.
class EfmLangserver < Formula
desc "General purpose Language Server"
homepage "https://github.com/mattn/efm-langserver"
url "https://github.com/mattn/efm-langserver.git",
tag: "v0.0.28",
revision: "b997190cf70bbd3fef78ca12ef296cbe14daaf7d"
license "MIT"
head "https://github.com/mattn/efm-langserver.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "499446c25b2badc8ac38d574b973462f127a22dd2572ff4dc40b3368df3663c8"
sha256 cellar: :any_skip_relocation, big_sur: "f6ce3f7dac6fd7a9758df174c34a938557e7b553eff9724ab3d6990d8dd0823c"
sha256 cellar: :any_skip_relocation, catalina: "6dff49d3273db600f9e5b0fe3ab3d5ba9d1d8014e019733c4709fdf739179f57"
sha256 cellar: :any_skip_relocation, mojave: "d71f9e059ef6b77f746dc0bed334365b663e7f46072d9c39ad41b0c4dd1c51e1"
end
depends_on "go" => :build
def install
system "go", "build", *std_go_args
end
test do
(testpath/"config.yml").write <<~EOS
version: 2
root-markers:
- ".git/"
languages:
python:
- lint-command: "flake8 --stdin-display-name ${INPUT} -"
lint-stdin: true
EOS
output = shell_output("#{bin}/efm-langserver -c #{testpath/"config.yml"} -d")
assert_match "version: 2", output
assert_match "lint-command: flake8 --stdin-display-name ${INPUT} -", output
end
end
|
class Procs < Formula
desc "Modern replacement for ps written by Rust"
homepage "https://github.com/dalance/procs"
url "https://github.com/dalance/procs/archive/v0.12.2.tar.gz"
sha256 "14be8440fe85dc46e544a3f7e89b887db455a61db981d5f75b91fd89b366d84f"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "f5b63bdde580ec32e5cd98ed7c834694cee7e02e15d90975e3d8c975c442b803"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "919ce7c7c4ea83d07829926e12e1dcf3274b31a2fe5e13b839945a7ffde7ee19"
sha256 cellar: :any_skip_relocation, monterey: "b4ff9817d939b163b445a6c44952bb1c13c434f050e211751e57a43d680e7a75"
sha256 cellar: :any_skip_relocation, big_sur: "00c44bcd69bc8fec500febf137d20700f9abef4a33d2414b606749eed0e85c04"
sha256 cellar: :any_skip_relocation, catalina: "af3f308dbfc8fb4db0d2993a4356a8f3ea1ac892c00343ce9d7475929a6e9bdd"
sha256 cellar: :any_skip_relocation, x86_64_linux: "afa0715a5f180622ac783fcbbbd4372f9d3b40abe7a714254f02a89567fc6d75"
end
depends_on "rust" => :build
def install
system "cargo", "install", *std_cargo_args
system bin/"procs", "--completion", "bash"
system bin/"procs", "--completion", "fish"
system bin/"procs", "--completion", "zsh"
bash_completion.install "procs.bash" => "procs"
fish_completion.install "procs.fish"
zsh_completion.install "_procs"
end
test do
output = shell_output(bin/"procs")
count = output.lines.count
assert count > 2
assert output.start_with?(" PID:")
end
end
procs 0.12.3
Closes #102232.
Signed-off-by: Michael Cho <ad37dc0e034c3938811c0096de6272abd124db31@users.noreply.github.com>
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
class Procs < Formula
desc "Modern replacement for ps written by Rust"
homepage "https://github.com/dalance/procs"
url "https://github.com/dalance/procs/archive/v0.12.3.tar.gz"
sha256 "59720db4abdff1878492929b1c015dedff7cdc0ea2352b1360084e3bb4fbff33"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "f5b63bdde580ec32e5cd98ed7c834694cee7e02e15d90975e3d8c975c442b803"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "919ce7c7c4ea83d07829926e12e1dcf3274b31a2fe5e13b839945a7ffde7ee19"
sha256 cellar: :any_skip_relocation, monterey: "b4ff9817d939b163b445a6c44952bb1c13c434f050e211751e57a43d680e7a75"
sha256 cellar: :any_skip_relocation, big_sur: "00c44bcd69bc8fec500febf137d20700f9abef4a33d2414b606749eed0e85c04"
sha256 cellar: :any_skip_relocation, catalina: "af3f308dbfc8fb4db0d2993a4356a8f3ea1ac892c00343ce9d7475929a6e9bdd"
sha256 cellar: :any_skip_relocation, x86_64_linux: "afa0715a5f180622ac783fcbbbd4372f9d3b40abe7a714254f02a89567fc6d75"
end
depends_on "rust" => :build
def install
system "cargo", "install", *std_cargo_args
system bin/"procs", "--completion", "bash"
system bin/"procs", "--completion", "fish"
system bin/"procs", "--completion", "zsh"
bash_completion.install "procs.bash" => "procs"
fish_completion.install "procs.fish"
zsh_completion.install "_procs"
end
test do
output = shell_output(bin/"procs")
count = output.lines.count
assert count > 2
assert output.start_with?(" PID:")
end
end
|
require 'formula'
class Graphicsmagick < Formula
homepage 'http://www.graphicsmagick.org/'
url 'https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.21/GraphicsMagick-1.3.21.tar.bz2'
sha256 'a0ce08f2710c158e39faa083463441f6eeeecce07dbd59510498ffa4e0b053d1'
head 'http://graphicsmagick.hg.sourceforge.net:8000/hgroot/graphicsmagick/graphicsmagick', :using => :hg
bottle do
sha1 "3e681ecf2e126ee5322a6c05e4228670de8b7f8e" => :mavericks
sha1 "6dbabb0a513590f9e000bdf6a9fc4cf15cc829ec" => :mountain_lion
sha1 "dbdef094a39a8052eb7b04bae77724b5c7c524e9" => :lion
end
option 'with-quantum-depth-8', 'Compile with a quantum depth of 8 bit'
option 'with-quantum-depth-16', 'Compile with a quantum depth of 16 bit'
option 'with-quantum-depth-32', 'Compile with a quantum depth of 32 bit'
option 'without-magick-plus-plus', 'disable build/install of Magick++'
option 'without-svg', 'Compile without svg support'
option 'with-perl', 'Build PerlMagick; provides the Graphics::Magick module'
depends_on "libtool" => :run
depends_on 'pkg-config' => :build
depends_on 'jpeg' => :recommended
depends_on 'libpng' => :recommended
depends_on 'freetype' => :recommended
depends_on :x11 => :optional
depends_on 'libtiff' => :optional
depends_on 'little-cms' => :optional
depends_on 'little-cms2' => :optional
depends_on 'jasper' => :optional
depends_on 'libwmf' => :optional
depends_on 'ghostscript' => :optional
fails_with :llvm do
build 2335
end
skip_clean :la
def ghostscript_fonts?
File.directory? "#{HOMEBREW_PREFIX}/share/ghostscript/fonts"
end
def install
args = [ "--prefix=#{prefix}",
"--disable-dependency-tracking",
"--enable-shared",
"--disable-static",
"--with-modules",
"--disable-openmp"]
args << "--without-gslib" if build.without? 'ghostscript'
args << "--with-gs-font-dir=#{HOMEBREW_PREFIX}/share/ghostscript/fonts" if build.without? 'ghostscript'
args << "--without-magick-plus-plus" if build.without? 'magick-plus-plus'
args << "--with-perl" if build.with? "perl"
if build.with? 'quantum-depth-32'
quantum_depth = 32
elsif build.with? 'quantum-depth-16'
quantum_depth = 16
elsif build.with? 'quantum-depth-8'
quantum_depth = 8
end
args << "--with-quantum-depth=#{quantum_depth}" if quantum_depth
args << "--without-x" if build.without? 'x11'
args << "--without-ttf" if build.without? 'freetype'
args << "--without-xml" if build.without? 'svg'
args << "--without-lcms" if build.without? 'little-cms'
args << "--without-lcms2" if build.without? 'little-cms2'
# versioned stuff in main tree is pointless for us
inreplace 'configure', '${PACKAGE_NAME}-${PACKAGE_VERSION}', '${PACKAGE_NAME}'
system "./configure", *args
system "make", "install"
if build.with? "perl"
cd 'PerlMagick' do
# Install the module under the GraphicsMagick prefix
system "perl", "Makefile.PL", "INSTALL_BASE=#{prefix}"
system "make"
system "make", "install"
end
end
end
test do
system "#{bin}/gm", "identify", test_fixtures("test.png")
end
def caveats
if build.with? "perl"
<<-EOS.undent
The Graphics::Magick perl module has been installed under:
#{lib}
EOS
end
end
end
graphicsmagick: update 1.3.21 bottle.
require 'formula'
class Graphicsmagick < Formula
homepage 'http://www.graphicsmagick.org/'
url 'https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.21/GraphicsMagick-1.3.21.tar.bz2'
sha256 'a0ce08f2710c158e39faa083463441f6eeeecce07dbd59510498ffa4e0b053d1'
head 'http://graphicsmagick.hg.sourceforge.net:8000/hgroot/graphicsmagick/graphicsmagick', :using => :hg
bottle do
sha1 "73175a47211a0e05b55b15cfbcefcb1fc34b93ca" => :yosemite
sha1 "d20dd246c9ae4f9bed6cd11a9de877490e5113ce" => :mavericks
sha1 "b9265254c6c11f0ff0e44960d514ef7087a89eeb" => :mountain_lion
end
option 'with-quantum-depth-8', 'Compile with a quantum depth of 8 bit'
option 'with-quantum-depth-16', 'Compile with a quantum depth of 16 bit'
option 'with-quantum-depth-32', 'Compile with a quantum depth of 32 bit'
option 'without-magick-plus-plus', 'disable build/install of Magick++'
option 'without-svg', 'Compile without svg support'
option 'with-perl', 'Build PerlMagick; provides the Graphics::Magick module'
depends_on "libtool" => :run
depends_on 'pkg-config' => :build
depends_on 'jpeg' => :recommended
depends_on 'libpng' => :recommended
depends_on 'freetype' => :recommended
depends_on :x11 => :optional
depends_on 'libtiff' => :optional
depends_on 'little-cms' => :optional
depends_on 'little-cms2' => :optional
depends_on 'jasper' => :optional
depends_on 'libwmf' => :optional
depends_on 'ghostscript' => :optional
fails_with :llvm do
build 2335
end
skip_clean :la
def ghostscript_fonts?
File.directory? "#{HOMEBREW_PREFIX}/share/ghostscript/fonts"
end
def install
args = [ "--prefix=#{prefix}",
"--disable-dependency-tracking",
"--enable-shared",
"--disable-static",
"--with-modules",
"--disable-openmp"]
args << "--without-gslib" if build.without? 'ghostscript'
args << "--with-gs-font-dir=#{HOMEBREW_PREFIX}/share/ghostscript/fonts" if build.without? 'ghostscript'
args << "--without-magick-plus-plus" if build.without? 'magick-plus-plus'
args << "--with-perl" if build.with? "perl"
if build.with? 'quantum-depth-32'
quantum_depth = 32
elsif build.with? 'quantum-depth-16'
quantum_depth = 16
elsif build.with? 'quantum-depth-8'
quantum_depth = 8
end
args << "--with-quantum-depth=#{quantum_depth}" if quantum_depth
args << "--without-x" if build.without? 'x11'
args << "--without-ttf" if build.without? 'freetype'
args << "--without-xml" if build.without? 'svg'
args << "--without-lcms" if build.without? 'little-cms'
args << "--without-lcms2" if build.without? 'little-cms2'
# versioned stuff in main tree is pointless for us
inreplace 'configure', '${PACKAGE_NAME}-${PACKAGE_VERSION}', '${PACKAGE_NAME}'
system "./configure", *args
system "make", "install"
if build.with? "perl"
cd 'PerlMagick' do
# Install the module under the GraphicsMagick prefix
system "perl", "Makefile.PL", "INSTALL_BASE=#{prefix}"
system "make"
system "make", "install"
end
end
end
test do
system "#{bin}/gm", "identify", test_fixtures("test.png")
end
def caveats
if build.with? "perl"
<<-EOS.undent
The Graphics::Magick perl module has been installed under:
#{lib}
EOS
end
end
end
|
require 'formula'
class Putty < Formula
url 'http://the.earth.li/~sgtatham/putty/latest/putty-0.60.tar.gz'
homepage 'http://www.chiark.greenend.org.uk/~sgtatham/putty/'
md5 '07e65fd98b16d115ae38a180bfb242e2'
def install
# use the unix build to make all PuTTY command line tools
cd "unix"
# disable GTK upon configure
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--disable-gtktest", "--with-gtk-prefix=/dev/null"
system "make VER=-DRELEASE=#{version} all-cli"
# install manually
bin.install %w{ plink pscp psftp puttygen }
cd "../doc"
man1.install %w{ plink.1 pscp.1 psftp.1 puttygen.1 }
end
def caveats
"This formula did not build the Mac OS X GUI PuTTY.app."
end
end
putty 0.61
Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com>
require 'formula'
class Putty < Formula
url 'http://the.earth.li/~sgtatham/putty/0.61/putty-0.61.tar.gz'
homepage 'http://www.chiark.greenend.org.uk/~sgtatham/putty/'
md5 'db0e37f6b82ea62f0ace87927d29b2a4'
def install
# use the unix build to make all PuTTY command line tools
cd "unix"
# disable GTK upon configure
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--disable-gtktest", "--with-gtk-prefix=/dev/null"
system "make VER=-DRELEASE=#{version} all-cli"
# install manually
bin.install %w{ plink pscp psftp puttygen }
cd "../doc"
man1.install %w{ plink.1 pscp.1 psftp.1 puttygen.1 }
end
def caveats
"This formula did not build the Mac OS X GUI PuTTY.app."
end
end
|
class Graphicsmagick < Formula
desc "Image processing tools collection"
homepage "http://www.graphicsmagick.org/"
url "https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.28/GraphicsMagick-1.3.28.tar.xz"
sha256 "942a68a9a8a5af6f682b896fd4f0ad617d8b49907e474acfe59549956bcc994a"
revision 1
head "http://hg.code.sf.net/p/graphicsmagick/code", :using => :hg
bottle do
sha256 "999255f3842b6184ec9fd9f8398611074b6642c25d0a3a707244f9c4f4c9e2c6" => :high_sierra
sha256 "f170545068ad94562775d481b21988c5b3692b5c4a252e7f2f7cc07ab8537a11" => :sierra
sha256 "9baa3988debf4eb1234fbb49e5bfc542bfd9db3dc6e8d155eec2b45705ac41e4" => :el_capitan
end
option "without-magick-plus-plus", "disable build/install of Magick++"
option "without-svg", "Compile without svg support"
option "with-perl", "Build PerlMagick; provides the Graphics::Magick module"
depends_on "pkg-config" => :build
depends_on "libtool" => :run
depends_on "jpeg" => :recommended
depends_on "libpng" => :recommended
depends_on "libtiff" => :recommended
depends_on "freetype" => :recommended
depends_on "jasper" => :recommended
depends_on "little-cms2" => :optional
depends_on "libwmf" => :optional
depends_on "ghostscript" => :optional
depends_on "webp" => :optional
depends_on :x11 => :optional
skip_clean :la
def install
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--enable-shared
--disable-static
--with-modules
--without-lzma
--disable-openmp
--with-quantum-depth=16
]
args << "--without-gslib" if build.without? "ghostscript"
args << "--with-gs-font-dir=#{HOMEBREW_PREFIX}/share/ghostscript/fonts" if build.without? "ghostscript"
args << "--without-magick-plus-plus" if build.without? "magick-plus-plus"
args << "--with-perl" if build.with? "perl"
args << "--with-webp=no" if build.without? "webp"
args << "--without-x" if build.without? "x11"
args << "--without-ttf" if build.without? "freetype"
args << "--without-xml" if build.without? "svg"
args << "--without-lcms2" if build.without? "little-cms2"
args << "--without-wmf" if build.without? "libwmf"
# versioned stuff in main tree is pointless for us
inreplace "configure", "${PACKAGE_NAME}-${PACKAGE_VERSION}", "${PACKAGE_NAME}"
system "./configure", *args
system "make", "install"
if build.with? "perl"
cd "PerlMagick" do
# Install the module under the GraphicsMagick prefix
system "perl", "Makefile.PL", "INSTALL_BASE=#{prefix}"
system "make"
system "make", "install"
end
end
end
def caveats
if build.with? "perl"
<<~EOS
The Graphics::Magick perl module has been installed under:
#{lib}
EOS
end
end
test do
fixture = test_fixtures("test.png")
assert_match "PNG 8x8+0+0", shell_output("#{bin}/gm identify #{fixture}")
end
end
graphicsmagick: update 1.3.28_1 bottle.
class Graphicsmagick < Formula
desc "Image processing tools collection"
homepage "http://www.graphicsmagick.org/"
url "https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.28/GraphicsMagick-1.3.28.tar.xz"
sha256 "942a68a9a8a5af6f682b896fd4f0ad617d8b49907e474acfe59549956bcc994a"
revision 1
head "http://hg.code.sf.net/p/graphicsmagick/code", :using => :hg
bottle do
sha256 "ff12a82870629fe3f6e425aa1500ae4da142809745b5b755a42498504f73f1ee" => :high_sierra
sha256 "92457b10f78aa756b3e560bc8be9fbc0fe0706c6d6913d3f30a645ff13ac3eff" => :sierra
sha256 "2658af1f23bc3d7a7d9aefa3c15cdf47303a556da88070221ca5796bd7225bc3" => :el_capitan
end
option "without-magick-plus-plus", "disable build/install of Magick++"
option "without-svg", "Compile without svg support"
option "with-perl", "Build PerlMagick; provides the Graphics::Magick module"
depends_on "pkg-config" => :build
depends_on "libtool" => :run
depends_on "jpeg" => :recommended
depends_on "libpng" => :recommended
depends_on "libtiff" => :recommended
depends_on "freetype" => :recommended
depends_on "jasper" => :recommended
depends_on "little-cms2" => :optional
depends_on "libwmf" => :optional
depends_on "ghostscript" => :optional
depends_on "webp" => :optional
depends_on :x11 => :optional
skip_clean :la
def install
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--enable-shared
--disable-static
--with-modules
--without-lzma
--disable-openmp
--with-quantum-depth=16
]
args << "--without-gslib" if build.without? "ghostscript"
args << "--with-gs-font-dir=#{HOMEBREW_PREFIX}/share/ghostscript/fonts" if build.without? "ghostscript"
args << "--without-magick-plus-plus" if build.without? "magick-plus-plus"
args << "--with-perl" if build.with? "perl"
args << "--with-webp=no" if build.without? "webp"
args << "--without-x" if build.without? "x11"
args << "--without-ttf" if build.without? "freetype"
args << "--without-xml" if build.without? "svg"
args << "--without-lcms2" if build.without? "little-cms2"
args << "--without-wmf" if build.without? "libwmf"
# versioned stuff in main tree is pointless for us
inreplace "configure", "${PACKAGE_NAME}-${PACKAGE_VERSION}", "${PACKAGE_NAME}"
system "./configure", *args
system "make", "install"
if build.with? "perl"
cd "PerlMagick" do
# Install the module under the GraphicsMagick prefix
system "perl", "Makefile.PL", "INSTALL_BASE=#{prefix}"
system "make"
system "make", "install"
end
end
end
def caveats
if build.with? "perl"
<<~EOS
The Graphics::Magick perl module has been installed under:
#{lib}
EOS
end
end
test do
fixture = test_fixtures("test.png")
assert_match "PNG 8x8+0+0", shell_output("#{bin}/gm identify #{fixture}")
end
end
|
require 'formula'
class Pwgen < Formula
url 'http://downloads.sourceforge.net/project/pwgen/pwgen/2.06/pwgen-2.06.tar.gz'
homepage 'http://pwgen.sourceforge.net/'
sha1 '43dc4fbe6c3bdf96ae24b20d44c4a4584df93d8e'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}", "--mandir=#{man}"
system "make install"
end
end
pwgen: style nits
require 'formula'
class Pwgen < Formula
homepage 'http://pwgen.sourceforge.net/'
url 'http://downloads.sourceforge.net/project/pwgen/pwgen/2.06/pwgen-2.06.tar.gz'
sha1 '43dc4fbe6c3bdf96ae24b20d44c4a4584df93d8e'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--mandir=#{man}"
system "make install"
end
end
|
require 'spec_helper'
module RubyEventStore
RSpec.describe Specification do
specify { expect(specification.each).to be_kind_of(Enumerator) }
specify { expect(specification.result.forward?).to eq(true) }
specify { expect(specification.result.backward?).to eq(false) }
specify { expect(specification.forward.result.forward?).to eq(true) }
specify { expect(specification.forward.result.backward?).to eq(false) }
specify { expect(specification.backward.result.forward?).to eq(false) }
specify { expect(specification.backward.result.backward?).to eq(true) }
specify { expect(specification.result.limit?).to eq(false) }
specify { expect(specification.result.limit).to eq(Float::INFINITY) }
specify { expect(specification.result.all?).to eq(true) }
specify { expect(specification.result.batched?).to eq(false) }
specify { expect(specification.result.first?).to eq(false) }
specify { expect(specification.result.last?).to eq(false) }
specify { expect{specification.limit(nil) }.to raise_error(InvalidPageSize) }
specify { expect{specification.limit(0)}.to raise_error(InvalidPageSize) }
specify { expect(specification.limit(1).result.limit).to eq(1) }
specify { expect(specification.result.limit?).to eq(false) }
specify { expect(specification.limit(100).result.limit?).to eq(true) }
specify { expect(specification.result.stream.name).to eq(GLOBAL_STREAM) }
specify { expect(specification.result.stream.global?).to eq(true) }
specify { expect{specification.stream(nil)}.to raise_error(IncorrectStreamData) }
specify { expect{specification.stream('')}.to raise_error(IncorrectStreamData) }
specify { expect(specification.stream('stream').result.stream.name).to eq('stream') }
specify { expect(specification.stream('nope').result.stream.global?).to eq(false) }
specify { expect(specification.stream('all').result.stream.name).to eq('all') }
specify { expect(specification.stream('all').result.stream.global?).to eq(false) }
specify { expect(specification.stream(GLOBAL_STREAM).result.stream.name).to eq( GLOBAL_STREAM) }
specify { expect(specification.stream(GLOBAL_STREAM).result.stream.global?).to eq(true) }
specify { expect(specification.result.head?).to eq(true) }
specify { expect(specification.from(:head).result.start).to eq(:head) }
specify { expect{specification.from(nil)}.to raise_error(InvalidPageStart) }
specify { expect{specification.from('')}.to raise_error(InvalidPageStart) }
specify { expect{specification.from(:dummy)}.to raise_error(InvalidPageStart) }
specify { expect{specification.from(none_such_id) }.to raise_error(EventNotFound, /#{none_such_id}/) }
specify { expect(specification.from(:head).result.head?).to eq(true) }
specify { expect{specification.to(nil)}.to raise_error(InvalidPageStop) }
specify { expect{specification.to('')}.to raise_error(InvalidPageStop) }
specify { expect{specification.to(:dummy) }.to raise_error(EventNotFound, /dummy/) }
specify { expect{specification.to(none_such_id) }.to raise_error(EventNotFound, /#{none_such_id}/) }
specify { expect(specification.result.with_ids).to be_nil }
specify { expect(specification.with_id([event_id]).result.with_ids).to eq([event_id]) }
specify { expect(specification.result.with_ids?).to eq(false) }
specify { expect(specification.with_id([event_id]).result.with_ids?).to eq(true) }
specify { expect(specification.with_id([]).result.with_ids?).to eq(true) }
specify { expect(specification.result.with_types).to be_nil }
specify { expect(specification.of_type([TestEvent]).result.with_types).to eq(['TestEvent']) }
specify { expect(specification.result.with_types?).to eq(false) }
specify { expect(specification.of_type([TestEvent]).result.with_types?).to eq(true) }
specify do
with_event_of_id(event_id) do
expect(specification.from(event_id).result.start).to eq(event_id)
expect(specification.from(event_id).result.head?).to eq(false)
expect(specification.from(:head).from(event_id).result.start).to eq(event_id)
end
end
specify do
with_event_of_id(event_id) do
expect(specification.to(event_id).result.stop).to eq(event_id)
end
end
specify do
with_event_of_id(event_id) do
spec = specification.backward.stream(stream_name).limit(10).from(event_id)
expect(spec.result.stream.name).to eq(stream_name)
expect(spec.result.stream.global?).to eq(false)
expect(spec.result.limit).to eq(10)
expect(spec.result.start).to eq(event_id)
expect(spec.result.backward?).to eq(true)
end
end
specify do
with_event_of_id(event_id) do
spec = specification.backward.stream(stream_name).limit(10).to(event_id)
expect(spec.result.stream.name).to eq(stream_name)
expect(spec.result.stream.global?).to eq(false)
expect(spec.result.limit).to eq(10)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(event_id)
expect(spec.result.backward?).to eq(true)
end
end
specify do
with_event_of_id(event_id) do
specs = [
specification.forward,
specification.backward,
specification.in_batches,
specification.read_first,
specification.read_last,
specification.limit(10),
specification.from(event_id),
specification.to(event_id),
specification.stream(stream_name),
specification.with_id([event_id]),
specification.of_type([TestEvent]),
]
expect(specs.map{|s| s.send(:reader)}.uniq).to eq([reader])
end
end
specify { expect(specification.in_batches(3).from(:head).result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).in_batches.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE) }
specify { expect(specification.in_batches(3).forward.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).backward.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).read_first.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).read_last.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).limit(1).result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).stream('dummy').result.batch_size).to eq(3) }
specify do
with_event_of_id(event_id) do
expect(specification.from(event_id).stream('dummy').result.start).to eq(event_id)
expect(specification.from(event_id).limit(1).result.start).to eq(event_id)
expect(specification.from(event_id).read_first.result.start).to eq(event_id)
expect(specification.from(event_id).read_last.result.start).to eq(event_id)
expect(specification.from(event_id).forward.result.start).to eq(event_id)
expect(specification.from(event_id).backward.result.start).to eq(event_id)
expect(specification.read_first.from(event_id).result.first?).to eq(true)
end
end
specify do
with_event_of_id(event_id) do
expect(specification.to(event_id).stream('dummy').result.stop).to eq(event_id)
expect(specification.to(event_id).limit(1).result.stop).to eq(event_id)
expect(specification.to(event_id).read_first.result.stop).to eq(event_id)
expect(specification.to(event_id).read_last.result.stop).to eq(event_id)
expect(specification.to(event_id).forward.result.stop).to eq(event_id)
expect(specification.to(event_id).backward.result.stop).to eq(event_id)
expect(specification.to(event_id).from(:head).result.stop).to eq(event_id)
expect(specification.read_last.to(event_id).result.last?).to eq(true)
end
end
specify { expect(specification.limit(3).stream('dummy').result.limit).to eq(3) }
specify { expect(specification.limit(3).read_first.result.limit).to eq(3) }
specify { expect(specification.limit(3).read_last.result.limit).to eq(3) }
specify { expect(specification.limit(3).forward.result.limit).to eq(3) }
specify { expect(specification.limit(3).backward.result.limit).to eq(3) }
specify { expect(specification.limit(3).in_batches.result.limit).to eq(3) }
specify { expect(specification.read_first.stream('dummy').result.first?).to eq(true) }
specify { expect(specification.stream('dummy').forward.result.stream.name).to eq('dummy') }
specify { expect(specification.stream('dummy').forward.result.stream.global?).to eq(false) }
specify { expect(specification.stream('dummy').backward.result.stream.name).to eq('dummy') }
specify { expect(specification.stream('dummy').backward.result.stream.global?).to eq(false) }
specify { expect(specification.stream('dummy').in_batches.result.stream.name).to eq('dummy') }
specify { expect(specification.stream('dummy').in_batches.result.stream.global?).to eq(false) }
specify { expect(specification.read_first.limit(1).result.first?).to eq(true) }
specify { expect(specification.read_first.forward.result.first?).to eq(true) }
specify { expect(specification.read_first.backward.result.first?).to eq(true) }
specify { expect(specification.backward.in_batches.result.backward?).to eq(true) }
specify 'immutable specification' do
with_event_of_id(event_id) do
spec = backward_specifcation = specification.backward
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.backward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.from(event_id)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(event_id)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.to(event_id)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(event_id)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.limit(10)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit).to eq(10)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.stream(stream_name)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(stream_name)
expect(spec.result.stream.global?).to eq(false)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.in_batches
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.batched?).to eq(true)
expect(spec.result.batch_size).to eq(100)
spec = specification
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = backward_specifcation.forward
expect(spec.result.object_id).not_to eq(backward_specifcation.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = backward_specifcation
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.backward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.read_first
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.first?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.read_last
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.last?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.with_id([event_id])
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
expect(spec.result.with_ids).to eq([event_id])
spec = specification.of_type([TestEvent])
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
expect(spec.result.with_types).to eq(['TestEvent'])
spec = specification
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
end
end
specify do
with_event_of_id(event_id) do
expect(specification.to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.stream(stream_name).to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.limit(1).to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.backward.to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.forward.to_a).to eq([test_event])
end
end
specify do
records = [test_record, test_record]
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.from(records[0].event_id).to_a).to eq([TestEvent.new(event_id: records[1].event_id)])
end
specify do
records = [test_record, test_record]
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.to(records[1].event_id).to_a.last.event_id).to eq(records[0].event_id)
end
specify do
batch_size = 100
records = (batch_size * 10).times.map { test_record }
repository.append_to_stream(records, Stream.new("batch"), ExpectedVersion.none)
expect(specification.stream("batch").in_batches.each_batch.to_a.size).to eq(10)
end
specify do
batch_size = 100
records = (batch_size * 10).times.map { test_record }
repository.append_to_stream(records, Stream.new("batch"), ExpectedVersion.none)
expect(specification.stream("batch").in_batches.to_a.size).to eq(1000)
end
specify do
with_event_of_id(event_id) do
expect(specification.in_batches.each_batch.to_a).to eq([[test_event]])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.in_batches.to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect { |b| specification.in_batches.each_batch(&b) }.to yield_successive_args([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect { |b| specification.in_batches.each(&b) }.to yield_successive_args(test_event)
end
end
specify do
with_event_of_id(event_id) do
expect { |b| specification.each(&b) }.to yield_successive_args(test_event)
end
end
specify do
expect(specification.in_batches_of.result).to eq(specification.in_batches.result)
expect(specification.in_batches_of(1000).result).to eq(specification.in_batches(1000).result)
end
specify do
records = 200.times.map { test_record }
repository.append_to_stream(records, Stream.new("whatever"), ExpectedVersion.none)
expect(specification.each_batch.to_a).to eq(specification.in_batches.each_batch.to_a)
expect(specification.each_batch.to_a).not_to eq(specification.in_batches(1000).each_batch.to_a)
end
specify do
expect(specification.first).to be_nil
expect(specification.last).to be_nil
records = 5.times.map { test_record }
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.stream("Another").first).to be_nil
expect(specification.stream("Another").last).to be_nil
expect(specification.first).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.last).to eq(TestEvent.new(event_id: records[4].event_id))
expect(specification.from(records[2].event_id).first).to eq(TestEvent.new(event_id: records[3].event_id))
expect(specification.from(records[2].event_id).last).to eq(TestEvent.new(event_id: records[4].event_id))
expect(specification.from(records[2].event_id).backward.first).to eq(TestEvent.new(event_id: records[1].event_id))
expect(specification.from(records[2].event_id).backward.last).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.from(records[4].event_id).first).to be_nil
expect(specification.from(records[4].event_id).last).to be_nil
expect(specification.from(records[0].event_id).backward.first).to be_nil
expect(specification.from(records[0].event_id).backward.last).to be_nil
end
specify do
expect(specification.event(event_id)).to be_nil
expect{specification.event!(event_id)}.to raise_error(EventNotFound, "Event not found: #{event_id}")
records = 5.times.map { test_record }
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.event(records[0].event_id)).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.event(records[3].event_id)).to eq(TestEvent.new(event_id: records[3].event_id))
expect(specification.event!(records[0].event_id)).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.event!(records[3].event_id)).to eq(TestEvent.new(event_id: records[3].event_id))
expect(specification.events([])).to be_kind_of(Enumerator)
expect(specification.events([0,2,4].map{|i| records[i].event_id})).to be_kind_of(Enumerator)
expect(specification.events([0,2,4].map{|i| records[i].event_id}).to_a).to eq(
[0,2,4].map{|i| TestEvent.new(event_id: records[i].event_id)})
expect(specification.events([records[0].event_id, SecureRandom.uuid]).to_a).to eq(
[TestEvent.new(event_id: records[0].event_id)])
end
specify do
repository.append_to_stream([test_record], Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.result.batched?).to eq(false)
expect(specification.result.first?).to eq(false)
expect(specification.result.last?).to eq(false)
expect(specification.read_first.result.batched?).to eq(false)
expect(specification.read_first.result.first?).to eq(true)
expect(specification.read_first.result.last?).to eq(false)
expect(specification.read_last.result.batched?).to eq(false)
expect(specification.read_last.result.first?).to eq(false)
expect(specification.read_last.result.last?).to eq(true)
expect(specification.in_batches.result.batched?).to eq(true)
expect(specification.in_batches.result.first?).to eq(false)
expect(specification.in_batches.result.last?).to eq(false)
end
specify{ expect(specification.result.frozen?).to eq(true) }
specify{ expect(specification.backward.result.frozen?).to eq(true) }
specify "#hash" do
expect(specification.result.hash).to eq(specification.forward.result.hash)
expect(specification.forward.result.hash).not_to eq(specification.backward.result.hash)
expect(specification.read_first.result.hash).to eq(specification.read_first.result.hash)
expect(specification.read_last.result.hash).to eq(specification.read_last.result.hash)
expect(specification.read_first.result.hash).not_to eq(specification.read_last.result.hash)
expect(specification.result.hash).not_to eq(specification.limit(10).result.hash)
expect(specification.in_batches.result.hash).to eq(specification.in_batches(Specification::DEFAULT_BATCH_SIZE).result.hash)
expect(specification.in_batches.result.hash).not_to eq(specification.in_batches(10).result.hash)
expect(specification.result.hash).to eq(specification.stream(GLOBAL_STREAM).result.hash)
expect(specification.result.hash).not_to eq(specification.stream('dummy').result.hash)
expect(specification.with_id(event_id).result.hash).to eq(specification.with_id(event_id).result.hash)
expect(specification.with_id(event_id).result.hash).not_to eq(specification.with_id(SecureRandom.uuid).result.hash)
expect(specification.of_type([TestEvent]).result.hash).to eq(specification.of_type([TestEvent]).result.hash)
expect(specification.of_type([TestEvent]).result.hash).not_to eq(specification.of_type([OrderCreated]).result.hash)
with_event_of_id(event_id) do
expect(specification.result.hash).to eq(specification.from(:head).result.hash)
expect(specification.from(event_id).result.hash).not_to eq(specification.from(:head).result.hash)
end
expect(specification.result.hash).not_to eq([
SpecificationResult,
:forward,
:head,
nil,
Float::INFINITY,
Stream.new(GLOBAL_STREAM),
:all,
Specification::DEFAULT_BATCH_SIZE,
nil,
nil,
].hash)
expect(Class.new(SpecificationResult).new.hash).not_to eq(specification.result.hash)
end
specify "#eql?" do
expect(specification.result).to eq(specification.forward.result)
expect(specification.forward.result).not_to eq(specification.backward.result)
expect(specification.read_first.result).to eq(specification.read_first.result)
expect(specification.read_last.result).to eq(specification.read_last.result)
expect(specification.read_first.result).not_to eq(specification.read_last.result)
expect(specification.result).not_to eq(specification.limit(10).result)
expect(specification.in_batches.result).to eq(specification.in_batches(Specification::DEFAULT_BATCH_SIZE).result)
expect(specification.in_batches.result).not_to eq(specification.in_batches(10).result)
expect(specification.result).to eq(specification.stream(GLOBAL_STREAM).result)
expect(specification.result).not_to eq(specification.stream('dummy').result)
expect(specification.with_id(event_id).result).to eq(specification.with_id(event_id).result)
expect(specification.with_id(event_id).result).not_to eq(specification.with_id(SecureRandom.uuid).result)
with_event_of_id(event_id) do
expect(specification.result).to eq(specification.from(:head).result)
expect(specification.from(event_id).result).not_to eq(specification.from(:head).result)
end
end
specify "#dup" do
expect(specification.result.dup).to eq(specification.result)
specification.result.dup do |result|
expect(result.object_id).not_to eq(specification.result.object_id)
end
end
specify "#count" do
expect(specification.count).to eq(0)
(1..3).each do
repository.append_to_stream([test_record], Stream.new(stream_name), ExpectedVersion.any)
end
expect(specification.count).to eq(3)
repository.append_to_stream([test_record(event_id)], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.count).to eq(4)
expect(specification.in_batches.count).to eq(4)
expect(specification.in_batches(2).count).to eq(4)
expect(specification.with_id([event_id]).count).to eq(1)
not_existing_uuid = SecureRandom.uuid
expect(specification.with_id([not_existing_uuid]).count).to eq(0)
expect(specification.stream(stream_name).count).to eq(3)
expect(specification.stream('Dummy').count).to eq(1)
expect(specification.stream('not-existing-stream').count).to eq(0)
repository.append_to_stream([test_record], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.from(:head).count).to eq(5)
expect(specification.from(event_id).count).to eq(1)
expect(specification.stream("Dummy").from(:head).count).to eq(2)
expect(specification.stream("Dummy").from(event_id).count).to eq(1)
expect(specification.to(event_id).count).to eq(3)
expect(specification.stream("Dummy").to(event_id).count).to eq(0)
expect(specification.limit(100).count).to eq(5)
expect(specification.limit(2).count).to eq(2)
repository.append_to_stream([test_record(event_type: OrderCreated)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.of_type([TestEvent]).count).to eq(5)
expect(specification.of_type([OrderCreated]).count).to eq(1)
expect(specification.of_type([ProductAdded]).count).to eq(2)
expect(specification.stream("Dummy").of_type([ProductAdded]).count).to eq(2)
expect(specification.stream(stream_name).of_type([ProductAdded]).count).to eq(0)
end
specify "#map" do
events = (1..3).map{|idx| test_record(data: { here: { will: { be: { dragon: idx }}}})}
repository.append_to_stream(events, Stream.new(stream_name), ExpectedVersion.any)
expect{ specification.map }.to raise_error(ArgumentError, "Block must be given")
expect(specification.map(&:event_id)).to eq events.map(&:event_id)
expect(specification.map{|ev| ev.data.dig(:here, :will, :be, :dragon)}).to eq [1,2,3]
expect(specification.backward.map{|ev| ev.data.dig(:here, :will, :be, :dragon)}).to eq [3,2,1]
expect(specification.stream('Dummy').map(&:event_id)).to eq []
end
specify "#reduce" do
events = (1..3).map{|idx| test_record(data: { here: { will: { be: { dragon: idx }}}})}
repository.append_to_stream(events, Stream.new(stream_name), ExpectedVersion.any)
expect{ specification.reduce }.to raise_error(ArgumentError, "Block must be given")
expect{ specification.reduce([]) }.to raise_error(ArgumentError, "Block must be given")
expect(specification.reduce([]) {|acc, ev| acc << ev.event_id}).to eq events.map(&:event_id)
expect(specification.reduce(0) {|acc, ev| acc += ev.data.dig(:here, :will, :be, :dragon)}).to eq 6
expect(specification.backward.reduce(0) {|acc, ev| acc += ev.data.dig(:here, :will, :be, :dragon)}).to eq 6
expect(specification.stream('Dummy').reduce(0) {|acc, ev| acc += ev.data.dig(:here, :will, :be, :dragon)}).to eq 0
end
specify "#of_type(s)" do
expect(specification.count).to eq(0)
repository.append_to_stream([test_record(event_type: TestEvent)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: OrderCreated)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.of_type(TestEvent).count).to eq(1)
expect(specification.of_type([TestEvent]).count).to eq(1)
expect(specification.of_types(TestEvent).count).to eq(1)
expect(specification.of_types([TestEvent]).count).to eq(1)
expect(specification.of_type([OrderCreated, ProductAdded]).count).to eq(3)
expect(specification.of_types([OrderCreated, ProductAdded]).count).to eq(3)
expect(specification.of_types(OrderCreated, ProductAdded).count).to eq(3)
end
specify ":head is deprecated" do
expect { specification.from(:head) }.to output(<<~EOS).to_stderr
`:head` has been deprecated. Use event_id or skip from instead.
EOS
end
let(:repository) { InMemoryRepository.new }
let(:mapper) { Mappers::Default.new }
let(:reader) { SpecificationReader.new(repository, mapper) }
let(:specification) { Specification.new(reader) }
let(:event_id) { SecureRandom.uuid }
let(:none_such_id) { SecureRandom.uuid }
let(:stream_name) { SecureRandom.hex }
let(:test_event) { TestEvent.new(event_id: event_id) }
def test_record(event_id = SecureRandom.uuid, event_type: TestEvent, data: {})
mapper.event_to_serialized_record(
event_type.new(event_id: event_id,
data: data,
)
)
end
def with_event_of_id(event_id, &block)
repository.append_to_stream(
[test_record(event_id)],
Stream.new(stream_name),
ExpectedVersion.none
)
block.call
end
end
end
Killing mutants
require 'spec_helper'
module RubyEventStore
RSpec.describe Specification do
specify { expect(specification.each).to be_kind_of(Enumerator) }
specify { expect(specification.result.forward?).to eq(true) }
specify { expect(specification.result.backward?).to eq(false) }
specify { expect(specification.forward.result.forward?).to eq(true) }
specify { expect(specification.forward.result.backward?).to eq(false) }
specify { expect(specification.backward.result.forward?).to eq(false) }
specify { expect(specification.backward.result.backward?).to eq(true) }
specify { expect(specification.result.limit?).to eq(false) }
specify { expect(specification.result.limit).to eq(Float::INFINITY) }
specify { expect(specification.result.all?).to eq(true) }
specify { expect(specification.result.batched?).to eq(false) }
specify { expect(specification.result.first?).to eq(false) }
specify { expect(specification.result.last?).to eq(false) }
specify { expect{specification.limit(nil) }.to raise_error(InvalidPageSize) }
specify { expect{specification.limit(0)}.to raise_error(InvalidPageSize) }
specify { expect(specification.limit(1).result.limit).to eq(1) }
specify { expect(specification.result.limit?).to eq(false) }
specify { expect(specification.limit(100).result.limit?).to eq(true) }
specify { expect(specification.result.stream.name).to eq(GLOBAL_STREAM) }
specify { expect(specification.result.stream.global?).to eq(true) }
specify { expect{specification.stream(nil)}.to raise_error(IncorrectStreamData) }
specify { expect{specification.stream('')}.to raise_error(IncorrectStreamData) }
specify { expect(specification.stream('stream').result.stream.name).to eq('stream') }
specify { expect(specification.stream('nope').result.stream.global?).to eq(false) }
specify { expect(specification.stream('all').result.stream.name).to eq('all') }
specify { expect(specification.stream('all').result.stream.global?).to eq(false) }
specify { expect(specification.stream(GLOBAL_STREAM).result.stream.name).to eq( GLOBAL_STREAM) }
specify { expect(specification.stream(GLOBAL_STREAM).result.stream.global?).to eq(true) }
specify { expect(specification.result.head?).to eq(true) }
specify { expect(specification.from(:head).result.start).to eq(:head) }
specify { expect{specification.from(nil)}.to raise_error(InvalidPageStart) }
specify { expect{specification.from('')}.to raise_error(InvalidPageStart) }
specify { expect{specification.from(:dummy)}.to raise_error(InvalidPageStart) }
specify { expect{specification.from(none_such_id) }.to raise_error(EventNotFound, /#{none_such_id}/) }
specify { expect(specification.from(:head).result.head?).to eq(true) }
specify { expect{specification.to(nil)}.to raise_error(InvalidPageStop) }
specify { expect{specification.to('')}.to raise_error(InvalidPageStop) }
specify { expect{specification.to(:dummy) }.to raise_error(EventNotFound, /dummy/) }
specify { expect{specification.to(none_such_id) }.to raise_error(EventNotFound, /#{none_such_id}/) }
specify { expect(specification.result.with_ids).to be_nil }
specify { expect(specification.with_id([event_id]).result.with_ids).to eq([event_id]) }
specify { expect(specification.result.with_ids?).to eq(false) }
specify { expect(specification.with_id([event_id]).result.with_ids?).to eq(true) }
specify { expect(specification.with_id([]).result.with_ids?).to eq(true) }
specify { expect(specification.result.with_types).to be_nil }
specify { expect(specification.of_type([TestEvent]).result.with_types).to eq(['TestEvent']) }
specify { expect(specification.result.with_types?).to eq(false) }
specify { expect(specification.of_type([TestEvent]).result.with_types?).to eq(true) }
specify do
with_event_of_id(event_id) do
expect(specification.from(event_id).result.start).to eq(event_id)
expect(specification.from(event_id).result.head?).to eq(false)
expect(specification.from(:head).from(event_id).result.start).to eq(event_id)
end
end
specify do
with_event_of_id(event_id) do
expect(specification.to(event_id).result.stop).to eq(event_id)
end
end
specify do
with_event_of_id(event_id) do
spec = specification.backward.stream(stream_name).limit(10).from(event_id)
expect(spec.result.stream.name).to eq(stream_name)
expect(spec.result.stream.global?).to eq(false)
expect(spec.result.limit).to eq(10)
expect(spec.result.start).to eq(event_id)
expect(spec.result.backward?).to eq(true)
end
end
specify do
with_event_of_id(event_id) do
spec = specification.backward.stream(stream_name).limit(10).to(event_id)
expect(spec.result.stream.name).to eq(stream_name)
expect(spec.result.stream.global?).to eq(false)
expect(spec.result.limit).to eq(10)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(event_id)
expect(spec.result.backward?).to eq(true)
end
end
specify do
with_event_of_id(event_id) do
specs = [
specification.forward,
specification.backward,
specification.in_batches,
specification.read_first,
specification.read_last,
specification.limit(10),
specification.from(event_id),
specification.to(event_id),
specification.stream(stream_name),
specification.with_id([event_id]),
specification.of_type([TestEvent]),
]
expect(specs.map{|s| s.send(:reader)}.uniq).to eq([reader])
end
end
specify { expect(specification.in_batches(3).from(:head).result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).in_batches.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE) }
specify { expect(specification.in_batches(3).forward.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).backward.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).read_first.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).read_last.result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).limit(1).result.batch_size).to eq(3) }
specify { expect(specification.in_batches(3).stream('dummy').result.batch_size).to eq(3) }
specify do
with_event_of_id(event_id) do
expect(specification.from(event_id).stream('dummy').result.start).to eq(event_id)
expect(specification.from(event_id).limit(1).result.start).to eq(event_id)
expect(specification.from(event_id).read_first.result.start).to eq(event_id)
expect(specification.from(event_id).read_last.result.start).to eq(event_id)
expect(specification.from(event_id).forward.result.start).to eq(event_id)
expect(specification.from(event_id).backward.result.start).to eq(event_id)
expect(specification.read_first.from(event_id).result.first?).to eq(true)
end
end
specify do
with_event_of_id(event_id) do
expect(specification.to(event_id).stream('dummy').result.stop).to eq(event_id)
expect(specification.to(event_id).limit(1).result.stop).to eq(event_id)
expect(specification.to(event_id).read_first.result.stop).to eq(event_id)
expect(specification.to(event_id).read_last.result.stop).to eq(event_id)
expect(specification.to(event_id).forward.result.stop).to eq(event_id)
expect(specification.to(event_id).backward.result.stop).to eq(event_id)
expect(specification.to(event_id).from(:head).result.stop).to eq(event_id)
expect(specification.read_last.to(event_id).result.last?).to eq(true)
end
end
specify { expect(specification.limit(3).stream('dummy').result.limit).to eq(3) }
specify { expect(specification.limit(3).read_first.result.limit).to eq(3) }
specify { expect(specification.limit(3).read_last.result.limit).to eq(3) }
specify { expect(specification.limit(3).forward.result.limit).to eq(3) }
specify { expect(specification.limit(3).backward.result.limit).to eq(3) }
specify { expect(specification.limit(3).in_batches.result.limit).to eq(3) }
specify { expect(specification.read_first.stream('dummy').result.first?).to eq(true) }
specify { expect(specification.stream('dummy').forward.result.stream.name).to eq('dummy') }
specify { expect(specification.stream('dummy').forward.result.stream.global?).to eq(false) }
specify { expect(specification.stream('dummy').backward.result.stream.name).to eq('dummy') }
specify { expect(specification.stream('dummy').backward.result.stream.global?).to eq(false) }
specify { expect(specification.stream('dummy').in_batches.result.stream.name).to eq('dummy') }
specify { expect(specification.stream('dummy').in_batches.result.stream.global?).to eq(false) }
specify { expect(specification.read_first.limit(1).result.first?).to eq(true) }
specify { expect(specification.read_first.forward.result.first?).to eq(true) }
specify { expect(specification.read_first.backward.result.first?).to eq(true) }
specify { expect(specification.backward.in_batches.result.backward?).to eq(true) }
specify 'immutable specification' do
with_event_of_id(event_id) do
spec = backward_specifcation = specification.backward
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.backward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.from(event_id)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(event_id)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.to(event_id)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(event_id)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.limit(10)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit).to eq(10)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.stream(stream_name)
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(stream_name)
expect(spec.result.stream.global?).to eq(false)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.in_batches
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.batched?).to eq(true)
expect(spec.result.batch_size).to eq(100)
spec = specification
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = backward_specifcation.forward
expect(spec.result.object_id).not_to eq(backward_specifcation.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = backward_specifcation
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.backward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.read_first
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.first?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.read_last
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.last?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
spec = specification.with_id([event_id])
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
expect(spec.result.with_ids).to eq([event_id])
spec = specification.of_type([TestEvent])
expect(spec.result.object_id).not_to eq(specification.result.object_id)
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
expect(spec.result.with_types).to eq(['TestEvent'])
spec = specification
expect(spec.result.forward?).to eq(true)
expect(spec.result.start).to eq(:head)
expect(spec.result.stop).to eq(nil)
expect(spec.result.limit?).to eq(false)
expect(spec.result.stream.name).to eq(GLOBAL_STREAM)
expect(spec.result.stream.global?).to eq(true)
expect(spec.result.all?).to eq(true)
expect(spec.result.batch_size).to eq(Specification::DEFAULT_BATCH_SIZE)
end
end
specify do
with_event_of_id(event_id) do
expect(specification.to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.stream(stream_name).to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.limit(1).to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.backward.to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.forward.to_a).to eq([test_event])
end
end
specify do
records = [test_record, test_record]
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.from(records[0].event_id).to_a).to eq([TestEvent.new(event_id: records[1].event_id)])
end
specify do
records = [test_record, test_record]
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.to(records[1].event_id).to_a.last.event_id).to eq(records[0].event_id)
end
specify do
batch_size = 100
records = (batch_size * 10).times.map { test_record }
repository.append_to_stream(records, Stream.new("batch"), ExpectedVersion.none)
expect(specification.stream("batch").in_batches.each_batch.to_a.size).to eq(10)
end
specify do
batch_size = 100
records = (batch_size * 10).times.map { test_record }
repository.append_to_stream(records, Stream.new("batch"), ExpectedVersion.none)
expect(specification.stream("batch").in_batches.to_a.size).to eq(1000)
end
specify do
with_event_of_id(event_id) do
expect(specification.in_batches.each_batch.to_a).to eq([[test_event]])
end
end
specify do
with_event_of_id(event_id) do
expect(specification.in_batches.to_a).to eq([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect { |b| specification.in_batches.each_batch(&b) }.to yield_successive_args([test_event])
end
end
specify do
with_event_of_id(event_id) do
expect { |b| specification.in_batches.each(&b) }.to yield_successive_args(test_event)
end
end
specify do
with_event_of_id(event_id) do
expect { |b| specification.each(&b) }.to yield_successive_args(test_event)
end
end
specify do
expect(specification.in_batches_of.result).to eq(specification.in_batches.result)
expect(specification.in_batches_of(1000).result).to eq(specification.in_batches(1000).result)
end
specify do
records = 200.times.map { test_record }
repository.append_to_stream(records, Stream.new("whatever"), ExpectedVersion.none)
expect(specification.each_batch.to_a).to eq(specification.in_batches.each_batch.to_a)
expect(specification.each_batch.to_a).not_to eq(specification.in_batches(1000).each_batch.to_a)
end
specify do
expect(specification.first).to be_nil
expect(specification.last).to be_nil
records = 5.times.map { test_record }
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.stream("Another").first).to be_nil
expect(specification.stream("Another").last).to be_nil
expect(specification.first).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.last).to eq(TestEvent.new(event_id: records[4].event_id))
expect(specification.from(records[2].event_id).first).to eq(TestEvent.new(event_id: records[3].event_id))
expect(specification.from(records[2].event_id).last).to eq(TestEvent.new(event_id: records[4].event_id))
expect(specification.from(records[2].event_id).backward.first).to eq(TestEvent.new(event_id: records[1].event_id))
expect(specification.from(records[2].event_id).backward.last).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.from(records[4].event_id).first).to be_nil
expect(specification.from(records[4].event_id).last).to be_nil
expect(specification.from(records[0].event_id).backward.first).to be_nil
expect(specification.from(records[0].event_id).backward.last).to be_nil
end
specify do
expect(specification.event(event_id)).to be_nil
expect{specification.event!(event_id)}.to raise_error(EventNotFound, "Event not found: #{event_id}")
records = 5.times.map { test_record }
repository.append_to_stream(records, Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.event(records[0].event_id)).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.event(records[3].event_id)).to eq(TestEvent.new(event_id: records[3].event_id))
expect(specification.event!(records[0].event_id)).to eq(TestEvent.new(event_id: records[0].event_id))
expect(specification.event!(records[3].event_id)).to eq(TestEvent.new(event_id: records[3].event_id))
expect(specification.events([])).to be_kind_of(Enumerator)
expect(specification.events([0,2,4].map{|i| records[i].event_id})).to be_kind_of(Enumerator)
expect(specification.events([0,2,4].map{|i| records[i].event_id}).to_a).to eq(
[0,2,4].map{|i| TestEvent.new(event_id: records[i].event_id)})
expect(specification.events([records[0].event_id, SecureRandom.uuid]).to_a).to eq(
[TestEvent.new(event_id: records[0].event_id)])
end
specify do
repository.append_to_stream([test_record], Stream.new("Dummy"), ExpectedVersion.none)
expect(specification.result.batched?).to eq(false)
expect(specification.result.first?).to eq(false)
expect(specification.result.last?).to eq(false)
expect(specification.read_first.result.batched?).to eq(false)
expect(specification.read_first.result.first?).to eq(true)
expect(specification.read_first.result.last?).to eq(false)
expect(specification.read_last.result.batched?).to eq(false)
expect(specification.read_last.result.first?).to eq(false)
expect(specification.read_last.result.last?).to eq(true)
expect(specification.in_batches.result.batched?).to eq(true)
expect(specification.in_batches.result.first?).to eq(false)
expect(specification.in_batches.result.last?).to eq(false)
end
specify{ expect(specification.result.frozen?).to eq(true) }
specify{ expect(specification.backward.result.frozen?).to eq(true) }
specify "#hash" do
expect(specification.result.hash).to eq(specification.forward.result.hash)
expect(specification.forward.result.hash).not_to eq(specification.backward.result.hash)
expect(specification.read_first.result.hash).to eq(specification.read_first.result.hash)
expect(specification.read_last.result.hash).to eq(specification.read_last.result.hash)
expect(specification.read_first.result.hash).not_to eq(specification.read_last.result.hash)
expect(specification.result.hash).not_to eq(specification.limit(10).result.hash)
expect(specification.in_batches.result.hash).to eq(specification.in_batches(Specification::DEFAULT_BATCH_SIZE).result.hash)
expect(specification.in_batches.result.hash).not_to eq(specification.in_batches(10).result.hash)
expect(specification.result.hash).to eq(specification.stream(GLOBAL_STREAM).result.hash)
expect(specification.result.hash).not_to eq(specification.stream('dummy').result.hash)
expect(specification.with_id(event_id).result.hash).to eq(specification.with_id(event_id).result.hash)
expect(specification.with_id(event_id).result.hash).not_to eq(specification.with_id(SecureRandom.uuid).result.hash)
expect(specification.of_type([TestEvent]).result.hash).to eq(specification.of_type([TestEvent]).result.hash)
expect(specification.of_type([TestEvent]).result.hash).not_to eq(specification.of_type([OrderCreated]).result.hash)
with_event_of_id(event_id) do
expect(specification.result.hash).to eq(specification.from(:head).result.hash)
expect(specification.from(event_id).result.hash).not_to eq(specification.from(:head).result.hash)
expect(specification.to(event_id).result.hash).not_to eq(specification.result.hash)
end
expect(specification.result.hash).not_to eq([
SpecificationResult,
:forward,
:head,
nil,
Float::INFINITY,
Stream.new(GLOBAL_STREAM),
:all,
Specification::DEFAULT_BATCH_SIZE,
nil,
nil,
].hash)
expect(Class.new(SpecificationResult).new.hash).not_to eq(specification.result.hash)
end
specify "#eql?" do
expect(specification.result).to eq(specification.forward.result)
expect(specification.forward.result).not_to eq(specification.backward.result)
expect(specification.read_first.result).to eq(specification.read_first.result)
expect(specification.read_last.result).to eq(specification.read_last.result)
expect(specification.read_first.result).not_to eq(specification.read_last.result)
expect(specification.result).not_to eq(specification.limit(10).result)
expect(specification.in_batches.result).to eq(specification.in_batches(Specification::DEFAULT_BATCH_SIZE).result)
expect(specification.in_batches.result).not_to eq(specification.in_batches(10).result)
expect(specification.result).to eq(specification.stream(GLOBAL_STREAM).result)
expect(specification.result).not_to eq(specification.stream('dummy').result)
expect(specification.with_id(event_id).result).to eq(specification.with_id(event_id).result)
expect(specification.with_id(event_id).result).not_to eq(specification.with_id(SecureRandom.uuid).result)
with_event_of_id(event_id) do
expect(specification.result).to eq(specification.from(:head).result)
expect(specification.from(event_id).result).not_to eq(specification.from(:head).result)
end
end
specify "#dup" do
expect(specification.result.dup).to eq(specification.result)
specification.result.dup do |result|
expect(result.object_id).not_to eq(specification.result.object_id)
end
end
specify "#count" do
expect(specification.count).to eq(0)
(1..3).each do
repository.append_to_stream([test_record], Stream.new(stream_name), ExpectedVersion.any)
end
expect(specification.count).to eq(3)
repository.append_to_stream([test_record(event_id)], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.count).to eq(4)
expect(specification.in_batches.count).to eq(4)
expect(specification.in_batches(2).count).to eq(4)
expect(specification.with_id([event_id]).count).to eq(1)
not_existing_uuid = SecureRandom.uuid
expect(specification.with_id([not_existing_uuid]).count).to eq(0)
expect(specification.stream(stream_name).count).to eq(3)
expect(specification.stream('Dummy').count).to eq(1)
expect(specification.stream('not-existing-stream').count).to eq(0)
repository.append_to_stream([test_record], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.from(:head).count).to eq(5)
expect(specification.from(event_id).count).to eq(1)
expect(specification.stream("Dummy").from(:head).count).to eq(2)
expect(specification.stream("Dummy").from(event_id).count).to eq(1)
expect(specification.to(event_id).count).to eq(3)
expect(specification.stream("Dummy").to(event_id).count).to eq(0)
expect(specification.limit(100).count).to eq(5)
expect(specification.limit(2).count).to eq(2)
repository.append_to_stream([test_record(event_type: OrderCreated)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.of_type([TestEvent]).count).to eq(5)
expect(specification.of_type([OrderCreated]).count).to eq(1)
expect(specification.of_type([ProductAdded]).count).to eq(2)
expect(specification.stream("Dummy").of_type([ProductAdded]).count).to eq(2)
expect(specification.stream(stream_name).of_type([ProductAdded]).count).to eq(0)
end
specify "#map" do
events = (1..3).map{|idx| test_record(data: { here: { will: { be: { dragon: idx }}}})}
repository.append_to_stream(events, Stream.new(stream_name), ExpectedVersion.any)
expect{ specification.map }.to raise_error(ArgumentError, "Block must be given")
expect(specification.map(&:event_id)).to eq events.map(&:event_id)
expect(specification.map{|ev| ev.data.dig(:here, :will, :be, :dragon)}).to eq [1,2,3]
expect(specification.backward.map{|ev| ev.data.dig(:here, :will, :be, :dragon)}).to eq [3,2,1]
expect(specification.stream('Dummy').map(&:event_id)).to eq []
end
specify "#reduce" do
events = (1..3).map{|idx| test_record(data: { here: { will: { be: { dragon: idx }}}})}
repository.append_to_stream(events, Stream.new(stream_name), ExpectedVersion.any)
expect{ specification.reduce }.to raise_error(ArgumentError, "Block must be given")
expect{ specification.reduce([]) }.to raise_error(ArgumentError, "Block must be given")
expect(specification.reduce([]) {|acc, ev| acc << ev.event_id}).to eq events.map(&:event_id)
expect(specification.reduce(0) {|acc, ev| acc += ev.data.dig(:here, :will, :be, :dragon)}).to eq 6
expect(specification.backward.reduce(0) {|acc, ev| acc += ev.data.dig(:here, :will, :be, :dragon)}).to eq 6
expect(specification.stream('Dummy').reduce(0) {|acc, ev| acc += ev.data.dig(:here, :will, :be, :dragon)}).to eq 0
end
specify "#of_type(s)" do
expect(specification.count).to eq(0)
repository.append_to_stream([test_record(event_type: TestEvent)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: OrderCreated)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
repository.append_to_stream([test_record(event_type: ProductAdded)], Stream.new("Dummy"), ExpectedVersion.any)
expect(specification.of_type(TestEvent).count).to eq(1)
expect(specification.of_type([TestEvent]).count).to eq(1)
expect(specification.of_types(TestEvent).count).to eq(1)
expect(specification.of_types([TestEvent]).count).to eq(1)
expect(specification.of_type([OrderCreated, ProductAdded]).count).to eq(3)
expect(specification.of_types([OrderCreated, ProductAdded]).count).to eq(3)
expect(specification.of_types(OrderCreated, ProductAdded).count).to eq(3)
end
specify ":head is deprecated" do
expect { specification.from(:head) }.to output(<<~EOS).to_stderr
`:head` has been deprecated. Use event_id or skip from instead.
EOS
with_event_of_id(event_id) do
expect { specification.from(event_id) }.not_to output.to_stderr
end
end
let(:repository) { InMemoryRepository.new }
let(:mapper) { Mappers::Default.new }
let(:reader) { SpecificationReader.new(repository, mapper) }
let(:specification) { Specification.new(reader) }
let(:event_id) { SecureRandom.uuid }
let(:none_such_id) { SecureRandom.uuid }
let(:stream_name) { SecureRandom.hex }
let(:test_event) { TestEvent.new(event_id: event_id) }
def test_record(event_id = SecureRandom.uuid, event_type: TestEvent, data: {})
mapper.event_to_serialized_record(
event_type.new(event_id: event_id,
data: data,
)
)
end
def with_event_of_id(event_id, &block)
repository.append_to_stream(
[test_record(event_id)],
Stream.new(stream_name),
ExpectedVersion.none
)
block.call
end
end
end
|
class Gtksourceview3 < Formula
desc "Text view with syntax, undo/redo, and text marks"
homepage "https://projects.gnome.org/gtksourceview/"
url "https://download.gnome.org/sources/gtksourceview/3.24/gtksourceview-3.24.6.tar.xz"
sha256 "7aa6bdfebcdc73a763dddeaa42f190c40835e6f8495bb9eb8f78587e2577c188"
bottle do
sha256 "09c930da2b0d2d1e4a844eb520e613343a60a9b6b8017ccab2732dc6c498578b" => :high_sierra
sha256 "e8f01b660c11773df3468db3005f5ff3c95be7e9697a83783a6551cee2e9dd86" => :sierra
sha256 "11aa50e21f27d6bc0c9abf17f73f0e4459a7afbd9a1ce0d16443ed2a69804a9a" => :el_capitan
end
depends_on "pkg-config" => :build
depends_on "intltool" => :build
depends_on "gettext"
depends_on "gtk+3"
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <gtksourceview/gtksourceview.h>
int main(int argc, char *argv[]) {
gchar *text = gtk_source_utils_unescape_search_text("hello world");
return 0;
}
EOS
ENV.libxml2
atk = Formula["atk"]
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
freetype = Formula["freetype"]
gdk_pixbuf = Formula["gdk-pixbuf"]
gettext = Formula["gettext"]
glib = Formula["glib"]
gtkx3 = Formula["gtk+3"]
libepoxy = Formula["libepoxy"]
libpng = Formula["libpng"]
pango = Formula["pango"]
pixman = Formula["pixman"]
flags = %W[
-I#{atk.opt_include}/atk-1.0
-I#{cairo.opt_include}/cairo
-I#{fontconfig.opt_include}
-I#{freetype.opt_include}/freetype2
-I#{gdk_pixbuf.opt_include}/gdk-pixbuf-2.0
-I#{gettext.opt_include}
-I#{glib.opt_include}/gio-unix-2.0/
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{gtkx3.opt_include}/gtk-3.0
-I#{include}/gtksourceview-3.0
-I#{libepoxy.opt_include}
-I#{libpng.opt_include}/libpng16
-I#{pango.opt_include}/pango-1.0
-I#{pixman.opt_include}/pixman-1
-D_REENTRANT
-L#{atk.opt_lib}
-L#{cairo.opt_lib}
-L#{gdk_pixbuf.opt_lib}
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{gtkx3.opt_lib}
-L#{lib}
-L#{pango.opt_lib}
-latk-1.0
-lcairo
-lcairo-gobject
-lgdk-3
-lgdk_pixbuf-2.0
-lgio-2.0
-lglib-2.0
-lgobject-2.0
-lgtk-3
-lgtksourceview-3.0
-lintl
-lpango-1.0
-lpangocairo-1.0
]
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end
gtksourceview3: update 3.24.6 bottle.
class Gtksourceview3 < Formula
desc "Text view with syntax, undo/redo, and text marks"
homepage "https://projects.gnome.org/gtksourceview/"
url "https://download.gnome.org/sources/gtksourceview/3.24/gtksourceview-3.24.6.tar.xz"
sha256 "7aa6bdfebcdc73a763dddeaa42f190c40835e6f8495bb9eb8f78587e2577c188"
bottle do
sha256 "426fdaf3013cd234269c7c0e561c8b2164c10f3535dd4a1d782b6c24207daa1f" => :high_sierra
sha256 "340708c5705e4af08456f7f131d9d89442084aee754e2f476e3efba08f720bd7" => :sierra
sha256 "34a063ee219a607bf9717c71b58c109ed74e6addafbd0b6eb83aeefd9cfd228a" => :el_capitan
end
depends_on "pkg-config" => :build
depends_on "intltool" => :build
depends_on "gettext"
depends_on "gtk+3"
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <gtksourceview/gtksourceview.h>
int main(int argc, char *argv[]) {
gchar *text = gtk_source_utils_unescape_search_text("hello world");
return 0;
}
EOS
ENV.libxml2
atk = Formula["atk"]
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
freetype = Formula["freetype"]
gdk_pixbuf = Formula["gdk-pixbuf"]
gettext = Formula["gettext"]
glib = Formula["glib"]
gtkx3 = Formula["gtk+3"]
libepoxy = Formula["libepoxy"]
libpng = Formula["libpng"]
pango = Formula["pango"]
pixman = Formula["pixman"]
flags = %W[
-I#{atk.opt_include}/atk-1.0
-I#{cairo.opt_include}/cairo
-I#{fontconfig.opt_include}
-I#{freetype.opt_include}/freetype2
-I#{gdk_pixbuf.opt_include}/gdk-pixbuf-2.0
-I#{gettext.opt_include}
-I#{glib.opt_include}/gio-unix-2.0/
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{gtkx3.opt_include}/gtk-3.0
-I#{include}/gtksourceview-3.0
-I#{libepoxy.opt_include}
-I#{libpng.opt_include}/libpng16
-I#{pango.opt_include}/pango-1.0
-I#{pixman.opt_include}/pixman-1
-D_REENTRANT
-L#{atk.opt_lib}
-L#{cairo.opt_lib}
-L#{gdk_pixbuf.opt_lib}
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{gtkx3.opt_lib}
-L#{lib}
-L#{pango.opt_lib}
-latk-1.0
-lcairo
-lcairo-gobject
-lgdk-3
-lgdk_pixbuf-2.0
-lgio-2.0
-lglib-2.0
-lgobject-2.0
-lgtk-3
-lgtksourceview-3.0
-lintl
-lpango-1.0
-lpangocairo-1.0
]
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end
|
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/v1.0.10.tar.gz"
sha256 "cc071d6a63445dc1f7cefa5961c74768bc3dadf8edab5c5a7e1d63bf536a99b5"
revision 1
version_scheme 1
head "https://github.com/pyenv/pyenv.git"
bottle do
cellar :any
sha256 "bb53d2af447f7b4e54511a89f8a5b18e2d9d0fc44887241c0bea7532aca93e0b" => :sierra
sha256 "c5ac14c00ed44d999ab972026b2a0fe3639b4144abb9668c5096de0f1f6e0cee" => :el_capitan
sha256 "31db3cb79bb7f8213787faea877bb6bc688acd12e3905210b3d73f7deaf8bdaf" => :yosemite
end
depends_on "autoconf" => [:recommended, :run]
depends_on "pkg-config" => [:recommended, :run]
depends_on "openssl" => :recommended
depends_on "readline" => [:recommended, :run]
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
end
test do
shell_output("eval \"$(#{bin}/pyenv init -)\" && pyenv versions")
end
end
pyenv 1.1.0
Closes #14652.
Signed-off-by: ilovezfs <fbd54dbbcf9e596abad4ccdc4dfc17f80ebeaee2@icloud.com>
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/v1.1.0.tar.gz"
sha256 "93c7321060c42f4a4e917566cecb62303d918eadb344c62f37adbd925899f339"
version_scheme 1
head "https://github.com/pyenv/pyenv.git"
bottle do
cellar :any
sha256 "bb53d2af447f7b4e54511a89f8a5b18e2d9d0fc44887241c0bea7532aca93e0b" => :sierra
sha256 "c5ac14c00ed44d999ab972026b2a0fe3639b4144abb9668c5096de0f1f6e0cee" => :el_capitan
sha256 "31db3cb79bb7f8213787faea877bb6bc688acd12e3905210b3d73f7deaf8bdaf" => :yosemite
end
depends_on "autoconf" => [:recommended, :run]
depends_on "pkg-config" => [:recommended, :run]
depends_on "openssl" => :recommended
depends_on "readline" => [:recommended, :run]
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
end
test do
shell_output("eval \"$(#{bin}/pyenv init -)\" && pyenv versions")
end
end
|
##
## See output at the end of this file for a list
## of everything this template includes
##
gem 'haml'
gem 'chriseppstein-compass', :lib => "compass", :source => 'http://gems.github.com/'
gem 'cucumber'
gem 'rspec', :lib => false
gem 'rspec-rails', :lib => false
gem 'sprockets'
gem 'webrat'
# Rspec generation
generate :rspec
# Cucumber generation
generate :cucumber
# Database.yml
run "rm -rf config/database.yml"
file 'config/database.yml.sample', <<-CODE
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
sqlite-test: &sqlite-test
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000
memory-test: &memory-test
adapter: sqlite3
database: ":memory:"
schema: automigrate
test:
<<: *memory-test
CODE
run "cp config/database.yml.sample config/database.yml"
# Enable auto migration with this initializer.
# Allows for much faster spec runs with a database in memory.
initializer 'schema_manager.rb', <<-CODE
case ActiveRecord::Base.configurations[RAILS_ENV]['schema']
when 'autoload'
silence_stream(STDOUT) {load "\#{RAILS_ROOT}/db/schema.rb"}
when 'automigrate'
silence_stream(STDOUT) {ActiveRecord::Migrator.up("\#{RAILS_ROOT}/db/migrate")}
end
CODE
# Initial application layout
file 'app/views/layouts/application.html.haml', <<-CODE
!!! XML
!!!
%html
%head
%title
TODO: Application title
= stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'compiled/print.css', :media => 'print'
/[if IE]
= stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
= sprockets_include_tag
:javascript
authenticity_token = '\#{form_authenticity_token}';
%body
#container
#header
#main
= yield
#footer
CODE
# Initial stylesheets and compass
run 'compass --rails -f blueprint .'
run 'touch public/stylesheets/compiled/.gitignore'
# Override strftime to accept '&m', '&I' and '&d' as format codes for
# month, hour and day without padding out to two characters.
file 'lib/time_extension.rb', <<-CODE
# Override strftime to accept '&m', '&I' and '&d' as format codes for
# month, hour and day without padding out to two characters.
class Time
alias_method :orig_strftime, :strftime
def strftime(x)
result = orig_strftime(x)
result.gsub!(/&m/) {"%d" % self.month}
result.gsub!(/&d/) {"%d" % self.day}
if self.hour > 12 then use_i_hour = self.hour - 12 else use_i_hour = self.hour end
if use_i_hour == 0 then use_i_hour = 12 end
result.gsub!(/&I/) {"%d" % use_i_hour}
result
end
end
CODE
initializer 'extensions.rb', <<-CODE
require 'time_extension'
CODE
file 'spec/lib/time_extension_spec.rb', <<-CODE
require File.dirname(__FILE__) + '/../spec_helper'
describe Time, 'extensions' do
before :each do
@time = Time.parse('2009-04-01 16:00:00')
end
it 'should drop the leading 0 from the date when &d instead of %d is passed into strftime' do
@time.strftime('%b &d').should == 'Apr 1'
end
it 'should drop the leading 0 from the hour when &I instead of %I is passed into strftime' do
@time.strftime('&I:%M %p').should == '4:00 PM'
end
end
CODE
# Site controller, specs, views
file 'app/controllers/site_controller.rb', <<-CODE
class SiteController < ApplicationController
def index; end
end
CODE
run 'mkdir -p app/views/site'
run 'touch app/views/site/index.html.haml'
run 'mkdir -p spec/controllers'
run 'mkdir -p spec/views/site'
file 'spec/controllers/site_controller_spec.rb', <<-CODE
require File.dirname(__FILE__) + '/../spec_helper'
describe SiteController do
describe 'routing' do
include ActionController::UrlWriter
it "should route / to the index method" do
root_path.should == '/'
action = {:controller => 'site', :action => 'index'}
route_for(action).should == root_path
params_from(:get, root_path).should == action
end
end
describe '#index' do
it "should render the index template" do
get(:index)
response.should render_template('site/index')
end
end
end
CODE
file 'spec/views/site/index.html.haml_spec.rb', <<-CODE
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "/site/index.html.haml" do
before(:each) do
render
end
it "should render successfully" do
response.should be_success
end
end
CODE
# Initial features
file 'features/home_page.feature', <<-CODE
Feature: Home Page
As a web user
In order to use this site
I want to visit the homepage
Scenario: view homepage
Given I am an outside user
When I go to the homepage
Then I should see the homepage
CODE
file 'features/step_definitions/home_page_steps.rb', <<-CODE
Given /^I am an outside user$/ do; end
When /^When I go to the homepage$/ do
visit '/'
end
Then /^I should see the homepage$/ do
response.should be_success
end
CODE
# Remove default routes and clean up the routes file
file 'config/routes.rb', <<-CODE
ActionController::Routing::Routes.draw do |map|
map.root :controller => 'site'
SprocketsApplication.routes(map)
end
CODE
# Filter password in logs
gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
# Delete all unnecessary files
run "rm README"
run "rm doc/README_FOR_APP"
run "rm public/index.html"
run "rm public/images/rails.png"
# Setup README'
run 'touch doc/README.md'
# Setup javascripts (jQuery, sprockets)
run 'script/plugin install git://github.com/sstephenson/sprockets-rails.git'
run 'rm -rf public/javascripts/*.js'
file 'config/sprockets.yml', <<-CODE
:asset_root: public
:load_path:
- app/javascripts
- vendor/sprockets/*/src
- vendor/plugins/*/javascripts
:source_files:
- app/javascripts/jquery-*.js
- app/javascripts/jquery.*.js
- app/javascripts/**/*.js
- app/javascripts/application.js
CODE
jquery_file_name = 'jquery-1.3.2.min.js'
run "curl -L http://jqueryjs.googlecode.com/files/#{jquery_file_name} > app/javascripts/#{jquery_file_name}"
file 'app/javascripts/application.js', <<-CODE
$(document).ready(function() {});
CODE
# Initialize git repository
git :init
# Setup .gitignore
file ".gitignore", <<-END
.svn
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
db/schema.rb
public/system
public/stylesheets/*.css
public/stylesheets/complied/*.css
END
run 'touch tmp/.gitignore log/.gitignore vendor/.gitignore db/.gitignore'
# Add plugins
plugin 'rspec-on-rails-matchers', :git => 'git://github.com/joshknowles/rspec-on-rails-matchers.git'
plugin 'ya-rspec-scaffolder', :git => 'git://github.com/hpoydar/ya-rspec-scaffolder.git'
# Initial commit
git :add => ".", :commit => "-m 'initial commit'"
# Run initial specs and features
puts 'Setting up schema ...'
run 'rake db:migrate'
puts 'Running initial specs ...'
run 'rake spec'
puts 'Stepping through initial features ...'
run 'rake features'
puts ''
puts 'Application setup with:'
puts '* git SCM'
puts '* Rspec BDD framework'
puts '* Cucumber BDD framework'
puts '* Haml/Sass formatting library'
puts '* Compass CSS framework manager with Blueprint CSS framework'
puts '* rspec-on-rails-matchers plugin'
puts '* ya-rspec-scaffolder plugin'
puts '* sprockets-rails plugin'
puts '* jQuery (in place of default prototype.js)'
puts '* sprockets.yml setup for jQuery'
puts '* DB-in-memory test environment'
puts '* README documentation converted to markdown'
puts '* A Time class extension for dropping leading zeros'
puts "* A general 'site' controller with an index action"
puts '* A single root path to the site controller'
puts '* A simple application layout in Haml'
puts '* Initial controller and view specs'
puts '* An initial Cucumber feature'
puts ''
Updated cucumber usage
##
## See output at the end of this file for a list
## of everything this template includes
##
gem 'haml'
gem 'chriseppstein-compass', :lib => "compass", :source => 'http://gems.github.com/'
gem 'cucumber'
gem 'rspec', :lib => false
gem 'rspec-rails', :lib => false
gem 'sprockets'
gem 'webrat'
# Rspec generation
generate :rspec
# Cucumber generation
generate :cucumber
# Database.yml
run "rm -rf config/database.yml"
file 'config/database.yml.sample', <<-CODE
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
sqlite-test: &sqlite-test
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000
memory-test: &memory-test
adapter: sqlite3
database: ":memory:"
schema: automigrate
test:
<<: *memory-test
cucumber:
<<: *sqlite-test
CODE
run "cp config/database.yml.sample config/database.yml"
# Enable auto migration with this initializer.
# Allows for much faster spec runs with a database in memory.
initializer 'schema_manager.rb', <<-CODE
case ActiveRecord::Base.configurations[RAILS_ENV]['schema']
when 'autoload'
silence_stream(STDOUT) {load "\#{RAILS_ROOT}/db/schema.rb"}
when 'automigrate'
silence_stream(STDOUT) {ActiveRecord::Migrator.up("\#{RAILS_ROOT}/db/migrate")}
end
CODE
# Initial application layout
file 'app/views/layouts/application.html.haml', <<-CODE
!!! XML
!!!
%html
%head
%title
TODO: Application title
= stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'compiled/print.css', :media => 'print'
/[if IE]
= stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
= sprockets_include_tag
:javascript
authenticity_token = '\#{form_authenticity_token}';
%body
#container
#header
#main
= yield
#footer
CODE
# Initial stylesheets and compass
run 'compass --rails -f blueprint .'
run 'touch public/stylesheets/compiled/.gitignore'
# Override strftime to accept '&m', '&I' and '&d' as format codes for
# month, hour and day without padding out to two characters.
file 'lib/time_extension.rb', <<-CODE
# Override strftime to accept '&m', '&I' and '&d' as format codes for
# month, hour and day without padding out to two characters.
class Time
alias_method :orig_strftime, :strftime
def strftime(x)
result = orig_strftime(x)
result.gsub!(/&m/) {"%d" % self.month}
result.gsub!(/&d/) {"%d" % self.day}
if self.hour > 12 then use_i_hour = self.hour - 12 else use_i_hour = self.hour end
if use_i_hour == 0 then use_i_hour = 12 end
result.gsub!(/&I/) {"%d" % use_i_hour}
result
end
end
CODE
initializer 'extensions.rb', <<-CODE
require 'time_extension'
CODE
file 'spec/lib/time_extension_spec.rb', <<-CODE
require File.dirname(__FILE__) + '/../spec_helper'
describe Time, 'extensions' do
before :each do
@time = Time.parse('2009-04-01 16:00:00')
end
it 'should drop the leading 0 from the date when &d instead of %d is passed into strftime' do
@time.strftime('%b &d').should == 'Apr 1'
end
it 'should drop the leading 0 from the hour when &I instead of %I is passed into strftime' do
@time.strftime('&I:%M %p').should == '4:00 PM'
end
end
CODE
# Site controller, specs, views
file 'app/controllers/site_controller.rb', <<-CODE
class SiteController < ApplicationController
def index; end
end
CODE
run 'mkdir -p app/views/site'
run 'touch app/views/site/index.html.haml'
run 'mkdir -p spec/controllers'
run 'mkdir -p spec/views/site'
file 'spec/controllers/site_controller_spec.rb', <<-CODE
require File.dirname(__FILE__) + '/../spec_helper'
describe SiteController do
describe 'routing' do
include ActionController::UrlWriter
it "should route / to the index method" do
root_path.should == '/'
action = {:controller => 'site', :action => 'index'}
route_for(action).should == root_path
params_from(:get, root_path).should == action
end
end
describe '#index' do
it "should render the index template" do
get(:index)
response.should render_template('site/index')
end
end
end
CODE
file 'spec/views/site/index.html.haml_spec.rb', <<-CODE
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "/site/index.html.haml" do
before(:each) do
render
end
it "should render successfully" do
response.should be_success
end
end
CODE
# Initial features
file 'features/home_page.feature', <<-CODE
Feature: Home Page
As a web user
In order to use this site
I want to visit the homepage
Scenario: view homepage
Given I am an outside user
When I go to the homepage
Then I should see the homepage
CODE
file 'features/step_definitions/home_page_steps.rb', <<-CODE
Given /^I am an outside user$/ do; end
When /^When I go to the homepage$/ do
visit '/'
end
Then /^I should see the homepage$/ do
response.should be_success
end
CODE
# Remove default routes and clean up the routes file
file 'config/routes.rb', <<-CODE
ActionController::Routing::Routes.draw do |map|
map.root :controller => 'site'
SprocketsApplication.routes(map)
end
CODE
# Filter password in logs
gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
# Delete all unnecessary files
run "rm README"
run "rm doc/README_FOR_APP"
run "rm public/index.html"
run "rm public/images/rails.png"
# Setup README'
run 'touch doc/README.md'
# Setup javascripts (jQuery, sprockets)
run 'script/plugin install git://github.com/sstephenson/sprockets-rails.git'
run 'rm -rf public/javascripts/*.js'
file 'config/sprockets.yml', <<-CODE
:asset_root: public
:load_path:
- app/javascripts
- vendor/sprockets/*/src
- vendor/plugins/*/javascripts
:source_files:
- app/javascripts/jquery-*.js
- app/javascripts/jquery.*.js
- app/javascripts/**/*.js
- app/javascripts/application.js
CODE
jquery_file_name = 'jquery-1.3.2.min.js'
run "curl -L http://jqueryjs.googlecode.com/files/#{jquery_file_name} > app/javascripts/#{jquery_file_name}"
file 'app/javascripts/application.js', <<-CODE
$(document).ready(function() {});
CODE
# Initialize git repository
git :init
# Setup .gitignore
file ".gitignore", <<-END
.svn
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
db/schema.rb
public/system
public/stylesheets/*.css
public/stylesheets/complied/*.css
END
run 'touch tmp/.gitignore log/.gitignore vendor/.gitignore db/.gitignore'
# Add plugins
plugin 'rspec-on-rails-matchers', :git => 'git://github.com/joshknowles/rspec-on-rails-matchers.git'
plugin 'ya-rspec-scaffolder', :git => 'git://github.com/hpoydar/ya-rspec-scaffolder.git'
# Initial commit
git :add => ".", :commit => "-m 'initial commit'"
# Run initial specs and features
puts 'Setting up schema ...'
run 'rake db:migrate'
puts 'Running initial specs ...'
run 'rake spec'
puts 'Stepping through initial features ...'
run 'rake cucumber:all'
puts ''
puts 'Application setup with:'
puts '* git SCM'
puts '* Rspec BDD framework'
puts '* Cucumber BDD framework'
puts '* Haml/Sass formatting library'
puts '* Compass CSS framework manager with Blueprint CSS framework'
puts '* rspec-on-rails-matchers plugin'
puts '* ya-rspec-scaffolder plugin'
puts '* sprockets-rails plugin'
puts '* jQuery (in place of default prototype.js)'
puts '* sprockets.yml setup for jQuery'
puts '* DB-in-memory test environment'
puts '* README documentation converted to markdown'
puts '* A Time class extension for dropping leading zeros'
puts "* A general 'site' controller with an index action"
puts '* A single root path to the site controller'
puts '* A simple application layout in Haml'
puts '* Initial controller and view specs'
puts '* An initial Cucumber feature'
puts ''
|
require 'formula'
class IcarusVerilog < Formula
homepage 'http://iverilog.icarus.com/'
url 'ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.5.tar.gz'
sha1 '3a69cb935ab562882a07a52904f3cba74aed2229'
devel do
url 'ftp://ftp.icarus.com/pub/eda/verilog/snapshots/verilog-20120501.tar.gz'
sha1 '313ab0f5dc4d198bd4687daaf2e54749c67558b3'
end
def install
# Fixes an assertion when XCode-4.4 tries to link with clang or llvm-gcc.
ENV['LD'] = MacOS.locate("ld")
system "./configure", "--prefix=#{prefix}"
# Separate steps, as install does not depend on compile properly
system 'make'
system 'make installdirs'
system 'make install'
end
end
verilog 0.9.6
Closes Homebrew/homebrew#19643.
require 'formula'
class IcarusVerilog < Formula
homepage 'http://iverilog.icarus.com/'
url 'ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.6.tar.gz'
sha1 'd81f586b801a2d897ba8c35971d660b960220ed4'
def install
# Fixes an assertion when XCode-4.4 tries to link with clang or llvm-gcc.
ENV['LD'] = MacOS.locate("ld")
system "./configure", "--prefix=#{prefix}"
# Separate steps, as install does not depend on compile properly
system 'make'
system 'make installdirs'
system 'make install'
end
end
|
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/refs/tags/v2.3.6.tar.gz"
sha256 "b8928b74b153864db9ed0c4ae321e233b7ea466ab85ca6abf2d73e86930cafa1"
license "MIT"
version_scheme 1
head "https://github.com/pyenv/pyenv.git", branch: "master"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+(-\d+)?)$/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "d0a5d960f7edec4eb6535608f0d6e0df0af42685882b209bd5191e64b086b02c"
sha256 cellar: :any, arm64_monterey: "70c0c86cac3343593fc470a13f5e906cbf605189226e981fb6f709ba2b4620e4"
sha256 cellar: :any, arm64_big_sur: "984c150a4d9340c688c215f325c839ec5100489445ebc7eb318b4a5a08e5f4b2"
sha256 cellar: :any, monterey: "e5c592a2aecc7fc19766d801b98b82919aa954889949e4ad68e6f0f2b1b8e530"
sha256 cellar: :any, big_sur: "44da2df9b0f397c4f76671b5d732d1c4bca562b88b5e43e6a4e3cbb156e20de0"
sha256 cellar: :any, catalina: "e767977d9b1456bebe983c426f31ba213b323a43b17e849c0779245d99b4a8c9"
sha256 cellar: :any_skip_relocation, x86_64_linux: "2682a35e90ca23ac5d8f598d38465236dfc3ae1a2932c6b8bed71b51bd89e49e"
end
depends_on "autoconf"
depends_on "openssl@1.1"
depends_on "pkg-config"
depends_on "readline"
uses_from_macos "python" => :test
uses_from_macos "bzip2"
uses_from_macos "libffi"
uses_from_macos "ncurses"
uses_from_macos "xz"
uses_from_macos "zlib"
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
inreplace "libexec/pyenv-rehash", "$(command -v pyenv)", opt_bin/"pyenv"
inreplace "pyenv.d/rehash/source.bash", "$(command -v pyenv)", opt_bin/"pyenv"
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
share.install prefix/"man"
# Do not manually install shell completions. See:
# - https://github.com/pyenv/pyenv/issues/1056#issuecomment-356818337
# - https://github.com/Homebrew/homebrew-core/pull/22727
end
test do
# Create a fake python version and executable.
pyenv_root = Pathname(shell_output("pyenv root").strip)
python_bin = pyenv_root/"versions/1.2.3/bin"
foo_script = python_bin/"foo"
foo_script.write "echo hello"
chmod "+x", foo_script
# Test versions.
versions = shell_output("eval \"$(#{bin}/pyenv init --path)\" " \
"&& eval \"$(#{bin}/pyenv init -)\" " \
"&& pyenv versions").split("\n")
assert_equal 2, versions.length
assert_match(/\* system/, versions[0])
assert_equal(" 1.2.3", versions[1])
# Test rehash.
system "pyenv", "rehash"
refute_match "Cellar", (pyenv_root/"shims/foo").read
assert_equal "hello", shell_output("eval \"$(#{bin}/pyenv init --path)\" " \
"&& eval \"$(#{bin}/pyenv init -)\" " \
"&& PYENV_VERSION='1.2.3' foo").chomp
end
end
pyenv: update 2.3.6 bottle.
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/refs/tags/v2.3.6.tar.gz"
sha256 "b8928b74b153864db9ed0c4ae321e233b7ea466ab85ca6abf2d73e86930cafa1"
license "MIT"
version_scheme 1
head "https://github.com/pyenv/pyenv.git", branch: "master"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+(-\d+)?)$/i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "87819c3d2531687c4d980e8bf8a5a8c7514b12a7165d8aea75f451f5bbccf5fd"
sha256 cellar: :any, arm64_big_sur: "735644e12860c65979da2938793b49ccf51bf6b353e35f5b54529a9075efc607"
sha256 cellar: :any, monterey: "4a3f7ba1938986d5f47cf764abba85ef03a886a77cebcaf4ad4b6e492283ed8c"
sha256 cellar: :any, big_sur: "7ead9838b5d50b5d443a12d2865f455c7bbad12d14d5859c77d1e5fa26bc7095"
sha256 cellar: :any, catalina: "94c91ef556f0970a8cd1ff53321ee59e42b46fa6fb1b1b7b5ebbd5338ce1c51b"
sha256 cellar: :any_skip_relocation, x86_64_linux: "5ba9657da7117f8d67aba782d06133b78fee09f4f3f8ca64f8e2c04a9c588653"
end
depends_on "autoconf"
depends_on "openssl@1.1"
depends_on "pkg-config"
depends_on "readline"
uses_from_macos "python" => :test
uses_from_macos "bzip2"
uses_from_macos "libffi"
uses_from_macos "ncurses"
uses_from_macos "xz"
uses_from_macos "zlib"
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
inreplace "libexec/pyenv-rehash", "$(command -v pyenv)", opt_bin/"pyenv"
inreplace "pyenv.d/rehash/source.bash", "$(command -v pyenv)", opt_bin/"pyenv"
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
share.install prefix/"man"
# Do not manually install shell completions. See:
# - https://github.com/pyenv/pyenv/issues/1056#issuecomment-356818337
# - https://github.com/Homebrew/homebrew-core/pull/22727
end
test do
# Create a fake python version and executable.
pyenv_root = Pathname(shell_output("pyenv root").strip)
python_bin = pyenv_root/"versions/1.2.3/bin"
foo_script = python_bin/"foo"
foo_script.write "echo hello"
chmod "+x", foo_script
# Test versions.
versions = shell_output("eval \"$(#{bin}/pyenv init --path)\" " \
"&& eval \"$(#{bin}/pyenv init -)\" " \
"&& pyenv versions").split("\n")
assert_equal 2, versions.length
assert_match(/\* system/, versions[0])
assert_equal(" 1.2.3", versions[1])
# Test rehash.
system "pyenv", "rehash"
refute_match "Cellar", (pyenv_root/"shims/foo").read
assert_equal "hello", shell_output("eval \"$(#{bin}/pyenv init --path)\" " \
"&& eval \"$(#{bin}/pyenv init -)\" " \
"&& PYENV_VERSION='1.2.3' foo").chomp
end
end
|
class IgnitionMsgs7 < Formula
desc "Middleware protobuf messages for robotics"
homepage "https://github.com/ignitionrobotics/ign-msgs"
url "https://osrf-distributions.s3.amazonaws.com/ign-msgs/releases/ignition-msgs7-7.1.0.tar.bz2"
sha256 "0e1ddb73327a863eac027b5e430277e9fa121053aa108cc3d8b9c43c1698af23"
license "Apache-2.0"
revision 2
head "https://github.com/ignitionrobotics/ign-msgs.git", branch: "main"
bottle do
root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation"
sha256 cellar: :any, catalina: "8d30ffb54fcec2cdd2fbfe71f43cb343f1c0b2378cd03a869f4d6301e53e2665"
sha256 cellar: :any, mojave: "8ad1faf95cc73381fef54dabe5c11b7835212287485078b58f2d8806e169e51b"
end
depends_on "protobuf-c" => :build
depends_on "cmake"
depends_on "ignition-cmake2"
depends_on "ignition-math6"
depends_on "ignition-tools"
depends_on macos: :high_sierra # c++17
depends_on "pkg-config"
depends_on "protobuf"
depends_on "tinyxml2"
def install
cmake_args = std_cmake_args
cmake_args << "-DBUILD_TESTING=Off"
system "cmake", ".", *cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<-EOS
#include <ignition/msgs.hh>
int main() {
ignition::msgs::UInt32;
return 0;
}
EOS
(testpath/"CMakeLists.txt").write <<-EOS
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
find_package(ignition-msgs7 QUIET REQUIRED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${IGNITION-MSGS_CXX_FLAGS}")
include_directories(${IGNITION-MSGS_INCLUDE_DIRS})
link_directories(${IGNITION-MSGS_LIBRARY_DIRS})
add_executable(test_cmake test.cpp)
target_link_libraries(test_cmake ignition-msgs7::ignition-msgs7)
EOS
# test building with pkg-config
system "pkg-config", "ignition-msgs7"
cflags = `pkg-config --cflags ignition-msgs7`.split
system ENV.cc, "test.cpp",
*cflags,
"-L#{lib}",
"-lignition-msgs7",
"-lc++",
"-o", "test"
system "./test"
# test building with cmake
mkdir "build" do
system "cmake", ".."
system "make"
system "./test_cmake"
end
# check for Xcode frameworks in bottle
cmd_not_grep_xcode = "! grep -rnI 'Applications[/]Xcode' #{prefix}"
system cmd_not_grep_xcode
end
end
ignition-msgs7 7.2.0 (#1568)
* update bottle.
Co-authored-by: Steve Peters <19cdd629ec3b4ea4663c77a4169548f370fdc02f@openrobotics.org>
class IgnitionMsgs7 < Formula
desc "Middleware protobuf messages for robotics"
homepage "https://github.com/ignitionrobotics/ign-msgs"
url "https://osrf-distributions.s3.amazonaws.com/ign-msgs/releases/ignition-msgs7-7.2.0.tar.bz2"
sha256 "02b41a692c99328ca706d2a2d731e35ef9626e42e0948b51af10a26a80eb529b"
license "Apache-2.0"
head "https://github.com/ignitionrobotics/ign-msgs.git", branch: "main"
bottle do
root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation"
sha256 cellar: :any, catalina: "94477c2c762fc311b90d2b9fdcc3022f29487b22bfbf8c411d21008163c88e42"
sha256 cellar: :any, mojave: "780dc02510d5fa63d31c7838a6666fdea4165b01c5f491f1d1b0109d22520b45"
end
depends_on "protobuf-c" => :build
depends_on "cmake"
depends_on "ignition-cmake2"
depends_on "ignition-math6"
depends_on "ignition-tools"
depends_on macos: :high_sierra # c++17
depends_on "pkg-config"
depends_on "protobuf"
depends_on "tinyxml2"
def install
cmake_args = std_cmake_args
cmake_args << "-DBUILD_TESTING=Off"
system "cmake", ".", *cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<-EOS
#include <ignition/msgs.hh>
int main() {
ignition::msgs::UInt32;
return 0;
}
EOS
(testpath/"CMakeLists.txt").write <<-EOS
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
find_package(ignition-msgs7 QUIET REQUIRED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${IGNITION-MSGS_CXX_FLAGS}")
include_directories(${IGNITION-MSGS_INCLUDE_DIRS})
link_directories(${IGNITION-MSGS_LIBRARY_DIRS})
add_executable(test_cmake test.cpp)
target_link_libraries(test_cmake ignition-msgs7::ignition-msgs7)
EOS
# test building with pkg-config
system "pkg-config", "ignition-msgs7"
cflags = `pkg-config --cflags ignition-msgs7`.split
system ENV.cc, "test.cpp",
*cflags,
"-L#{lib}",
"-lignition-msgs7",
"-lc++",
"-o", "test"
system "./test"
# test building with cmake
mkdir "build" do
system "cmake", ".."
system "make"
system "./test_cmake"
end
# check for Xcode frameworks in bottle
cmd_not_grep_xcode = "! grep -rnI 'Applications[/]Xcode' #{prefix}"
system cmd_not_grep_xcode
end
end
|
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/v1.2.7.tar.gz"
sha256 "b5f41187fb71f9fbf2d22d5d18910bdbe473c9f2acdcc5fa2de3f0b53760bb1c"
version_scheme 1
head "https://github.com/pyenv/pyenv.git"
bottle do
cellar :any
sha256 "44c787de32fd6e1d17a79e6e927a20cfd175056948f0ad1bb621a6c2f06b8534" => :high_sierra
sha256 "20c3dd22f4baa8b4557229483258d0c65bfefe8e4546c0a15a948e17ad51f315" => :sierra
sha256 "86182bb87c253e24eb02a5c621e9a393c36dc9411678afb61dd934f6847237d5" => :el_capitan
end
depends_on "autoconf" => :recommended
depends_on "pkg-config" => :recommended
depends_on "openssl" => :recommended
depends_on "readline" => :recommended
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
end
test do
shell_output("eval \"$(#{bin}/pyenv init -)\" && pyenv versions")
end
end
pyenv: update 1.2.7 bottle for Linuxbrew.
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/v1.2.7.tar.gz"
sha256 "b5f41187fb71f9fbf2d22d5d18910bdbe473c9f2acdcc5fa2de3f0b53760bb1c"
version_scheme 1
head "https://github.com/pyenv/pyenv.git"
bottle do
cellar :any
sha256 "44c787de32fd6e1d17a79e6e927a20cfd175056948f0ad1bb621a6c2f06b8534" => :high_sierra
sha256 "20c3dd22f4baa8b4557229483258d0c65bfefe8e4546c0a15a948e17ad51f315" => :sierra
sha256 "86182bb87c253e24eb02a5c621e9a393c36dc9411678afb61dd934f6847237d5" => :el_capitan
sha256 "fb40931a6e3e92b5dc2bae7961448a338cfd371bdf5b281179e1ad70376d05cb" => :x86_64_linux
end
depends_on "autoconf" => :recommended
depends_on "pkg-config" => :recommended
depends_on "openssl" => :recommended
depends_on "readline" => :recommended
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
end
test do
shell_output("eval \"$(#{bin}/pyenv init -)\" && pyenv versions")
end
end
|
class KubernetesCli < Formula
desc "Kubernetes command-line interface"
homepage "https://kubernetes.io/"
url "https://github.com/kubernetes/kubernetes.git",
:tag => "v1.15.2",
:revision => "f6278300bebbb750328ac16ee6dd3aa7d3549568"
head "https://github.com/kubernetes/kubernetes.git"
bottle do
cellar :any_skip_relocation
sha256 "554b3ff75df7105fc83f33036e6120b0cfb059302679fd5b223f08d9d80c9029" => :mojave
sha256 "409d049aeb458b272a37859064d2d66a095b1c634067b783dd82f099706a9473" => :high_sierra
sha256 "d0500cd79ae691c229aeae364c427feca1dad8d526c6add39b590de92ef8806d" => :sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
dir = buildpath/"src/k8s.io/kubernetes"
dir.install buildpath.children - [buildpath/".brew_home"]
cd dir do
# Race condition still exists in OS X Yosemite
# Filed issue: https://github.com/kubernetes/kubernetes/issues/34635
ENV.deparallelize { system "make", "generated_files" }
# Make binary
system "make", "kubectl"
bin.install "_output/local/bin/darwin/amd64/kubectl"
# Install bash completion
output = Utils.popen_read("#{bin}/kubectl completion bash")
(bash_completion/"kubectl").write output
# Install zsh completion
output = Utils.popen_read("#{bin}/kubectl completion zsh")
(zsh_completion/"_kubectl").write output
prefix.install_metafiles
# Install man pages
# Leave this step for the end as this dirties the git tree
system "hack/generate-docs.sh"
man1.install Dir["docs/man/man1/*.1"]
end
end
test do
run_output = shell_output("#{bin}/kubectl 2>&1")
assert_match "kubectl controls the Kubernetes cluster manager.", run_output
version_output = shell_output("#{bin}/kubectl version --client 2>&1")
assert_match "GitTreeState:\"clean\"", version_output
if build.stable?
assert_match stable.instance_variable_get(:@resource)
.instance_variable_get(:@specs)[:revision],
version_output
end
end
end
kubernetes-cli: update 1.15.2 bottle.
class KubernetesCli < Formula
desc "Kubernetes command-line interface"
homepage "https://kubernetes.io/"
url "https://github.com/kubernetes/kubernetes.git",
:tag => "v1.15.2",
:revision => "f6278300bebbb750328ac16ee6dd3aa7d3549568"
head "https://github.com/kubernetes/kubernetes.git"
bottle do
cellar :any_skip_relocation
sha256 "8f15a9fe1d0436d6a8b9a3dbb98195a28ae118f9e4493df396e1e7445695be71" => :mojave
sha256 "2156fdcf1e31852d9dcc12159cddc77b3f25d0d4a145de933c4141c1268bebcb" => :high_sierra
sha256 "9132bd36c0d1b42b31c0987920baf2378f401cf104d598a187462d4030f29f24" => :sierra
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
dir = buildpath/"src/k8s.io/kubernetes"
dir.install buildpath.children - [buildpath/".brew_home"]
cd dir do
# Race condition still exists in OS X Yosemite
# Filed issue: https://github.com/kubernetes/kubernetes/issues/34635
ENV.deparallelize { system "make", "generated_files" }
# Make binary
system "make", "kubectl"
bin.install "_output/local/bin/darwin/amd64/kubectl"
# Install bash completion
output = Utils.popen_read("#{bin}/kubectl completion bash")
(bash_completion/"kubectl").write output
# Install zsh completion
output = Utils.popen_read("#{bin}/kubectl completion zsh")
(zsh_completion/"_kubectl").write output
prefix.install_metafiles
# Install man pages
# Leave this step for the end as this dirties the git tree
system "hack/generate-docs.sh"
man1.install Dir["docs/man/man1/*.1"]
end
end
test do
run_output = shell_output("#{bin}/kubectl 2>&1")
assert_match "kubectl controls the Kubernetes cluster manager.", run_output
version_output = shell_output("#{bin}/kubectl version --client 2>&1")
assert_match "GitTreeState:\"clean\"", version_output
if build.stable?
assert_match stable.instance_variable_get(:@resource)
.instance_variable_get(:@specs)[:revision],
version_output
end
end
end
|
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/v1.2.18.tar.gz"
sha256 "cc147f020178bb2f1ce0a8b9acb0bdf73979d967ce7d7415e22746e84e0eec7a"
version_scheme 1
head "https://github.com/pyenv/pyenv.git"
bottle do
cellar :any
sha256 "bd9f719f153e9574dcc65dc7fea28a3816557bd46b0ff90ad8de43f3f8dc72c4" => :catalina
sha256 "05f0414ec85ad0eb46a4046d9bee6da318b2b68fd9b64b11875cb2457ac808ec" => :mojave
sha256 "e789844a5fc1efd1e53a60d87032b279823933cb1a79839fb67dd34a9fd7e96a" => :high_sierra
end
depends_on "autoconf"
depends_on "openssl@1.1"
depends_on "pkg-config"
depends_on "readline"
uses_from_macos "bzip2"
uses_from_macos "libffi"
uses_from_macos "ncurses"
uses_from_macos "xz"
uses_from_macos "zlib"
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
# Do not manually install shell completions. See:
# - https://github.com/pyenv/pyenv/issues/1056#issuecomment-356818337
# - https://github.com/Homebrew/homebrew-core/pull/22727
end
test do
shell_output("eval \"$(#{bin}/pyenv init -)\" && pyenv versions")
end
end
pyenv 1.2.19
Closes #56451.
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
class Pyenv < Formula
desc "Python version management"
homepage "https://github.com/pyenv/pyenv"
url "https://github.com/pyenv/pyenv/archive/v1.2.19.tar.gz"
sha256 "e93466735ac9c34d68b7d5d71f32c16a2b4b1a6a1adffb85acc4126a3398b9d0"
version_scheme 1
head "https://github.com/pyenv/pyenv.git"
bottle do
cellar :any
sha256 "bd9f719f153e9574dcc65dc7fea28a3816557bd46b0ff90ad8de43f3f8dc72c4" => :catalina
sha256 "05f0414ec85ad0eb46a4046d9bee6da318b2b68fd9b64b11875cb2457ac808ec" => :mojave
sha256 "e789844a5fc1efd1e53a60d87032b279823933cb1a79839fb67dd34a9fd7e96a" => :high_sierra
end
depends_on "autoconf"
depends_on "openssl@1.1"
depends_on "pkg-config"
depends_on "readline"
uses_from_macos "bzip2"
uses_from_macos "libffi"
uses_from_macos "ncurses"
uses_from_macos "xz"
uses_from_macos "zlib"
def install
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
system "src/configure"
system "make", "-C", "src"
prefix.install Dir["*"]
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
end
# Do not manually install shell completions. See:
# - https://github.com/pyenv/pyenv/issues/1056#issuecomment-356818337
# - https://github.com/Homebrew/homebrew-core/pull/22727
end
test do
shell_output("eval \"$(#{bin}/pyenv init -)\" && pyenv versions")
end
end
|
class LibdbusmenuQt < Formula
desc "C++ dbusmenu library for Qt"
homepage "https://launchpad.net/libdbusmenu-qt"
url "http://launchpad.net/libdbusmenu-qt/trunk/0.9.2/+download/libdbusmenu-qt-0.9.2.tar.bz2"
sha256 "ae6c1cb6da3c683aefed39df3e859537a31d80caa04f3023315ff09e5e8919ec"
depends_on "cmake" => :build
depends_on "doxygen" => :build
depends_on "qt"
depends_on "qjson"
def install
mkdir "macbuild" do
args = std_cmake_args + [".."]
system "cmake", *args
system "make", "install"
end
end
end
libdbusmenu-qt: https launchpad
class LibdbusmenuQt < Formula
desc "C++ dbusmenu library for Qt"
homepage "https://launchpad.net/libdbusmenu-qt"
url "https://launchpad.net/libdbusmenu-qt/trunk/0.9.2/+download/libdbusmenu-qt-0.9.2.tar.bz2"
sha256 "ae6c1cb6da3c683aefed39df3e859537a31d80caa04f3023315ff09e5e8919ec"
depends_on "cmake" => :build
depends_on "doxygen" => :build
depends_on "qt"
depends_on "qjson"
def install
mkdir "macbuild" do
args = std_cmake_args + [".."]
system "cmake", *args
system "make", "install"
end
end
end
|
class Pypy3 < Formula
desc "Implementation of Python 3 in Python"
homepage "https://pypy.org/"
url "https://bitbucket.org/pypy/pypy/downloads/pypy3.6-v7.3.1-src.tar.bz2"
sha256 "0c2cc3229da36c6984baee128c8ff8bb4516d69df1d73275dc4622bf249afa83"
revision 1
head "https://foss.heptapod.net/pypy/pypy", using: :hg, branch: "py3.7"
bottle do
cellar :any
sha256 "384b960848c433008154103f8cdf57c77b8ee805115818cae4cb502e5485f043" => :catalina
sha256 "de50ccf32775b38c4d1e2324fe7b9c0e23856fbe34eaf6ebd7b23e7d6d8f6459" => :mojave
sha256 "ea4031fc8f85001fea131cc880108416f0d9bbac400655a7d8337ad8cb8f1547" => :high_sierra
end
depends_on "pkg-config" => :build
depends_on "pypy" => :build
depends_on arch: :x86_64
depends_on "gdbm"
# pypy does not find system libffi, and its location cannot be given
# as a build option
depends_on "libffi" if DevelopmentTools.clang_build_version >= 1000
depends_on "openssl@1.1"
depends_on "sqlite"
depends_on "tcl-tk"
depends_on "xz"
uses_from_macos "expat"
uses_from_macos "libffi"
uses_from_macos "unzip"
uses_from_macos "zlib"
# packaging depends on pyparsing
resource "pyparsing" do
url "https://files.pythonhosted.org/packages/c1/47/dfc9c342c9842bbe0036c7f763d2d6686bcf5eb1808ba3e170afdb282210/pyparsing-2.4.7.tar.gz"
sha256 "c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"
end
# packaging and setuptools depend on six
resource "six" do
url "https://files.pythonhosted.org/packages/21/9f/b251f7f8a76dec1d6651be194dfba8fb8d7781d10ab3987190de8391d08e/six-1.14.0.tar.gz"
sha256 "236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"
end
# setuptools depends on packaging
resource "packaging" do
url "https://files.pythonhosted.org/packages/65/37/83e3f492eb52d771e2820e88105f605335553fe10422cba9d256faeb1702/packaging-20.3.tar.gz"
sha256 "3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3"
end
# setuptools depends on appdirs
resource "appdirs" do
url "https://files.pythonhosted.org/packages/48/69/d87c60746b393309ca30761f8e2b49473d43450b150cb08f3c6df5c11be5/appdirs-1.4.3.tar.gz"
sha256 "9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92"
end
resource "setuptools" do
url "https://files.pythonhosted.org/packages/b5/96/af1686ea8c1e503f4a81223d4a3410e7587fd52df03083de24161d0df7d4/setuptools-46.1.3.zip"
sha256 "795e0475ba6cd7fa082b1ee6e90d552209995627a2a227a47c6ea93282f4bfb1"
end
resource "pip" do
url "https://files.pythonhosted.org/packages/8e/76/66066b7bc71817238924c7e4b448abdb17eb0c92d645769c223f9ace478f/pip-20.0.2.tar.gz"
sha256 "7db0c8ea4c7ea51c8049640e8e6e7fde949de672bfa4949920675563a5a6967f"
end
def install
ENV.prepend_path "PKG_CONFIG_PATH", "#{prefix}/opt/openssl/lib/pkgconfig:#{prefix}/opt/tcl-tk/lib/pkgconfig"
ENV.prepend "LDFLAGS", "-L#{prefix}/opt/tcl-tk/lib"
ENV.prepend "CPPFLAGS", "-I#{prefix}/opt/tcl-tk/include"
# Work around "dyld: Symbol not found: _utimensat"
ENV.delete("SDKROOT") if MacOS.version == :sierra && MacOS::Xcode.version >= "9.0"
# Fix build on High Sierra
inreplace "lib_pypy/_tkinter/tklib_build.py" do |s|
s.gsub! "/System/Library/Frameworks/Tk.framework/Versions/Current/Headers/",
"#{prefix}/opt/tcl-tk/include"
s.gsub! "libdirs = []",
"libdirs = ['#{prefix}/opt/tcl-tk/lib']"
end
# Having PYTHONPATH set can cause the build to fail if another
# Python is present, e.g. a Homebrew-provided Python 2.x
# See https://github.com/Homebrew/homebrew/issues/24364
ENV["PYTHONPATH"] = ""
ENV["PYPY_USESSION_DIR"] = buildpath
python = Formula["pypy"].opt_bin/"pypy"
cd "pypy/goal" do
system python, buildpath/"rpython/bin/rpython",
"-Ojit", "--shared", "--cc", ENV.cc, "--verbose",
"--make-jobs", ENV.make_jobs, "targetpypystandalone.py"
end
libexec.mkpath
cd "pypy/tool/release" do
system python, "package.py", "--archive-name", "pypy3", "--targetdir", "."
system "tar", "-C", libexec.to_s, "--strip-components", "1", "-xf", "pypy3.tar.bz2"
end
(libexec/"lib").install libexec/"bin/libpypy3-c.dylib" => "libpypy3-c.dylib"
MachO::Tools.change_install_name("#{libexec}/bin/pypy3",
"@rpath/libpypy3-c.dylib",
"#{libexec}/lib/libpypy3-c.dylib")
MachO::Tools.change_dylib_id("#{libexec}/lib/libpypy3-c.dylib",
"#{opt_libexec}/lib/libpypy3-c.dylib")
(libexec/"lib-python").install "lib-python/3"
libexec.install %w[include lib_pypy]
# The PyPy binary install instructions suggest installing somewhere
# (like /opt) and symlinking in binaries as needed. Specifically,
# we want to avoid putting PyPy's Python.h somewhere that configure
# scripts will find it.
bin.install_symlink libexec/"bin/pypy3"
bin.install_symlink libexec/"bin/pypy" => "pypy3.6"
lib.install_symlink libexec/"lib/libpypy3-c.dylib"
end
def post_install
# Precompile cffi extensions in lib_pypy
# list from create_cffi_import_libraries in pypy/tool/release/package.py
%w[_sqlite3 _curses syslog gdbm _tkinter].each do |module_name|
quiet_system bin/"pypy3", "-c", "import #{module_name}"
end
# Post-install, fix up the site-packages and install-scripts folders
# so that user-installed Python software survives minor updates, such
# as going from 1.7.0 to 1.7.1.
# Create a site-packages in the prefix.
prefix_site_packages.mkpath
# Symlink the prefix site-packages into the cellar.
libexec.install_symlink prefix_site_packages
# Tell distutils-based installers where to put scripts
scripts_folder.mkpath
(distutils+"distutils.cfg").atomic_write <<~EOS
[install]
install-scripts=#{scripts_folder}
EOS
%w[appdirs six packaging setuptools pyparsing pip].each do |pkg|
resource(pkg).stage do
system bin/"pypy3", "-s", "setup.py", "install", "--force", "--verbose"
end
end
# Symlinks to easy_install_pypy3 and pip_pypy3
bin.install_symlink scripts_folder/"easy_install" => "easy_install_pypy3"
bin.install_symlink scripts_folder/"pip" => "pip_pypy3"
# post_install happens after linking
%w[easy_install_pypy3 pip_pypy3].each { |e| (HOMEBREW_PREFIX/"bin").install_symlink bin/e }
end
def caveats
<<~EOS
A "distutils.cfg" has been written to:
#{distutils}
specifying the install-scripts folder as:
#{scripts_folder}
If you install Python packages via "pypy3 setup.py install", easy_install_pypy3,
or pip_pypy3, any provided scripts will go into the install-scripts folder
above, so you may want to add it to your PATH *after* #{HOMEBREW_PREFIX}/bin
so you don't overwrite tools from CPython.
Setuptools and pip have been installed, so you can use easy_install_pypy3 and
pip_pypy3.
To update pip and setuptools between pypy3 releases, run:
pip_pypy3 install --upgrade pip setuptools
See: https://docs.brew.sh/Homebrew-and-Python
EOS
end
# The HOMEBREW_PREFIX location of site-packages
def prefix_site_packages
HOMEBREW_PREFIX+"lib/pypy3/site-packages"
end
# Where setuptools will install executable scripts
def scripts_folder
HOMEBREW_PREFIX+"share/pypy3"
end
# The Cellar location of distutils
def distutils
libexec+"lib-python/3/distutils"
end
test do
system bin/"pypy3", "-c", "print('Hello, world!')"
system scripts_folder/"pip", "list"
end
end
pypy3: add license
class Pypy3 < Formula
desc "Implementation of Python 3 in Python"
homepage "https://pypy.org/"
url "https://bitbucket.org/pypy/pypy/downloads/pypy3.6-v7.3.1-src.tar.bz2"
sha256 "0c2cc3229da36c6984baee128c8ff8bb4516d69df1d73275dc4622bf249afa83"
license "MIT"
revision 1
head "https://foss.heptapod.net/pypy/pypy", using: :hg, branch: "py3.7"
bottle do
cellar :any
sha256 "384b960848c433008154103f8cdf57c77b8ee805115818cae4cb502e5485f043" => :catalina
sha256 "de50ccf32775b38c4d1e2324fe7b9c0e23856fbe34eaf6ebd7b23e7d6d8f6459" => :mojave
sha256 "ea4031fc8f85001fea131cc880108416f0d9bbac400655a7d8337ad8cb8f1547" => :high_sierra
end
depends_on "pkg-config" => :build
depends_on "pypy" => :build
depends_on arch: :x86_64
depends_on "gdbm"
# pypy does not find system libffi, and its location cannot be given
# as a build option
depends_on "libffi" if DevelopmentTools.clang_build_version >= 1000
depends_on "openssl@1.1"
depends_on "sqlite"
depends_on "tcl-tk"
depends_on "xz"
uses_from_macos "expat"
uses_from_macos "libffi"
uses_from_macos "unzip"
uses_from_macos "zlib"
# packaging depends on pyparsing
resource "pyparsing" do
url "https://files.pythonhosted.org/packages/c1/47/dfc9c342c9842bbe0036c7f763d2d6686bcf5eb1808ba3e170afdb282210/pyparsing-2.4.7.tar.gz"
sha256 "c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"
end
# packaging and setuptools depend on six
resource "six" do
url "https://files.pythonhosted.org/packages/21/9f/b251f7f8a76dec1d6651be194dfba8fb8d7781d10ab3987190de8391d08e/six-1.14.0.tar.gz"
sha256 "236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"
end
# setuptools depends on packaging
resource "packaging" do
url "https://files.pythonhosted.org/packages/65/37/83e3f492eb52d771e2820e88105f605335553fe10422cba9d256faeb1702/packaging-20.3.tar.gz"
sha256 "3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3"
end
# setuptools depends on appdirs
resource "appdirs" do
url "https://files.pythonhosted.org/packages/48/69/d87c60746b393309ca30761f8e2b49473d43450b150cb08f3c6df5c11be5/appdirs-1.4.3.tar.gz"
sha256 "9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92"
end
resource "setuptools" do
url "https://files.pythonhosted.org/packages/b5/96/af1686ea8c1e503f4a81223d4a3410e7587fd52df03083de24161d0df7d4/setuptools-46.1.3.zip"
sha256 "795e0475ba6cd7fa082b1ee6e90d552209995627a2a227a47c6ea93282f4bfb1"
end
resource "pip" do
url "https://files.pythonhosted.org/packages/8e/76/66066b7bc71817238924c7e4b448abdb17eb0c92d645769c223f9ace478f/pip-20.0.2.tar.gz"
sha256 "7db0c8ea4c7ea51c8049640e8e6e7fde949de672bfa4949920675563a5a6967f"
end
def install
ENV.prepend_path "PKG_CONFIG_PATH", "#{prefix}/opt/openssl/lib/pkgconfig:#{prefix}/opt/tcl-tk/lib/pkgconfig"
ENV.prepend "LDFLAGS", "-L#{prefix}/opt/tcl-tk/lib"
ENV.prepend "CPPFLAGS", "-I#{prefix}/opt/tcl-tk/include"
# Work around "dyld: Symbol not found: _utimensat"
ENV.delete("SDKROOT") if MacOS.version == :sierra && MacOS::Xcode.version >= "9.0"
# Fix build on High Sierra
inreplace "lib_pypy/_tkinter/tklib_build.py" do |s|
s.gsub! "/System/Library/Frameworks/Tk.framework/Versions/Current/Headers/",
"#{prefix}/opt/tcl-tk/include"
s.gsub! "libdirs = []",
"libdirs = ['#{prefix}/opt/tcl-tk/lib']"
end
# Having PYTHONPATH set can cause the build to fail if another
# Python is present, e.g. a Homebrew-provided Python 2.x
# See https://github.com/Homebrew/homebrew/issues/24364
ENV["PYTHONPATH"] = ""
ENV["PYPY_USESSION_DIR"] = buildpath
python = Formula["pypy"].opt_bin/"pypy"
cd "pypy/goal" do
system python, buildpath/"rpython/bin/rpython",
"-Ojit", "--shared", "--cc", ENV.cc, "--verbose",
"--make-jobs", ENV.make_jobs, "targetpypystandalone.py"
end
libexec.mkpath
cd "pypy/tool/release" do
system python, "package.py", "--archive-name", "pypy3", "--targetdir", "."
system "tar", "-C", libexec.to_s, "--strip-components", "1", "-xf", "pypy3.tar.bz2"
end
(libexec/"lib").install libexec/"bin/libpypy3-c.dylib" => "libpypy3-c.dylib"
MachO::Tools.change_install_name("#{libexec}/bin/pypy3",
"@rpath/libpypy3-c.dylib",
"#{libexec}/lib/libpypy3-c.dylib")
MachO::Tools.change_dylib_id("#{libexec}/lib/libpypy3-c.dylib",
"#{opt_libexec}/lib/libpypy3-c.dylib")
(libexec/"lib-python").install "lib-python/3"
libexec.install %w[include lib_pypy]
# The PyPy binary install instructions suggest installing somewhere
# (like /opt) and symlinking in binaries as needed. Specifically,
# we want to avoid putting PyPy's Python.h somewhere that configure
# scripts will find it.
bin.install_symlink libexec/"bin/pypy3"
bin.install_symlink libexec/"bin/pypy" => "pypy3.6"
lib.install_symlink libexec/"lib/libpypy3-c.dylib"
end
def post_install
# Precompile cffi extensions in lib_pypy
# list from create_cffi_import_libraries in pypy/tool/release/package.py
%w[_sqlite3 _curses syslog gdbm _tkinter].each do |module_name|
quiet_system bin/"pypy3", "-c", "import #{module_name}"
end
# Post-install, fix up the site-packages and install-scripts folders
# so that user-installed Python software survives minor updates, such
# as going from 1.7.0 to 1.7.1.
# Create a site-packages in the prefix.
prefix_site_packages.mkpath
# Symlink the prefix site-packages into the cellar.
libexec.install_symlink prefix_site_packages
# Tell distutils-based installers where to put scripts
scripts_folder.mkpath
(distutils+"distutils.cfg").atomic_write <<~EOS
[install]
install-scripts=#{scripts_folder}
EOS
%w[appdirs six packaging setuptools pyparsing pip].each do |pkg|
resource(pkg).stage do
system bin/"pypy3", "-s", "setup.py", "install", "--force", "--verbose"
end
end
# Symlinks to easy_install_pypy3 and pip_pypy3
bin.install_symlink scripts_folder/"easy_install" => "easy_install_pypy3"
bin.install_symlink scripts_folder/"pip" => "pip_pypy3"
# post_install happens after linking
%w[easy_install_pypy3 pip_pypy3].each { |e| (HOMEBREW_PREFIX/"bin").install_symlink bin/e }
end
def caveats
<<~EOS
A "distutils.cfg" has been written to:
#{distutils}
specifying the install-scripts folder as:
#{scripts_folder}
If you install Python packages via "pypy3 setup.py install", easy_install_pypy3,
or pip_pypy3, any provided scripts will go into the install-scripts folder
above, so you may want to add it to your PATH *after* #{HOMEBREW_PREFIX}/bin
so you don't overwrite tools from CPython.
Setuptools and pip have been installed, so you can use easy_install_pypy3 and
pip_pypy3.
To update pip and setuptools between pypy3 releases, run:
pip_pypy3 install --upgrade pip setuptools
See: https://docs.brew.sh/Homebrew-and-Python
EOS
end
# The HOMEBREW_PREFIX location of site-packages
def prefix_site_packages
HOMEBREW_PREFIX+"lib/pypy3/site-packages"
end
# Where setuptools will install executable scripts
def scripts_folder
HOMEBREW_PREFIX+"share/pypy3"
end
# The Cellar location of distutils
def distutils
libexec+"lib-python/3/distutils"
end
test do
system bin/"pypy3", "-c", "print('Hello, world!')"
system scripts_folder/"pip", "list"
end
end
|
class Libphonenumber < Formula
desc "C++ Phone Number library by Google"
homepage "https://github.com/google/libphonenumber"
url "https://github.com/google/libphonenumber/archive/v8.12.39.tar.gz"
sha256 "ff16330f130917e42bc0b1a7efe5e4fba46633bfa62e35268acec855e17e385c"
license "Apache-2.0"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any, arm64_monterey: "a88efcd9e2e3fc7b88c2d547b338b489a9464c34dcb5379b373f6cff8f1fbd46"
sha256 cellar: :any, arm64_big_sur: "be6a424ea281261dbc87472a396213788af847741280e0047c14827deb10a6ad"
sha256 cellar: :any, monterey: "cefe5040591ac37cc1ed084b679f09a82e0bf8dba8a42895bc2afe9b0ef23aeb"
sha256 cellar: :any, big_sur: "1cb623f85f7cdd6614515499049f1d0a7c70ffffbd8f9c11e1003f21e39e2b08"
sha256 cellar: :any, catalina: "27ab0236ba00f6f8bb9f1a069f5e61424d3aeefad3e3be1fe219109272de9c98"
sha256 cellar: :any_skip_relocation, x86_64_linux: "0f933801a07767652de4c30f5f7678e44db8e2317ac37226120b30d82cd97ef5"
end
depends_on "cmake" => :build
depends_on "googletest" => :build
depends_on "boost"
depends_on "icu4c"
depends_on "protobuf"
depends_on "re2"
def install
ENV.cxx11
system "cmake", "cpp", "-DGTEST_INCLUDE_DIR=#{Formula["googletest"].include}",
*std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <phonenumbers/phonenumberutil.h>
#include <phonenumbers/phonenumber.pb.h>
#include <iostream>
#include <string>
using namespace i18n::phonenumbers;
int main() {
PhoneNumberUtil *phone_util_ = PhoneNumberUtil::GetInstance();
PhoneNumber test_number;
string formatted_number;
test_number.set_country_code(1);
test_number.set_national_number(6502530000ULL);
phone_util_->Format(test_number, PhoneNumberUtil::E164, &formatted_number);
if (formatted_number == "+16502530000") {
return 0;
} else {
return 1;
}
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test"
system "./test"
end
end
libphonenumber: revision bump (protobuf 3.19.1)
class Libphonenumber < Formula
desc "C++ Phone Number library by Google"
homepage "https://github.com/google/libphonenumber"
url "https://github.com/google/libphonenumber/archive/v8.12.39.tar.gz"
sha256 "ff16330f130917e42bc0b1a7efe5e4fba46633bfa62e35268acec855e17e385c"
license "Apache-2.0"
revision 1
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any, arm64_monterey: "a88efcd9e2e3fc7b88c2d547b338b489a9464c34dcb5379b373f6cff8f1fbd46"
sha256 cellar: :any, arm64_big_sur: "be6a424ea281261dbc87472a396213788af847741280e0047c14827deb10a6ad"
sha256 cellar: :any, monterey: "cefe5040591ac37cc1ed084b679f09a82e0bf8dba8a42895bc2afe9b0ef23aeb"
sha256 cellar: :any, big_sur: "1cb623f85f7cdd6614515499049f1d0a7c70ffffbd8f9c11e1003f21e39e2b08"
sha256 cellar: :any, catalina: "27ab0236ba00f6f8bb9f1a069f5e61424d3aeefad3e3be1fe219109272de9c98"
sha256 cellar: :any_skip_relocation, x86_64_linux: "0f933801a07767652de4c30f5f7678e44db8e2317ac37226120b30d82cd97ef5"
end
depends_on "cmake" => :build
depends_on "googletest" => :build
depends_on "boost"
depends_on "icu4c"
depends_on "protobuf"
depends_on "re2"
def install
ENV.cxx11
system "cmake", "cpp", "-DGTEST_INCLUDE_DIR=#{Formula["googletest"].include}",
*std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <phonenumbers/phonenumberutil.h>
#include <phonenumbers/phonenumber.pb.h>
#include <iostream>
#include <string>
using namespace i18n::phonenumbers;
int main() {
PhoneNumberUtil *phone_util_ = PhoneNumberUtil::GetInstance();
PhoneNumber test_number;
string formatted_number;
test_number.set_country_code(1);
test_number.set_national_number(6502530000ULL);
phone_util_->Format(test_number, PhoneNumberUtil::E164, &formatted_number);
if (formatted_number == "+16502530000") {
return 0;
} else {
return 1;
}
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test"
system "./test"
end
end
|
require File.expand_path("../../Requirements/qgis_requirements",
Pathname.new(__FILE__).realpath)
class Qgis2 < Formula
desc "Open Source Geographic Information System"
homepage "https://www.qgis.org"
revision 1
head "https://github.com/qgis/QGIS.git", :branch => "release-2_18"
stable do
url "https://github.com/qgis/QGIS/archive/final-2_18_13.tar.gz"
sha256 "de26fb9ee5394414f9410543bc7f7731d071ce3d8310ef40abb497a080a9619b"
# patches that represent all backports to release-2_18 branch, since release tag
# see: https://github.com/qgis/QGIS/commits/release-2_18
# patch do
# # thru commit ?, minus windows-formatted patches
# # (just commit https://github.com/qgis/QGIS/commit/5e1e441 for now)
# url ""
# sha256 ""
# end
end
bottle do
root_url "http://qgis.dakotacarto.com/bottles"
sha256 "7dc855eddec6571e18a79ff3bcbaf3b2f5113874394c64120eb5cfb5b202e0e2" => :sierra
sha256 "7dc855eddec6571e18a79ff3bcbaf3b2f5113874394c64120eb5cfb5b202e0e2" => :high_sierra
end
def pour_bottle?
brewed_python?
end
option "with-isolation", "Isolate .app's environment to HOMEBREW_PREFIX, to coexist with other QGIS installs"
option "without-debug", "Disable debug build, which outputs info to system.log or console"
option "without-server", "Build without QGIS Server (qgis_mapserv.fcgi)"
option "without-postgresql", "Build without current PostgreSQL client"
option "with-gdal-1", "Build with GDAL/OGR v1.x instead of v2.x"
option "with-globe", "Build with Globe plugin, based upon osgEarth"
option "with-grass", "Build with GRASS 7 integration plugin and Processing plugin support (or install grass-7x first)"
option "with-grass6", "Build extra GRASS 6 for Processing plugin"
option "with-oracle", "Build extra Oracle geospatial database and raster support"
option "with-orfeo5", "Build extra Orfeo Toolbox for Processing plugin"
option "with-r", "Build extra R for Processing plugin"
option "with-saga-gis-lts", "Build extra Saga GIS for Processing plugin"
# option "with-qt-mysql", "Build extra Qt MySQL plugin for eVis plugin"
option "with-qspatialite", "Build QSpatialite Qt database driver"
option "with-api-docs", "Build the API documentation with Doxygen and Graphviz"
# depends on UnlinkedQGIS2
# core qgis
depends_on "cmake" => :build
depends_on "bison" => :build
depends_on "flex" => :build
if build.with? "api-docs"
depends_on "graphviz" => :build
depends_on "doxygen" => :build
end
depends_on (build.with?("isolation") || MacOS.version < :lion) ? "python" : :python
depends_on "qt-4"
depends_on "sip-qt4"
depends_on "pyqt-qt4"
depends_on "qca-qt4"
depends_on "qscintilla2-qt4"
depends_on "qwt-qt4"
depends_on "qwtpolar-qt4"
depends_on "qjson-qt4"
depends_on "gsl"
depends_on "sqlite" # keg_only
depends_on "expat" # keg_only
depends_on "proj"
depends_on "spatialindex"
depends_on "fcgi" if build.with? "server"
# use newer postgresql client than Apple's, also needed by `psycopg2`
depends_on "postgresql" => :recommended
# core providers
if build.with? "gdal-1"
depends_on "gdal"
else
depends_on "gdal2"
depends_on "gdal2-python"
end
depends_on "oracle-client-sdk" if build.with? "oracle"
# TODO: add MSSQL third-party support formula?, :optional
# core plugins (c++ and python)
if build.with?("grass") || (HOMEBREW_PREFIX/"opt/grass7").exist?
depends_on "grass7"
depends_on "gettext"
end
if build.with? "globe"
# this is pretty borked with OS X >= 10.10+
# depends on "open-scene-graph" => ["with-qt"]
depends_on "open-scene-graph"
depends_on "homebrew/science/osgearth"
end
depends_on "gpsbabel-qt4" => :optional
# TODO: remove "pyspatialite" when PyPi package supports spatialite 4.x
# or DB Manager supports libspatialite >= 4.2.0 (with mod_spatialite)
depends_on "pyspatialite" # for DB Manager
# depends on "qt-mysql" => :optional # for eVis plugin (non-functional in 2.x?)
# core processing plugin extras
# see `grass` above
depends_on "grass6" => :optional
depends_on "orfeo5" => :optional
depends_on "r" => :optional
depends_on "saga-gis-lts" => :optional
# TODO: LASTools straight build (2 reporting tools), or via `wine` (10 tools)
# TODO: Fusion from USFS (via `wine`?)
resource "pyqgis-startup" do
url "https://gist.githubusercontent.com/dakcarto/11385561/raw/e49f75ecec96ed7d6d3950f45ad3f30fe94d4fb2/pyqgis_startup.py"
sha256 "385dce925fc2d29f05afd6508bc1f46ec84c0bc607cc0c8dfce78a4bb93b9c4e"
version "2.14.0"
end
def install
# Set bundling level back to 0 (the default in all versions prior to 1.8.0)
# so that no time and energy is wasted copying the Qt frameworks into QGIS.
# Install custom widgets Designer plugin to local qt-4 plugins prefix
inreplace "src/customwidgets/CMakeLists.txt",
"${QT_PLUGINS_DIR}/designer", lib_qt4/"plugins/designer".to_s
# Fix custom widgets designer module install path
# TODO: add for QtWebkit bindings and PYQT5_MOD_DIR in qgis-dev
inreplace "CMakeLists.txt",
"${PYQT4_MOD_DIR}", lib_qt4/"python2.7/site-packages/PyQt4".to_s
# Install qspatialite db plugin to local qt-4 plugins prefix
if build.with? "qspatialite"
inreplace "src/providers/spatialite/qspatialite/CMakeLists.txt",
"${QT_PLUGINS_DIR}/sqldrivers", lib_qt4/"plugins/sqldrivers".to_s
end
qwt_fw = Formula["qwt-qt4"].opt_lib/"qwt.framework"
qwtpolar_fw = Formula["qwtpolar-qt4"].opt_lib/"qwtpolar.framework"
qsci_opt = Formula["qscintilla2-qt4"].opt_prefix
args = std_cmake_args
args << "-DCMAKE_BUILD_TYPE=RelWithDebInfo" if build.with? "debug" # override
args += %W[
-DBISON_EXECUTABLE=#{Formula["bison"].opt_bin}/bison
-DFLEX_EXECUTABLE=#{Formula["flex"].opt_bin}/flex
-DENABLE_TESTS=FALSE
-DENABLE_MODELTEST=FALSE
-DSUPPRESS_QT_WARNINGS=TRUE
-DQWT_INCLUDE_DIR=#{qwt_fw}/Headers
-DQWT_LIBRARY=#{qwt_fw}/qwt
-DQWTPOLAR_INCLUDE_DIR=#{qwtpolar_fw}/Headers
-DQWTPOLAR_LIBRARY=#{qwtpolar_fw}/qwtpolar
-DQSCINTILLA_INCLUDE_DIR=#{qsci_opt}/libexec/include
-DQSCINTILLA_LIBRARY=#{qsci_opt}/libexec/lib/libqscintilla2.dylib
-DQSCI_SIP_DIR=#{qsci_opt}/share/sip-qt4
-DWITH_QWTPOLAR=TRUE
-DWITH_INTERNAL_QWTPOLAR=FALSE
-DQGIS_MACAPP_BUNDLE=0
-DQGIS_MACAPP_INSTALL_DEV=FALSE
-DWITH_QSCIAPI=FALSE
-DWITH_STAGED_PLUGINS=TRUE
-DWITH_GRASS=FALSE
-DWITH_CUSTOM_WIDGETS=TRUE
]
if build.without? "gdal-1"
args << "-DGDAL_LIBRARY=#{Formula["gdal2"].opt_lib}/libgdal.dylib"
args << "-DGDAL_INCLUDE_DIR=#{Formula["gdal2"].opt_include}"
# These specific includes help ensure any gdal v1 includes are not
# accidentally pulled from /usr/local/include
# In CMakeLists.txt throughout QGIS source tree these includes may come
# before opt/gdal2/include; 'fixing' many CMakeLists.txt may be unwise
args << "-DGEOS_INCLUDE_DIR=#{Formula["geos"].opt_include}"
args << "-DGSL_INCLUDE_DIR=#{Formula["gsl"].opt_include}"
args << "-DPROJ_INCLUDE_DIR=#{Formula["proj"].opt_include}"
args << "-DQCA_INCLUDE_DIR=#{Formula["qca-qt4"].opt_lib}/qca.framework/Headers"
args << "-DSPATIALINDEX_INCLUDE_DIR=#{Formula["spatialindex"].opt_include}/spatialindex"
args << "-DSPATIALITE_INCLUDE_DIR=#{Formula["libspatialite"].opt_include}"
args << "-DSQLITE3_INCLUDE_DIR=#{Formula["sqlite"].opt_include}"
end
args << "-DPYTHON_EXECUTABLE='#{`python2 -c "import sys; print(sys.executable)"`.chomp}'"
args << "-DPYTHON_CUSTOM_FRAMEWORK='#{`python2 -c "import sys; print(sys.prefix)"`.chomp}'"
# find git revision for HEAD build
if build.head? && File.exist?("#{cached_download}/.git/index")
args << "-DGITCOMMAND=#{Formula["git"].opt_bin}/git"
args << "-DGIT_MARKER=#{cached_download}/.git/index"
end
args << "-DWITH_SERVER=#{build.with?("server") ? "TRUE" : "FALSE"}"
if build.with? "server"
fcgi_opt = Formula["fcgi"].opt_prefix
args << "-DFCGI_INCLUDE_DIR=#{fcgi_opt}/include"
args << "-DFCGI_LIBRARY=#{fcgi_opt}/lib/libfcgi.dylib"
end
args << "-DPOSTGRES_CONFIG=#{Formula["postgresql"].opt_bin}/pg_config" if build.with? "postgresql"
args << "-DWITH_GRASS7=#{(build.with?("grass") || brewed_grass7?) ? "TRUE" : "FALSE"}"
if build.with?("grass") || brewed_grass7?
# this is to build the GRASS Plugin, not for Processing plugin support
grass7 = Formula["grass7"]
args << "-DGRASS_PREFIX7='#{grass7.opt_prefix}/grass-base'"
# Keep superenv from stripping (use Cellar prefix)
ENV.append "CXXFLAGS", "-isystem #{grass7.prefix.resolved_path}/grass-base/include"
# So that `libintl.h` can be found (use Cellar prefix)
ENV.append "CXXFLAGS", "-isystem #{Formula["gettext"].include.resolved_path}"
end
args << "-DWITH_GLOBE=#{build.with?("globe") ? "TRUE" : "FALSE"}"
if build.with? "globe"
osg = Formula["open-scene-graph"]
opoo "`open-scene-graph` formula's keg not linked." unless osg.linked_keg.exist?
# must be HOMEBREW_PREFIX/lib/osgPlugins-#.#.#, since all osg plugins are symlinked there
args << "-DOSG_PLUGINS_PATH=#{HOMEBREW_PREFIX}/lib/osgPlugins-#{osg.version}"
end
args << "-DWITH_ORACLE=#{build.with?("oracle") ? "TRUE" : "FALSE"}"
if build.with? "oracle"
oracle_opt = Formula["oracle-client-sdk"].opt_prefix
args << "-DOCI_INCLUDE_DIR=#{oracle_opt}/include/oci"
args << "-DOCI_LIBRARY=#{oracle_opt}/lib/libclntsh.dylib"
end
args << "-DWITH_QSPATIALITE=#{build.with?("qspatialite") ? "TRUE" : "FALSE"}"
args << "-DWITH_APIDOC=#{build.with?("api-docs") ? "TRUE" : "FALSE"}"
# Avoid ld: framework not found QtSql
# (https://github.com/Homebrew/homebrew-science/issues/23)
ENV.append "CXXFLAGS", "-F#{Formula["qt-4"].opt_lib}"
# if using Homebrew's Python, make sure its components are always found first
# see: https://github.com/Homebrew/homebrew/pull/28597
ENV["PYTHONHOME"] = brewed_python_framework.to_s if brewed_python?
# handle custom site-packages for qt-4 keg-only modules and packages
ENV["PYTHONPATH"] = python_qt4_site_packages
# handle some compiler warnings
ENV["CXX_EXTRA_FLAGS"] = "-Wno-unused-private-field -Wno-deprecated-register"
if ENV.compiler == :clang && (MacOS::Xcode.version >= "7.0" || MacOS::CLT.version >= "7.0")
ENV.append "CXX_EXTRA_FLAGS", "-Wno-inconsistent-missing-override"
end
mkdir "build" do
# bbedit = "/usr/local/bin/bbedit"
# cmake_config = Pathname("#{Dir.pwd}/#{name}_cmake-config.txt")
# cmake_config.write ["cmake ..", *args].join(" \\\n")
# system bbedit, cmake_config.to_s
# raise
system "cmake", "..", *args
# system bbedit, "CMakeCache.txt"
# raise
system "make"
system "make", "install"
end
# Fixup some errant lib linking
# TODO: fix upstream in CMake
dy_libs = [lib_qt4/"plugins/designer/libqgis_customwidgets.dylib"]
dy_libs << lib_qt4/"plugins/sqldrivers/libqsqlspatialite.dylib" if build.with? "qspatialite"
dy_libs.each do |dy_lib|
MachO::Tools.dylibs(dy_lib.to_s).each do |i_n|
%w[core gui].each do |f_n|
sufx = i_n[/(qgis_#{f_n}\.framework.*)/, 1]
next if sufx.nil?
i_n_to = "#{opt_prefix}/QGIS.app/Contents/Frameworks/#{sufx}"
puts "Changing install name #{i_n} to #{i_n_to} in #{dy_lib}" if ARGV.debug?
dy_lib.ensure_writable do
MachO::Tools.change_install_name(dy_lib.to_s, i_n.to_s, i_n_to, :strict => false)
end
end
end
end
# Update .app's bundle identifier, so Kyngchaos.com installer doesn't get confused
inreplace prefix/"QGIS.app/Contents/Info.plist",
"org.qgis.qgis2", "org.qgis.qgis2-hb#{build.head? ? "-dev" : ""}"
py_lib = libexec/"python2.7/site-packages"
py_lib.mkpath
ln_s "../../../QGIS.app/Contents/Resources/python/qgis", py_lib/"qgis"
ln_s "QGIS.app/Contents/MacOS/fcgi-bin", prefix/"fcgi-bin" if build.with? "server"
doc.mkpath
mv prefix/"QGIS.app/Contents/Resources/doc/api", doc/"api" if build.with? "api-docs"
ln_s "../../../QGIS.app/Contents/Resources/doc", doc/"doc"
# copy PYQGIS_STARTUP file pyqgis_startup.py, even if not isolating (so tap can be untapped)
# only works with QGIS > 2.0.1
# doesn't need executable bit set, loaded by Python runner in QGIS
libexec.install resource("pyqgis-startup")
bin.mkdir
qgis_bin = bin/name.to_s
touch qgis_bin.to_s # so it will be linked into HOMEBREW_PREFIX
qgis_bin.chmod 0755
post_install
end
def post_install
# configure environment variables for .app and launching binary directly.
# having this in `post_intsall` allows it to be individually run *after* installation with:
# `brew postinstall -v <formula-name>`
app = prefix/"QGIS.app"
tab = Tab.for_formula(self)
opts = tab.used_options
# bottle_poured = tab.poured_from_bottle
# define default isolation env vars
pthsep = File::PATH_SEPARATOR
pypth = python_site_packages.to_s
pths = %w[/usr/bin /bin /usr/sbin /sbin /opt/X11/bin /usr/X11/bin]
unless opts.include?("with-isolation")
pths = ORIGINAL_PATHS.dup
pyenv = ENV["PYTHONPATH"]
if pyenv
pypth = pyenv.include?(pypth) ? pyenv : pypth + pthsep + pyenv
end
end
unless pths.include?(HOMEBREW_PREFIX/"bin")
pths = pths.insert(0, HOMEBREW_PREFIX/"bin")
end
# set qt-4's then install's libexec/python2.7/site-packages first, so app will work if unlinked
pypths = %W[#{python_qt4_site_packages} #{opt_libexec}/python2.7/site-packages #{pypth}]
unless opts.include?("with-gdal-1")
pths.insert(0, Formula["gdal2"].opt_bin.to_s)
pths.insert(0, Formula["gdal2-python"].opt_bin.to_s)
pypths.insert(0, "#{Formula["gdal2-python"].opt_lib}/python2.7/site-packages")
end
# prepend qt-4 based utils to PATH (reverse order)
pths.insert(0, Formula["qca-qt4"].opt_bin.to_s)
pths.insert(0, Formula["pyqt-qt4"].opt_bin.to_s)
pths.insert(0, "#{Formula["sip-qt4"].opt_libexec}/bin")
pths.insert(0, Formula["qt-4"].opt_bin.to_s)
if opts.include?("with-gpsbabel-qt4")
pths.insert(0, Formula["gpsbabel-qt4"].opt_bin.to_s)
end
envars = {
:PATH => pths.join(pthsep),
:PYTHONPATH => pypths.join(pthsep),
:GDAL_DRIVER_PATH => "#{HOMEBREW_PREFIX}/lib/gdalplugins",
}
envars[:GDAL_DATA] = "#{Formula[opts.include?("with-gdal-1") ? "gdal": "gdal2"].opt_share}/gdal"
proc_algs = "Contents/Resources/python/plugins/processing/algs"
if opts.include?("with-grass") || brewed_grass7?
grass7 = Formula["grass7"]
# for core integration plugin support
envars[:GRASS_PREFIX] = "#{grass7.opt_prefix}/grass-base"
begin
inreplace app/"#{proc_algs}/grass7/Grass7Utils.py",
"/Applications/GRASS-7.0.app/Contents/MacOS",
"#{grass7.opt_prefix}/grass-base"
puts "GRASS 7 GrassUtils.py has been updated"
rescue Utils::InreplaceError
puts "GRASS 7 GrassUtils.py already updated"
end
end
if opts.include?("with-grass6") || brewed_grass6?
grass6 = Formula["grass6"]
begin
inreplace app/"#{proc_algs}/grass/GrassUtils.py",
"/Applications/GRASS-6.4.app/Contents/MacOS",
"#{grass6.opt_prefix}/grass-base"
puts "GRASS 6 GrassUtils.py has been updated"
rescue Utils::InreplaceError
puts "GRASS 6 GrassUtils.py already updated"
end
end
if opts.include?("with-orfeo5") || brewed_orfeo5?
orfeo5 = Formula["orfeo5"]
begin
inreplace app/"#{proc_algs}/otb/OTBUtils.py" do |s|
# default geoid path
# try to replace first, so it fails (if already done) before global replaces
s.sub! "OTB_GEOID_FILE) or ''", "OTB_GEOID_FILE) or '#{orfeo5.opt_libexec}/default_geoid/egm96.grd'"
# default bin and lib path
s.gsub! "/usr/local/bin", orfeo5.opt_bin.to_s
s.gsub! "/usr/local/lib", orfeo5.opt_lib.to_s
end
puts "ORFEO 5 OTBUtils.py has been updated"
rescue Utils::InreplaceError
puts "ORFEO 5 OTBUtils.py already updated"
end
end
unless opts.include?("without-globe")
osg = Formula["open-scene-graph"]
envars[:OSG_LIBRARY_PATH] = "#{HOMEBREW_PREFIX}/lib/osgPlugins-#{osg.version}"
end
if opts.include?("with-isolation")
envars[:DYLD_FRAMEWORK_PATH] = "#{HOMEBREW_PREFIX}/Frameworks:/System/Library/Frameworks"
versioned = %W[
#{Formula["sqlite"].opt_lib}
#{Formula["expat"].opt_lib}
#{Formula["libxml2"].opt_lib}
#{HOMEBREW_PREFIX}/lib
]
envars[:DYLD_VERSIONED_LIBRARY_PATH] = versioned.join(pthsep)
end
if opts.include?("with-isolation") || File.exist?("/Library/Frameworks/GDAL.framework")
envars[:PYQGIS_STARTUP] = opt_libexec/"pyqgis_startup.py"
end
# envars.each { |key, value| puts "#{key.to_s}=#{value}" }
# exit
# add env vars to QGIS.app's Info.plist, in LSEnvironment section
plst = app/"Contents/Info.plist"
# first delete any LSEnvironment setting, ignoring errors
# CAUTION!: may not be what you want, if .app already has LSEnvironment settings
dflt = `defaults read-type \"#{plst}\" LSEnvironment 2> /dev/null`
`defaults delete \"#{plst}\" LSEnvironment` if dflt
kv = "{ "
envars.each { |key, value| kv += "'#{key}' = '#{value}'; " }
kv += "}"
`defaults write \"#{plst}\" LSEnvironment \"#{kv}\"`
# add ability to toggle high resolution in Get Info dialog for app
hrc = `defaults read-type \"#{plst}\" NSHighResolutionCapable 2> /dev/null`
`defaults delete \"#{plst}\" NSHighResolutionCapable` if hrc
`defaults write \"#{plst}\" NSHighResolutionCapable \"False\"`
# leave the plist readable; convert from binary to XML format
`plutil -convert xml1 -- \"#{plst}\"`
# make sure plist is readble by all users
plst.chmod 0644
# update modification date on app bundle, or changes won't take effect
touch app.to_s
# add env vars to launch script for QGIS app's binary
qgis_bin = bin/name.to_s
rm_f qgis_bin if File.exist?(qgis_bin) # install generates empty file
bin_cmds = %W[#!/bin/sh\n]
# setup shell-prepended env vars (may result in duplication of paths)
unless pths.include? HOMEBREW_PREFIX/"bin"
pths.insert(0, HOMEBREW_PREFIX/"bin")
end
# even though this should be affected by with-isolation, allow local env override
pths << "$PATH"
pypths << "$PYTHONPATH"
envars[:PATH] = pths.join(pthsep)
envars[:PYTHONPATH] = pypths.join(pthsep)
envars.each { |key, value| bin_cmds << "export #{key}=#{value}" }
bin_cmds << opt_prefix/"QGIS.app/Contents/MacOS/QGIS \"$@\""
qgis_bin.write(bin_cmds.join("\n"))
qgis_bin.chmod 0755
end
def caveats
s = <<-EOS.undent
Bottles support only Homebrew's Python
QGIS is built as an application bundle. Environment variables for the
Homebrew prefix are embedded in QGIS.app:
#{opt_prefix}/QGIS.app
You may also symlink QGIS.app into /Applications or ~/Applications:
brew linkapps [--local]
To directly run the `QGIS.app/Contents/MacOS/QGIS` binary use the wrapper
script pre-defined with Homebrew prefix environment variables:
#{opt_bin}/#{name}
NOTE: Your current PATH and PYTHONPATH environment variables are honored
when launching via the wrapper script, while launching QGIS.app
bundle they are not.
For standalone Python development, set the following environment variable:
export PYTHONPATH=#{libexec/"python2.7/site-packages"}:#{python_qt4_site_packages}:#{python_site_packages}:$PYTHONPATH
EOS
if build.with? "isolation"
s += <<-EOS.undent
QGIS built with isolation enabled. This allows it to coexist with other
types of installations of QGIS on your Mac. However, on versions >= 2.0.1,
this also means Python modules installed in the *system* Python will NOT
be available to Python processes within QGIS.app.
EOS
end
# check for required run-time Python module dependencies
# TODO: add "pyspatialite" when PyPi package supports spatialite 4.x
xm = []
%w[psycopg2 matplotlib pyparsing requests future jinja2 pygments].each do |m|
xm << m unless module_importable? m
end
unless xm.empty?
s += <<-EOS.undent
#{Tty.red}
The following Python modules are needed by QGIS during run-time:
#{xm.join(", ")}
You can install manually, via installer package or with `pip` (if availble):
pip install <module> OR pip-2.7 install <module>
#{Tty.red}
#{Tty.reset}
EOS
end
# TODO: remove this when libqscintilla.dylib becomes core build dependency?
unless module_importable? "PyQt4.Qsci"
s += <<-EOS.undent
QScintilla Python module is needed by QGIS during run-time.
Ensure `qscintilla2-qt4` formula is linked.
EOS
end
s += <<-EOS.undent
If you have built GRASS 6.4.x or 7.0.x support for the Processing plugin set
the following in QGIS:
Processing->Options: Providers->GRASS commands->GRASS folder to:
#{HOMEBREW_PREFIX}/opt/grass6/grass-base
Processing->Options: Providers->GRASS GIS 7 commands->GRASS 7 folder to:
#{HOMEBREW_PREFIX}/opt/grass7/grass-base
EOS
s
end
test do
output = `#{bin}/#{name.to_s} --help 2>&1` # why does help go to stderr?
assert_match /^QGIS is a user friendly/, output
end
private
def brewed_grass7?
Formula["grass7"].opt_prefix.exist?
end
def brewed_grass6?
Formula["grass6"].opt_prefix.exist?
end
def brewed_orfeo5?
Formula["orfeo5"].opt_prefix.exist?
end
def brewed_python_framework
HOMEBREW_PREFIX/"Frameworks/Python.framework/Versions/2.7"
end
def brewed_python_framework?
brewed_python_framework.exist?
end
def brewed_python?
Formula["python"].linked_keg.exist? && brewed_python_framework?
end
def python_exec
if brewed_python?
brewed_python_framework/"bin/python2"
else
which("python")
end
end
def python_incdir
Pathname.new(`#{python_exec} -c "from distutils import sysconfig; print(sysconfig.get_python_inc())"`.strip)
end
def python_libdir
Pathname.new(`#{python_exec} -c "from distutils import sysconfig; print(sysconfig.get_config_var('LIBPL'))"`.strip)
end
def python_site_packages
HOMEBREW_PREFIX/"lib/python2.7/site-packages"
end
def hb_lib_qt4
HOMEBREW_PREFIX/"lib/qt-4"
end
def python_qt4_site_packages
hb_lib_qt4/"python2.7/site-packages"
end
def lib_qt4
lib/"qt-4"
end
def opt_lib_qt4
opt_lib/"qt-4"
end
def module_importable?(mod)
quiet_system python_exec, "-c", "import sys;sys.path.insert(1, '#{python_qt4_site_packages}'); import #{mod}"
end
end
qgis2: fix Qt4 plugin installs; define QT_PLUGIN_PATH for multi-paths
[ci skip]
require File.expand_path("../../Requirements/qgis_requirements",
Pathname.new(__FILE__).realpath)
class Qgis2 < Formula
desc "Open Source Geographic Information System"
homepage "https://www.qgis.org"
revision 1
head "https://github.com/qgis/QGIS.git", :branch => "release-2_18"
stable do
url "https://github.com/qgis/QGIS/archive/final-2_18_13.tar.gz"
sha256 "de26fb9ee5394414f9410543bc7f7731d071ce3d8310ef40abb497a080a9619b"
# patches that represent all backports to release-2_18 branch, since release tag
# see: https://github.com/qgis/QGIS/commits/release-2_18
# patch do
# # thru commit ?, minus windows-formatted patches
# url ""
# sha256 ""
# end
end
bottle do
root_url "http://qgis.dakotacarto.com/bottles"
sha256 "7dc855eddec6571e18a79ff3bcbaf3b2f5113874394c64120eb5cfb5b202e0e2" => :sierra
sha256 "7dc855eddec6571e18a79ff3bcbaf3b2f5113874394c64120eb5cfb5b202e0e2" => :high_sierra
end
def pour_bottle?
brewed_python?
end
option "with-isolation", "Isolate .app's environment to HOMEBREW_PREFIX, to coexist with other QGIS installs"
option "without-debug", "Disable debug build, which outputs info to system.log or console"
option "without-server", "Build without QGIS Server (qgis_mapserv.fcgi)"
option "without-postgresql", "Build without current PostgreSQL client"
option "with-gdal-1", "Build with GDAL/OGR v1.x instead of v2.x"
option "with-globe", "Build with Globe plugin, based upon osgEarth"
option "with-grass", "Build with GRASS 7 integration plugin and Processing plugin support (or install grass-7x first)"
option "with-grass6", "Build extra GRASS 6 for Processing plugin"
option "with-oracle", "Build extra Oracle geospatial database and raster support"
option "with-orfeo5", "Build extra Orfeo Toolbox for Processing plugin"
option "with-r", "Build extra R for Processing plugin"
option "with-saga-gis-lts", "Build extra Saga GIS for Processing plugin"
# option "with-qt-mysql", "Build extra Qt MySQL plugin for eVis plugin"
option "with-qspatialite", "Build QSpatialite Qt database driver"
option "with-api-docs", "Build the API documentation with Doxygen and Graphviz"
# depends on UnlinkedQGIS2
# core qgis
depends_on "cmake" => :build
depends_on "bison" => :build
depends_on "flex" => :build
if build.with? "api-docs"
depends_on "graphviz" => :build
depends_on "doxygen" => :build
end
depends_on (build.with?("isolation") || MacOS.version < :lion) ? "python" : :python
depends_on "qt-4"
depends_on "sip-qt4"
depends_on "pyqt-qt4"
depends_on "qca-qt4"
depends_on "qscintilla2-qt4"
depends_on "qwt-qt4"
depends_on "qwtpolar-qt4"
depends_on "qjson-qt4"
depends_on "gsl"
depends_on "sqlite" # keg_only
depends_on "expat" # keg_only
depends_on "proj"
depends_on "spatialindex"
depends_on "fcgi" if build.with? "server"
# use newer postgresql client than Apple's, also needed by `psycopg2`
depends_on "postgresql" => :recommended
# core providers
if build.with? "gdal-1"
depends_on "gdal"
else
depends_on "gdal2"
depends_on "gdal2-python"
end
depends_on "oracle-client-sdk" if build.with? "oracle"
# TODO: add MSSQL third-party support formula?, :optional
# core plugins (c++ and python)
if build.with?("grass") || (HOMEBREW_PREFIX/"opt/grass7").exist?
depends_on "grass7"
depends_on "gettext"
end
if build.with? "globe"
# this is pretty borked with OS X >= 10.10+
# depends on "open-scene-graph" => ["with-qt"]
depends_on "open-scene-graph"
depends_on "homebrew/science/osgearth"
end
depends_on "gpsbabel-qt4" => :optional
# TODO: remove "pyspatialite" when PyPi package supports spatialite 4.x
# or DB Manager supports libspatialite >= 4.2.0 (with mod_spatialite)
depends_on "pyspatialite" # for DB Manager
# depends on "qt-mysql" => :optional # for eVis plugin (non-functional in 2.x?)
# core processing plugin extras
# see `grass` above
depends_on "grass6" => :optional
depends_on "orfeo5" => :optional
depends_on "r" => :optional
depends_on "saga-gis-lts" => :optional
# TODO: LASTools straight build (2 reporting tools), or via `wine` (10 tools)
# TODO: Fusion from USFS (via `wine`?)
resource "pyqgis-startup" do
url "https://gist.githubusercontent.com/dakcarto/11385561/raw/e49f75ecec96ed7d6d3950f45ad3f30fe94d4fb2/pyqgis_startup.py"
sha256 "385dce925fc2d29f05afd6508bc1f46ec84c0bc607cc0c8dfce78a4bb93b9c4e"
version "2.14.0"
end
def install
# Set bundling level back to 0 (the default in all versions prior to 1.8.0)
# so that no time and energy is wasted copying the Qt frameworks into QGIS.
# Install custom widgets Designer plugin to local qt-4 plugins prefix
inreplace "src/customwidgets/CMakeLists.txt",
"${QT_PLUGINS_DIR}/designer", lib_qt4/"plugins/designer".to_s
# Fix custom widgets Designer module install path
inreplace "CMakeLists.txt",
"${PYQT4_MOD_DIR}", lib_qt4/"python2.7/site-packages/PyQt4".to_s
# Install db plugins to local qt-4 plugins prefix
if build.with? "qspatialite"
inreplace "src/providers/spatialite/qspatialite/CMakeLists.txt",
"${QT_PLUGINS_DIR}/sqldrivers", lib_qt4/"plugins/sqldrivers".to_s
end
if build.with? "oracle"
inreplace "src/providers/oracle/ocispatial/CMakeLists.txt",
"${QT_PLUGINS_DIR}/sqldrivers", lib_qt4/"plugins/sqldrivers".to_s
end
qwt_fw = Formula["qwt-qt4"].opt_lib/"qwt.framework"
qwtpolar_fw = Formula["qwtpolar-qt4"].opt_lib/"qwtpolar.framework"
qsci_opt = Formula["qscintilla2-qt4"].opt_prefix
args = std_cmake_args
args << "-DCMAKE_BUILD_TYPE=RelWithDebInfo" if build.with? "debug" # override
args += %W[
-DBISON_EXECUTABLE=#{Formula["bison"].opt_bin}/bison
-DFLEX_EXECUTABLE=#{Formula["flex"].opt_bin}/flex
-DENABLE_TESTS=FALSE
-DENABLE_MODELTEST=FALSE
-DSUPPRESS_QT_WARNINGS=TRUE
-DQWT_INCLUDE_DIR=#{qwt_fw}/Headers
-DQWT_LIBRARY=#{qwt_fw}/qwt
-DQWTPOLAR_INCLUDE_DIR=#{qwtpolar_fw}/Headers
-DQWTPOLAR_LIBRARY=#{qwtpolar_fw}/qwtpolar
-DQSCINTILLA_INCLUDE_DIR=#{qsci_opt}/libexec/include
-DQSCINTILLA_LIBRARY=#{qsci_opt}/libexec/lib/libqscintilla2.dylib
-DQSCI_SIP_DIR=#{qsci_opt}/share/sip-qt4
-DWITH_QWTPOLAR=TRUE
-DWITH_INTERNAL_QWTPOLAR=FALSE
-DQGIS_MACAPP_BUNDLE=0
-DQGIS_MACAPP_INSTALL_DEV=FALSE
-DWITH_QSCIAPI=FALSE
-DWITH_STAGED_PLUGINS=TRUE
-DWITH_GRASS=FALSE
-DWITH_CUSTOM_WIDGETS=TRUE
]
if build.without? "gdal-1"
args << "-DGDAL_LIBRARY=#{Formula["gdal2"].opt_lib}/libgdal.dylib"
args << "-DGDAL_INCLUDE_DIR=#{Formula["gdal2"].opt_include}"
# These specific includes help ensure any gdal v1 includes are not
# accidentally pulled from /usr/local/include
# In CMakeLists.txt throughout QGIS source tree these includes may come
# before opt/gdal2/include; 'fixing' many CMakeLists.txt may be unwise
args << "-DGEOS_INCLUDE_DIR=#{Formula["geos"].opt_include}"
args << "-DGSL_INCLUDE_DIR=#{Formula["gsl"].opt_include}"
args << "-DPROJ_INCLUDE_DIR=#{Formula["proj"].opt_include}"
args << "-DQCA_INCLUDE_DIR=#{Formula["qca-qt4"].opt_lib}/qca.framework/Headers"
args << "-DSPATIALINDEX_INCLUDE_DIR=#{Formula["spatialindex"].opt_include}/spatialindex"
args << "-DSPATIALITE_INCLUDE_DIR=#{Formula["libspatialite"].opt_include}"
args << "-DSQLITE3_INCLUDE_DIR=#{Formula["sqlite"].opt_include}"
end
args << "-DPYTHON_EXECUTABLE='#{`python2 -c "import sys; print(sys.executable)"`.chomp}'"
args << "-DPYTHON_CUSTOM_FRAMEWORK='#{`python2 -c "import sys; print(sys.prefix)"`.chomp}'"
# find git revision for HEAD build
if build.head? && File.exist?("#{cached_download}/.git/index")
args << "-DGITCOMMAND=#{Formula["git"].opt_bin}/git"
args << "-DGIT_MARKER=#{cached_download}/.git/index"
end
args << "-DWITH_SERVER=#{build.with?("server") ? "TRUE" : "FALSE"}"
if build.with? "server"
fcgi_opt = Formula["fcgi"].opt_prefix
args << "-DFCGI_INCLUDE_DIR=#{fcgi_opt}/include"
args << "-DFCGI_LIBRARY=#{fcgi_opt}/lib/libfcgi.dylib"
end
args << "-DPOSTGRES_CONFIG=#{Formula["postgresql"].opt_bin}/pg_config" if build.with? "postgresql"
args << "-DWITH_GRASS7=#{(build.with?("grass") || brewed_grass7?) ? "TRUE" : "FALSE"}"
if build.with?("grass") || brewed_grass7?
# this is to build the GRASS Plugin, not for Processing plugin support
grass7 = Formula["grass7"]
args << "-DGRASS_PREFIX7='#{grass7.opt_prefix}/grass-base'"
# Keep superenv from stripping (use Cellar prefix)
ENV.append "CXXFLAGS", "-isystem #{grass7.prefix.resolved_path}/grass-base/include"
# So that `libintl.h` can be found (use Cellar prefix)
ENV.append "CXXFLAGS", "-isystem #{Formula["gettext"].include.resolved_path}"
end
args << "-DWITH_GLOBE=#{build.with?("globe") ? "TRUE" : "FALSE"}"
if build.with? "globe"
osg = Formula["open-scene-graph"]
opoo "`open-scene-graph` formula's keg not linked." unless osg.linked_keg.exist?
# must be HOMEBREW_PREFIX/lib/osgPlugins-#.#.#, since all osg plugins are symlinked there
args << "-DOSG_PLUGINS_PATH=#{HOMEBREW_PREFIX}/lib/osgPlugins-#{osg.version}"
end
args << "-DWITH_ORACLE=#{build.with?("oracle") ? "TRUE" : "FALSE"}"
if build.with? "oracle"
oracle_opt = Formula["oracle-client-sdk"].opt_prefix
args << "-DOCI_INCLUDE_DIR=#{oracle_opt}/include/oci"
args << "-DOCI_LIBRARY=#{oracle_opt}/lib/libclntsh.dylib"
end
args << "-DWITH_QSPATIALITE=#{build.with?("qspatialite") ? "TRUE" : "FALSE"}"
args << "-DWITH_APIDOC=#{build.with?("api-docs") ? "TRUE" : "FALSE"}"
# Avoid ld: framework not found QtSql
# (https://github.com/Homebrew/homebrew-science/issues/23)
ENV.append "CXXFLAGS", "-F#{Formula["qt-4"].opt_lib}"
# if using Homebrew's Python, make sure its components are always found first
# see: https://github.com/Homebrew/homebrew/pull/28597
ENV["PYTHONHOME"] = brewed_python_framework.to_s if brewed_python?
# handle custom site-packages for qt-4 keg-only modules and packages
ENV["PYTHONPATH"] = python_qt4_site_packages
# handle some compiler warnings
ENV["CXX_EXTRA_FLAGS"] = "-Wno-unused-private-field -Wno-deprecated-register"
if ENV.compiler == :clang && (MacOS::Xcode.version >= "7.0" || MacOS::CLT.version >= "7.0")
ENV.append "CXX_EXTRA_FLAGS", "-Wno-inconsistent-missing-override"
end
mkdir "build" do
# bbedit = "/usr/local/bin/bbedit"
# cmake_config = Pathname("#{Dir.pwd}/#{name}_cmake-config.txt")
# cmake_config.write ["cmake ..", *args].join(" \\\n")
# system bbedit, cmake_config.to_s
# raise
system "cmake", "..", *args
# system bbedit, "CMakeCache.txt"
# raise
system "make"
system "make", "install"
end
# Fixup some errant lib linking
# TODO: fix upstream in CMake
dy_libs = [lib_qt4/"plugins/designer/libqgis_customwidgets.dylib"]
dy_libs << lib_qt4/"plugins/sqldrivers/libqsqlspatialite.dylib" if build.with? "qspatialite"
dy_libs.each do |dy_lib|
MachO::Tools.dylibs(dy_lib.to_s).each do |i_n|
%w[core gui].each do |f_n|
sufx = i_n[/(qgis_#{f_n}\.framework.*)/, 1]
next if sufx.nil?
i_n_to = "#{opt_prefix}/QGIS.app/Contents/Frameworks/#{sufx}"
puts "Changing install name #{i_n} to #{i_n_to} in #{dy_lib}" if ARGV.debug?
dy_lib.ensure_writable do
MachO::Tools.change_install_name(dy_lib.to_s, i_n.to_s, i_n_to, :strict => false)
end
end
end
end
# Update .app's bundle identifier, so Kyngchaos.com installer doesn't get confused
inreplace prefix/"QGIS.app/Contents/Info.plist",
"org.qgis.qgis2", "org.qgis.qgis2-hb#{build.head? ? "-dev" : ""}"
py_lib = libexec/"python2.7/site-packages"
py_lib.mkpath
ln_s "../../../QGIS.app/Contents/Resources/python/qgis", py_lib/"qgis"
ln_s "QGIS.app/Contents/MacOS/fcgi-bin", prefix/"fcgi-bin" if build.with? "server"
doc.mkpath
mv prefix/"QGIS.app/Contents/Resources/doc/api", doc/"api" if build.with? "api-docs"
ln_s "../../../QGIS.app/Contents/Resources/doc", doc/"doc"
# copy PYQGIS_STARTUP file pyqgis_startup.py, even if not isolating (so tap can be untapped)
# only works with QGIS > 2.0.1
# doesn't need executable bit set, loaded by Python runner in QGIS
libexec.install resource("pyqgis-startup")
bin.mkdir
qgis_bin = bin/name.to_s
touch qgis_bin.to_s # so it will be linked into HOMEBREW_PREFIX
qgis_bin.chmod 0755
post_install
end
def post_install
# configure environment variables for .app and launching binary directly.
# having this in `post_intsall` allows it to be individually run *after* installation with:
# `brew postinstall -v <formula-name>`
app = prefix/"QGIS.app"
tab = Tab.for_formula(self)
opts = tab.used_options
# bottle_poured = tab.poured_from_bottle
# define default isolation env vars
pthsep = File::PATH_SEPARATOR
pypth = python_site_packages.to_s
pths = %w[/usr/bin /bin /usr/sbin /sbin /opt/X11/bin /usr/X11/bin]
unless opts.include?("with-isolation")
pths = ORIGINAL_PATHS.dup
pyenv = ENV["PYTHONPATH"]
if pyenv
pypth = pyenv.include?(pypth) ? pyenv : pypth + pthsep + pyenv
end
end
unless pths.include?(HOMEBREW_PREFIX/"bin")
pths = pths.insert(0, HOMEBREW_PREFIX/"bin")
end
# set qt-4's then install's libexec/python2.7/site-packages first, so app will work if unlinked
pypths = %W[#{python_qt4_site_packages} #{opt_libexec}/python2.7/site-packages #{pypth}]
unless opts.include?("with-gdal-1")
pths.insert(0, Formula["gdal2"].opt_bin.to_s)
pths.insert(0, Formula["gdal2-python"].opt_bin.to_s)
pypths.insert(0, "#{Formula["gdal2-python"].opt_lib}/python2.7/site-packages")
end
# prepend qt-4 based utils to PATH (reverse order)
pths.insert(0, Formula["qca-qt4"].opt_bin.to_s)
pths.insert(0, Formula["pyqt-qt4"].opt_bin.to_s)
pths.insert(0, "#{Formula["sip-qt4"].opt_libexec}/bin")
pths.insert(0, Formula["qt-4"].opt_bin.to_s)
if opts.include?("with-gpsbabel-qt4")
pths.insert(0, Formula["gpsbabel-qt4"].opt_bin.to_s)
end
envars = {
:PATH => pths.join(pthsep),
:PYTHONPATH => pypths.join(pthsep),
:GDAL_DRIVER_PATH => "#{HOMEBREW_PREFIX}/lib/gdalplugins",
}
envars[:GDAL_DATA] = "#{Formula[opts.include?("with-gdal-1") ? "gdal": "gdal2"].opt_share}/gdal"
# handle multiple Qt plugins directories
qtplgpths = %W[
#{Formula["qt-4"].opt_prefix}/plugins
#{hb_lib_qt4}/plugins
]
envars[:QT_PLUGIN_PATH] = qtplgpths.join(pthsep)
proc_algs = "Contents/Resources/python/plugins/processing/algs"
if opts.include?("with-grass") || brewed_grass7?
grass7 = Formula["grass7"]
# for core integration plugin support
envars[:GRASS_PREFIX] = "#{grass7.opt_prefix}/grass-base"
begin
inreplace app/"#{proc_algs}/grass7/Grass7Utils.py",
"/Applications/GRASS-7.0.app/Contents/MacOS",
"#{grass7.opt_prefix}/grass-base"
puts "GRASS 7 GrassUtils.py has been updated"
rescue Utils::InreplaceError
puts "GRASS 7 GrassUtils.py already updated"
end
end
if opts.include?("with-grass6") || brewed_grass6?
grass6 = Formula["grass6"]
begin
inreplace app/"#{proc_algs}/grass/GrassUtils.py",
"/Applications/GRASS-6.4.app/Contents/MacOS",
"#{grass6.opt_prefix}/grass-base"
puts "GRASS 6 GrassUtils.py has been updated"
rescue Utils::InreplaceError
puts "GRASS 6 GrassUtils.py already updated"
end
end
if opts.include?("with-orfeo5") || brewed_orfeo5?
orfeo5 = Formula["orfeo5"]
begin
inreplace app/"#{proc_algs}/otb/OTBUtils.py" do |s|
# default geoid path
# try to replace first, so it fails (if already done) before global replaces
s.sub! "OTB_GEOID_FILE) or ''", "OTB_GEOID_FILE) or '#{orfeo5.opt_libexec}/default_geoid/egm96.grd'"
# default bin and lib path
s.gsub! "/usr/local/bin", orfeo5.opt_bin.to_s
s.gsub! "/usr/local/lib", orfeo5.opt_lib.to_s
end
puts "ORFEO 5 OTBUtils.py has been updated"
rescue Utils::InreplaceError
puts "ORFEO 5 OTBUtils.py already updated"
end
end
unless opts.include?("without-globe")
osg = Formula["open-scene-graph"]
envars[:OSG_LIBRARY_PATH] = "#{HOMEBREW_PREFIX}/lib/osgPlugins-#{osg.version}"
end
if opts.include?("with-isolation")
envars[:DYLD_FRAMEWORK_PATH] = "#{HOMEBREW_PREFIX}/Frameworks:/System/Library/Frameworks"
versioned = %W[
#{Formula["sqlite"].opt_lib}
#{Formula["expat"].opt_lib}
#{Formula["libxml2"].opt_lib}
#{HOMEBREW_PREFIX}/lib
]
envars[:DYLD_VERSIONED_LIBRARY_PATH] = versioned.join(pthsep)
end
if opts.include?("with-isolation") || File.exist?("/Library/Frameworks/GDAL.framework")
envars[:PYQGIS_STARTUP] = opt_libexec/"pyqgis_startup.py"
end
# envars.each { |key, value| puts "#{key.to_s}=#{value}" }
# exit
# add env vars to QGIS.app's Info.plist, in LSEnvironment section
plst = app/"Contents/Info.plist"
# first delete any LSEnvironment setting, ignoring errors
# CAUTION!: may not be what you want, if .app already has LSEnvironment settings
dflt = `defaults read-type \"#{plst}\" LSEnvironment 2> /dev/null`
`defaults delete \"#{plst}\" LSEnvironment` if dflt
kv = "{ "
envars.each { |key, value| kv += "'#{key}' = '#{value}'; " }
kv += "}"
`defaults write \"#{plst}\" LSEnvironment \"#{kv}\"`
# add ability to toggle high resolution in Get Info dialog for app
hrc = `defaults read-type \"#{plst}\" NSHighResolutionCapable 2> /dev/null`
`defaults delete \"#{plst}\" NSHighResolutionCapable` if hrc
`defaults write \"#{plst}\" NSHighResolutionCapable \"False\"`
# leave the plist readable; convert from binary to XML format
`plutil -convert xml1 -- \"#{plst}\"`
# make sure plist is readble by all users
plst.chmod 0644
# update modification date on app bundle, or changes won't take effect
touch app.to_s
# add env vars to launch script for QGIS app's binary
qgis_bin = bin/name.to_s
rm_f qgis_bin if File.exist?(qgis_bin) # install generates empty file
bin_cmds = %W[#!/bin/sh\n]
# setup shell-prepended env vars (may result in duplication of paths)
unless pths.include? HOMEBREW_PREFIX/"bin"
pths.insert(0, HOMEBREW_PREFIX/"bin")
end
# even though this should be affected by with-isolation, allow local env override
pths << "$PATH"
pypths << "$PYTHONPATH"
envars[:PATH] = pths.join(pthsep)
envars[:PYTHONPATH] = pypths.join(pthsep)
envars.each { |key, value| bin_cmds << "export #{key}=#{value}" }
bin_cmds << opt_prefix/"QGIS.app/Contents/MacOS/QGIS \"$@\""
qgis_bin.write(bin_cmds.join("\n"))
qgis_bin.chmod 0755
end
def caveats
s = <<-EOS.undent
Bottles support only Homebrew's Python
QGIS is built as an application bundle. Environment variables for the
Homebrew prefix are embedded in QGIS.app:
#{opt_prefix}/QGIS.app
You may also symlink QGIS.app into /Applications or ~/Applications:
brew linkapps [--local]
To directly run the `QGIS.app/Contents/MacOS/QGIS` binary use the wrapper
script pre-defined with Homebrew prefix environment variables:
#{opt_bin}/#{name}
NOTE: Your current PATH and PYTHONPATH environment variables are honored
when launching via the wrapper script, while launching QGIS.app
bundle they are not.
For standalone Python development, set the following environment variable:
export PYTHONPATH=#{libexec/"python2.7/site-packages"}:#{python_qt4_site_packages}:#{python_site_packages}:$PYTHONPATH
EOS
if build.with? "isolation"
s += <<-EOS.undent
QGIS built with isolation enabled. This allows it to coexist with other
types of installations of QGIS on your Mac. However, on versions >= 2.0.1,
this also means Python modules installed in the *system* Python will NOT
be available to Python processes within QGIS.app.
EOS
end
# check for required run-time Python module dependencies
# TODO: add "pyspatialite" when PyPi package supports spatialite 4.x
xm = []
%w[psycopg2 matplotlib pyparsing requests future jinja2 pygments].each do |m|
xm << m unless module_importable? m
end
unless xm.empty?
s += <<-EOS.undent
#{Tty.red}
The following Python modules are needed by QGIS during run-time:
#{xm.join(", ")}
You can install manually, via installer package or with `pip` (if availble):
pip install <module> OR pip-2.7 install <module>
#{Tty.red}
#{Tty.reset}
EOS
end
# TODO: remove this when libqscintilla.dylib becomes core build dependency?
unless module_importable? "PyQt4.Qsci"
s += <<-EOS.undent
QScintilla Python module is needed by QGIS during run-time.
Ensure `qscintilla2-qt4` formula is linked.
EOS
end
s += <<-EOS.undent
If you have built GRASS 6.4.x or 7.0.x support for the Processing plugin set
the following in QGIS:
Processing->Options: Providers->GRASS commands->GRASS folder to:
#{HOMEBREW_PREFIX}/opt/grass6/grass-base
Processing->Options: Providers->GRASS GIS 7 commands->GRASS 7 folder to:
#{HOMEBREW_PREFIX}/opt/grass7/grass-base
EOS
s
end
test do
output = `#{bin}/#{name.to_s} --help 2>&1` # why does help go to stderr?
assert_match /^QGIS is a user friendly/, output
end
private
def brewed_grass7?
Formula["grass7"].opt_prefix.exist?
end
def brewed_grass6?
Formula["grass6"].opt_prefix.exist?
end
def brewed_orfeo5?
Formula["orfeo5"].opt_prefix.exist?
end
def brewed_python_framework
HOMEBREW_PREFIX/"Frameworks/Python.framework/Versions/2.7"
end
def brewed_python_framework?
brewed_python_framework.exist?
end
def brewed_python?
Formula["python"].linked_keg.exist? && brewed_python_framework?
end
def python_exec
if brewed_python?
brewed_python_framework/"bin/python2"
else
which("python")
end
end
def python_incdir
Pathname.new(`#{python_exec} -c "from distutils import sysconfig; print(sysconfig.get_python_inc())"`.strip)
end
def python_libdir
Pathname.new(`#{python_exec} -c "from distutils import sysconfig; print(sysconfig.get_config_var('LIBPL'))"`.strip)
end
def python_site_packages
HOMEBREW_PREFIX/"lib/python2.7/site-packages"
end
def hb_lib_qt4
HOMEBREW_PREFIX/"lib/qt-4"
end
def python_qt4_site_packages
hb_lib_qt4/"python2.7/site-packages"
end
def lib_qt4
lib/"qt-4"
end
def opt_lib_qt4
opt_lib/"qt-4"
end
def module_importable?(mod)
quiet_system python_exec, "-c", "import sys;sys.path.insert(1, '#{python_qt4_site_packages}'); import #{mod}"
end
end
|
class Libphonenumber < Formula
desc "C++ Phone Number library by Google"
homepage "https://github.com/google/libphonenumber"
url "https://github.com/google/libphonenumber/archive/v8.12.41.tar.gz"
sha256 "5960f19594f4cbca4a5ff172e12d2bc6e8a7e7399522ba82cd4f58cb0d7270c4"
license "Apache-2.0"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any, arm64_monterey: "0156e3c0377566bf8ba4b9faf0765e1f26d703bf6ec3cdedbc54cd2366edf7eb"
sha256 cellar: :any, arm64_big_sur: "88ccadf83370dbd83bfe19e164ecd1c724cc78e45f3b48b0425aa0b80df25f69"
sha256 cellar: :any, monterey: "cff413c0eacb0b5ec2e85b88da8100de889ad0e27effd787a1fcfc697991b3d8"
sha256 cellar: :any, big_sur: "c8610093094b35e936782fe6754684dd3d77c39930c05d6bcafa90424a80c6ad"
sha256 cellar: :any, catalina: "2bab5129d8081bf9ecd74a4137d689f229d33a40515df31b5d244a7454383fed"
sha256 cellar: :any_skip_relocation, x86_64_linux: "5af80ea009a3fd44fbfef7a6423011bed8c729987166ae022a8f6f3db04643e5"
end
depends_on "cmake" => :build
depends_on "googletest" => :build
depends_on "boost"
depends_on "icu4c"
depends_on "protobuf"
depends_on "re2"
def install
ENV.cxx11
system "cmake", "cpp", "-DGTEST_INCLUDE_DIR=#{Formula["googletest"].include}",
*std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <phonenumbers/phonenumberutil.h>
#include <phonenumbers/phonenumber.pb.h>
#include <iostream>
#include <string>
using namespace i18n::phonenumbers;
int main() {
PhoneNumberUtil *phone_util_ = PhoneNumberUtil::GetInstance();
PhoneNumber test_number;
string formatted_number;
test_number.set_country_code(1);
test_number.set_national_number(6502530000ULL);
phone_util_->Format(test_number, PhoneNumberUtil::E164, &formatted_number);
if (formatted_number == "+16502530000") {
return 0;
} else {
return 1;
}
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test"
system "./test"
end
end
libphonenumber: update 8.12.41 bottle.
class Libphonenumber < Formula
desc "C++ Phone Number library by Google"
homepage "https://github.com/google/libphonenumber"
url "https://github.com/google/libphonenumber/archive/v8.12.41.tar.gz"
sha256 "5960f19594f4cbca4a5ff172e12d2bc6e8a7e7399522ba82cd4f58cb0d7270c4"
license "Apache-2.0"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any, arm64_monterey: "cf3ff517725784eb9cca46d353368c13ddac364673e18c0be45ade62c4c64393"
sha256 cellar: :any, arm64_big_sur: "9a4c1ec6723f3009cd2edcf88798433402f6b59ae4094a30fb239cd4762fa209"
sha256 cellar: :any, monterey: "22a548daecab4399bf876cd0ca2502aa49999f4aeef7b299ada633726dd9888b"
sha256 cellar: :any, big_sur: "65fd9e3a7548884ff271baae51be081eb86016c000f1697b8ff3c3bf1fb51b9b"
sha256 cellar: :any, catalina: "6f8b77944a64f11b265bdfbc0d34b21dcbba0ef8ec6fcd0dce3790a8a48869a4"
sha256 cellar: :any_skip_relocation, x86_64_linux: "41811ff208839c356658b11c4a46751be12a52f61e3446950c590edc1e630435"
end
depends_on "cmake" => :build
depends_on "googletest" => :build
depends_on "boost"
depends_on "icu4c"
depends_on "protobuf"
depends_on "re2"
def install
ENV.cxx11
system "cmake", "cpp", "-DGTEST_INCLUDE_DIR=#{Formula["googletest"].include}",
*std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <phonenumbers/phonenumberutil.h>
#include <phonenumbers/phonenumber.pb.h>
#include <iostream>
#include <string>
using namespace i18n::phonenumbers;
int main() {
PhoneNumberUtil *phone_util_ = PhoneNumberUtil::GetInstance();
PhoneNumber test_number;
string formatted_number;
test_number.set_country_code(1);
test_number.set_national_number(6502530000ULL);
phone_util_->Format(test_number, PhoneNumberUtil::E164, &formatted_number);
if (formatted_number == "+16502530000") {
return 0;
} else {
return 1;
}
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-L#{lib}", "-lphonenumber", "-o", "test"
system "./test"
end
end
|
class Redex < Formula
desc "Bytecode optimizer for Android apps"
homepage "http://fbredex.com"
url "https://github.com/facebook/redex/archive/v1.1.0.tar.gz"
sha256 "31c41ec774577875782ac83bfd9a03520c7bfcb1a04026fb35417803a319d749"
revision 1
head "https://github.com/facebook/redex.git"
bottle do
cellar :any
sha256 "0486e6105e25f310e802b4adc0f6e50ad2fcb02c4b1d4edc1f85d16963892b86" => :sierra
sha256 "af389493d114dac27c04ec780d16c4865591c1fa5e611e9b84f94f0562b22078" => :el_capitan
sha256 "3c8b98773de86c4025b3f2be18a3666987b5e06b958f1bf03c64ab2e3193c8e7" => :yosemite
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libevent" => :build
depends_on "libtool" => :build
depends_on "boost"
depends_on "python3"
depends_on "jsoncpp"
resource "test_apk" do
url "https://raw.githubusercontent.com/facebook/redex/master/test/instr/redex-test.apk"
sha256 "7851cf2a15230ea6ff076639c2273bc4ca4c3d81917d2e13c05edcc4d537cc04"
end
def install
system "autoreconf", "-ivf"
system "./configure", "--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
resource("test_apk").stage do
system "#{bin}/redex", "redex-test.apk", "-o", "redex-test-out.apk"
end
end
end
redex: update 1.1.0_1 bottle.
class Redex < Formula
desc "Bytecode optimizer for Android apps"
homepage "http://fbredex.com"
url "https://github.com/facebook/redex/archive/v1.1.0.tar.gz"
sha256 "31c41ec774577875782ac83bfd9a03520c7bfcb1a04026fb35417803a319d749"
revision 1
head "https://github.com/facebook/redex.git"
bottle do
cellar :any
sha256 "c66e4160ebdcad99f1854a99fa6fefc8a8da2f1bc62d808cc1aa79cd9e2c2bed" => :high_sierra
sha256 "0486e6105e25f310e802b4adc0f6e50ad2fcb02c4b1d4edc1f85d16963892b86" => :sierra
sha256 "af389493d114dac27c04ec780d16c4865591c1fa5e611e9b84f94f0562b22078" => :el_capitan
sha256 "3c8b98773de86c4025b3f2be18a3666987b5e06b958f1bf03c64ab2e3193c8e7" => :yosemite
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libevent" => :build
depends_on "libtool" => :build
depends_on "boost"
depends_on "python3"
depends_on "jsoncpp"
resource "test_apk" do
url "https://raw.githubusercontent.com/facebook/redex/master/test/instr/redex-test.apk"
sha256 "7851cf2a15230ea6ff076639c2273bc4ca4c3d81917d2e13c05edcc4d537cc04"
end
def install
system "autoreconf", "-ivf"
system "./configure", "--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
resource("test_apk").stage do
system "#{bin}/redex", "redex-test.apk", "-o", "redex-test-out.apk"
end
end
end
|
class ObjectiveCaml < Formula
homepage "http://ocaml.org"
url "http://caml.inria.fr/pub/distrib/ocaml-4.02/ocaml-4.02.1.tar.gz"
sha1 "6af8c67f2badece81d8e1d1ce70568a16e42313e"
revision 2
head "http://caml.inria.fr/svn/ocaml/trunk", :using => :svn
option "with-x11", "Install with the Graphics module"
depends_on :x11 => :optional
bottle do
end
def install
args = %W[
--prefix #{HOMEBREW_PREFIX}
--mandir #{man}
-cc #{ENV.cc}
-with-debug-runtime
]
args << "-aspp" << "#{ENV.cc} -c"
args << "-no-graph" if build.without? "x11"
ENV.deparallelize # Builds are not parallel-safe, esp. with many cores
system "./configure", *args
system "make", "world"
system "make", "opt"
system "make", "opt.opt"
system "make", "PREFIX=#{prefix}", "install"
end
end
objective-caml: update 4.02.1_2 bottle.
class ObjectiveCaml < Formula
homepage "http://ocaml.org"
url "http://caml.inria.fr/pub/distrib/ocaml-4.02/ocaml-4.02.1.tar.gz"
sha1 "6af8c67f2badece81d8e1d1ce70568a16e42313e"
revision 2
head "http://caml.inria.fr/svn/ocaml/trunk", :using => :svn
option "with-x11", "Install with the Graphics module"
depends_on :x11 => :optional
bottle do
sha1 "d3f09d213f57210e4a9e1b482ca8e2fdf39d5836" => :yosemite
sha1 "5fb1b744f2e8efa49d00d5bcf01547db2b3d32c4" => :mavericks
sha1 "e551c48370a3b5a43d843510b81032fccc2197ec" => :mountain_lion
end
def install
args = %W[
--prefix #{HOMEBREW_PREFIX}
--mandir #{man}
-cc #{ENV.cc}
-with-debug-runtime
]
args << "-aspp" << "#{ENV.cc} -c"
args << "-no-graph" if build.without? "x11"
ENV.deparallelize # Builds are not parallel-safe, esp. with many cores
system "./configure", *args
system "make", "world"
system "make", "opt"
system "make", "opt.opt"
system "make", "PREFIX=#{prefix}", "install"
end
end
|
class Redex < Formula
desc "Bytecode optimizer for Android apps"
homepage "https://fbredex.com"
url "https://github.com/facebook/redex/archive/v2017.10.31.tar.gz"
sha256 "18a840e4db0fc51f79e17dfd749b2ffcce65a28e7ef9c2b3c255c5ad89f6fd6f"
revision 2
head "https://github.com/facebook/redex.git"
bottle do
cellar :any
sha256 "3fdb0934bc6c433012cd90838cd5bf5596631c88b0f6442d4ef7e862300ca933" => :mojave
sha256 "9b7043294449d585d6a9437997ecd6d0e5d04fda4d6e3b84ed117fa3489a292f" => :high_sierra
sha256 "5b50d1e1bdd836835043055e3ca1bb380aab6c896512096a6424110a9ad3de14" => :sierra
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libevent" => :build
depends_on "libtool" => :build
depends_on "boost"
depends_on "jsoncpp"
depends_on "python"
resource "test_apk" do
url "https://raw.githubusercontent.com/facebook/redex/fa32d542d4074dbd485584413d69ea0c9c3cbc98/test/instr/redex-test.apk"
sha256 "7851cf2a15230ea6ff076639c2273bc4ca4c3d81917d2e13c05edcc4d537cc04"
end
def install
system "autoreconf", "-ivf"
system "./configure", "--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
resource("test_apk").stage do
system "#{bin}/redex", "redex-test.apk", "-o", "redex-test-out.apk"
end
end
end
redex: revision bump for jsoncpp
class Redex < Formula
desc "Bytecode optimizer for Android apps"
homepage "https://fbredex.com"
url "https://github.com/facebook/redex/archive/v2017.10.31.tar.gz"
sha256 "18a840e4db0fc51f79e17dfd749b2ffcce65a28e7ef9c2b3c255c5ad89f6fd6f"
revision 3
head "https://github.com/facebook/redex.git"
bottle do
cellar :any
sha256 "3fdb0934bc6c433012cd90838cd5bf5596631c88b0f6442d4ef7e862300ca933" => :mojave
sha256 "9b7043294449d585d6a9437997ecd6d0e5d04fda4d6e3b84ed117fa3489a292f" => :high_sierra
sha256 "5b50d1e1bdd836835043055e3ca1bb380aab6c896512096a6424110a9ad3de14" => :sierra
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libevent" => :build
depends_on "libtool" => :build
depends_on "boost"
depends_on "jsoncpp"
depends_on "python"
resource "test_apk" do
url "https://raw.githubusercontent.com/facebook/redex/fa32d542d4074dbd485584413d69ea0c9c3cbc98/test/instr/redex-test.apk"
sha256 "7851cf2a15230ea6ff076639c2273bc4ca4c3d81917d2e13c05edcc4d537cc04"
end
def install
system "autoreconf", "-ivf"
system "./configure", "--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
resource("test_apk").stage do
system "#{bin}/redex", "redex-test.apk", "-o", "redex-test-out.apk"
end
end
end
|
class Unlinked < Requirement
fatal true
satisfy(:build_env => false) { !core_psqlodbc_linked }
def core_psqlodbc_linked
Formula["psqlodbc"].linked_keg.exist?
rescue
return false
end
def message
s = "\033[31mYou have other linked versions!\e[0m\n\n"
s += "Unlink with \e[32mbrew unlink psqlodbc\e[0m or remove with \e[32mbrew uninstall --ignore-dependencies psqlodbc\e[0m\n\n" if core_psqlodbc_linked
s
end
end
class OsgeoPsqlodbc < Formula
desc "Official PostgreSQL ODBC driver"
homepage "https://odbc.postgresql.org"
url "https://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-12.01.0000.tar.gz"
sha256 "fdbb3edfcc9730787bb84d76e61fcf7584ced1913d7bfccea0bcbf5a150a5f74"
# revision 1
bottle do
root_url "https://bottle.download.osgeo.org"
cellar :any
rebuild 1
sha256 "9184542ccf288784794bd6c3ec4d13127771166c7619ff305d7c56816984c89f" => :mojave
sha256 "9184542ccf288784794bd6c3ec4d13127771166c7619ff305d7c56816984c89f" => :high_sierra
sha256 "ec4d537d87495060b8084da9f79e01ad3408d07c5d1161add9bd46a77130fe98" => :sierra
end
# revision 1
head do
url "https://git.postgresql.org/git/psqlodbc.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
# keg_only "psqlodbc is already provided by homebrew/core"
# we will verify that other versions are not linked
depends_on Unlinked
depends_on "openssl"
depends_on "unixodbc"
if build.with?("pg10")
depends_on "osgeo-postgresql@10"
else
depends_on "osgeo-postgresql"
end
def install
system "./bootstrap" if build.head?
system "./configure", "--prefix=#{prefix}",
"--with-unixodbc=#{Formula["unixodbc"].opt_prefix}"
system "make"
system "make", "install"
end
test do
output = shell_output("#{Formula["unixodbc"].bin}/dltest #{lib}/psqlodbcw.so")
assert_equal "SUCCESS: Loaded #{lib}/psqlodbcw.so\n", output
end
end
Updated bottles for: osgeo-psqlodbc
Committed for FJ Perini<21315242+fjperini@users.noreply.github.com>
[ci skip]
class Unlinked < Requirement
fatal true
satisfy(:build_env => false) { !core_psqlodbc_linked }
def core_psqlodbc_linked
Formula["psqlodbc"].linked_keg.exist?
rescue
return false
end
def message
s = "\033[31mYou have other linked versions!\e[0m\n\n"
s += "Unlink with \e[32mbrew unlink psqlodbc\e[0m or remove with \e[32mbrew uninstall --ignore-dependencies psqlodbc\e[0m\n\n" if core_psqlodbc_linked
s
end
end
class OsgeoPsqlodbc < Formula
desc "Official PostgreSQL ODBC driver"
homepage "https://odbc.postgresql.org"
url "https://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-12.01.0000.tar.gz"
sha256 "fdbb3edfcc9730787bb84d76e61fcf7584ced1913d7bfccea0bcbf5a150a5f74"
# revision 1
bottle do
root_url "https://bottle.download.osgeo.org"
cellar :any
sha256 "0841ce24156487783a5397b65316e2cff5cc07a7747973fe490e89a0335476dd" => :catalina
sha256 "0841ce24156487783a5397b65316e2cff5cc07a7747973fe490e89a0335476dd" => :mojave
sha256 "0841ce24156487783a5397b65316e2cff5cc07a7747973fe490e89a0335476dd" => :high_sierra
end
# revision 1
head do
url "https://git.postgresql.org/git/psqlodbc.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
# keg_only "psqlodbc is already provided by homebrew/core"
# we will verify that other versions are not linked
depends_on Unlinked
depends_on "openssl"
depends_on "unixodbc"
if build.with?("pg10")
depends_on "osgeo-postgresql@10"
else
depends_on "osgeo-postgresql"
end
def install
system "./bootstrap" if build.head?
system "./configure", "--prefix=#{prefix}",
"--with-unixodbc=#{Formula["unixodbc"].opt_prefix}"
system "make"
system "make", "install"
end
test do
output = shell_output("#{Formula["unixodbc"].bin}/dltest #{lib}/psqlodbcw.so")
assert_equal "SUCCESS: Loaded #{lib}/psqlodbcw.so\n", output
end
end
|
class Rgbds < Formula
desc "Rednex GameBoy development system"
homepage "https://www.anjbe.name/rgbds/"
url "https://github.com/bentley/rgbds/releases/download/v0.2.3/rgbds-0.2.3.tar.gz"
sha256 "7918cd7642d9b72a990c8e98e6b29268a267cbfa023cf5b20a0acf33e879c6f0"
head "https://github.com/bentley/rgbds.git"
bottle do
cellar :any
sha256 "b38aeefaffb931fece069ba16e57cf1c033c4cf6df6d60811520940be424470a" => :yosemite
sha256 "d9d7ac1db608efe738507b248d1881a84aa3b71c839165628f98449459d17919" => :mavericks
sha256 "858232f6f636e4fe3f3061d51c56fcf7c3de74fa9a17cbfeaae3e52ab3b73a16" => :mountain_lion
end
def install
system "make", "install", "PREFIX=#{prefix}", "MANPREFIX=#{man}"
end
test do
(testpath/"source.asm").write <<-EOS.undent
SECTION "Org $100",HOME[$100]
nop
jp begin
begin:
ld sp, $ffff
ld a, $1
ld b, a
add a, b
EOS
system "#{bin}/rgbasm", "source.asm"
end
end
rgbds 0.2.4
Closes Homebrew/homebrew#45477.
Signed-off-by: Dominyk Tiller <53e438f55903875d07efdd98a8aaf887e7208dd3@gmail.com>
class Rgbds < Formula
desc "Rednex GameBoy development system"
homepage "https://www.anjbe.name/rgbds/"
url "https://github.com/bentley/rgbds/releases/download/v0.2.4/rgbds-0.2.4.tar.gz"
sha256 "a7d32f369c6acf65fc0875c72873ef21f4d3a5813d3a2ab74ea604429f7f0435"
head "https://github.com/bentley/rgbds.git"
bottle do
cellar :any
sha256 "b38aeefaffb931fece069ba16e57cf1c033c4cf6df6d60811520940be424470a" => :yosemite
sha256 "d9d7ac1db608efe738507b248d1881a84aa3b71c839165628f98449459d17919" => :mavericks
sha256 "858232f6f636e4fe3f3061d51c56fcf7c3de74fa9a17cbfeaae3e52ab3b73a16" => :mountain_lion
end
def install
system "make", "install", "PREFIX=#{prefix}", "MANPREFIX=#{man}"
end
test do
(testpath/"source.asm").write <<-EOS.undent
SECTION "Org $100",HOME[$100]
nop
jp begin
begin:
ld sp, $ffff
ld a, $1
ld b, a
add a, b
EOS
system "#{bin}/rgbasm", "source.asm"
end
end
|
class OsgeoSagaLts < Formula
desc "System for Automated Geoscientific Analyses - Long Term Support"
homepage "http://saga-gis.org"
url "https://git.code.sf.net/p/saga-gis/code.git",
:branch => "release-2-3-lts",
:revision => "b6f474f8af4af7f0ff82548cc6f88c53547d91f5"
version "2.3.2"
revision 1
head "https://git.code.sf.net/p/saga-gis/code.git", :branch => "release-2-3-lts"
bottle do
root_url "https://dl.bintray.com/homebrew-osgeo/osgeo-bottles"
sha256 "700eb8a1e1ab0e85ed668ed70721d1aba71c33e988cbe511c5a63c100fba8222" => :mojave
sha256 "700eb8a1e1ab0e85ed668ed70721d1aba71c33e988cbe511c5a63c100fba8222" => :high_sierra
sha256 "d962a016d89ce90b3633f1d04f6a3d224b36cdd65bddc497b421d4b390939496" => :sierra
end
# - saga_api, CSG_Table::Del_Records(): bug fix, check record count correctly
# - fix clang
# - io_gdal, org_driver: do not use methods marked as deprecated in GDAL 2.0
# https://sourceforge.net/p/saga-gis/bugs/245/
patch :DATA
keg_only "LTS version is specifically for working with QGIS"
option "with-postgresql10", "Build with PostgreSQL 10 client"
option "with-app", "Build SAGA.app Package"
depends_on "automake" => :build
depends_on "autoconf" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "python@2"
depends_on "proj"
depends_on "wxmac"
depends_on "wxpython"
depends_on "geos"
depends_on "jasper"
depends_on "fftw"
depends_on "libtiff"
depends_on "swig"
depends_on "xz" # lzma
depends_on "giflib"
depends_on "opencv@2"
depends_on "unixodbc"
depends_on "libharu"
depends_on "qhull" # instead of looking for triangle
depends_on "poppler"
depends_on "hdf4"
depends_on "hdf5"
depends_on "netcdf"
depends_on "sqlite"
depends_on "osgeo-laszip@2"
depends_on "osgeo-gdal" # (gdal-curl, gdal-filegdb, gdal-hdf4)
depends_on "osgeo-liblas"
# Vigra support builds, but dylib in saga shows 'failed' when loaded
# Also, using --with-python will trigger vigra to be built with it, which
# triggers a source (re)build of boost --with-python
depends_on "osgeo-vigra" => :optional
if build.with?("postgresql10")
depends_on "postgresql@10"
else
depends_on "postgresql"
end
resource "app_icon" do
url "https://osgeo4mac.s3.amazonaws.com/src/saga_gui.icns"
sha256 "288e589d31158b8ffb9ef76fdaa8e62dd894cf4ca76feabbae24a8e7015e321f"
end
def install
ENV.cxx11
# SKIP liblas support until SAGA supports > 1.8.1, which should support GDAL 2;
# otherwise, SAGA binaries may lead to multiple GDAL versions being loaded
# See: https://github.com/libLAS/libLAS/issues/106
# Update: https://github.com/libLAS/libLAS/issues/106
# https://sourceforge.net/p/saga-gis/wiki/Compiling%20SAGA%20on%20Mac%20OS%20X/
# configure FEATURES CXX="CXX" CPPFLAGS="DEFINES GDAL_H $PROJ_H" LDFLAGS="GDAL_SRCH PROJ_SRCH LINK_MISC"
# cppflags : wx-config --version=3.0 --cppflags
# defines : -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__
cppflags = "-I#{HOMEBREW_PREFIX}/lib/wx/include/osx_cocoa-unicode-3.0 -I#{HOMEBREW_PREFIX}/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__"
# libs : wx-config --version=3.0 --libs
ldflags = "-L#{HOMEBREW_PREFIX}/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_xrc-3.0 -lwx_osx_cocoau_webview-3.0 -lwx_osx_cocoau_html-3.0 -lwx_osx_cocoau_qa-3.0 -lwx_osx_cocoau_adv-3.0 -lwx_osx_cocoau_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0"
# xcode : xcrun --show-sdk-path
link_misc = "-arch x86_64 -mmacosx-version-min=10.9 -isysroot #{MacOS::Xcode.prefix}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{MacOS.version}.sdk -lstdc++"
ENV.append "CPPFLAGS", "-I#{Formula["proj"].opt_include} -I#{Formula["gdal2"].opt_include} #{cppflags}"
ENV.append "LDFLAGS", "-L#{Formula["proj"].opt_lib}/libproj.dylib -L#{Formula["gdal2"].opt_lib}/libgdal.dylib #{link_misc} #{ldflags}"
# Disable narrowing warnings when compiling in C++11 mode.
ENV.append "CXXFLAGS", "-Wno-c++11-narrowing -std=c++11"
ENV.append "PYTHON_VERSION", "2.7"
ENV.append "PYTHON", "#{Formula["python@2"].opt_bin}/python2"
cd "saga-gis"
# fix homebrew-specific header location for qhull
inreplace "src/modules/grid/grid_gridding/nn/delaunay.c", "qhull/", "libqhull/" # if build.with? "qhull"
# libfire and triangle are for non-commercial use only, skip them
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--disable-openmp
--disable-libfire
--enable-shared
--enable-debug
--enable-gui
]
# --disable-gui
# --enable-unicode
args << "--disable-odbc" if build.without? "unixodbc"
args << "--disable-triangle" # if build.with? "qhull"
args << "--enable-python" # if build.with? "python"
if build.with?("postgresql10")
args << "--with-postgresql=#{Formula["postgresql@10"].opt_bin}/pg_config"
else
args << "--with-postgresql=#{Formula["postgresql"].opt_bin}/pg_config" # if build.with? "postgresql"
end
system "autoreconf", "-i"
system "./configure", *args
system "make", "install"
if build.with? "app"
(prefix/"SAGA.app/Contents/PkgInfo").write "APPLSAGA"
(prefix/"SAGA.app/Contents/Resources").install resource("app_icon")
config = <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>saga_gui</string>
<key>CFBundleIconFile</key>
<string>saga_gui.icns</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>SAGA</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>SAGA</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHighResolutionCapable</key>
<string>True</string>
</dict>
</plist>
EOS
(prefix/"SAGA.app/Contents/Info.plist").write config
chdir "#{prefix}/SAGA.app/Contents" do
mkdir "MacOS" do
ln_s "#{bin}/saga_gui", "saga_gui"
end
end
end
end
def caveats
if build.with? "app"
<<~EOS
SAGA.app was installed in:
#{prefix}
You may also symlink QGIS.app into /Applications or ~/Applications:
ln -Fs `find $(brew --prefix) -name "SAGA.app"` /Applications/SAGA.app
Note that the SAGA GUI does not work very well yet.
It has problems with creating a preferences file in the correct location and sometimes won't shut down (use Activity Monitor to force quit if necessary).
EOS
end
end
test do
output = `#{bin}/saga_cmd --help`
assert_match /The SAGA command line interpreter/, output
end
end
__END__
--- a/saga-gis/src/saga_core/saga_api/table.cpp
+++ b/saga-gis/src/saga_core/saga_api/table.cpp
@@ -901,7 +901,7 @@
//---------------------------------------------------------
bool CSG_Table::Del_Records(void)
{
- if( m_Records > 0 )
+ if( m_nRecords > 0 )
{
_Index_Destroy();
--- a/saga-gis/src/modules/imagery/imagery_maxent/me.cpp
+++ b/saga-gis/src/modules/imagery/imagery_maxent/me.cpp
@@ -21,7 +21,7 @@
#ifdef _SAGA_MSW
#define isinf(x) (!_finite(x))
#else
-#define isinf(x) (!finite(x))
+#define isinf(x) (!isfinite(x))
#endif
/** The input array contains a set of log probabilities lp1, lp2, lp3
--- a/saga-gis/src/modules/io/io_gdal/ogr_driver.cpp
+++ b/saga-gis/src/modules/io/io_gdal/ogr_driver.cpp
@@ -531,12 +531,11 @@
//---------------------------------------------------------
int CSG_OGR_DataSet::Get_Count(void) const
{
- if( m_pDataSet )
- {
- return OGR_DS_GetLayerCount( m_pDataSet );
- }
-
- return( 0 );
+#ifdef USE_GDAL_V2
+ return( m_pDataSet ? GDALDatasetGetLayerCount(m_pDataSet) : 0 );
+#else
+ return( m_pDataSet ? OGR_DS_GetLayerCount(m_pDataSet) : 0 );
+#endif
}
//---------------------------------------------------------
@@ -544,7 +543,11 @@
{
if( m_pDataSet && iLayer >= 0 && iLayer < Get_Count() )
{
- return OGR_DS_GetLayer( m_pDataSet, iLayer);
+#ifdef USE_GDAL_V2
+ return( GDALDatasetGetLayer(m_pDataSet, iLayer) );
+#else
+ return( OGR_DS_GetLayer(m_pDataSet, iLayer) );
+#endif
}
return( NULL );
@@ -630,44 +633,43 @@
}
//-----------------------------------------------------
- OGRFeatureDefnH pDef = OGR_L_GetLayerDefn( pLayer );
- CSG_Shapes *pShapes = SG_Create_Shapes(Get_Type(iLayer), CSG_String(OGR_Fld_GetNameRef(pDef)), NULL, Get_Coordinate_Type(iLayer));
+ OGRFeatureDefnH pDefn = OGR_L_GetLayerDefn(pLayer);
+ CSG_Shapes *pShapes = SG_Create_Shapes(Get_Type(iLayer), CSG_String(OGR_L_GetName(pLayer)), NULL, Get_Coordinate_Type(iLayer));
pShapes->Get_Projection() = Get_Projection(iLayer);
//-----------------------------------------------------
- int iField;
-
- for(iField=0; iField< OGR_FD_GetFieldCount(pDef); iField++)
- {
- OGRFieldDefnH pDefField = OGR_FD_GetFieldDefn( pDef, iField);
-
- pShapes->Add_Field( OGR_Fld_GetNameRef( pDefField ), CSG_OGR_Drivers::Get_Data_Type( OGR_Fld_GetType( pDefField ) ) );
- }
+ {
+ for(int iField=0; iField<OGR_FD_GetFieldCount(pDefn); iField++)
+ {
+ OGRFieldDefnH pDefnField = OGR_FD_GetFieldDefn(pDefn, iField);
+
+ pShapes->Add_Field(OGR_Fld_GetNameRef(pDefnField), CSG_OGR_Drivers::Get_Data_Type(OGR_Fld_GetType(pDefnField)));
+ }
+ }
+
//-----------------------------------------------------
OGRFeatureH pFeature;
-
- OGR_L_ResetReading( pLayer );
-
- while( (pFeature = OGR_L_GetNextFeature( pLayer ) ) != NULL && SG_UI_Process_Get_Okay(false) )
- {
- OGRGeometryH pGeometry = OGR_F_GetGeometryRef( pFeature );
+ OGR_L_ResetReading(pLayer);
+
+ while( (pFeature = OGR_L_GetNextFeature(pLayer)) != NULL && SG_UI_Process_Get_Okay(false) )
+ {
+ OGRGeometryH pGeometry = OGR_F_GetGeometryRef(pFeature);
if( pGeometry != NULL )
{
CSG_Shape *pShape = pShapes->Add_Shape();
- for(iField=0; iField<OGR_FD_GetFieldCount(pDef); iField++)
+ for(int iField=0; iField<pShapes->Get_Field_Count(); iField++)
{
- OGRFieldDefnH pDefField = OGR_FD_GetFieldDefn(pDef, iField);
-
- switch( OGR_Fld_GetType( pDefField ) )
+ switch( pShapes->Get_Field_Type(iField) )
{
- default: pShape->Set_Value(iField, OGR_F_GetFieldAsString( pFeature, iField)); break;
- case OFTString: pShape->Set_Value(iField, OGR_F_GetFieldAsString( pFeature, iField)); break;
- case OFTInteger: pShape->Set_Value(iField, OGR_F_GetFieldAsInteger( pFeature, iField)); break;
- case OFTReal: pShape->Set_Value(iField, OGR_F_GetFieldAsDouble( pFeature, iField)); break;
+ default : pShape->Set_Value(iField, OGR_F_GetFieldAsString (pFeature, iField)); break;
+ case SG_DATATYPE_String: pShape->Set_Value(iField, OGR_F_GetFieldAsString (pFeature, iField)); break;
+ case SG_DATATYPE_Int : pShape->Set_Value(iField, OGR_F_GetFieldAsInteger(pFeature, iField)); break;
+ case SG_DATATYPE_Float : pShape->Set_Value(iField, OGR_F_GetFieldAsDouble (pFeature, iField)); break;
+ case SG_DATATYPE_Double: pShape->Set_Value(iField, OGR_F_GetFieldAsDouble (pFeature, iField)); break;
}
}
Update osgeo-saga.rb
class OsgeoSagaLts < Formula
desc "System for Automated Geoscientific Analyses - Long Term Support"
homepage "http://saga-gis.org"
url "https://git.code.sf.net/p/saga-gis/code.git",
:branch => "release-2-3-lts",
:revision => "b6f474f8af4af7f0ff82548cc6f88c53547d91f5"
version "2.3.2"
revision 2
head "https://git.code.sf.net/p/saga-gis/code.git", :branch => "release-2-3-lts"
bottle do
root_url "https://dl.bintray.com/homebrew-osgeo/osgeo-bottles"
sha256 "700eb8a1e1ab0e85ed668ed70721d1aba71c33e988cbe511c5a63c100fba8222" => :mojave
sha256 "700eb8a1e1ab0e85ed668ed70721d1aba71c33e988cbe511c5a63c100fba8222" => :high_sierra
sha256 "d962a016d89ce90b3633f1d04f6a3d224b36cdd65bddc497b421d4b390939496" => :sierra
end
# - saga_api, CSG_Table::Del_Records(): bug fix, check record count correctly
# - fix clang
# - io_gdal, org_driver: do not use methods marked as deprecated in GDAL 2.0
# https://sourceforge.net/p/saga-gis/bugs/245/
patch :DATA
keg_only "LTS version is specifically for working with QGIS"
option "with-pg10", "Build with PostgreSQL 10 client"
option "with-app", "Build SAGA.app Package"
depends_on "automake" => :build
depends_on "autoconf" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "python@2"
depends_on "proj"
depends_on "wxmac"
depends_on "wxpython"
depends_on "geos"
depends_on "jasper"
depends_on "fftw"
depends_on "libtiff"
depends_on "swig"
depends_on "xz" # lzma
depends_on "giflib"
depends_on "opencv@2"
depends_on "unixodbc"
depends_on "libharu"
depends_on "qhull" # instead of looking for triangle
depends_on "poppler"
depends_on "osgeo-hdf4"
depends_on "hdf5"
depends_on "netcdf"
depends_on "sqlite"
depends_on "osgeo-laszip@2"
depends_on "osgeo-gdal" # (gdal-curl, gdal-filegdb, gdal-hdf4)
depends_on "osgeo-liblas"
# Vigra support builds, but dylib in saga shows 'failed' when loaded
# Also, using --with-python will trigger vigra to be built with it, which
# triggers a source (re)build of boost --with-python
depends_on "osgeo-vigra" => :optional
if build.with?("pg10")
depends_on "osgeo-postgresql@10"
else
depends_on "postgresql"
end
resource "app_icon" do
url "https://osgeo4mac.s3.amazonaws.com/src/saga_gui.icns"
sha256 "288e589d31158b8ffb9ef76fdaa8e62dd894cf4ca76feabbae24a8e7015e321f"
end
def install
ENV.cxx11
# SKIP liblas support until SAGA supports > 1.8.1, which should support GDAL 2;
# otherwise, SAGA binaries may lead to multiple GDAL versions being loaded
# See: https://github.com/libLAS/libLAS/issues/106
# Update: https://github.com/libLAS/libLAS/issues/106
# https://sourceforge.net/p/saga-gis/wiki/Compiling%20SAGA%20on%20Mac%20OS%20X/
# configure FEATURES CXX="CXX" CPPFLAGS="DEFINES GDAL_H $PROJ_H" LDFLAGS="GDAL_SRCH PROJ_SRCH LINK_MISC"
# cppflags : wx-config --version=3.0 --cppflags
# defines : -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__
cppflags = "-I#{HOMEBREW_PREFIX}/lib/wx/include/osx_cocoa-unicode-3.0 -I#{HOMEBREW_PREFIX}/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__"
# libs : wx-config --version=3.0 --libs
ldflags = "-L#{HOMEBREW_PREFIX}/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_xrc-3.0 -lwx_osx_cocoau_webview-3.0 -lwx_osx_cocoau_html-3.0 -lwx_osx_cocoau_qa-3.0 -lwx_osx_cocoau_adv-3.0 -lwx_osx_cocoau_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0"
# xcode : xcrun --show-sdk-path
link_misc = "-arch x86_64 -mmacosx-version-min=10.9 -isysroot #{MacOS::Xcode.prefix}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{MacOS.version}.sdk -lstdc++"
ENV.append "CPPFLAGS", "-I#{Formula["proj"].opt_include} -I#{Formula["osgeo-gdal"].opt_include} #{cppflags}"
ENV.append "LDFLAGS", "-L#{Formula["proj"].opt_lib}/libproj.dylib -L#{Formula["osgeo-gdal"].opt_lib}/libgdal.dylib #{link_misc} #{ldflags}"
# Disable narrowing warnings when compiling in C++11 mode.
ENV.append "CXXFLAGS", "-Wno-c++11-narrowing -std=c++11"
ENV.append "PYTHON_VERSION", "2.7"
ENV.append "PYTHON", "#{Formula["python@2"].opt_bin}/python2"
cd "saga-gis"
# fix homebrew-specific header location for qhull
inreplace "src/modules/grid/grid_gridding/nn/delaunay.c", "qhull/", "libqhull/" # if build.with? "qhull"
# libfire and triangle are for non-commercial use only, skip them
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--disable-openmp
--disable-libfire
--enable-shared
--enable-debug
--enable-gui
]
# --disable-gui
# --enable-unicode
args << "--disable-odbc" if build.without? "unixodbc"
args << "--disable-triangle" # if build.with? "qhull"
args << "--enable-python" # if build.with? "python"
if build.with?("postgresql10")
args << "--with-postgresql=#{Formula["postgresql@10"].opt_bin}/pg_config"
else
args << "--with-postgresql=#{Formula["postgresql"].opt_bin}/pg_config" # if build.with? "postgresql"
end
system "autoreconf", "-i"
system "./configure", *args
system "make", "install"
if build.with? "app"
(prefix/"SAGA.app/Contents/PkgInfo").write "APPLSAGA"
(prefix/"SAGA.app/Contents/Resources").install resource("app_icon")
config = <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>saga_gui</string>
<key>CFBundleIconFile</key>
<string>saga_gui.icns</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>SAGA</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>SAGA</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHighResolutionCapable</key>
<string>True</string>
</dict>
</plist>
EOS
(prefix/"SAGA.app/Contents/Info.plist").write config
chdir "#{prefix}/SAGA.app/Contents" do
mkdir "MacOS" do
ln_s "#{bin}/saga_gui", "saga_gui"
end
end
end
end
def caveats
if build.with? "app"
<<~EOS
SAGA.app was installed in:
#{prefix}
You may also symlink QGIS.app into /Applications or ~/Applications:
ln -Fs `find $(brew --prefix) -name "SAGA.app"` /Applications/SAGA.app
Note that the SAGA GUI does not work very well yet.
It has problems with creating a preferences file in the correct location and sometimes won't shut down (use Activity Monitor to force quit if necessary).
EOS
end
end
test do
output = `#{bin}/saga_cmd --help`
assert_match /The SAGA command line interpreter/, output
end
end
__END__
--- a/saga-gis/src/saga_core/saga_api/table.cpp
+++ b/saga-gis/src/saga_core/saga_api/table.cpp
@@ -901,7 +901,7 @@
//---------------------------------------------------------
bool CSG_Table::Del_Records(void)
{
- if( m_Records > 0 )
+ if( m_nRecords > 0 )
{
_Index_Destroy();
--- a/saga-gis/src/modules/imagery/imagery_maxent/me.cpp
+++ b/saga-gis/src/modules/imagery/imagery_maxent/me.cpp
@@ -21,7 +21,7 @@
#ifdef _SAGA_MSW
#define isinf(x) (!_finite(x))
#else
-#define isinf(x) (!finite(x))
+#define isinf(x) (!isfinite(x))
#endif
/** The input array contains a set of log probabilities lp1, lp2, lp3
--- a/saga-gis/src/modules/io/io_gdal/ogr_driver.cpp
+++ b/saga-gis/src/modules/io/io_gdal/ogr_driver.cpp
@@ -531,12 +531,11 @@
//---------------------------------------------------------
int CSG_OGR_DataSet::Get_Count(void) const
{
- if( m_pDataSet )
- {
- return OGR_DS_GetLayerCount( m_pDataSet );
- }
-
- return( 0 );
+#ifdef USE_GDAL_V2
+ return( m_pDataSet ? GDALDatasetGetLayerCount(m_pDataSet) : 0 );
+#else
+ return( m_pDataSet ? OGR_DS_GetLayerCount(m_pDataSet) : 0 );
+#endif
}
//---------------------------------------------------------
@@ -544,7 +543,11 @@
{
if( m_pDataSet && iLayer >= 0 && iLayer < Get_Count() )
{
- return OGR_DS_GetLayer( m_pDataSet, iLayer);
+#ifdef USE_GDAL_V2
+ return( GDALDatasetGetLayer(m_pDataSet, iLayer) );
+#else
+ return( OGR_DS_GetLayer(m_pDataSet, iLayer) );
+#endif
}
return( NULL );
@@ -630,44 +633,43 @@
}
//-----------------------------------------------------
- OGRFeatureDefnH pDef = OGR_L_GetLayerDefn( pLayer );
- CSG_Shapes *pShapes = SG_Create_Shapes(Get_Type(iLayer), CSG_String(OGR_Fld_GetNameRef(pDef)), NULL, Get_Coordinate_Type(iLayer));
+ OGRFeatureDefnH pDefn = OGR_L_GetLayerDefn(pLayer);
+ CSG_Shapes *pShapes = SG_Create_Shapes(Get_Type(iLayer), CSG_String(OGR_L_GetName(pLayer)), NULL, Get_Coordinate_Type(iLayer));
pShapes->Get_Projection() = Get_Projection(iLayer);
//-----------------------------------------------------
- int iField;
-
- for(iField=0; iField< OGR_FD_GetFieldCount(pDef); iField++)
- {
- OGRFieldDefnH pDefField = OGR_FD_GetFieldDefn( pDef, iField);
-
- pShapes->Add_Field( OGR_Fld_GetNameRef( pDefField ), CSG_OGR_Drivers::Get_Data_Type( OGR_Fld_GetType( pDefField ) ) );
- }
+ {
+ for(int iField=0; iField<OGR_FD_GetFieldCount(pDefn); iField++)
+ {
+ OGRFieldDefnH pDefnField = OGR_FD_GetFieldDefn(pDefn, iField);
+
+ pShapes->Add_Field(OGR_Fld_GetNameRef(pDefnField), CSG_OGR_Drivers::Get_Data_Type(OGR_Fld_GetType(pDefnField)));
+ }
+ }
+
//-----------------------------------------------------
OGRFeatureH pFeature;
-
- OGR_L_ResetReading( pLayer );
-
- while( (pFeature = OGR_L_GetNextFeature( pLayer ) ) != NULL && SG_UI_Process_Get_Okay(false) )
- {
- OGRGeometryH pGeometry = OGR_F_GetGeometryRef( pFeature );
+ OGR_L_ResetReading(pLayer);
+
+ while( (pFeature = OGR_L_GetNextFeature(pLayer)) != NULL && SG_UI_Process_Get_Okay(false) )
+ {
+ OGRGeometryH pGeometry = OGR_F_GetGeometryRef(pFeature);
if( pGeometry != NULL )
{
CSG_Shape *pShape = pShapes->Add_Shape();
- for(iField=0; iField<OGR_FD_GetFieldCount(pDef); iField++)
+ for(int iField=0; iField<pShapes->Get_Field_Count(); iField++)
{
- OGRFieldDefnH pDefField = OGR_FD_GetFieldDefn(pDef, iField);
-
- switch( OGR_Fld_GetType( pDefField ) )
+ switch( pShapes->Get_Field_Type(iField) )
{
- default: pShape->Set_Value(iField, OGR_F_GetFieldAsString( pFeature, iField)); break;
- case OFTString: pShape->Set_Value(iField, OGR_F_GetFieldAsString( pFeature, iField)); break;
- case OFTInteger: pShape->Set_Value(iField, OGR_F_GetFieldAsInteger( pFeature, iField)); break;
- case OFTReal: pShape->Set_Value(iField, OGR_F_GetFieldAsDouble( pFeature, iField)); break;
+ default : pShape->Set_Value(iField, OGR_F_GetFieldAsString (pFeature, iField)); break;
+ case SG_DATATYPE_String: pShape->Set_Value(iField, OGR_F_GetFieldAsString (pFeature, iField)); break;
+ case SG_DATATYPE_Int : pShape->Set_Value(iField, OGR_F_GetFieldAsInteger(pFeature, iField)); break;
+ case SG_DATATYPE_Float : pShape->Set_Value(iField, OGR_F_GetFieldAsDouble (pFeature, iField)); break;
+ case SG_DATATYPE_Double: pShape->Set_Value(iField, OGR_F_GetFieldAsDouble (pFeature, iField)); break;
}
}
|
class Scala < Formula
desc "JVM-based programming language"
homepage "http://www.scala-lang.org/"
stable do
url "http://www.scala-lang.org/files/archive/scala-2.11.7.tgz"
sha256 "ffe4196f13ee98a66cf54baffb0940d29432b2bd820bd0781a8316eec22926d0"
depends_on :java => "1.6+"
resource "docs" do
url "http://www.scala-lang.org/files/archive/scala-docs-2.11.7.zip"
sha256 "90981bf388552465ce07761c8f991c13be332ee07e97ff44f4b8be278f489667"
end
resource "src" do
url "https://github.com/scala/scala/archive/v2.11.7.tar.gz"
sha256 "1679ee604bc4e881b0d325e164c39c02dcfa711d53cd3115f5a6c9676c5915ef"
end
end
bottle do
cellar :any_skip_relocation
sha256 "dcc350cf8dcc527b283b52d81ce27f0ee19403f1b805c6de74cbbd1c00571483" => :el_capitan
sha256 "abe3bdb7c49c2d8542731b5bff8ddd2b64b361e5fbc104217ca2f2423b73fbb9" => :yosemite
sha256 "87619ccc086a0636f89fec974759ae952dc1979948567f7e7d6200b7be64dffc" => :mavericks
sha256 "44c9502a3195a7cd25699162948b4eb80676547a24ed0a001520320d6a54aac7" => :mountain_lion
end
devel do
url "http://www.scala-lang.org/files/archive/scala-2.12.0-M3.tgz"
sha256 "67ee3394ff5f9a98f9579accc9e20e0c9911d6f0bce96d70cf63cbb676643802"
version "2.12.0-M3"
depends_on :java => "1.8+"
resource "docs" do
url "http://www.scala-lang.org/files/archive/scala-docs-2.12.0-M3.zip"
sha256 "f5c5bc3635c08dde2e938b8051974404bb7126c27039753de337f7e3fa4e5844"
version "2.12.0-M3"
end
resource "src" do
url "https://github.com/scala/scala/archive/v2.12.0-M3.tar.gz"
sha256 "104a5ec973bfc40bfd1cd1bbaeec43b767555367c65fa7880a615f2285550d70"
version "2.12.0-M3"
end
end
option "with-docs", "Also install library documentation"
option "with-src", "Also install sources for IDE support"
resource "completion" do
url "https://raw.githubusercontent.com/scala/scala-dist/v2.11.4/bash-completion/src/main/resources/completion.d/2.9.1/scala"
sha256 "95aeba51165ce2c0e36e9bf006f2904a90031470ab8d10b456e7611413d7d3fd"
end
def install
rm_f Dir["bin/*.bat"]
doc.install Dir["doc/*"]
share.install "man"
libexec.install "bin", "lib"
bin.install_symlink Dir["#{libexec}/bin/*"]
bash_completion.install resource("completion")
doc.install resource("docs") if build.with? "docs"
libexec.install resource("src").files("src") if build.with? "src"
# Set up an IntelliJ compatible symlink farm in 'idea'
idea = prefix/"idea"
idea.install_symlink libexec/"src", libexec/"lib"
idea.install_symlink doc => "doc"
end
def caveats; <<-EOS.undent
To use with IntelliJ, set the Scala home to:
#{opt_prefix}/idea
EOS
end
test do
file = testpath/"Test.scala"
file.write <<-EOS.undent
object Test {
def main(args: Array[String]) {
println(s"${2 + 2}")
}
}
EOS
out = shell_output("#{bin}/scala #{file}").strip
# Shut down the compile server so as not to break Travis
system bin/"fsc", "-shutdown"
assert_equal "4", out
end
end
scala 2.11.8
Closes Homebrew/homebrew#49897.
Signed-off-by: Dominyk Tiller <53e438f55903875d07efdd98a8aaf887e7208dd3@gmail.com>
class Scala < Formula
desc "JVM-based programming language"
homepage "http://www.scala-lang.org/"
stable do
url "http://downloads.lightbend.com/scala/2.11.8/scala-2.11.8.tgz"
sha256 "87fc86a19d9725edb5fd9866c5ee9424cdb2cd86b767f1bb7d47313e8e391ace"
depends_on :java => "1.6+"
resource "docs" do
url "http://downloads.lightbend.com/scala/2.11.8/scala-docs-2.11.8.zip"
sha256 "73bd44375ebffd5f401950a11d78addc52f8164c30d8528d26c82c1f819cfc16"
end
resource "src" do
url "https://github.com/scala/scala/archive/v2.11.8.tar.gz"
sha256 "4f11273b4b3c771019253b2c09102245d063a7abeb65c7b1c4519bd57605edcf"
end
end
bottle do
cellar :any_skip_relocation
sha256 "dcc350cf8dcc527b283b52d81ce27f0ee19403f1b805c6de74cbbd1c00571483" => :el_capitan
sha256 "abe3bdb7c49c2d8542731b5bff8ddd2b64b361e5fbc104217ca2f2423b73fbb9" => :yosemite
sha256 "87619ccc086a0636f89fec974759ae952dc1979948567f7e7d6200b7be64dffc" => :mavericks
sha256 "44c9502a3195a7cd25699162948b4eb80676547a24ed0a001520320d6a54aac7" => :mountain_lion
end
devel do
url "http://www.scala-lang.org/files/archive/scala-2.12.0-M3.tgz"
sha256 "67ee3394ff5f9a98f9579accc9e20e0c9911d6f0bce96d70cf63cbb676643802"
version "2.12.0-M3"
depends_on :java => "1.8+"
resource "docs" do
url "http://www.scala-lang.org/files/archive/scala-docs-2.12.0-M3.zip"
sha256 "f5c5bc3635c08dde2e938b8051974404bb7126c27039753de337f7e3fa4e5844"
version "2.12.0-M3"
end
resource "src" do
url "https://github.com/scala/scala/archive/v2.12.0-M3.tar.gz"
sha256 "104a5ec973bfc40bfd1cd1bbaeec43b767555367c65fa7880a615f2285550d70"
version "2.12.0-M3"
end
end
option "with-docs", "Also install library documentation"
option "with-src", "Also install sources for IDE support"
resource "completion" do
url "https://raw.githubusercontent.com/scala/scala-dist/v2.11.4/bash-completion/src/main/resources/completion.d/2.9.1/scala"
sha256 "95aeba51165ce2c0e36e9bf006f2904a90031470ab8d10b456e7611413d7d3fd"
end
def install
rm_f Dir["bin/*.bat"]
doc.install Dir["doc/*"]
share.install "man"
libexec.install "bin", "lib"
bin.install_symlink Dir["#{libexec}/bin/*"]
bash_completion.install resource("completion")
doc.install resource("docs") if build.with? "docs"
libexec.install resource("src").files("src") if build.with? "src"
# Set up an IntelliJ compatible symlink farm in 'idea'
idea = prefix/"idea"
idea.install_symlink libexec/"src", libexec/"lib"
idea.install_symlink doc => "doc"
end
def caveats; <<-EOS.undent
To use with IntelliJ, set the Scala home to:
#{opt_prefix}/idea
EOS
end
test do
file = testpath/"Test.scala"
file.write <<-EOS.undent
object Test {
def main(args: Array[String]) {
println(s"${2 + 2}")
}
}
EOS
out = shell_output("#{bin}/scala #{file}").strip
# Shut down the compile server so as not to break Travis
system bin/"fsc", "-shutdown"
assert_equal "4", out
end
end
|
class PerconaServer < Formula
desc "Drop-in MySQL replacement"
homepage "https://www.percona.com"
url "https://www.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.19-10/source/tarball/percona-server-8.0.19-10.tar.gz"
sha256 "b819d81b9cdef497dd5fd1044ddb033d222b986cf610cb5d4bb1fa5010dba580"
bottle do
sha256 "c6ad05c52e82f419f65a46bd627c784fec43dfb8545e68fb4939995fb5fefed2" => :catalina
sha256 "cae8782ea16aa5fdfebe4ccac3189d2e7fbdc0d6290c0b8fda6ab46792f956eb" => :mojave
sha256 "30719045c2ee376f8cf269e12fcd307f7d0313338b59b6e1c24861207177b287" => :high_sierra
sha256 "01688c524edd4d9449141e73c9eee00c27e5ed8075281c70b3bc2e7ad04307ea" => :x86_64_linux
end
pour_bottle? do
reason "The bottle needs a var/mysql datadir (yours is var/percona)."
satisfy { datadir == var/"mysql" }
end
depends_on "cmake" => :build
depends_on "openssl@1.1"
on_linux do
depends_on "pkg-config" => :build
depends_on "libedit"
depends_on "readline"
end
uses_from_macos "curl"
conflicts_with "mariadb", "mysql",
:because => "percona, mariadb, and mysql install the same binaries."
conflicts_with "protobuf",
:because => "both install libprotobuf(-lite) libraries."
# https://bugs.mysql.com/bug.php?id=86711
# https://github.com/Homebrew/homebrew-core/pull/20538
fails_with :clang do
build 800
cause "Wrong inlining with Clang 8.0, see MySQL Bug #86711"
end
resource "boost" do
url "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.bz2"
sha256 "430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778"
end
# Where the database files should be located. Existing installs have them
# under var/percona, but going forward they will be under var/mysql to be
# shared with the mysql and mariadb formulae.
def datadir
@datadir ||= (var/"percona").directory? ? var/"percona" : var/"mysql"
end
def install
args = %W[
-DFORCE_INSOURCE_BUILD=1
-DCOMPILATION_COMMENT=Homebrew
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_INFODIR=share/info
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_PLUGINDIR=lib/percona-server/plugin
-DMYSQL_DATADIR=#{datadir}
-DSYSCONFDIR=#{etc}
-DWITH_SSL=yes
-DWITH_UNIT_TESTS=OFF
-DWITH_EMBEDDED_SERVER=ON
-DENABLED_LOCAL_INFILE=1
-DWITH_INNODB_MEMCACHED=ON
-DWITH_EDITLINE=system
]
args << "-DWITH_EDITLINE=system" if OS.mac?
# MySQL >5.7.x mandates Boost as a requirement to build & has a strict
# version check in place to ensure it only builds against expected release.
# This is problematic when Boost releases don't align with MySQL releases.
(buildpath/"boost").install resource("boost")
args << "-DWITH_BOOST=#{buildpath}/boost"
# Percona MyRocks does not compile on macOS
# https://bugs.launchpad.net/percona-server/+bug/1741639
args.concat %w[-DWITHOUT_ROCKSDB=1]
# TokuDB does not compile on macOS
# https://bugs.launchpad.net/percona-server/+bug/1531446
args.concat %w[-DWITHOUT_TOKUDB=1]
system "cmake", ".", *std_cmake_args, *args
system "make"
system "make", "install"
if OS.mac?
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{Dir.mktmpdir}"
end
end
# Test is disabled on Linux as it is currently failing
# Remove the tests directory
rm_rf prefix/"mysql-test"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Fix up the control script and link into bin.
inreplace "#{prefix}/support-files/mysql.server",
/^(PATH=".*)(")/,
"\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"
# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
etc.install "my.cnf"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<~EOS
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
EOS
if (my_cnf = ["/etc/my.cnf", "/etc/mysql/my.cnf"].find { |x| File.exist? x })
s += <<~EOS
A "#{my_cnf}" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
# Expects datadir to be a completely clean dir, which testpath isn't.
dir = Dir.mktmpdir
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{dir}", "--tmpdir=#{dir}"
pid = fork do
exec bin/"mysqld", "--bind-address=127.0.0.1", "--datadir=#{dir}"
end
sleep 2
output = shell_output("curl 127.0.0.1:3306")
output.force_encoding("ASCII-8BIT") if output.respond_to?(:force_encoding)
assert_match version.to_s, output
ensure
Process.kill(9, pid)
Process.wait(pid)
end
end
percona-server: fix components order.
class PerconaServer < Formula
desc "Drop-in MySQL replacement"
homepage "https://www.percona.com"
url "https://www.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.19-10/source/tarball/percona-server-8.0.19-10.tar.gz"
sha256 "b819d81b9cdef497dd5fd1044ddb033d222b986cf610cb5d4bb1fa5010dba580"
bottle do
sha256 "c6ad05c52e82f419f65a46bd627c784fec43dfb8545e68fb4939995fb5fefed2" => :catalina
sha256 "cae8782ea16aa5fdfebe4ccac3189d2e7fbdc0d6290c0b8fda6ab46792f956eb" => :mojave
sha256 "30719045c2ee376f8cf269e12fcd307f7d0313338b59b6e1c24861207177b287" => :high_sierra
sha256 "01688c524edd4d9449141e73c9eee00c27e5ed8075281c70b3bc2e7ad04307ea" => :x86_64_linux
end
pour_bottle? do
reason "The bottle needs a var/mysql datadir (yours is var/percona)."
satisfy { datadir == var/"mysql" }
end
depends_on "cmake" => :build
depends_on "openssl@1.1"
uses_from_macos "curl"
on_linux do
depends_on "pkg-config" => :build
depends_on "libedit"
depends_on "readline"
end
conflicts_with "mariadb", "mysql",
:because => "percona, mariadb, and mysql install the same binaries."
conflicts_with "protobuf",
:because => "both install libprotobuf(-lite) libraries."
# https://bugs.mysql.com/bug.php?id=86711
# https://github.com/Homebrew/homebrew-core/pull/20538
fails_with :clang do
build 800
cause "Wrong inlining with Clang 8.0, see MySQL Bug #86711"
end
resource "boost" do
url "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.bz2"
sha256 "430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778"
end
# Where the database files should be located. Existing installs have them
# under var/percona, but going forward they will be under var/mysql to be
# shared with the mysql and mariadb formulae.
def datadir
@datadir ||= (var/"percona").directory? ? var/"percona" : var/"mysql"
end
def install
args = %W[
-DFORCE_INSOURCE_BUILD=1
-DCOMPILATION_COMMENT=Homebrew
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_INFODIR=share/info
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_PLUGINDIR=lib/percona-server/plugin
-DMYSQL_DATADIR=#{datadir}
-DSYSCONFDIR=#{etc}
-DWITH_SSL=yes
-DWITH_UNIT_TESTS=OFF
-DWITH_EMBEDDED_SERVER=ON
-DENABLED_LOCAL_INFILE=1
-DWITH_INNODB_MEMCACHED=ON
-DWITH_EDITLINE=system
]
args << "-DWITH_EDITLINE=system" if OS.mac?
# MySQL >5.7.x mandates Boost as a requirement to build & has a strict
# version check in place to ensure it only builds against expected release.
# This is problematic when Boost releases don't align with MySQL releases.
(buildpath/"boost").install resource("boost")
args << "-DWITH_BOOST=#{buildpath}/boost"
# Percona MyRocks does not compile on macOS
# https://bugs.launchpad.net/percona-server/+bug/1741639
args.concat %w[-DWITHOUT_ROCKSDB=1]
# TokuDB does not compile on macOS
# https://bugs.launchpad.net/percona-server/+bug/1531446
args.concat %w[-DWITHOUT_TOKUDB=1]
system "cmake", ".", *std_cmake_args, *args
system "make"
system "make", "install"
if OS.mac?
(prefix/"mysql-test").cd do
system "./mysql-test-run.pl", "status", "--vardir=#{Dir.mktmpdir}"
end
end
# Test is disabled on Linux as it is currently failing
# Remove the tests directory
rm_rf prefix/"mysql-test"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Fix up the control script and link into bin.
inreplace "#{prefix}/support-files/mysql.server",
/^(PATH=".*)(")/,
"\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"
# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
etc.install "my.cnf"
end
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
def caveats
s = <<~EOS
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
EOS
if (my_cnf = ["/etc/my.cnf", "/etc/mysql/my.cnf"].find { |x| File.exist? x })
s += <<~EOS
A "#{my_cnf}" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
end
s
end
plist_options :manual => "mysql.server start"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mysqld_safe</string>
<string>--datadir=#{datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{datadir}</string>
</dict>
</plist>
EOS
end
test do
# Expects datadir to be a completely clean dir, which testpath isn't.
dir = Dir.mktmpdir
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{dir}", "--tmpdir=#{dir}"
pid = fork do
exec bin/"mysqld", "--bind-address=127.0.0.1", "--datadir=#{dir}"
end
sleep 2
output = shell_output("curl 127.0.0.1:3306")
output.force_encoding("ASCII-8BIT") if output.respond_to?(:force_encoding)
assert_match version.to_s, output
ensure
Process.kill(9, pid)
Process.wait(pid)
end
end
|
class Scipy < Formula
desc "Software for mathematics, science, and engineering"
homepage "https://www.scipy.org"
url "https://files.pythonhosted.org/packages/0a/2e/44795c6398e24e45fa0bb61c3e98de1cfea567b1b51efd3751e2f7ff9720/scipy-1.9.3.tar.gz"
sha256 "fbc5c05c85c1a02be77b1ff591087c83bc44579c6d2bd9fb798bb64ea5e1a027"
license "BSD-3-Clause"
head "https://github.com/scipy/scipy.git", branch: "master"
bottle do
sha256 cellar: :any, arm64_ventura: "455c198c142f0054ae790af648812f41b29f1c3edb8fba3c1ffb49f69e527859"
sha256 cellar: :any, arm64_monterey: "2512ac50b80ad92ed389dc61c94179e8160042177947e0bda7e311195b2750d6"
sha256 cellar: :any, arm64_big_sur: "c367e57dcdf1b3db85b83b457aff95dfe2554ec0ec4925d85f56624606b80121"
sha256 cellar: :any, monterey: "a5d8342faf46f4f723972fd334e6809ad6b6e7ab7fd76b3f73dc2cd77db4a7aa"
sha256 cellar: :any, big_sur: "208d32b6a8d44a72a361e28fb71323a1dee9f1f04b08b67ae294f03c00bd653e"
sha256 cellar: :any, catalina: "23ddcd03518a66cb676796fa86084fa908ed8eb8f484a281f18e94f317365376"
sha256 cellar: :any_skip_relocation, x86_64_linux: "893bc4b5608de2723a31aad55142f3f5920b15c0f4507cd42f8daecdfbc98dc8"
end
depends_on "libcython" => :build
depends_on "pythran" => :build
depends_on "swig" => :build
depends_on "gcc" # for gfortran
depends_on "numpy"
depends_on "openblas"
depends_on "pybind11"
depends_on "python@3.10"
cxxstdlib_check :skip
fails_with gcc: "5"
def python3
"python3.10"
end
def install
openblas = Formula["openblas"]
ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework
ENV["BLAS"] = ENV["LAPACK"] = openblas.opt_lib/shared_library("libopenblas")
config = <<~EOS
[DEFAULT]
library_dirs = #{HOMEBREW_PREFIX}/lib
include_dirs = #{HOMEBREW_PREFIX}/include
[openblas]
libraries = openblas
library_dirs = #{openblas.opt_lib}
include_dirs = #{openblas.opt_include}
EOS
Pathname("site.cfg").write config
site_packages = Language::Python.site_packages(python3)
ENV.prepend_path "PYTHONPATH", Formula["libcython"].opt_libexec/site_packages
ENV.prepend_path "PYTHONPATH", Formula["pythran"].opt_libexec/site_packages
ENV.prepend_path "PYTHONPATH", Formula["numpy"].opt_prefix/site_packages
ENV.prepend_create_path "PYTHONPATH", site_packages
system python3, "setup.py", "build", "--fcompiler=gfortran", "--parallel=#{ENV.make_jobs}"
system python3, *Language::Python.setup_install_args(prefix, python3)
end
# cleanup leftover .pyc files from previous installs which can cause problems
# see https://github.com/Homebrew/homebrew-python/issues/185#issuecomment-67534979
def post_install
rm_f Dir["#{HOMEBREW_PREFIX}/lib/python*.*/site-packages/scipy/**/*.pyc"]
end
test do
system python3, "-c", "import scipy"
end
end
scipy: migrate to `python@3.11`
Closes #115544.
Signed-off-by: Sean Molenaar <2b250e3fea88cfef248b497ad5fc17f7dc435154@users.noreply.github.com>
Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com>
class Scipy < Formula
desc "Software for mathematics, science, and engineering"
homepage "https://www.scipy.org"
url "https://files.pythonhosted.org/packages/0a/2e/44795c6398e24e45fa0bb61c3e98de1cfea567b1b51efd3751e2f7ff9720/scipy-1.9.3.tar.gz"
sha256 "fbc5c05c85c1a02be77b1ff591087c83bc44579c6d2bd9fb798bb64ea5e1a027"
license "BSD-3-Clause"
revision 1
head "https://github.com/scipy/scipy.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_ventura: "455c198c142f0054ae790af648812f41b29f1c3edb8fba3c1ffb49f69e527859"
sha256 cellar: :any, arm64_monterey: "2512ac50b80ad92ed389dc61c94179e8160042177947e0bda7e311195b2750d6"
sha256 cellar: :any, arm64_big_sur: "c367e57dcdf1b3db85b83b457aff95dfe2554ec0ec4925d85f56624606b80121"
sha256 cellar: :any, monterey: "a5d8342faf46f4f723972fd334e6809ad6b6e7ab7fd76b3f73dc2cd77db4a7aa"
sha256 cellar: :any, big_sur: "208d32b6a8d44a72a361e28fb71323a1dee9f1f04b08b67ae294f03c00bd653e"
sha256 cellar: :any, catalina: "23ddcd03518a66cb676796fa86084fa908ed8eb8f484a281f18e94f317365376"
sha256 cellar: :any_skip_relocation, x86_64_linux: "893bc4b5608de2723a31aad55142f3f5920b15c0f4507cd42f8daecdfbc98dc8"
end
depends_on "libcython" => :build
depends_on "pythran" => :build
depends_on "swig" => :build
depends_on "gcc" # for gfortran
depends_on "numpy"
depends_on "openblas"
depends_on "pybind11"
depends_on "python@3.11"
cxxstdlib_check :skip
fails_with gcc: "5"
def python3
"python3.11"
end
def install
openblas = Formula["openblas"]
ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework
ENV["BLAS"] = ENV["LAPACK"] = openblas.opt_lib/shared_library("libopenblas")
config = <<~EOS
[DEFAULT]
library_dirs = #{HOMEBREW_PREFIX}/lib
include_dirs = #{HOMEBREW_PREFIX}/include
[openblas]
libraries = openblas
library_dirs = #{openblas.opt_lib}
include_dirs = #{openblas.opt_include}
EOS
Pathname("site.cfg").write config
site_packages = Language::Python.site_packages(python3)
ENV.prepend_path "PYTHONPATH", Formula["libcython"].opt_libexec/site_packages
ENV.prepend_path "PYTHONPATH", Formula["pythran"].opt_libexec/site_packages
ENV.prepend_path "PYTHONPATH", Formula["numpy"].opt_prefix/site_packages
ENV.prepend_create_path "PYTHONPATH", site_packages
system python3, "setup.py", "build", "--fcompiler=gfortran", "--parallel=#{ENV.make_jobs}"
system python3, *Language::Python.setup_install_args(prefix, python3)
end
# cleanup leftover .pyc files from previous installs which can cause problems
# see https://github.com/Homebrew/homebrew-python/issues/185#issuecomment-67534979
def post_install
rm_f Dir["#{HOMEBREW_PREFIX}/lib/python*.*/site-packages/scipy/**/*.pyc"]
end
test do
(testpath/"test.py").write <<~EOS
from scipy import special
print(special.exp10(3))
EOS
assert_equal "1000.0", shell_output("#{python3} test.py").chomp
end
end
|
class PostgresqlAT95 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v9.5.14/postgresql-9.5.14.tar.bz2"
sha256 "3e2cd5ea0117431f72c9917c1bbad578ea68732cb284d1691f37356ca0301a4d"
bottle do
sha256 "2de49b45cb095b3f6496bd1b419ae4259290533ec121ca6c21d697c7c4cf1f90" => :high_sierra
sha256 "2eff09a3882395cc5977e44d0b30034e2d0a0d5efd28a919b0f0619cad68b407" => :sierra
sha256 "eedf1f4356caddb999721ef77fa5c6ebd9b628001de31eb499658bbfb08b3046" => :el_capitan
end
keg_only :versioned_formula
option "without-perl", "Build without Perl support"
if OS.mac?
option "without-tcl", "Build without Tcl support"
else
option "with-tcl", "Build with Tcl support"
end
option "with-dtrace", "Build with DTrace support"
option "with-python", "Build with Python3 (incompatible with --with-python@2)"
option "with-python@2", "Build with Python2 (incompatible with --with-python)"
deprecated_option "with-python3" => "with-python"
depends_on "openssl"
depends_on "readline"
depends_on "python" => :optional
depends_on "python@2" => :optional
unless OS.mac?
depends_on "libxslt"
depends_on "perl" => :recommended # for libperl.so
depends_on "tcl-tk" if build.with? "tcl"
depends_on "util-linux" # for libuuid
end
fails_with :clang do
build 211
cause "Miscompilation resulting in segfault on queries"
end
def install
ENV.prepend "LDFLAGS", "-L#{Formula["openssl"].opt_lib} -L#{Formula["readline"].opt_lib}"
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl"].opt_include} -I#{Formula["readline"].opt_include}"
# avoid adding the SDK library directory to the linker search path
ENV["XML2_CONFIG"] = "xml2-config --exec-prefix=/usr"
args = %W[
--disable-debug
--prefix=#{prefix}
--datadir=#{pkgshare}
--libdir=#{lib}
--sysconfdir=#{prefix}/etc
--docdir=#{doc}
--enable-thread-safety
--with-openssl
--with-libxml
--with-libxslt
]
args += %w[
--with-bonjour
--with-gssapi
--with-ldap
--with-pam
] if OS.mac?
args << "--with-perl" if build.with? "perl"
which_python = nil
if build.with?("python") && build.with?("python@2")
odie "Cannot provide both --with-python and --with-python@2"
elsif build.with?("python") || build.with?("python@2")
args << "--with-python"
which_python = which(build.with?("python") ? "python3" : "python2.7")
end
ENV["PYTHON"] = which_python
# The CLT is required to build Tcl support on 10.7 and 10.8 because
# tclConfig.sh is not part of the SDK
if build.with?("tcl") && (MacOS.version >= :mavericks || MacOS::CLT.installed?)
args << "--with-tcl"
if File.exist?("#{MacOS.sdk_path}/System/Library/Frameworks/Tcl.framework/tclConfig.sh")
args << "--with-tclconfig=#{MacOS.sdk_path}/System/Library/Frameworks/Tcl.framework"
end
end
args << "--enable-dtrace" if build.with? "dtrace"
args << "--with-uuid=e2fs"
system "./configure", *args
system "make"
system "make", "install-world", "datadir=#{pkgshare}",
"libdir=#{lib}",
"pkglibdir=#{lib}"
end
def post_install
(var/"log").mkpath
(var/name).mkpath
unless File.exist? "#{var}/#{name}/PG_VERSION"
system "#{bin}/initdb", "#{var}/#{name}"
end
end
def caveats; <<~EOS
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/legacy-homebrew/issues/2510
To migrate existing data from a previous major version (pre-9.0) of PostgreSQL, see:
https://www.postgresql.org/docs/9.5/static/upgrading.html
To migrate existing data from a previous minor version (9.0-9.4) of PostgreSQL, see:
https://www.postgresql.org/docs/9.5/static/pgupgrade.html
You will need your previous PostgreSQL installation from brew to perform `pg_upgrade`.
Do not run `brew cleanup postgresql@9.5` until you have performed the migration.
EOS
end
plist_options :manual => "pg_ctl -D #{HOMEBREW_PREFIX}/var/postgresql@9.5 start"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/postgres</string>
<string>-D</string>
<string>#{var}/#{name}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/#{name}.log</string>
</dict>
</plist>
EOS
end
test do
system "#{bin}/initdb", testpath/"test"
assert_equal pkgshare.to_s, shell_output("#{bin}/pg_config --sharedir").chomp
assert_equal lib.to_s, shell_output("#{bin}/pg_config --libdir").chomp
assert_equal lib.to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
end
end
postgresql@9.5: update 9.5.14 bottle for Linuxbrew.
Closes Linuxbrew/homebrew-core#8812.
Signed-off-by: Michka Popoff <7b0496f66f66ee22a38826c310c38b415671b832@gmail.com>
class PostgresqlAT95 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v9.5.14/postgresql-9.5.14.tar.bz2"
sha256 "3e2cd5ea0117431f72c9917c1bbad578ea68732cb284d1691f37356ca0301a4d"
bottle do
sha256 "2de49b45cb095b3f6496bd1b419ae4259290533ec121ca6c21d697c7c4cf1f90" => :high_sierra
sha256 "2eff09a3882395cc5977e44d0b30034e2d0a0d5efd28a919b0f0619cad68b407" => :sierra
sha256 "eedf1f4356caddb999721ef77fa5c6ebd9b628001de31eb499658bbfb08b3046" => :el_capitan
sha256 "d42738d853e6cc083508abc16402d91c0b633f650e8ebb0941b07f9116fc77ea" => :x86_64_linux
end
keg_only :versioned_formula
option "without-perl", "Build without Perl support"
if OS.mac?
option "without-tcl", "Build without Tcl support"
else
option "with-tcl", "Build with Tcl support"
end
option "with-dtrace", "Build with DTrace support"
option "with-python", "Build with Python3 (incompatible with --with-python@2)"
option "with-python@2", "Build with Python2 (incompatible with --with-python)"
deprecated_option "with-python3" => "with-python"
depends_on "openssl"
depends_on "readline"
depends_on "python" => :optional
depends_on "python@2" => :optional
unless OS.mac?
depends_on "libxslt"
depends_on "perl" => :recommended # for libperl.so
depends_on "tcl-tk" if build.with? "tcl"
depends_on "util-linux" # for libuuid
end
fails_with :clang do
build 211
cause "Miscompilation resulting in segfault on queries"
end
def install
ENV.prepend "LDFLAGS", "-L#{Formula["openssl"].opt_lib} -L#{Formula["readline"].opt_lib}"
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl"].opt_include} -I#{Formula["readline"].opt_include}"
# avoid adding the SDK library directory to the linker search path
ENV["XML2_CONFIG"] = "xml2-config --exec-prefix=/usr"
args = %W[
--disable-debug
--prefix=#{prefix}
--datadir=#{pkgshare}
--libdir=#{lib}
--sysconfdir=#{prefix}/etc
--docdir=#{doc}
--enable-thread-safety
--with-openssl
--with-libxml
--with-libxslt
]
args += %w[
--with-bonjour
--with-gssapi
--with-ldap
--with-pam
] if OS.mac?
args << "--with-perl" if build.with? "perl"
which_python = nil
if build.with?("python") && build.with?("python@2")
odie "Cannot provide both --with-python and --with-python@2"
elsif build.with?("python") || build.with?("python@2")
args << "--with-python"
which_python = which(build.with?("python") ? "python3" : "python2.7")
end
ENV["PYTHON"] = which_python
# The CLT is required to build Tcl support on 10.7 and 10.8 because
# tclConfig.sh is not part of the SDK
if build.with?("tcl") && (MacOS.version >= :mavericks || MacOS::CLT.installed?)
args << "--with-tcl"
if File.exist?("#{MacOS.sdk_path}/System/Library/Frameworks/Tcl.framework/tclConfig.sh")
args << "--with-tclconfig=#{MacOS.sdk_path}/System/Library/Frameworks/Tcl.framework"
end
end
args << "--enable-dtrace" if build.with? "dtrace"
args << "--with-uuid=e2fs"
system "./configure", *args
system "make"
system "make", "install-world", "datadir=#{pkgshare}",
"libdir=#{lib}",
"pkglibdir=#{lib}"
end
def post_install
(var/"log").mkpath
(var/name).mkpath
unless File.exist? "#{var}/#{name}/PG_VERSION"
system "#{bin}/initdb", "#{var}/#{name}"
end
end
def caveats; <<~EOS
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/legacy-homebrew/issues/2510
To migrate existing data from a previous major version (pre-9.0) of PostgreSQL, see:
https://www.postgresql.org/docs/9.5/static/upgrading.html
To migrate existing data from a previous minor version (9.0-9.4) of PostgreSQL, see:
https://www.postgresql.org/docs/9.5/static/pgupgrade.html
You will need your previous PostgreSQL installation from brew to perform `pg_upgrade`.
Do not run `brew cleanup postgresql@9.5` until you have performed the migration.
EOS
end
plist_options :manual => "pg_ctl -D #{HOMEBREW_PREFIX}/var/postgresql@9.5 start"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/postgres</string>
<string>-D</string>
<string>#{var}/#{name}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/#{name}.log</string>
</dict>
</plist>
EOS
end
test do
system "#{bin}/initdb", testpath/"test"
assert_equal pkgshare.to_s, shell_output("#{bin}/pg_config --sharedir").chomp
assert_equal lib.to_s, shell_output("#{bin}/pg_config --libdir").chomp
assert_equal lib.to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
end
end
|
class Scons < Formula
include Language::Python::Virtualenv
desc "Substitute for classic 'make' tool with autoconf/automake functionality"
homepage "https://www.scons.org/"
url "https://files.pythonhosted.org/packages/5e/f1/82e5d9c0621f116415526181610adf3f9b07ffca419620f4edfc41ef5237/SCons-4.2.0.tar.gz"
sha256 "691893b63f38ad14295f5104661d55cb738ec6514421c6261323351c25432b0a"
license "MIT"
revision 1
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "e2d4ba2cf999877f61995e55235552997d2236d66d69d29d9e93059876cf7656"
sha256 cellar: :any_skip_relocation, big_sur: "a5e7cc6c2d5dc05d1cd02ca3927425ccaf583cbbe2a8d97760bfa45d8479bd80"
sha256 cellar: :any_skip_relocation, catalina: "a5e7cc6c2d5dc05d1cd02ca3927425ccaf583cbbe2a8d97760bfa45d8479bd80"
sha256 cellar: :any_skip_relocation, mojave: "a5e7cc6c2d5dc05d1cd02ca3927425ccaf583cbbe2a8d97760bfa45d8479bd80"
sha256 cellar: :any_skip_relocation, x86_64_linux: "6ea01cfe768ad1e59ec0c1dc6e777c6ab36fb821ca553bf5e54d9f74dd35b07f"
end
depends_on "python@3.10"
def install
virtualenv_install_with_resources
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
int main()
{
printf("Homebrew");
return 0;
}
EOS
(testpath/"SConstruct").write "Program('test.c')"
system bin/"scons"
assert_equal "Homebrew", shell_output("#{testpath}/test")
end
end
scons: update 4.2.0_1 bottle.
class Scons < Formula
include Language::Python::Virtualenv
desc "Substitute for classic 'make' tool with autoconf/automake functionality"
homepage "https://www.scons.org/"
url "https://files.pythonhosted.org/packages/5e/f1/82e5d9c0621f116415526181610adf3f9b07ffca419620f4edfc41ef5237/SCons-4.2.0.tar.gz"
sha256 "691893b63f38ad14295f5104661d55cb738ec6514421c6261323351c25432b0a"
license "MIT"
revision 1
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "e2d4ba2cf999877f61995e55235552997d2236d66d69d29d9e93059876cf7656"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "e2d4ba2cf999877f61995e55235552997d2236d66d69d29d9e93059876cf7656"
sha256 cellar: :any_skip_relocation, big_sur: "a5e7cc6c2d5dc05d1cd02ca3927425ccaf583cbbe2a8d97760bfa45d8479bd80"
sha256 cellar: :any_skip_relocation, catalina: "a5e7cc6c2d5dc05d1cd02ca3927425ccaf583cbbe2a8d97760bfa45d8479bd80"
sha256 cellar: :any_skip_relocation, mojave: "a5e7cc6c2d5dc05d1cd02ca3927425ccaf583cbbe2a8d97760bfa45d8479bd80"
sha256 cellar: :any_skip_relocation, x86_64_linux: "6ea01cfe768ad1e59ec0c1dc6e777c6ab36fb821ca553bf5e54d9f74dd35b07f"
end
depends_on "python@3.10"
def install
virtualenv_install_with_resources
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
int main()
{
printf("Homebrew");
return 0;
}
EOS
(testpath/"SConstruct").write "Program('test.c')"
system bin/"scons"
assert_equal "Homebrew", shell_output("#{testpath}/test")
end
end
|
class PrometheusCpp < Formula
desc "Prometheus Client Library for Modern C++"
homepage "https://github.com/jupp0r/prometheus-cpp"
url "https://github.com/jupp0r/prometheus-cpp.git",
tag: "v0.12.0",
revision: "af8449400d1bd8fcdb760cb8eb8f9866322e6831",
shallow: false
license "MIT"
head "https://github.com/jupp0r/prometheus-cpp.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "70a31e89a4af6f09ef7cb066ab77af273a7f3cbb48aca8ef7eaa6f745115faab"
sha256 cellar: :any_skip_relocation, big_sur: "0300ab178d6db69859e839f636d01d21382728c82e000109e57f6514337ad966"
sha256 cellar: :any_skip_relocation, catalina: "b32c20bd785eb14081f392ee9228365a7d73982b757c501951258f6547fb6a73"
sha256 cellar: :any_skip_relocation, mojave: "145d8f33887aafd06efbcaf6cd23931c728ce9de4fff31fe67bc0ecf32f65e44"
end
depends_on "cmake" => :build
uses_from_macos "curl"
uses_from_macos "zlib"
def install
system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <prometheus/Registry.h>
int main() {
prometheus::Registry reg;
return 0;
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-I#{include}", "-L#{lib}", "-lprometheus-cpp-core", "-o", "test"
system "./test"
end
end
prometheus-cpp 0.12.1
Closes #70504.
Signed-off-by: Carlo Cabrera <3ffc397d0e4bded29cb84b56167de54c01e3a55b@users.noreply.github.com>
class PrometheusCpp < Formula
desc "Prometheus Client Library for Modern C++"
homepage "https://github.com/jupp0r/prometheus-cpp"
url "https://github.com/jupp0r/prometheus-cpp.git",
tag: "v0.12.1",
revision: "38130aee330377d6289a076628dbe450d59ef3e9",
shallow: false
license "MIT"
head "https://github.com/jupp0r/prometheus-cpp.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "70a31e89a4af6f09ef7cb066ab77af273a7f3cbb48aca8ef7eaa6f745115faab"
sha256 cellar: :any_skip_relocation, big_sur: "0300ab178d6db69859e839f636d01d21382728c82e000109e57f6514337ad966"
sha256 cellar: :any_skip_relocation, catalina: "b32c20bd785eb14081f392ee9228365a7d73982b757c501951258f6547fb6a73"
sha256 cellar: :any_skip_relocation, mojave: "145d8f33887aafd06efbcaf6cd23931c728ce9de4fff31fe67bc0ecf32f65e44"
end
depends_on "cmake" => :build
uses_from_macos "curl"
uses_from_macos "zlib"
def install
system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <prometheus/Registry.h>
int main() {
prometheus::Registry reg;
return 0;
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-I#{include}", "-L#{lib}", "-lprometheus-cpp-core", "-o", "test"
system "./test"
end
end
|
class Scons < Formula
include Language::Python::Virtualenv
desc "Substitute for classic 'make' tool with autoconf/automake functionality"
homepage "https://www.scons.org/"
url "https://files.pythonhosted.org/packages/ae/a4/2eb8d05b0ac9e168e8ff0681624c123a123c743487e528757c68ea995d20/SCons-4.0.1.tar.gz"
mirror "https://downloads.sourceforge.net/project/scons/scons/4.0.1/scons-4.0.1.tar.gz"
sha256 "722ed104b5c624ecdc89bd4e02b094d2b14d99d47b5d0501961e47f579a2007c"
livecheck do
url :stable
end
bottle do
cellar :any_skip_relocation
sha256 "304947ac78f6fb291360bca97c7ba495a82f999511fb3d3860c135ad73ca47d3" => :catalina
sha256 "9a9b2241fd86340b88542b562a1083e999010d7cc856268b62e3f0db8ec01cf4" => :mojave
sha256 "80eeb9e673e901db3e9a2e040f438e8cece45a5ca9d38e39f504bfe8bcbf7ea4" => :high_sierra
end
depends_on "python@3.8"
def install
virtualenv_install_with_resources
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
int main()
{
printf("Homebrew");
return 0;
}
EOS
(testpath/"SConstruct").write "Program('test.c')"
system bin/"scons"
assert_equal "Homebrew", shell_output("#{testpath}/test")
end
end
scons: migrate to python@3.9
class Scons < Formula
include Language::Python::Virtualenv
desc "Substitute for classic 'make' tool with autoconf/automake functionality"
homepage "https://www.scons.org/"
url "https://files.pythonhosted.org/packages/ae/a4/2eb8d05b0ac9e168e8ff0681624c123a123c743487e528757c68ea995d20/SCons-4.0.1.tar.gz"
mirror "https://downloads.sourceforge.net/project/scons/scons/4.0.1/scons-4.0.1.tar.gz"
sha256 "722ed104b5c624ecdc89bd4e02b094d2b14d99d47b5d0501961e47f579a2007c"
revision 1
livecheck do
url :stable
end
bottle do
cellar :any_skip_relocation
sha256 "304947ac78f6fb291360bca97c7ba495a82f999511fb3d3860c135ad73ca47d3" => :catalina
sha256 "9a9b2241fd86340b88542b562a1083e999010d7cc856268b62e3f0db8ec01cf4" => :mojave
sha256 "80eeb9e673e901db3e9a2e040f438e8cece45a5ca9d38e39f504bfe8bcbf7ea4" => :high_sierra
end
depends_on "python@3.9"
def install
virtualenv_install_with_resources
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
int main()
{
printf("Homebrew");
return 0;
}
EOS
(testpath/"SConstruct").write "Program('test.c')"
system bin/"scons"
assert_equal "Homebrew", shell_output("#{testpath}/test")
end
end
|
class ShairportSync < Formula
desc "AirTunes emulator that adds multi-room capability"
homepage "https://github.com/mikebrady/shairport-sync"
url "https://github.com/mikebrady/shairport-sync/archive/3.1.4.tar.gz"
sha256 "4c5a2ab40ef49896f5b6e59b20df4f621ebce47ee64d8571336f59820ae66379"
head "https://github.com/mikebrady/shairport-sync.git", :branch => "development"
bottle do
sha256 "6a9a583ac9762accefd763a1da03780b1379dbf195016186543d341baf78151b" => :high_sierra
sha256 "7295bb44ed4cb087e4ab07d1b146b955982e93e099320bfefb671f2fbeeddfcc" => :sierra
sha256 "3ffa9e0965500ecfd2a673d99030af823a8b9b55df98b84b634d049150178466" => :el_capitan
end
depends_on "pkg-config" => :build
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "openssl"
depends_on "popt"
depends_on "libsoxr"
depends_on "libao"
depends_on "libdaemon"
depends_on "libconfig"
def install
system "autoreconf", "-fvi"
args = %W[
--with-os=darwin
--with-ssl=openssl
--with-dns_sd
--with-ao
--with-stdout
--with-pipe
--with-soxr
--with-metadata
--with-piddir=#{var}/run
--sysconfdir=#{etc}/shairport-sync
--prefix=#{prefix}
]
system "./configure", *args
system "make", "install"
end
def post_install
(var/"run").mkpath
end
test do
output = shell_output("#{bin}/shairport-sync -V", 1)
assert_match "OpenSSL-ao-stdout-pipe-soxr-metadata", output
end
end
shairport-sync 3.1.7
Closes #22694.
Signed-off-by: ilovezfs <fbd54dbbcf9e596abad4ccdc4dfc17f80ebeaee2@icloud.com>
class ShairportSync < Formula
desc "AirTunes emulator that adds multi-room capability"
homepage "https://github.com/mikebrady/shairport-sync"
url "https://github.com/mikebrady/shairport-sync/archive/3.1.7.tar.gz"
sha256 "2f5751c9be2236045f697c71c34abd1a6463457750c7df3d4a42568eeef6d98c"
head "https://github.com/mikebrady/shairport-sync.git", :branch => "development"
bottle do
sha256 "6a9a583ac9762accefd763a1da03780b1379dbf195016186543d341baf78151b" => :high_sierra
sha256 "7295bb44ed4cb087e4ab07d1b146b955982e93e099320bfefb671f2fbeeddfcc" => :sierra
sha256 "3ffa9e0965500ecfd2a673d99030af823a8b9b55df98b84b634d049150178466" => :el_capitan
end
depends_on "pkg-config" => :build
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "openssl"
depends_on "popt"
depends_on "libsoxr"
depends_on "libao"
depends_on "libdaemon"
depends_on "libconfig"
def install
system "autoreconf", "-fvi"
args = %W[
--with-os=darwin
--with-ssl=openssl
--with-dns_sd
--with-ao
--with-stdout
--with-pipe
--with-soxr
--with-metadata
--with-piddir=#{var}/run
--sysconfdir=#{etc}/shairport-sync
--prefix=#{prefix}
]
system "./configure", *args
system "make", "install"
end
def post_install
(var/"run").mkpath
end
test do
output = shell_output("#{bin}/shairport-sync -V", 1)
assert_match "OpenSSL-ao-stdout-pipe-soxr-metadata", output
end
end
|
class Admin::FormBuilder < ActionView::Helpers::FormBuilder
def content_block_fields(options = {})
render 'admin/content_blocks/block_list', f: self
end
def multi_select_field(method, *args)
options = args.extract_options!
options.reverse_merge!({
class: '',
data: {}
})
options[:data][:'autoload-path'] = options.delete(:path)
options[:class] += " multi-select-input"
text_field(method, *args, options)
end
def relation_field(name, *args)
options = args.extract_options!
options.reverse_merge!({
class: '',
data: {},
label_field: 'title'
})
label = options.delete(:label_field)
collection = @object.send(name)
options[:class] += " relation-input"
options[:data][:'label-field'] = label
options[:data][:preload] = collection.to_json
options[:value] = collection.collect(&:id).join(', ')
options[:path] = polymorphic_path([:admin, name], format: :json)
multi_select_field(name, *args, options)
end
def tag_field(name, *args)
options = args.extract_options!
options.reverse_merge!({
class: ''
})
list_name = "#{name.to_s.singularize}_list".to_sym
options[:path] = polymorphic_path([:admin, @object.class], action: 'tags', scope: name, format: :json)
options[:class] += " tag-input #{name}-input"
multi_select_field(list_name, *args, options)
end
def image_field(method, *args)
options = args.extract_options!
options.reverse_merge!({
progress_template: 'admin/shared/progress_template'
})
content_tag :div, class: 'image-field' do
image = @object.send(method.to_sym) || @object.send("build_#{method}")
uploader = fields_for(method, image) do |fields|
attachment = fields.file_field(:attachment, data: {
url: admin_images_path(format: :json)
})
content_tag(:div, class: 'image') do
concat image_attachment(image) unless image.new_record?
concat fields.image_destroy_field()
concat fields.hidden_field(:attachment_cache)
concat fields.hidden_field(:id, class: 'image-id')
end + attachment
end
concat uploader
concat render(options[:progress_template])
end
end
def images_field(method, *args, &block)
options = args.extract_options!
options.reverse_merge!({
progress_template: 'admin/shared/progress_template'
})
content_tag :div, class: 'images-field' do
images = image_field_images(method, @object.send(method), &block)
image = @object.send(method).new
uploader = fields_for(method, [image], child_index: image.object_id) do |fields|
template = content_tag :div, class: 'image' do
concat fields.image_attachment
concat fields.image_destroy_field
concat fields.position_field
concat fields.hidden_field(:id, class: 'image-id')
concat block.call(fields).html_safe if block
end
concat fields.file_field(:attachment, data: {
url: admin_images_path(format: :json),
multiple: true,
template: template.gsub(/\n/, ''),
replacement_id: image.object_id
})
end
concat images
concat uploader
concat render(options[:progress_template])
end
end
def image_field_images(method, images, &block)
content_tag :div, class: 'images' do
images.map do |image|
concat image_field_image(method, image, &block)
end
end
end
def image_field_image(method, image, &block)
content_tag :div, class: 'image' do
attribute_fields = fields_for(method, image) do |fields|
concat(block.call(fields)) if block
concat(fields.image_destroy_field)
concat fields.position_field
end
concat image_attachment(image) unless image.new_record?
concat attribute_fields
end
end
def image_attachment(image = nil)
image ||= @object
if image.attachment_url && image.attachment_url.split(//).last(3).join == 'pdf'
image_tag('brb/pdf-icon.png', width: 56, height: 57, class: 'image-attachment') +
content_tag(:div, image.attachment_url.split('/').last, class: 'pdf-attachment')
else
image_tag(image.attachment_url(:admin_thumb), class: 'image-attachment')
end
end
def image_destroy_field(options = {})
destroy_field(options) + link_to(raw('✘'), '#', class: 'delete')
end
def rich_text_area(*args)
options = args.extract_options!
options.reverse_merge!({
class: '',
toolbar: true
})
options[:class] += ' textarea'
display_toolbar = options.delete(:toolbar)
content_tag :div, class: 'rich-text-area' do
concat toolbar if display_toolbar
concat text_area(*args, options)
end
end
def video_field(name, *args)
options = args.extract_options!
options.reverse_merge!({
class: ''
})
options[:class] += ' video-field'
text_field(name, *args, options)
end
def toolbar
render 'admin/content_blocks/toolbar', field: self
end
def actions
content_tag :div, class: 'withgutters', id: 'submit-with-content-blocks' do
concat submit(data: {disable_with: 'Saving...'})
concat cancel_link
end
end
def cancel_link
path = polymorphic_path([:admin, @object.class])
link_to('Cancel', path, class: 'cancel-button')
end
def destroy_field(options = {})
options.reverse_merge!({
class: 'destroy',
value: @object && @object.marked_for_destruction?,
id: "destroy-#{self.object_id}"
})
hidden_field :_destroy, options
end
def position_field
hidden_field :position, class: 'position'
end
def new_slideshow_slide_button(label, options = {})
options.reverse_merge!({
type: :text
})
slide = @object.send(:slides).new slide_type: options[:type].to_s
id = slide.object_id
fields = fields_for :slides, slide, child_index: id do |field|
render('admin/content_blocks/slideshow_block/slide', f: field)
end
link_to(label, '#', data: { id: id, type: 'Slide', fields: fields.gsub('\n', '') }, class: 'new-slideshow-slide small-button')
end
def new_content_block(name, block_type, options = {})
options.reverse_merge! class: 'large-button'
content_block = @object.send(:content_blocks).new
id = content_block.object_id
fields = fields_for :content_blocks, content_block do |content_block_field|
render('admin/content_blocks/new', id: id, block_type: block_type, content_block: content_block, content_block_field: content_block_field, f: self, content_block_id: id)
end
link_to(name, '#', data: { id: id, type: block_type, fields: fields.gsub('\n', '') }, class: "new-content-block #{options[:class]}")
end
def new_content_block_buttons
content_tag :div, class: 'content-block-buttons' do
resource.available_content_blocks.each do |cb|
concat new_content_block("New #{cb}", cb)
end
end
end
def field(type, *args)
options = args.extract_options!
label = options[:label] || args.first
content_tag :div, class: 'field' do
concat self.label(label)
concat self.send(type, *args, options)
end
end
protected
def concat(*args)
@template.concat(*args)
end
def method_missing(method, *args, &block)
if @template.respond_to?(method)
@template.send(method, *args, &block)
else
super
end
end
private
def submit_default_value
object = convert_to_model(@object)
key = object ? (object.persisted? ? :update : :create) : :submit
model = if object.class.respond_to?(:to_title)
object.class.to_title
elsif object.class.respond_to?(:model_name)
object.class.model_name.human
else
@object_name.to_s.humanize
end
defaults = []
defaults << :"helpers.submit.#{object_name}.#{key}"
defaults << :"helpers.submit.#{key}"
defaults << "#{key.to_s.humanize} #{model}"
I18n.t(defaults.shift, model: model, default: defaults)
end
end
add state field
class Admin::FormBuilder < ActionView::Helpers::FormBuilder
def content_block_fields(options = {})
render 'admin/content_blocks/block_list', f: self
end
def multi_select_field(method, *args)
options = args.extract_options!
options.reverse_merge!({
class: '',
data: {}
})
options[:data][:'autoload-path'] = options.delete(:path)
options[:class] += " multi-select-input"
text_field(method, *args, options)
end
def relation_field(name, *args)
options = args.extract_options!
options.reverse_merge!({
class: '',
data: {},
label_field: 'title'
})
label = options.delete(:label_field)
collection = @object.send(name)
options[:class] += " relation-input"
options[:data][:'label-field'] = label
options[:data][:preload] = collection.to_json
options[:value] = collection.collect(&:id).join(', ')
options[:path] = polymorphic_path([:admin, name], format: :json)
multi_select_field(name, *args, options)
end
def tag_field(name, *args)
options = args.extract_options!
options.reverse_merge!({
class: ''
})
list_name = "#{name.to_s.singularize}_list".to_sym
options[:path] = polymorphic_path([:admin, @object.class], action: 'tags', scope: name, format: :json)
options[:class] += " tag-input #{name}-input"
multi_select_field(list_name, *args, options)
end
def image_field(method, *args)
options = args.extract_options!
options.reverse_merge!({
progress_template: 'admin/shared/progress_template'
})
content_tag :div, class: 'image-field' do
image = @object.send(method.to_sym) || @object.send("build_#{method}")
uploader = fields_for(method, image) do |fields|
attachment = fields.file_field(:attachment, data: {
url: admin_images_path(format: :json)
})
content_tag(:div, class: 'image') do
concat image_attachment(image) unless image.new_record?
concat fields.image_destroy_field()
concat fields.hidden_field(:attachment_cache)
concat fields.hidden_field(:id, class: 'image-id')
end + attachment
end
concat uploader
concat render(options[:progress_template])
end
end
def images_field(method, *args, &block)
options = args.extract_options!
options.reverse_merge!({
progress_template: 'admin/shared/progress_template'
})
content_tag :div, class: 'images-field' do
images = image_field_images(method, @object.send(method), &block)
image = @object.send(method).new
uploader = fields_for(method, [image], child_index: image.object_id) do |fields|
template = content_tag :div, class: 'image' do
concat fields.image_attachment
concat fields.image_destroy_field
concat fields.position_field
concat fields.hidden_field(:id, class: 'image-id')
concat block.call(fields).html_safe if block
end
concat fields.file_field(:attachment, data: {
url: admin_images_path(format: :json),
multiple: true,
template: template.gsub(/\n/, ''),
replacement_id: image.object_id
})
end
concat images
concat uploader
concat render(options[:progress_template])
end
end
def image_field_images(method, images, &block)
content_tag :div, class: 'images' do
images.map do |image|
concat image_field_image(method, image, &block)
end
end
end
def image_field_image(method, image, &block)
content_tag :div, class: 'image' do
attribute_fields = fields_for(method, image) do |fields|
concat(block.call(fields)) if block
concat(fields.image_destroy_field)
concat fields.position_field
end
concat image_attachment(image) unless image.new_record?
concat attribute_fields
end
end
def image_attachment(image = nil)
image ||= @object
if image.attachment_url && image.attachment_url.split(//).last(3).join == 'pdf'
image_tag('brb/pdf-icon.png', width: 56, height: 57, class: 'image-attachment') +
content_tag(:div, image.attachment_url.split('/').last, class: 'pdf-attachment')
else
image_tag(image.attachment_url(:admin_thumb), class: 'image-attachment')
end
end
def image_destroy_field(options = {})
destroy_field(options) + link_to(raw('✘'), '#', class: 'delete')
end
def rich_text_area(*args)
options = args.extract_options!
options.reverse_merge!({
class: '',
toolbar: true
})
options[:class] += ' textarea'
display_toolbar = options.delete(:toolbar)
content_tag :div, class: 'rich-text-area' do
concat toolbar if display_toolbar
concat text_area(*args, options)
end
end
def video_field(name, *args)
options = args.extract_options!
options.reverse_merge!({
class: ''
})
options[:class] += ' video-field'
text_field(name, *args, options)
end
def toolbar
render 'admin/content_blocks/toolbar', field: self
end
def actions
content_tag :div, class: 'withgutters', id: 'submit-with-content-blocks' do
concat submit(data: {disable_with: 'Saving...'})
concat cancel_link
end
end
def cancel_link
path = polymorphic_path([:admin, @object.class])
link_to('Cancel', path, class: 'cancel-button')
end
def destroy_field(options = {})
options.reverse_merge!({
class: 'destroy',
value: @object && @object.marked_for_destruction?,
id: "destroy-#{self.object_id}"
})
hidden_field :_destroy, options
end
def position_field
hidden_field :position, class: 'position'
end
def new_slideshow_slide_button(label, options = {})
options.reverse_merge!({
type: :text
})
slide = @object.send(:slides).new slide_type: options[:type].to_s
id = slide.object_id
fields = fields_for :slides, slide, child_index: id do |field|
render('admin/content_blocks/slideshow_block/slide', f: field)
end
link_to(label, '#', data: { id: id, type: 'Slide', fields: fields.gsub('\n', '') }, class: 'new-slideshow-slide small-button')
end
def new_content_block(name, block_type, options = {})
options.reverse_merge! class: 'large-button'
content_block = @object.send(:content_blocks).new
id = content_block.object_id
fields = fields_for :content_blocks, content_block do |content_block_field|
render('admin/content_blocks/new', id: id, block_type: block_type, content_block: content_block, content_block_field: content_block_field, f: self, content_block_id: id)
end
link_to(name, '#', data: { id: id, type: block_type, fields: fields.gsub('\n', '') }, class: "new-content-block #{options[:class]}")
end
def new_content_block_buttons
content_tag :div, class: 'content-block-buttons' do
resource.available_content_blocks.each do |cb|
concat new_content_block("New #{cb}", cb)
end
end
end
def state_field(name)
content_tag :div, style: "display: inline-block;" do
@object.aasm.states.each do |state|
concat state_option(name, state)
end
end
end
def state_option(name, state)
content_tag(:div, class: 'state-option') do
concat self.radio_button(name, state.name)
concat ' '
concat self.label("#{name}_#{state.name}".to_sym, state.localized_name)
end
end
def field(type, *args)
options = args.extract_options!
label = options[:label] || args.first
content_tag :div, class: 'field' do
concat self.label(label)
concat self.send(type, *args, options)
end
end
protected
def concat(*args)
@template.concat(*args)
end
def method_missing(method, *args, &block)
if @template.respond_to?(method)
@template.send(method, *args, &block)
else
super
end
end
private
def submit_default_value
object = convert_to_model(@object)
key = object ? (object.persisted? ? :update : :create) : :submit
model = if object.class.respond_to?(:to_title)
object.class.to_title
elsif object.class.respond_to?(:model_name)
object.class.model_name.human
else
@object_name.to_s.humanize
end
defaults = []
defaults << :"helpers.submit.#{object_name}.#{key}"
defaults << :"helpers.submit.#{key}"
defaults << "#{key.to_s.humanize} #{model}"
I18n.t(defaults.shift, model: model, default: defaults)
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.