Module: BusinessCatalyst
- Defined in:
- lib/business_catalyst.rb,
lib/business_catalyst/csv/row.rb,
lib/business_catalyst/version.rb,
lib/business_catalyst/csv/catalog_row.rb,
lib/business_catalyst/csv/product_row.rb,
lib/business_catalyst/csv/transformers.rb,
lib/business_catalyst/csv/file_splitter.rb,
lib/business_catalyst/csv/product_attribute.rb,
lib/business_catalyst/csv/transformers/transformer.rb,
lib/business_catalyst/csv/transformers/uri_transformer.rb,
lib/business_catalyst/csv/transformers/catalog_transformer.rb,
lib/business_catalyst/csv/transformers/invalid_input_error.rb,
lib/business_catalyst/csv/transformers/currency_transformer.rb,
lib/business_catalyst/csv/transformers/uri_array_transformer.rb,
lib/business_catalyst/csv/transformers/product_code_transformer.rb,
lib/business_catalyst/csv/transformers/seo_friendly_url_transformer.rb,
lib/business_catalyst/csv/transformers/product_attributes_transformer.rb
Defined Under Namespace
Modules: CSV
Constant Summary collapse
- CATALOG_CHAR_BLACKLIST =
The following characters cause an error message if they appear in a catalog name.
/[\\\/;#:"\|_@=\?]/.freeze
- MORE_STRICT_BLACKLIST =
/[\\\/;&,#:"\|\._@=\?]/.freeze
- VERSION =
"0.1.2"
Class Method Summary collapse
- .reset_global_urls! ⇒ Object
-
.sanitize_catalog_name(name) ⇒ Object
Strip all characters out of a catalog name that will cause an error.
-
.seo_friendly_url(name) ⇒ Object
A guess as to how business catalyst converts names to URL’s, based on this blog entry: www.businesscatalyst.com/bc-blog/seo-friendly-urls-for-products-and-catalogs.
Class Method Details
.reset_global_urls! ⇒ Object
36 37 38 |
# File 'lib/business_catalyst.rb', line 36 def self.reset_global_urls! BusinessCatalyst::CSV::SEOFriendlyUrlTransformer.reset_global_urls! end |
.sanitize_catalog_name(name) ⇒ Object
Strip all characters out of a catalog name that will cause an error. Replaces them with “ ” and then squishes all whitespace to single space to preserve word structure.
18 19 20 21 22 23 24 |
# File 'lib/business_catalyst.rb', line 18 def self.sanitize_catalog_name(name) return name if name.nil? sanitized = name.strip sanitized.gsub!(CATALOG_CHAR_BLACKLIST, " ") sanitized.gsub!(/\s+/, " ") sanitized end |
.seo_friendly_url(name) ⇒ Object
A guess as to how business catalyst converts names to URL’s, based on this blog entry: www.businesscatalyst.com/bc-blog/seo-friendly-urls-for-products-and-catalogs
Downcases, converts invalid characters and whitespace to ‘-’, and finally removes multiple consecutive dashes and leading and trailing dashes. Does NOT append numbers to ensure uniqueness, you must do this yourself after conversion.
32 33 34 |
# File 'lib/business_catalyst.rb', line 32 def self.seo_friendly_url(name) name.strip.downcase.gsub(/[^a-z0-9\-]/, "-").gsub(/-{2,}/, "-").gsub(/\A-+|-+\Z/, "") end |