solidus_sample 3.2.9 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dcd17379cb0c7f39274cdb043b62d35b181b9785f6d11a082cb306efb0577d0
4
- data.tar.gz: 183258f39b9d8155fd8d6e3f89fba535c996b9fb294038dcbbb1663f9ad734c3
3
+ metadata.gz: 9059d419333a8d29cf2200810e316412fce44a7880972f372411e426683334ca
4
+ data.tar.gz: 3a65c64b84261703933c6d800df8f456e549df9815e20e11a4ea3624cb50d7b1
5
5
  SHA512:
6
- metadata.gz: 981972aa924da72f8feff0778e872b055e9b70575d15a2de2c18bce2ac5e411c9439c399ff99f4a36c3e7383151d1842cb12a3d0f1b8aeb8caf948733a0e81cd
7
- data.tar.gz: 50620ce2fc96cde08e6a7ac567695ca4e309c88b225189d246456e4d529d08aa4e984f63b826fdc94a0cd73933f91619bac52b1347f5e4637c5c66696085b8d5
6
+ metadata.gz: b901b32401f03babb6a6626311c5ff57c692b9a3daca5dad9dfd2582be42370187f47f2797d37cb1b7e799a5c154769b2e64b1958614438bde5f342f03cc2790
7
+ data.tar.gz: 4897085d9f96ca79bc1b1a84f120db60be8b497a772432549eaffab2ae19e20565308b74365da4e71fae878edb5a3d168d5dd607b380d5c77113dd33b6a1b9cf
data/db/samples/assets.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'thor'
4
+ shell = Thor::Base.shell.new
5
+
3
6
  Spree::Sample.load_sample("products")
4
7
  Spree::Sample.load_sample("variants")
5
8
 
@@ -17,7 +20,7 @@ products[:ruby_mug] = Spree::Product.find_by!(name: "Ruby Mug")
17
20
  products[:solidus_tote] = Spree::Product.find_by!(name: "Solidus Tote")
18
21
  products[:ruby_tote] = Spree::Product.find_by!(name: "Ruby Tote")
19
22
 
20
- def image(name, type = "jpg")
23
+ image = ->(name, type = "jpg") do
21
24
  images_path = Pathname.new(File.dirname(__FILE__)) + "images"
22
25
  path = images_path + "#{name}.#{type}"
23
26
 
@@ -29,61 +32,61 @@ end
29
32
  images = {
30
33
  products[:solidus_snapback_cap].master => [
31
34
  {
32
- attachment: image("solidus_snapback_cap")
35
+ attachment: image["solidus_snapback_cap"]
33
36
  }
34
37
  ],
35
38
  products[:solidus_hoodie].master => [
36
39
  {
37
- attachment: image("solidus_hoodie")
40
+ attachment: image["solidus_hoodie"]
38
41
  }
39
42
  ],
40
43
  products[:ruby_hoodie].master => [
41
44
  {
42
- attachment: image("ruby_hoodie")
45
+ attachment: image["ruby_hoodie"]
43
46
  }
44
47
  ],
45
48
  products[:ruby_hoodie_zip].master => [
46
49
  {
47
- attachment: image("ruby_hoodie_zip")
50
+ attachment: image["ruby_hoodie_zip"]
48
51
  }
49
52
  ],
50
53
  products[:ruby_polo].master => [
51
54
  {
52
- attachment: image("ruby_polo")
55
+ attachment: image["ruby_polo"]
53
56
  },
54
57
  {
55
- attachment: image("ruby_polo_back")
58
+ attachment: image["ruby_polo_back"]
56
59
  }
57
60
  ],
58
61
  products[:solidus_mug].master => [
59
62
  {
60
- attachment: image("solidus_mug")
63
+ attachment: image["solidus_mug"]
61
64
  }
62
65
  ],
63
66
  products[:ruby_mug].master => [
64
67
  {
65
- attachment: image("ruby_mug")
68
+ attachment: image["ruby_mug"]
66
69
  }
67
70
  ],
68
71
  products[:solidus_tote].master => [
69
72
  {
70
- attachment: image("tote_bag_solidus")
73
+ attachment: image["tote_bag_solidus"]
71
74
  }
72
75
  ],
73
76
  products[:ruby_tote].master => [
74
77
  {
75
- attachment: image("tote_bag_ruby")
78
+ attachment: image["tote_bag_ruby"]
76
79
  }
77
80
  ]
78
81
  }
79
82
 
80
83
  products[:solidus_tshirt].variants.each do |variant|
81
- color = variant.option_value("tshirt-color").downcase
82
- main_image = image("solidus_tshirt_#{color}", "png")
84
+ color = variant.option_value("clothing-color").downcase
85
+ main_image = image["solidus_tshirt_#{color}", "png"]
83
86
  File.open(main_image) do |f|
84
87
  variant.images.create!(attachment: f)
85
88
  end
86
- back_image = image("solidus_tshirt_back_#{color}", "png")
89
+ back_image = image["solidus_tshirt_back_#{color}", "png"]
87
90
 
88
91
  next unless back_image
89
92
 
@@ -93,12 +96,12 @@ products[:solidus_tshirt].variants.each do |variant|
93
96
  end
94
97
 
95
98
  products[:solidus_long].variants.each do |variant|
96
- color = variant.option_value("tshirt-color").downcase
97
- main_image = image("solidus_long_#{color}", "png")
99
+ color = variant.option_value("clothing-color").downcase
100
+ main_image = image["solidus_long_#{color}", "png"]
98
101
  File.open(main_image) do |f|
99
102
  variant.images.create!(attachment: f)
100
103
  end
101
- back_image = image("solidus_long_back_#{color}", "png")
104
+ back_image = image["solidus_long_back_#{color}", "png"]
102
105
 
103
106
  next unless back_image
104
107
 
@@ -108,15 +111,15 @@ products[:solidus_long].variants.each do |variant|
108
111
  end
109
112
 
110
113
  products[:solidus_womens_tshirt].reload.variants.each do |variant|
111
- color = variant.option_value("tshirt-color").downcase
112
- main_image = image("solidus_womens_tshirt_#{color}", "png")
114
+ color = variant.option_value("clothing-color").downcase
115
+ main_image = image["solidus_womens_tshirt_#{color}", "png"]
113
116
  File.open(main_image) do |f|
114
117
  variant.images.create!(attachment: f)
115
118
  end
116
119
  end
117
120
 
118
121
  images.each do |variant, attachments|
119
- puts "Loading images for #{variant.product.name}"
122
+ shell.say_status :sample, "images for #{variant.product.name}"
120
123
  attachments.each do |attachment|
121
124
  File.open(attachment[:attachment]) do |f|
122
125
  variant.images.create!(attachment: f)
@@ -2,12 +2,12 @@
2
2
 
3
3
  Spree::OptionType.create!([
4
4
  {
5
- name: "tshirt-size",
5
+ name: "clothing-size",
6
6
  presentation: "Size",
7
7
  position: 1
8
8
  },
9
9
  {
10
- name: "tshirt-color",
10
+ name: "clothing-color",
11
11
  presentation: "Color",
12
12
  position: 2
13
13
  }
@@ -5,6 +5,12 @@ Spree::Sample.load_sample("products")
5
5
  size = Spree::OptionType.find_by!(presentation: "Size")
6
6
  color = Spree::OptionType.find_by!(presentation: "Color")
7
7
 
8
- solidus_tshirt = Spree::Product.find_by!(name: "Solidus T-Shirt")
9
- solidus_tshirt.option_types = [size, color]
10
- solidus_tshirt.save!
8
+ colored_clothes = [
9
+ "Solidus T-Shirt", "Solidus Long Sleeve", "Solidus Women's T-Shirt"
10
+ ]
11
+
12
+ Spree::Product.all.each do |product|
13
+ product.option_types = [size]
14
+ product.option_types << color if colored_clothes.include?(product.name)
15
+ product.save!
16
+ end
@@ -157,6 +157,96 @@ variants = [
157
157
  option_values: [medium, black],
158
158
  sku: "SOL-WM006",
159
159
  cost_price: 17
160
+ },
161
+ {
162
+ product: solidus_snapback_cap,
163
+ option_values: [small],
164
+ sku: "SOL-SNC02",
165
+ cost_price: 17
166
+ },
167
+ {
168
+ product: solidus_snapback_cap,
169
+ option_values: [medium],
170
+ sku: "SOL-SNC03",
171
+ cost_price: 17
172
+ },
173
+ {
174
+ product: solidus_snapback_cap,
175
+ option_values: [large],
176
+ sku: "SOL-SNC04",
177
+ cost_price: 17
178
+ },
179
+ {
180
+ product: solidus_hoodie,
181
+ option_values: [small],
182
+ sku: "SOL-HD02",
183
+ cost_price: 27
184
+ },
185
+ {
186
+ product: solidus_hoodie,
187
+ option_values: [medium],
188
+ sku: "SOL-HD03",
189
+ cost_price: 27
190
+ },
191
+ {
192
+ product: solidus_hoodie,
193
+ option_values: [large],
194
+ sku: "SOL-HD04",
195
+ cost_price: 27
196
+ },
197
+ {
198
+ product: ruby_hoodie,
199
+ option_values: [small],
200
+ sku: "RUB-HD02",
201
+ cost_price: 27
202
+ },
203
+ {
204
+ product: ruby_hoodie,
205
+ option_values: [medium],
206
+ sku: "RUB-HD03",
207
+ cost_price: 27
208
+ },
209
+ {
210
+ product: ruby_hoodie,
211
+ option_values: [large],
212
+ sku: "RUB-HD04",
213
+ cost_price: 27
214
+ },
215
+ {
216
+ product: ruby_hoodie_zip,
217
+ option_values: [small],
218
+ sku: "RUB-HD05",
219
+ cost_price: 27
220
+ },
221
+ {
222
+ product: ruby_hoodie_zip,
223
+ option_values: [medium],
224
+ sku: "RUB-HD06",
225
+ cost_price: 27
226
+ },
227
+ {
228
+ product: ruby_hoodie_zip,
229
+ option_values: [large],
230
+ sku: "RUB-HD07",
231
+ cost_price: 27
232
+ },
233
+ {
234
+ product: ruby_polo,
235
+ option_values: [small],
236
+ sku: "RUB-PL02",
237
+ cost_price: 23
238
+ },
239
+ {
240
+ product: ruby_polo,
241
+ option_values: [medium],
242
+ sku: "RUB-PL03",
243
+ cost_price: 23
244
+ },
245
+ {
246
+ product: ruby_polo,
247
+ option_values: [large],
248
+ sku: "RUB-PL04",
249
+ cost_price: 23
160
250
  }
161
251
  ]
162
252
 
data/lib/spree/sample.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'thor'
3
4
  require 'spree_core'
5
+
4
6
  module Spree
5
7
  module Sample
6
8
  class << self
7
- def load_sample(file)
9
+ def load_sample(file, shell: Thor::Base.shell.new)
8
10
  # If file is exists within application it takes precendence.
9
11
  if File.exist?(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
10
12
  path = File.expand_path(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
@@ -13,9 +15,9 @@ module Spree
13
15
  path = File.expand_path(samples_path + "#{file}.rb")
14
16
  end
15
17
  # Check to see if the specified file has been loaded before
16
- if !$LOADED_FEATURES.include?(path)
18
+ unless $LOADED_FEATURES.include?(path)
19
+ shell.say_status :sample, file.titleize
17
20
  require path
18
- puts "Loaded #{file.titleize} samples"
19
21
  end
20
22
  end
21
23
 
@@ -7,14 +7,14 @@ namespace :spree_sample do
7
7
  desc 'Loads sample data'
8
8
  task load: :environment do
9
9
  if ARGV.include?("db:migrate")
10
- puts %{
11
- Please run db:migrate separately from spree_sample:load.
10
+ puts <<~TEXT
11
+ Please run db:migrate separately from spree_sample:load.
12
12
 
13
- Running db:migrate and spree_sample:load at the same time has been known to
14
- cause problems where columns may be not available during sample data loading.
13
+ Running db:migrate and spree_sample:load at the same time has been known to
14
+ cause problems where columns may be not available during sample data loading.
15
15
 
16
- Migrations have been run. Please run "rake spree_sample:load" by itself now.
17
- }
16
+ Migrations have been run. Please run "rake spree_sample:load" by itself now.
17
+ TEXT
18
18
  exit(1)
19
19
  end
20
20
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  f.match(%r{^(spec|script)/})
21
21
  end
22
22
 
23
- s.required_ruby_version = '>= 2.5.0'
23
+ s.required_ruby_version = '>= 2.7.0'
24
24
  s.required_rubygems_version = '>= 1.8.23'
25
25
 
26
26
  s.add_dependency 'solidus_core', s.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_sample
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.9
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-14 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.9
19
+ version: 3.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.9
26
+ version: 3.3.0
27
27
  description: Sample data (including images) for use with Solidus.
28
28
  email: contact@solidus.io
29
29
  executables: []
@@ -102,14 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - ">="
104
104
  - !ruby/object:Gem::Version
105
- version: 2.5.0
105
+ version: 2.7.0
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.8.23
111
111
  requirements: []
112
- rubygems_version: 3.4.9
112
+ rubygems_version: 3.3.26
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Sample data (including images) for use with Solidus.