business_catalyst 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -4
- data/README.md +73 -8
- data/Rakefile +7 -1
- data/business_catalyst.gemspec +4 -3
- data/lib/business_catalyst/csv/catalog_row.rb +1 -0
- data/lib/business_catalyst/csv/product_attribute.rb +34 -3
- data/lib/business_catalyst/version.rb +1 -1
- metadata +25 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9272b0607f422d8c6918c3b2c6e029caf84e16cc
|
|
4
|
+
data.tar.gz: 541a6512cd442b3ef87cc10485afe830ff361a11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e1d2c13d6c44435d0f5c134bb3ee26b9732364f701b3d27b2d6eb3bc8b1c56890e56de612bd5d52d9b234294c805e16f745dd6c2a34aa9b810facf2f316c2cb
|
|
7
|
+
data.tar.gz: e1be3f0029f8d95c30558b50eb5e2e3dc93685ed7a0393ba05f59d96d3634ac5b668ac086990a287684facb5bfa60fd328232a11c7cd91e1cd36c0a57d98aac6
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# BusinessCatalyst
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
Tools for building CSV's for Adobe Business Catalyst e-commerce platform in Ruby. Use a Ruby DSL to turn your data into CSV's that can be imported in the BC admin. Supports product and catalog CSV's, and splitting large CSV's (over 10k products) into multiple files.
|
|
4
6
|
|
|
7
|
+
**Compatible with Ruby 1.8.7 and Ruby 2.3+.** Intended to be useful as a tool for migrating very old Rails sites, so we deliberately preserve Ruby 1.8 compatibility, even when it is a huge pain. Otherwise, we only maintain compatibility with the latest version because most sites that can run on 1.9 can be upgraded to 2.3 with **much** less effort.
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
Add this line to your application's Gemfile:
|
|
@@ -22,8 +26,9 @@ Start with subclassing any of the provided Row classes:
|
|
|
22
26
|
Then define methods to return values for the various BC columns.
|
|
23
27
|
Use the #map method to ensure correct naming. (In general, it is just the
|
|
24
28
|
underscored version of the BC column name, with '?' appended for
|
|
25
|
-
boolean columns.
|
|
26
|
-
|
|
29
|
+
boolean columns. __Refer to COLUMNS constant in the base class, or
|
|
30
|
+
https://github.com/tortus/business_catalyst/wiki for a complete list
|
|
31
|
+
of columns.__)
|
|
27
32
|
|
|
28
33
|
### Building a Product CSV
|
|
29
34
|
|
|
@@ -54,6 +59,8 @@ products.each do |product|
|
|
|
54
59
|
end
|
|
55
60
|
```
|
|
56
61
|
|
|
62
|
+
__Refer to https://github.com/tortus/business_catalyst/wiki for the complete list of columns.__
|
|
63
|
+
|
|
57
64
|
### Returning Ruby data types in your methods
|
|
58
65
|
|
|
59
66
|
In general, you can define your methods to return Ruby types such as Array,
|
|
@@ -75,7 +82,7 @@ map(:enabled?) { true } # becomes: "Y"
|
|
|
75
82
|
### If you have more than 10k product rows to import, use BusinessCatalyst::CSV::FileSplitter
|
|
76
83
|
|
|
77
84
|
Business Catalyst limits the number of products you can import in a single
|
|
78
|
-
CSV to
|
|
85
|
+
CSV to 10,000. However, you can get around this limit by importing multiple
|
|
79
86
|
files. We have a class to help!
|
|
80
87
|
|
|
81
88
|
```ruby
|
|
@@ -90,15 +97,73 @@ end
|
|
|
90
97
|
```
|
|
91
98
|
See the class definition for all available options.
|
|
92
99
|
|
|
100
|
+
### Product Attributes
|
|
101
|
+
|
|
102
|
+
This gem has full support for multiple product attributes with multiple options.
|
|
103
|
+
In your attributes column definition, create and return one or more instances
|
|
104
|
+
of BusinessCatalyst::CSV::ProductAttribute.
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
class MyRow < BusinessCatalyst::CSV::ProductRow
|
|
108
|
+
map :attributes do
|
|
109
|
+
# Shorthand usage with no price differences or images
|
|
110
|
+
size = BusinessCatalyst::CSV::ProductAttribute.new("Size",
|
|
111
|
+
:display_as => :dropdown,
|
|
112
|
+
:required => true,
|
|
113
|
+
:keep_stock => false
|
|
114
|
+
)
|
|
115
|
+
size.add_options("Small", "Medium", "Large")
|
|
116
|
+
|
|
117
|
+
# Radio buttons with images and different prices for each option
|
|
118
|
+
color = BusinessCatalyst::CSV::ProductAttribute.new("Color",
|
|
119
|
+
:display_as => :radio,
|
|
120
|
+
:required => true,
|
|
121
|
+
:keep_stock => false
|
|
122
|
+
)
|
|
123
|
+
color.add_option("Red", "live/url/for/red.jpg", "US/25.0")
|
|
124
|
+
color.add_option("Green", "live/url/for/green.jpg", "US/22.0")
|
|
125
|
+
color.add_option("Blue", "live/url/for/blue.jpg", "US/26.0")
|
|
126
|
+
|
|
127
|
+
# Checkbox example without images
|
|
128
|
+
addon = BusinessCatalyst::CSV::ProductAttribute.new("Addon",
|
|
129
|
+
:display_as => :checkbox,
|
|
130
|
+
:required => false,
|
|
131
|
+
:keep_stock => false
|
|
132
|
+
)
|
|
133
|
+
addon.add_option("Some cool bling", nil, "US/5.00")
|
|
134
|
+
|
|
135
|
+
[size, color, addon]
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Notes on Currency
|
|
142
|
+
|
|
143
|
+
You can always return prices as Ruby Numeric types, or a raw String in
|
|
144
|
+
the format that BC understands "US/10.00".
|
|
145
|
+
|
|
146
|
+
* If you ureturn a Ruby Numeric type, the "default currency" will be used.
|
|
147
|
+
* If you return a String, it will pass through "as-is".
|
|
148
|
+
* You can also return an array of Strings or numbers. These will be converted to the correct string format and joined with ";" allowing you to specify multiple prices.
|
|
149
|
+
|
|
150
|
+
```ruby
|
|
151
|
+
BusinessCatalyst::CSV::CurrencyTransformer.default_currency = "US"
|
|
152
|
+
|
|
153
|
+
map(:sell_price) { 10 }
|
|
154
|
+
# => "US/10.00"
|
|
155
|
+
|
|
156
|
+
map(:sell_price) { ["US/10", "EU/12"] }
|
|
157
|
+
# => "US/10.00;EU/12.00"
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
|
|
93
162
|
## Contributing
|
|
94
163
|
|
|
95
164
|
1. Fork it
|
|
96
165
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
97
|
-
3. Run tests:
|
|
98
|
-
|
|
99
|
-
$ bundle install
|
|
100
|
-
$ bundle exec rspec spec
|
|
101
|
-
|
|
166
|
+
3. Run tests: ```bundle exec rspec spec```
|
|
102
167
|
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
103
168
|
5. Push to the branch (`git push origin my-new-feature`)
|
|
104
169
|
6. Create new Pull Request
|
data/Rakefile
CHANGED
data/business_catalyst.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ require 'business_catalyst/version'
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "business_catalyst"
|
|
8
8
|
spec.version = BusinessCatalyst::VERSION
|
|
9
|
-
spec.authors = ["
|
|
9
|
+
spec.authors = ["William Makley"]
|
|
10
10
|
spec.email = ["support@tortus.com"]
|
|
11
11
|
spec.description = %q{Tools for creating CSV's for the Adobe Business Catalyst e-commerce platform in Ruby. Use a Ruby DSL to turn your data into CSV's that can be imported in the BC admin. Supports product and catalog CSV's, and splitting large CSV's (over 10k products) into multiple files.}
|
|
12
12
|
spec.summary = "business_catalyst-#{BusinessCatalyst::VERSION}"
|
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
20
|
spec.require_paths = ["lib"]
|
|
21
21
|
|
|
22
|
-
spec.add_development_dependency "bundler", "
|
|
23
|
-
spec.add_development_dependency "rake", "
|
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.3"
|
|
23
|
+
spec.add_development_dependency "rake", "< 11.0"
|
|
24
24
|
spec.add_development_dependency "rspec", "~> 2.14"
|
|
25
|
+
spec.add_development_dependency "rdoc"
|
|
25
26
|
end
|
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
|
|
2
3
|
module BusinessCatalyst
|
|
3
4
|
module CSV
|
|
4
|
-
|
|
5
|
+
# Usage:
|
|
6
|
+
#
|
|
7
|
+
# # Dropdowns with custom image and price:
|
|
8
|
+
# size = BusinessCatalyst::CSV::ProductAttribute.new("Size",
|
|
9
|
+
# :display_as => :radio,
|
|
10
|
+
# :required => true,
|
|
11
|
+
# :keep_stock => false
|
|
12
|
+
# )
|
|
13
|
+
# size.add_option("Small", "live/url/for/small.jpg", "US/20.00")
|
|
14
|
+
# size.add_option("Large", "live/url/for/large.jpg", "US/25.00")
|
|
15
|
+
#
|
|
16
|
+
# # Shorthand for multiple radio buttons with no image or price:
|
|
17
|
+
# color = BusinessCatalyst::CSV::ProductAttribute.new("Size",
|
|
18
|
+
# :display_as => :radio,
|
|
19
|
+
# :required => true,
|
|
20
|
+
# :keep_stock => false
|
|
21
|
+
# )
|
|
22
|
+
# color.add_options("Red", "Green", "Blue")
|
|
23
|
+
#
|
|
24
|
+
# # Checkboxes are supported as well:
|
|
25
|
+
# addon = BusinessCatalyst::CSV::ProductAttribute.new("Addon",
|
|
26
|
+
# :display_as => :checkbox,
|
|
27
|
+
# :required => false,
|
|
28
|
+
# :keep_stock => false
|
|
29
|
+
# )
|
|
30
|
+
# addon.add_option("Cool thing 1", nil, "US/5.00")
|
|
31
|
+
#
|
|
5
32
|
class ProductAttribute
|
|
6
33
|
Option = Struct.new(:name, :image, :price)
|
|
7
34
|
|
|
8
|
-
attr_accessor :name, :required, :keep_stock
|
|
9
|
-
attr_reader :display_as
|
|
35
|
+
attr_accessor :name, :required, :keep_stock, :display_as
|
|
10
36
|
|
|
37
|
+
# Available options:
|
|
38
|
+
#
|
|
39
|
+
# * :display_as => :dropdown / :checkbox / :radio
|
|
40
|
+
# * :required => true / false
|
|
41
|
+
# * :keep_stock => true / false
|
|
11
42
|
def initialize(name, options = {})
|
|
12
43
|
@name = name
|
|
13
44
|
self.display_as = options.delete(:display_as) { nil }
|
metadata
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: business_catalyst
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- William Makley
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.3'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.3'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - "<"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '11.0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - "<"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '11.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '2.14'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rdoc
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
55
69
|
description: Tools for creating CSV's for the Adobe Business Catalyst e-commerce platform
|
|
56
70
|
in Ruby. Use a Ruby DSL to turn your data into CSV's that can be imported in the
|
|
57
71
|
BC admin. Supports product and catalog CSV's, and splitting large CSV's (over 10k
|
|
@@ -122,10 +136,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
122
136
|
version: '0'
|
|
123
137
|
requirements: []
|
|
124
138
|
rubyforge_project:
|
|
125
|
-
rubygems_version: 2.
|
|
139
|
+
rubygems_version: 2.6.13
|
|
126
140
|
signing_key:
|
|
127
141
|
specification_version: 4
|
|
128
|
-
summary: business_catalyst-0.1.
|
|
142
|
+
summary: business_catalyst-0.1.2
|
|
129
143
|
test_files:
|
|
130
144
|
- spec/lib/business_catalyst/business_catalyst_spec.rb
|
|
131
145
|
- spec/lib/business_catalyst/csv/catalog_row_spec.rb
|