module Config
create a config.rb to override any of the jungle⦠values as needed:
Public Class Methods
application()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 49 def self.application jungle.application.id = 5 jungle.application.root_dir = ::File.expand_path('..',::File.dirname(__FILE__)) jungle.application.public_dir = File.join(jungle.application.root_dir, 'web_apps', 'public') jungle.application.name = 'jungle_path' jungle.application.url = nil jungle.application.logger = Logging.make_logger(jungle.application.root_dir, "#{jungle.application.name}_requests.log") # $stdout puts "application root dir: #{jungle.application.root_dir}" puts "application public dir: #{jungle.application.public_dir}" end
config_override()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 252 def self.config_override begin require_relative 'override' puts "[application root]/config/override.rb file was loaded." rescue LoadError => ex puts "warning!!! [application root]/config/override.rb file was not found, please create an override.rb file so that you can override default settings in 'config.rb'! override.rb should be in the same directory as config.rb." end end
db()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 64 def self.db jungle.db.name = "jungle_path" jungle.db.type = "postgres" jungle.db.user_name = "junglepath" jungle.db.password = nil jungle.db.host = "localhost" jungle.db.extensions = [:pg_json] jungle.db.port = nil # defaults to PostgreSQL default port of 5432 if nil. jungle.db.options = {max_connections: 4} end
debug()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 248 def self.debug jungle.debug.show_params = false end
environment()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 35 def self.environment # create 'environment.rb' file to override this setting: jungle.environment.name = "dev" # "dev", "stage", or "prod" begin require_relative 'environment' puts "[application root]/config/environment.rb file was loaded." puts "jungle.environment.name == '#{jungle.environment.name}'" rescue LoadError => ex puts "[application root]/config/environment.rb file was not found, defaulting to jungle.environment.name == '#{jungle.environment.name}'." puts "to override, create file ./config/environment.rb with one line like this:" puts "jungle.environment.name = 'stage' \# valid environments may be: 'dev', 'stage' or 'prod' or whatever you want to use :)" end end
init()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 8 def self.init # setting global config settings name 'jungle' on: JunglePath::Config.set_global_on # configuration will be global: can access 'jungle...' anywhere. environment application on_startup db smtp sms password_settings roles users schema_filters role_schema_filters role_query_filters restriction_query_filters user_query_filters role_table_filters restriction_table_filters user_table_filters #permissions_and_restrictions route_access debug config_override jungle.lock = true end
on_startup()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 60 def self.on_startup jungle.on_startup.run_database_migrations = false # Servers usually handle this on their own with deployments. For devs, may want to override in override.rb. end
password_settings()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 92 def self.password_settings jungle.password_settings = { length: {must_be_greater_than: 0, message: "Password length must be at least 1 characters."}, #length: {must_be_greater_than: 7, message: "Password length must be at least 8 characters."}, regular_expression_matches: [ ## {expression: /[[:alpha:]]/, message: "Password must have at least one alphabetical character."}, ## {expression: /[[:digit:]]/, message: "Password must have at least one numeric character."} #{expression: /\D/, message: "Password must have at least one alphabetical character."}, #{expression: /\d/, message: "Password must have at least one numeric character."} ] } end
restriction_query_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 192 def self.restriction_query_filters jungle.restriction_query_filters = lambda {|identity| filters = { #me_related:[ # {table_name: :user, sub_select: "select id from user where id = #{identity.user.id}"} #] } } end
restriction_table_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 218 def self.restriction_table_filters #jungle.restriction_table_filters = { # me_related:[ # {table_name: :contact, replacement: :filter_contact} # ] #} jungle.restriction_table_filters = {} end
role_query_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 181 def self.role_query_filters jungle.role_query_filters = lambda {|identity| filters = { admin: [ {table_name: :table_i_want_to_filter, sub_select: "select id from table_i_want_to_filter where a = b", use_not_in: false} ] # more... } } end
role_schema_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 173 def self.role_schema_filters jungle.role_schema_filters = { root: :allow_all_tables, admin: :allow_all_tables, user: :hide_nonpublic_tables } end
role_table_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 208 def self.role_table_filters # Replace usage of a table in a query with the given view or parameterized function jungle.role_table_filters = { user: [ {table_name: :contact, replacement: :filter_contact}, {table_name: :test, replacement: :filter_test} ] } end
roles()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 105 def self.roles jungle.roles = { root: { id: 0, name: :root, description: 'root can do anything', permissions: [:root], restrictions: [] }, admin: { id: 1, name: :admin, description: 'admin and add, edit and delete users, but not root users.', permissions: [:admin, :read], restrictions: [] }, user: { id: 2, name: :user, description: 'basic system user -- has read only access.', permissions: [:read, :assumable_user_identity], restrictions: [:query_only, :me_related] } } end
route_access()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 231 def self.route_access jungle.route_access = { public: { get: { routes: ['/', '/app', '/admin', '/query', '/query/doc'], routes_start_with: ['/activate/', '/passwordresetcode/'] } }, authenticated: { get: { routes: ['/query/schema_tree'], routes_start_with: [] } } } end
schema_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 166 def self.schema_filters jungle.schema_filters = { allow_all_tables: {allow: [table: /./]}, hide_nonpublic_tables: {allow: [{table: /./}], deny: [{table: /^utility_/}, {table: /^temp_/}]} } end
sms()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 86 def self.sms # (texting) jungle.sms.from_phone_number = nil jungle.sms.account_sid = nil jungle.sms.auth_token = nil end
smtp()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 75 def self.smtp # (email) jungle.smtp.host = "localhost" jungle.smtp.port = 25 #587 # 25 jungle.smtp.domain_of_sender = 'mydomain.com' jungle.smtp.user_name = nil jungle.smtp.password = nil jungle.smtp.enable_tls = false jungle.smtp.authentication = nil jungle.smtp.from = nil # 'me@mydomain.com' end
user_query_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 202 def self.user_query_filters jungle.user_query_filters = lambda {|identity| filters = {} } end
user_table_filters()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 227 def self.user_table_filters jungle.user_table_filters = {} end
users()
click to toggle source
# File lib/jungle_path/app/config/config.rb, line 131 def self.users jungle.users = { root: { id: 0, name: 'root', email: nil, phone: nil, active: true, user_name: :root, password: 'test', role: :root }, admin: { id: 1, name: 'admin', email: nil, phone: nil, active: true, user_name: :admin, password: 'test', role: :admin }, user: { id: 2, name: 'user', email: nil, phone: nil, active: true, user_name: :user, password: 'test', roles: :user } } end