Update temp_file.

This commit is contained in:
BoHung Chiu 2022-09-08 20:01:09 +08:00
parent f7e4abe2a7
commit 2b43026c29
2 changed files with 62 additions and 24 deletions

View File

@ -7,6 +7,7 @@ require "action_mailer/railtie"
require "sprockets/railtie" require "sprockets/railtie"
require "rails/test_unit/railtie" require "rails/test_unit/railtie"
require "mongoid" require "mongoid"
require "mongoid/config"
require "mongoid/railtie" require "mongoid/railtie"
require "bson" require "bson"
require 'rails' require 'rails'
@ -19,6 +20,32 @@ if Rails.version.to_i>4
end end
end end
end end
class ActionController::Parameters
BSON_TYPE = Hash.new.bson_type
def bson_type
BSON_TYPE
end
def method_missing(method_sym, *args, &block)
if @parameters.respond_to?(method_sym)
message = <<-DEPRECATE.squish
Method #{method_sym} is deprecated and will be removed in Rails 5.1,
as `ActionController::Parameters` no longer inherits from
hash. Using this deprecated behavior exposes potential security
problems. If you continue to use this method you may be creating
a security vulnerability in your app that can be exploited. Instead,
consider using one of these documented methods which are not
deprecated: http://api.rubyonrails.org/v#{ActionPack.version}/classes/ActionController/Parameters.html
DEPRECATE
ActiveSupport::Deprecation.warn(message)
@parameters.public_send(method_sym, *args, &block)
else
super
end
end
def to_bson_key(validating_keys = BSON::Config.validating_keys?)
self.to_s
end
end
end end
if RUBY_VERSION.to_f > 2.1 if RUBY_VERSION.to_f > 2.1
@ -72,6 +99,9 @@ if Mongoid::VERSION.to_i < 5
require "moped" require "moped"
Moped::BSON = BSON Moped::BSON = BSON
else else
if Mongoid::Config.respond_to?(:belongs_to_required_by_default)
Mongoid::Config.belongs_to_required_by_default = false
end
Mongoid::Sessions = Mongoid::Clients Mongoid::Sessions = Mongoid::Clients
Mongoid::Clients::StorageOptions::ClassMethods.module_eval do Mongoid::Clients::StorageOptions::ClassMethods.module_eval do
def store_in(options) def store_in(options)
@ -126,7 +156,7 @@ else
else else
Boolean = Mongoid::Boolean Boolean = Mongoid::Boolean
class Mongoid::Criteria::Queryable::Key class Mongoid::Criteria::Queryable::Key
def to_bson_key(validating_keys = Config.validating_keys?) def to_bson_key(validating_keys = BSON::Config.validating_keys?)
self.to_s self.to_s
end end
end end
@ -174,8 +204,17 @@ already_required = Bundler.require.map{|b| b.name}
if Thread.current[:dependency_gems].nil? if Thread.current[:dependency_gems].nil?
require File.expand_path('../set_global_variable.rb', __FILE__) require File.expand_path('../set_global_variable.rb', __FILE__)
end end
Thread.current[:dependency_gems].each{|gem_name| Bundler.require.push(Bundler::Dependency.new(gem_name,:runtime)) unless already_required.include?(gem_name)} dependency_gems = Thread.current[:dependency_gems]
Thread.current[:dependency_gems] = nil if dependency_gems.nil?
built_in_ext_lines = File.readlines('built_in_extensions.rb').map{|s| s.split("#")[0].to_s} rescue []
downloaded_ext_lines = File.readlines('downloaded_extensions.rb').map{|s| s.split("#")[0].to_s} rescue []
extras_ext_lines = File.readlines('extra_gems.rb').map{|s| s.split("#")[0].to_s} rescue []
orbit_ext_lines = (built_in_ext_lines + downloaded_ext_lines + extras_ext_lines)
orbit_ext_gems = orbit_ext_lines.map{|l| l.match(/gem\s+['"](\w+)['"]/)[1] rescue nil}.select{|s| s.present?}.uniq
orbit_gem_specs = Gem::Specification.find_all.select{|g| orbit_ext_gems.include?(g.name) & (g.source.class != Bundler::Source::Rubygems)}
dependency_gems = orbit_gem_specs.flat_map{|spec| spec.dependent_specs.map{|s| s.name}}.uniq
end
dependency_gems.each{|gem_name| Bundler.require.push(Bundler::Dependency.new(gem_name,:runtime)) unless already_required.include?(gem_name)}
Bundler.require(:default, Rails.env) Bundler.require(:default, Rails.env)
class CssPostProcessor class CssPostProcessor
def call(input) def call(input)

View File

@ -1,12 +1,31 @@
$:.push File.expand_path("../..", __FILE__) $:.push File.expand_path("../..", __FILE__)
require 'bundler' require 'bundler'
require 'config/boot' require 'config/boot'
require 'rails'
built_in_ext_lines = File.readlines('built_in_extensions.rb').map{|s| s.split("#")[0].to_s} rescue []
downloaded_ext_lines = File.readlines('downloaded_extensions.rb').map{|s| s.split("#")[0].to_s} rescue []
extras_ext_lines = File.readlines('extra_gems.rb').map{|s| s.split("#")[0].to_s} rescue []
orbit_ext_lines = (built_in_ext_lines + downloaded_ext_lines + extras_ext_lines)
orbit_ext_gems = orbit_ext_lines.map{|l| l.match(/gem\s+['"](\w+)['"]/)[1] rescue nil}.select{|s| s.present?}.uniq
orbit_gem_specs = Gem::Specification.find_all.select{|g| orbit_ext_gems.include?(g.name) & (g.source.class != Bundler::Source::Rubygems)}
Thread.current[:dependency_gems] = orbit_gem_specs.flat_map{|spec| spec.dependent_specs.map{|s| s.name}}.uniq
orbit_gems_paths = orbit_gem_specs.map{|gem| gem.full_gem_path}
orbit_ext_gems_models_paths = orbit_gems_paths.map{|d| Dir.glob("#{d}/app/models/*")}
orbit_models_categorized = orbit_ext_gems_models_paths.map.with_index do |models_paths,i|
gem_name = orbit_gem_specs[i].name
categorized = models_paths.select{|fn| File.read(fn).include?("OrbitCategory::Categorizable") rescue false}.map{|fn| File.basename(fn).split(".")[0].classify}
[gem_name, categorized]
end.to_h
orbit_ext_gems_models = orbit_ext_gems_models_paths.flatten.map{|fn| File.basename(fn).split(".")[0].classify}
File.open("orbit_ext_gems_tmp.txt","w+"){|f| f.write(orbit_ext_gems.to_json)}
File.open("orbit_ext_gems_models_tmp.txt","w+"){|f| f.write(orbit_ext_gems_models.to_json)}
File.open("orbit_categorized_tmp.txt","w+"){|f| f.write(orbit_models_categorized.to_json)}
require "config/application"
require 'lib/orbit_category/categorizable' require 'lib/orbit_category/categorizable'
require 'lib/orbit_tag/taggable' require 'lib/orbit_tag/taggable'
require 'lib/orbit_model/impression' require 'lib/orbit_model/impression'
require 'lib/orbit_model/status' require 'lib/orbit_model/status'
require 'rails'
require "mongoid" require "mongoid"
require "kaminari/mongoid" require "kaminari/mongoid"
require "mongoid/railtie" require "mongoid/railtie"
@ -43,26 +62,6 @@ if Site.count == 0
site.template = (Dir.glob("#{ENV['PWD']}/app/templates/*").collect{|temp| temp.split('/').last}-['mobile']).first site.template = (Dir.glob("#{ENV['PWD']}/app/templates/*").collect{|temp| temp.split('/').last}-['mobile']).first
site.save site.save
end end
built_in_ext_lines = File.readlines('built_in_extensions.rb').map{|s| s.split("#")[0].to_s} rescue []
downloaded_ext_lines = File.readlines('downloaded_extensions.rb').map{|s| s.split("#")[0].to_s} rescue []
extras_ext_lines = File.readlines('extra_gems.rb').map{|s| s.split("#")[0].to_s} rescue []
orbit_ext_lines = (built_in_ext_lines + downloaded_ext_lines + extras_ext_lines)
orbit_ext_gems = orbit_ext_lines.map{|l| l.match(/gem\s+['"](\w+)['"]/)[1] rescue nil}.select{|s| s.present?}.uniq
orbit_gem_specs = Gem::Specification.find_all.select{|g| orbit_ext_gems.include?(g.name) & (g.source.class != Bundler::Source::Rubygems)}
Thread.current[:dependency_gems] = orbit_gem_specs.flat_map{|spec| spec.dependent_specs.map{|s| s.name}}.uniq
orbit_gems_paths = orbit_gem_specs.map{|gem| gem.full_gem_path}
orbit_ext_gems_models_paths = orbit_gems_paths.map{|d| Dir.glob("#{d}/app/models/*")}
orbit_models_categorized = orbit_ext_gems_models_paths.map.with_index do |models_paths,i|
gem_name = orbit_gem_specs[i].name
categorized = models_paths.select{|fn| File.read(fn).include?("OrbitCategory::Categorizable") rescue false}.map{|fn| File.basename(fn).split(".")[0].classify}
[gem_name, categorized]
end.to_h
orbit_ext_gems_models = orbit_ext_gems_models_paths.flatten.map{|fn| File.basename(fn).split(".")[0].classify}
File.open("orbit_ext_gems_tmp.txt","w+"){|f| f.write(orbit_ext_gems.to_json)}
File.open("orbit_ext_gems_models_tmp.txt","w+"){|f| f.write(orbit_ext_gems_models.to_json)}
File.open("orbit_categorized_tmp.txt","w+"){|f| f.write(orbit_models_categorized.to_json)}
begin begin
require 'process_shared' require 'process_shared'
class ProcesssShareWraper class ProcesssShareWraper