diff --git a/temp_file/config/application.rb b/temp_file/config/application.rb index 0a9a878..efd6b14 100644 --- a/temp_file/config/application.rb +++ b/temp_file/config/application.rb @@ -7,6 +7,7 @@ require "action_mailer/railtie" require "sprockets/railtie" require "rails/test_unit/railtie" require "mongoid" +require "mongoid/config" require "mongoid/railtie" require "bson" require 'rails' @@ -19,6 +20,32 @@ if Rails.version.to_i>4 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 if RUBY_VERSION.to_f > 2.1 @@ -72,6 +99,9 @@ if Mongoid::VERSION.to_i < 5 require "moped" Moped::BSON = BSON 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::Clients::StorageOptions::ClassMethods.module_eval do def store_in(options) @@ -126,7 +156,7 @@ else else Boolean = Mongoid::Boolean 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 end end @@ -174,8 +204,17 @@ already_required = Bundler.require.map{|b| b.name} if Thread.current[:dependency_gems].nil? require File.expand_path('../set_global_variable.rb', __FILE__) end -Thread.current[:dependency_gems].each{|gem_name| Bundler.require.push(Bundler::Dependency.new(gem_name,:runtime)) unless already_required.include?(gem_name)} -Thread.current[:dependency_gems] = nil +dependency_gems = Thread.current[:dependency_gems] +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) class CssPostProcessor def call(input) diff --git a/temp_file/config/set_global_variable.rb b/temp_file/config/set_global_variable.rb index 903c0fd..2826028 100644 --- a/temp_file/config/set_global_variable.rb +++ b/temp_file/config/set_global_variable.rb @@ -1,12 +1,31 @@ $:.push File.expand_path("../..", __FILE__) require 'bundler' 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_tag/taggable' require 'lib/orbit_model/impression' require 'lib/orbit_model/status' -require 'rails' require "mongoid" require "kaminari/mongoid" 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.save 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 require 'process_shared' class ProcesssShareWraper