# PlatformX - gems require "platformx/version" require "platformx/auth" require "platformx/form" require "platformx/layout" require "platformx/date" require "platformx/notify" require "platformx/mail" require "platformx/stripe" require "platformx/faker" require "platformx/pdf" require "platformx/text" require "platformx/aws" # 3rd party gems require "sinatra/base" require "sinatra/contrib/all" require "sinatra/partial" require "sinatra/support" require "sinatra/flash" require "digest" require "base64" require "json" require "encrypted_cookie" require "encryptor" require "active_support/all" require "stripe" require "better_errors" require "rack-ssl-enforcer" require "slugify" require "data_mapper" require "dm-validations" require "securerandom" require "faker" require "uuidtools" require "net/ssh" require "fog/aws" module Platformx class << self # Controls the app configuration # @return [Platformx::Configuration] configuration object attr_accessor :configuration end # Configure the PlatformX gem # # @example # Platformxe.confgure do |config| # config.bugsnag_api_key = "XYZ" # # config.mail_from = "John Doe" # config.mail_address = "johndoe@example.com" # config.mail_port = "578" # config.mail_domain = "smtp.mailgun.org" # config.mail_user_name = "" # config.mail_password = "" # config.mail_authentication = "plain" # # config.aws_bucket = "" # config.aws_access_key_id = "" # config.aws_secret_access_key = "" # config.aws_region = "" # end def self.configure self.configuration ||= Configuration.new yield(configuration) end # # PlatformX configuration class. # # @author Tim Mushen # class Configuration # Controls the bugsnag api key attribute # @return [String] Bugsnag api key # attr_accessor :bugsnag_api_key # Controls the mail from # @return [String] the mail from attr_accessor :mail_from # Controls the mail address # @return [String] the mail address attr_accessor :mail_address # Controls the mail port number # @return [String] the mail port number attr_accessor :mail_port # Controls the mail domain # @return [String] the mail domain attr_accessor :mail_domain # Controls the mail user name # @return [String] the mail user name attr_accessor :mail_user_name # Controls the mail password # @return [String] the mail password attr_accessor :mail_password # Controls mail authentication # @return [String] mail authentication attr_accessor :mail_authentication # Controls the aws bucket name # @return [String] aws bucket name attr_accessor :aws_bucket # Controls the aws access key id # @return [String] the aws access key id attr_accessor :aws_access_key_id # Controls the aws secret access key # @return [String] the aws secret access key attr_accessor :aws_secret_access_key # Controls the aws region # @return [String] aws region attr_accessor :aws_region # Initialize Platformx configuration object and set defaults def initialize # Bugsnag # @bugsnag_api_key = "" # X_mail @mail_from = "" @mail_address = "smtp.mailgun.org" @mail_port = "587" @mail_domain = "smtp.mailgun.org" @mail_user_name = "" @mail_password = "" @mail_authentication = "plain" # For AWS/Fog @aws_bucket = "" @aws_secret_access_key = "" @aws_access_key_id = "" @aws_region = "" end end # Platformx - Sinatra module module Sinatra def self.registered(app) app.helpers Platformx::DateHelpers app.helpers Platformx::StripeHelpers app.helpers Platformx::AuthHelpers app.helpers Platformx::FormHelpers app.helpers Platformx::LayoutHelpers app.helpers Platformx::NotifyHelpers app.helpers Platformx::FakerHelpers app.helpers Platformx::TextHelpers app.helpers Platformx::PdfHelpers app.helpers Platformx::S3Helpers # #BugSnag # if Platformx.configuration.bugsnag_api_key != "" # app.Bugsnag.configure do |config| # config.api_key = Platformx.configuration.bugsnag_api_key # end # app.use Bugsnag::Rack # app.enable :raise_errors # end # Configure Better Errors if app.development? app.use BetterErrors::Middleware BetterErrors.application_root = __dir__ end # Configure Rack Protection if app.production? app.use Rack::Protection end end end # End Sinatra end #Register Helpers Sinatra.register Platformx::Sinatra Sinatra.register Sinatra::Numeric Sinatra.register Sinatra::HtmlHelpers