Module: Caboose

Defined in:
app/models/caboose/export.rb,
lib/caboose.rb,
lib/caboose/version.rb,
app/models/caboose/ga.rb,
app/models/caboose/review.rb,
app/models/caboose/vendor.rb,
app/models/caboose/address.rb,
app/models/caboose/authnet.rb,
app/models/caboose/invoice.rb,
app/models/caboose/message.rb,
app/models/caboose/product.rb,
app/models/caboose/variant.rb,
app/models/caboose/calendar.rb,
app/models/caboose/category.rb,
app/models/caboose/discount.rb,
app/models/caboose/mimetype.rb,
app/models/caboose/tax_line.rb,
app/models/caboose/gift_card.rb,
app/models/caboose/line_item.rb,
app/models/caboose/std_class.rb,
app/models/caboose/wish_list.rb,
app/models/caboose/ab_testing.rb,
app/models/caboose/crumbtrail.rb,
app/models/caboose/page_cache.rb,
app/models/caboose/block_cache.rb,
app/models/caboose/invoice_log.rb,
app/models/caboose/invoice_pdf.rb,
app/models/caboose/page_cacher.rb,
app/models/caboose/model_binder.rb,
app/models/caboose/modification.rb,
app/models/caboose/store_config.rb,
app/models/caboose/subscription.rb,
app/helpers/caboose/pages_helper.rb,
app/mailers/caboose/login_mailer.rb,
app/models/caboose/asset_manager.rb,
app/models/caboose/authenticator.rb,
app/models/caboose/page_template.rb,
app/models/caboose/product_image.rb,
app/models/caboose/search_filter.rb,
app/models/caboose/variant_child.rb,
app/models/caboose/variant_limit.rb,
app/models/caboose/asset_manifest.rb,
app/models/caboose/calendar_event.rb,
app/models/caboose/comment_routes.rb,
app/models/caboose/tax_calculator.rb,
app/mailers/caboose/caboose_mailer.rb,
app/models/caboose/invoice_package.rb,
app/models/caboose/product_default.rb,
app/models/caboose/shipping_method.rb,
app/models/caboose/stackable_group.rb,
app/models/caboose/variant_default.rb,
app/helpers/caboose/checkout_helper.rb,
app/helpers/caboose/products_helper.rb,
app/mailers/caboose/invoices_mailer.rb,
app/models/caboose/block_cache_file.rb,
app/models/caboose/block_type_icons.rb,
app/models/caboose/invoice_discount.rb,
app/models/caboose/invoice_reporter.rb,
app/models/caboose/shipping_package.rb,
app/models/caboose/block_cache_image.rb,
app/models/caboose/block_type_parser.rb,
app/helpers/caboose/categories_helper.rb,
app/models/caboose/modification_value.rb,
app/models/caboose/page_bar_generator.rb,
app/models/caboose/retargeting_config.rb,
app/controllers/caboose/sns_controller.rb,
app/helpers/caboose/application_helper.rb,
app/helpers/caboose/permissions_helper.rb,
app/models/caboose/category_membership.rb,
app/models/caboose/invoice_transaction.rb,
app/models/caboose/shipping_calculator.rb,
app/models/caboose/wish_list_line_item.rb,
app/controllers/caboose/cart_controller.rb,
app/controllers/caboose/smtp_controller.rb,
app/models/caboose/calendar_event_group.rb,
app/models/caboose/pending_invoices_pdf.rb,
app/controllers/caboose/admin_controller.rb,
app/controllers/caboose/fonts_controller.rb,
app/controllers/caboose/inbox_controller.rb,
app/controllers/caboose/login_controller.rb,
app/controllers/caboose/media_controller.rb,
app/controllers/caboose/modal_controller.rb,
app/controllers/caboose/pages_controller.rb,
app/controllers/caboose/posts_controller.rb,
app/controllers/caboose/roles_controller.rb,
app/controllers/caboose/sites_controller.rb,
app/controllers/caboose/store_controller.rb,
app/controllers/caboose/users_controller.rb,
app/models/caboose/product_category_sort.rb,
app/models/caboose/product_image_variant.rb,
app/controllers/caboose/assets_controller.rb,
app/controllers/caboose/blocks_controller.rb,
app/controllers/caboose/events_controller.rb,
app/controllers/caboose/logout_controller.rb,
app/controllers/caboose/social_controller.rb,
app/controllers/caboose/themes_controller.rb,
app/models/caboose/line_item_modification.rb,
app/models/caboose/page_template_category.rb,
app/models/caboose/rich_text_block_parser.rb,
app/models/caboose/shipping_method_loader.rb,
app/controllers/caboose/domains_controller.rb,
app/controllers/caboose/reviews_controller.rb,
app/controllers/caboose/station_controller.rb,
app/controllers/caboose/vendors_controller.rb,
app/models/caboose/shipping_package_method.rb,
app/controllers/caboose/checkout_controller.rb,
app/controllers/caboose/invoices_controller.rb,
app/controllers/caboose/products_controller.rb,
app/controllers/caboose/register_controller.rb,
app/controllers/caboose/settings_controller.rb,
app/controllers/caboose/variants_controller.rb,
app/models/caboose/customization_membership.rb,
app/controllers/caboose/calendars_controller.rb,
app/controllers/caboose/redirects_controller.rb,
app/controllers/caboose/ab_options_controller.rb,
app/controllers/caboose/categories_controller.rb,
app/controllers/caboose/gift_cards_controller.rb,
app/controllers/caboose/line_items_controller.rb,
app/controllers/caboose/login_logs_controller.rb,
app/controllers/caboose/my_account_controller.rb,
app/models/caboose/invoice_package_calculator.rb,
app/models/caboose/letsencrypt_plugin_setting.rb,
app/controllers/caboose/ab_variants_controller.rb,
app/controllers/caboose/application_controller.rb,
app/controllers/caboose/block_types_controller.rb,
app/controllers/caboose/permissions_controller.rb,
app/controllers/caboose/retargeting_controller.rb,
app/controllers/caboose/theme_files_controller.rb,
app/controllers/caboose/event_groups_controller.rb,
app/models/caboose/letsencrypt_plugin_challenge.rb,
app/controllers/caboose/modifications_controller.rb,
app/controllers/caboose/subscriptions_controller.rb,
app/controllers/caboose/page_templates_controller.rb,
app/controllers/caboose/product_images_controller.rb,
app/controllers/caboose/variant_limits_controller.rb,
app/models/caboose/modification_value_input_field.rb,
app/controllers/caboose/invoice_reports_controller.rb,
app/controllers/caboose/post_categories_controller.rb,
app/controllers/caboose/block_type_store_controller.rb,
app/controllers/caboose/invoice_packages_controller.rb,
app/controllers/caboose/media_categories_controller.rb,
app/controllers/caboose/page_permissions_controller.rb,
app/controllers/caboose/stackable_groups_controller.rb,
app/controllers/caboose/variant_children_controller.rb,
app/controllers/caboose/billing_addresses_controller.rb,
app/controllers/caboose/shipping_packages_controller.rb,
app/controllers/caboose/block_type_sources_controller.rb,
app/controllers/caboose/page_custom_fields_controller.rb,
app/controllers/caboose/post_custom_fields_controller.rb,
app/controllers/caboose/shipping_addresses_controller.rb,
app/controllers/caboose/event_custom_fields_controller.rb,
app/controllers/caboose/google_spreadsheets_controller.rb,
app/controllers/caboose/modification_values_controller.rb,
app/controllers/caboose/my_account_invoices_controller.rb,
app/controllers/caboose/invoice_transactions_controller.rb,
app/controllers/caboose/block_type_categories_controller.rb,
app/controllers/caboose/my_account_line_items_controller.rb,
app/controllers/caboose/page_custom_field_values_controller.rb,
app/controllers/caboose/post_custom_field_values_controller.rb,
app/controllers/caboose/event_custom_field_values_controller.rb,
app/controllers/caboose/modification_value_input_fields_controller.rb,
lib/caboose/engine.rb

Overview

include ActiveMerchant::Shipping

Defined Under Namespace

Modules: ApplicationHelper, CategoriesHelper, CheckoutHelper, PagesHelper, PermissionsHelper, ProductsHelper Classes: AbOption, AbOptionsController, AbTesting, AbValue, AbVariant, AbVariantsController, Address, AdminController, ApplicationController, ApprovalRequest, Asset, AssetManager, AssetManifest, AssetsController, Authenticator, Authnet, BillingAddressesController, Block, BlockCache, BlockCacheFile, BlockCacheImage, BlockType, BlockTypeCategoriesController, BlockTypeCategory, BlockTypeIcons, BlockTypeParser, BlockTypeSiteMembership, BlockTypeSource, BlockTypeSourcesController, BlockTypeStoreController, BlockTypeSummary, BlockTypesController, BlocksController, CabooseMailer, CaboosePlugin, Calendar, CalendarEvent, CalendarEventGroup, CalendarsController, CartController, CategoriesController, Category, CategoryMembership, CheckoutController, CommentRoutes, CorePlugin, Crumbtrail, CustomizationMembership, DatabaseSession, Discount, Domain, DomainConstraint, DomainsController, Engine, EventCustomField, EventCustomFieldValue, EventCustomFieldValuesController, EventCustomFieldsController, EventGroupsController, EventsController, Export, Font, FontFamily, FontVariant, FontsController, FormSubmission, GA, GiftCard, GiftCardsController, GoogleSpreadsheetsController, InboxController, Invoice, InvoiceDiscount, InvoiceLog, InvoicePackage, InvoicePackageCalculator, InvoicePackagesController, InvoicePdf, InvoiceReporter, InvoiceTransaction, InvoiceTransactionsController, InvoicesController, InvoicesMailer, LetsencryptPluginChallenge, LetsencryptPluginSetting, LineItem, LineItemModification, LineItemsController, LoginController, LoginLog, LoginLogsController, LoginMailer, LogoutController, Media, MediaCategoriesController, MediaCategory, MediaController, MenuBlock, Message, Mimetype, ModalController, ModelBinder, Modification, ModificationValue, ModificationValueInputField, ModificationValueInputFieldsController, ModificationValuesController, ModificationsController, MyAccountController, MyAccountInvoicesController, MyAccountLineItemsController, Page, PageBarGenerator, PageCache, PageCacher, PageCustomField, PageCustomFieldValue, PageCustomFieldValuesController, PageCustomFieldsController, PagePermission, PagePermissionsController, PageTag, PageTemplate, PageTemplateCategory, PageTemplatesController, Pager, PagesController, PendingInvoicesPdf, PermanentRedirect, Permission, PermissionsController, Post, PostCategoriesController, PostCategory, PostCategoryMembership, PostCustomField, PostCustomFieldValue, PostCustomFieldValuesController, PostCustomFieldsController, PostsController, Product, ProductCategorySort, ProductDefault, ProductImage, ProductImageVariant, ProductImagesController, ProductsController, RedirectsController, RegisterController, RetargetingConfig, RetargetingController, Review, ReviewsController, RichTextBlockParser, Role, RoleMembership, RolePermission, RolesController, Schema, SearchFilter, Setting, SettingsController, ShippingAddressesController, ShippingCalculator, ShippingMethod, ShippingMethodLoader, ShippingPackage, ShippingPackageMethod, ShippingPackagesController, Site, SiteMembership, SitesController, SmtpConfig, SmtpController, SnsController, SocialConfig, SocialController, StackableGroup, StackableGroupsController, States, StationController, StdClass, StoreConfig, StoreController, Subscription, SubscriptionsController, TaxCalculator, TaxLine, Theme, ThemeFile, ThemeFileMembership, ThemeFilesController, ThemesController, User, UsersController, Variant, VariantChild, VariantChildrenController, VariantDefault, VariantLimit, VariantLimitsController, VariantsController, Vendor, VendorsController, WishList, WishListLineItem

Constant Summary collapse

VERSION =
'1.0.2'
@@salt =
"This needs to be changed pronto."
@@assets_path =
"assets"
@@plugins =
['Caboose::CorePlugin']
@@schemas =
['Caboose::Schema', 'Schema']
@@modeljs_js_files =
[]
@@modeljs_js_paths =
[]
@@modeljs_css_files =
[]
@@authenticator_class =
'Caboose::Authenticator'
@@use_url_params =
true
@@use_ab_testing =
true
@@use_cloudinary =
false
@@website_name =
"Website"
@@website_domain =
"http://www.google.com"
@@cdn_domain =
""
@@email_from =
"[email protected]"
@@javascripts =
[]
@@stylesheets =
[]
@@session_length =
24
@@parse_richtext_blocks =
true
@@timezone =
'Central Time (US & Canada)'
@@register_layout =
'caboose/modal'
@@login_layout =
'caboose/modal'
@@use_store =
false
@@store_url =
''
@@payment_processor =
{
  :name => 'stripe',
  :api_key => '',
  :username => '',
  :password => ''
}
@@store_shipping =
{
  :ups    => { :username => '', :password => '', :key => '' },  
  :usps   => { :username => 'avondalebrewing', :password => 'Missfancy2011', :key => '' },  
  :origin => { :country  => '', :state => '', :city => '', :zip => '' },
  :allowed_shipping_method_codes => [],
  :default_shipping_method_code => ''  
}
@@store_fulfillment_email =
''
@@store_shipping_email =
''
@@store_contact_email =
''
@@store_handling_percentage =
''
@@from_address =
''
@@uploads_bucket =
''
@@use_comment_routes =
true
@@site_assets_path =
"sites"

Class Method Summary collapse

Class Method Details

.json(obj, defaultvalue = "", options = {}) ⇒ Object


45
46
47
48
# File 'lib/caboose/engine.rb', line 45

def Caboose.json(obj, defaultvalue = "", options = {})
  return defaultvalue.to_json if obj.nil?
  return obj.to_json(options)
end

.log(message, title = nil) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/caboose/engine.rb', line 19

def Caboose.log(message, title = nil)
  if (Rails.logger.nil?)
    puts "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    puts title.to_s unless title.nil?
    puts message
    puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
  else
    Rails.logger.info("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    Rails.logger.info(title.to_s) unless title.nil?
    Rails.logger.info(message)
    Rails.logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n")
  end                
end

.plugin_hook(*args) ⇒ Object


33
34
35
36
37
38
39
40
41
42
43
# File 'lib/caboose/engine.rb', line 33

def Caboose.plugin_hook(*args)
  resp = nil
  args[0] = args[0].to_sym 
  Caboose.plugins.each do |mod|
    #resp = mod.constantize.send(*args)      
    if (mod.constantize.respond_to?(args[0]))
      resp = mod.constantize.send(*args)
    end
  end
  return resp
end

.random_string(length) ⇒ Object


69
70
71
72
# File 'lib/caboose/engine.rb', line 69

def Caboose.random_string(length)
  o = [('a'..'z'),('A'..'Z'),('0'..'9')].map { |i| i.to_a }.flatten
  return (0...length).map { o[rand(o.length)] }.join
end

.rootObject


8
9
10
# File 'lib/caboose.rb', line 8

def self.root
  File.expand_path '../..', __FILE__
end

.teaser_text(str, length = 100) ⇒ Object

Strips html and returns the text that breaks closest to the given length


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/caboose/engine.rb', line 51

def Caboose.teaser_text(str, length = 100)
  return '' if str.nil?    
  str2 = ActionController::Base.helpers.strip_tags(str).gsub("\n", ' ')
  return '' if str2.nil? || str2.length == 0
  if str2.length > length
    i = str2.index(' ', length)
    if i.nil?
      i = length
    else
      i = i - 1
    end
    str2 = str2[0..i]
    str2[str2.length-1] = "" if str2.ends_with?(",")
    str2 = "#{str2}..."
  end
  return str2
end