lib/platformx.rb in platformx-0.0.7 vs lib/platformx.rb in platformx-0.0.8

- old
+ new

@@ -1,5 +1,6 @@ +# PlatformX - gems require "platformx/version" require "platformx/auth" require "platformx/form" require "platformx/layout" require "platformx/date" @@ -9,11 +10,11 @@ require "platformx/faker" require "platformx/pdf" require "platformx/text" require "platformx/aws" -########################### Require Gems ############################ +# 3rd party gems require "sinatra/base" require "sinatra/contrib/all" require "sinatra/partial" require "sinatra/support" require "sinatra/flash" @@ -40,45 +41,97 @@ require "fog" 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 -######################################################## -# -# Start Configuration Class -# -######################################################## + # + # PlatformX configuration class. + # + # @author Tim Mushen + # class Configuration - # For Bugsnag + # Controls the bugsnag api key attribute + # @return [String] Bugsnag api key attr_accessor :bugsnag_api_key - # X_mail + # 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 - - # For AWS/Fog + + # 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 @bugsnag_api_key = "" # X_mail @mail_from = "" @mail_address = "smtp.mailgun.org" @@ -96,56 +149,48 @@ end end - - -######################################################## -# -# Start Sinatra Module -# -######################################################## - + # 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 - + 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 + # 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 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 - # 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 \ No newline at end of file +Sinatra.register Sinatra::HtmlHelpers