adbanner-test/ad_banner.gemspec

91 lines
3.3 KiB
Ruby
Raw Permalink Normal View History

2014-04-11 07:47:33 +00:00
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "ad_banner/version"
2022-08-25 02:14:24 +00:00
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
if bundle_update_flag
2023-06-14 12:01:00 +00:00
env_pwd = ENV['PWD']
begin
require ::File.expand_path('app/helpers/bundler_helper.rb', env_pwd)
extend BundlerHelper
rescue LoadError
def bundler_with_clean_env(&block)
if block_given?
if Bundler.respond_to?(:with_unbundled_env)
Bundler.with_unbundled_env(&block)
else
Bundler.with_clean_env(&block)
end
end
end
end
2022-08-25 02:14:24 +00:00
require "fileutils"
app_path = File.expand_path(__dir__)
template_path = ENV['PWD'] + '/app/templates'
all_template = Dir.glob(template_path+'/*/')
puts 'copying module'
all_template.each do |folder|
if folder.split('/')[-1] != 'mobile'
begin
system ('cp -r '+ app_path + '/modules/ ' + folder)
rescue
puts 'error copy'
end
2021-04-10 15:16:17 +00:00
end
end
2022-08-25 02:14:24 +00:00
if Dir.exist?(ENV['PWD'] + "/public/uploads/ad_image")
puts "Fixing video blocked by ad block..."
begin
system ("mv #{ENV['PWD']}/public/uploads/ad_image #{ENV['PWD']}/public/uploads/banner_image")
rescue
puts 'error moving'
end
puts "Finish fixing!"
2022-01-03 09:33:54 +00:00
end
2022-08-25 02:14:24 +00:00
#download ffmpeg
begin
destination = ENV['PWD']+'/tmp/ffmpeg'
if Dir[destination].length==0
FileUtils.mkdir_p("#{ENV['PWD']}/tmp")
require 'open-uri'
if RUBY_VERSION.to_f >= 2.7
2022-10-04 05:14:34 +00:00
download = URI.open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip',:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)
2022-08-25 02:14:24 +00:00
else
2022-10-04 05:14:34 +00:00
download = open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip',:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)
2022-08-25 02:14:24 +00:00
end
save_zip_name = "#{ENV['PWD']}/tmp/ffmpeg-4.2-linux-64.zip"
IO.copy_stream(download, save_zip_name)
2023-06-14 12:01:00 +00:00
begin
require 'zip'
rescue LoadError
bundler_with_clean_env{system("gem install zip-zip")}
end
2022-08-25 02:14:24 +00:00
FileUtils.mkdir_p(destination)
Zip::File.open(save_zip_name) do |zip_file|
zip_file.each do |f|
fpath = File.join(destination, f.name)
zip_file.extract(f, fpath) unless File.exist?(fpath)
end
2021-10-22 15:31:10 +00:00
end
end
2022-08-25 02:14:24 +00:00
rescue => e
FileUtils.rmdir(destination) rescue nil
puts ["download ffmpeg failed",e]
2021-10-22 15:31:10 +00:00
end
end
#./ffmpeg -i 2.mp4 -c:v libvpx-vp9 -crf 35 -b:v 0 -b:a 96k -c:a libopus -filter:v fps=20 output.webm -cpu-used 4
2014-04-11 07:47:33 +00:00
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "ad_banner"
s.version = AdBanner::VERSION
s.authors = ["Ruling Digital"]
s.email = ["orbit@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = "Ad Banner management"
s.description = "Create Banners for Orbit"
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
end