spree_china_sample 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +26 -0
- data/db/samples/addresses.rb +26 -0
- data/db/samples/adjustments.rb +20 -0
- data/db/samples/assets.rb +159 -0
- data/db/samples/images/apache_baseball.png +0 -0
- data/db/samples/images/ror_bag.jpeg +0 -0
- data/db/samples/images/ror_baseball.jpeg +0 -0
- data/db/samples/images/ror_baseball_back.jpeg +0 -0
- data/db/samples/images/ror_baseball_jersey_back_blue.png +0 -0
- data/db/samples/images/ror_baseball_jersey_back_green.png +0 -0
- data/db/samples/images/ror_baseball_jersey_back_red.png +0 -0
- data/db/samples/images/ror_baseball_jersey_blue.png +0 -0
- data/db/samples/images/ror_baseball_jersey_green.png +0 -0
- data/db/samples/images/ror_baseball_jersey_red.png +0 -0
- data/db/samples/images/ror_jr_spaghetti.jpeg +0 -0
- data/db/samples/images/ror_mug.jpeg +0 -0
- data/db/samples/images/ror_mug_back.jpeg +0 -0
- data/db/samples/images/ror_ringer.jpeg +0 -0
- data/db/samples/images/ror_ringer_back.jpeg +0 -0
- data/db/samples/images/ror_stein.jpeg +0 -0
- data/db/samples/images/ror_stein_back.jpeg +0 -0
- data/db/samples/images/ror_tote.jpeg +0 -0
- data/db/samples/images/ror_tote_back.jpeg +0 -0
- data/db/samples/images/ruby_baseball.png +0 -0
- data/db/samples/images/spree_bag.jpeg +0 -0
- data/db/samples/images/spree_jersey.jpeg +0 -0
- data/db/samples/images/spree_jersey_back.jpeg +0 -0
- data/db/samples/images/spree_mug.jpeg +0 -0
- data/db/samples/images/spree_mug_back.jpeg +0 -0
- data/db/samples/images/spree_ringer_t.jpeg +0 -0
- data/db/samples/images/spree_ringer_t_back.jpeg +0 -0
- data/db/samples/images/spree_spaghetti.jpeg +0 -0
- data/db/samples/images/spree_stein.jpeg +0 -0
- data/db/samples/images/spree_stein_back.jpeg +0 -0
- data/db/samples/images/spree_tote_back.jpeg +0 -0
- data/db/samples/images/spree_tote_front.jpeg +0 -0
- data/db/samples/option_types.rb +12 -0
- data/db/samples/option_values.rb +49 -0
- data/db/samples/orders.rb +38 -0
- data/db/samples/payment_methods.rb +15 -0
- data/db/samples/payments.rb +22 -0
- data/db/samples/product_option_types.rb +12 -0
- data/db/samples/product_properties.rb +118 -0
- data/db/samples/products.rb +137 -0
- data/db/samples/prototypes.rb +21 -0
- data/db/samples/shipping_categories.rb +1 -0
- data/db/samples/shipping_methods.rb +60 -0
- data/db/samples/stock.rb +12 -0
- data/db/samples/tax_categories.rb +2 -0
- data/db/samples/tax_rates.rb +9 -0
- data/db/samples/taxonomies.rb +8 -0
- data/db/samples/taxons.rb +145 -0
- data/db/samples/variants.rb +164 -0
- data/db/samples.rb +2 -0
- data/lib/spree/sample.rb +23 -0
- data/lib/spree_sample.rb +31 -0
- data/lib/tasks/sample.rake +24 -0
- metadata +115 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
Spree::Sample.load_sample("option_values")
|
2
|
+
Spree::Sample.load_sample("products")
|
3
|
+
|
4
|
+
ror_baseball_jersey = Spree::Product.find_by_name!("Ruby on Rails Baseball Jersey")
|
5
|
+
ror_tote = Spree::Product.find_by_name!("Ruby on Rails Tote")
|
6
|
+
ror_bag = Spree::Product.find_by_name!("Ruby on Rails Bag")
|
7
|
+
ror_jr_spaghetti = Spree::Product.find_by_name!("Ruby on Rails Jr. Spaghetti")
|
8
|
+
ror_mug = Spree::Product.find_by_name!("Ruby on Rails Mug")
|
9
|
+
ror_ringer = Spree::Product.find_by_name!("Ruby on Rails Ringer T-Shirt")
|
10
|
+
ror_stein = Spree::Product.find_by_name!("Ruby on Rails Stein")
|
11
|
+
spree_baseball_jersey = Spree::Product.find_by_name!("Spree Baseball Jersey")
|
12
|
+
spree_stein = Spree::Product.find_by_name!("Spree Stein")
|
13
|
+
spree_jr_spaghetti = Spree::Product.find_by_name!("Spree Jr. Spaghetti")
|
14
|
+
spree_mug = Spree::Product.find_by_name!("Spree Mug")
|
15
|
+
spree_ringer = Spree::Product.find_by_name!("Spree Ringer T-Shirt")
|
16
|
+
spree_tote = Spree::Product.find_by_name!("Spree Tote")
|
17
|
+
spree_bag = Spree::Product.find_by_name!("Spree Bag")
|
18
|
+
ruby_baseball_jersey = Spree::Product.find_by_name!("Ruby Baseball Jersey")
|
19
|
+
apache_baseball_jersey = Spree::Product.find_by_name!("Apache Baseball Jersey")
|
20
|
+
|
21
|
+
small = Spree::OptionValue.where(name: "Small").first
|
22
|
+
medium = Spree::OptionValue.where(name: "Medium").first
|
23
|
+
large = Spree::OptionValue.where(name: "Large").first
|
24
|
+
extra_large = Spree::OptionValue.where(name: "Extra Large").first
|
25
|
+
|
26
|
+
red = Spree::OptionValue.where(name: "Red").first
|
27
|
+
blue = Spree::OptionValue.where(name: "Blue").first
|
28
|
+
green = Spree::OptionValue.where(name: "Green").first
|
29
|
+
|
30
|
+
variants = [
|
31
|
+
{
|
32
|
+
:product => ror_baseball_jersey,
|
33
|
+
:option_values => [small, red],
|
34
|
+
:sku => "ROR-00001",
|
35
|
+
:cost_price => 17
|
36
|
+
},
|
37
|
+
{
|
38
|
+
:product => ror_baseball_jersey,
|
39
|
+
:option_values => [small, blue],
|
40
|
+
:sku => "ROR-00002",
|
41
|
+
:cost_price => 17
|
42
|
+
},
|
43
|
+
{
|
44
|
+
:product => ror_baseball_jersey,
|
45
|
+
:option_values => [small, green],
|
46
|
+
:sku => "ROR-00003",
|
47
|
+
:cost_price => 17
|
48
|
+
},
|
49
|
+
{
|
50
|
+
:product => ror_baseball_jersey,
|
51
|
+
:option_values => [medium, red],
|
52
|
+
:sku => "ROR-00004",
|
53
|
+
:cost_price => 17
|
54
|
+
},
|
55
|
+
{
|
56
|
+
:product => ror_baseball_jersey,
|
57
|
+
:option_values => [medium, blue],
|
58
|
+
:sku => "ROR-00005",
|
59
|
+
:cost_price => 17
|
60
|
+
},
|
61
|
+
{
|
62
|
+
:product => ror_baseball_jersey,
|
63
|
+
:option_values => [medium, green],
|
64
|
+
:sku => "ROR-00006",
|
65
|
+
:cost_price => 17
|
66
|
+
},
|
67
|
+
{
|
68
|
+
:product => ror_baseball_jersey,
|
69
|
+
:option_values => [large, red],
|
70
|
+
:sku => "ROR-00007",
|
71
|
+
:cost_price => 17
|
72
|
+
},
|
73
|
+
{
|
74
|
+
:product => ror_baseball_jersey,
|
75
|
+
:option_values => [large, blue],
|
76
|
+
:sku => "ROR-00008",
|
77
|
+
:cost_price => 17
|
78
|
+
},
|
79
|
+
{
|
80
|
+
:product => ror_baseball_jersey,
|
81
|
+
:option_values => [large, green],
|
82
|
+
:sku => "ROR-00009",
|
83
|
+
:cost_price => 17
|
84
|
+
},
|
85
|
+
{
|
86
|
+
:product => ror_baseball_jersey,
|
87
|
+
:option_values => [extra_large, green],
|
88
|
+
:sku => "ROR-00010",
|
89
|
+
:cost_price => 17
|
90
|
+
},
|
91
|
+
]
|
92
|
+
|
93
|
+
masters = {
|
94
|
+
ror_baseball_jersey => {
|
95
|
+
:sku => "ROR-001",
|
96
|
+
:cost_price => 17,
|
97
|
+
},
|
98
|
+
ror_tote => {
|
99
|
+
:sku => "ROR-00011",
|
100
|
+
:cost_price => 17
|
101
|
+
},
|
102
|
+
ror_bag => {
|
103
|
+
:sku => "ROR-00012",
|
104
|
+
:cost_price => 21
|
105
|
+
},
|
106
|
+
ror_jr_spaghetti => {
|
107
|
+
:sku => "ROR-00013",
|
108
|
+
:cost_price => 17
|
109
|
+
},
|
110
|
+
ror_mug => {
|
111
|
+
:sku => "ROR-00014",
|
112
|
+
:cost_price => 11
|
113
|
+
},
|
114
|
+
ror_ringer => {
|
115
|
+
:sku => "ROR-00015",
|
116
|
+
:cost_price => 17
|
117
|
+
},
|
118
|
+
ror_stein => {
|
119
|
+
:sku => "ROR-00016",
|
120
|
+
:cost_price => 15
|
121
|
+
},
|
122
|
+
apache_baseball_jersey => {
|
123
|
+
:sku => "APC-00001",
|
124
|
+
:cost_price => 17
|
125
|
+
},
|
126
|
+
ruby_baseball_jersey => {
|
127
|
+
:sku => "RUB-00001",
|
128
|
+
:cost_price => 17
|
129
|
+
},
|
130
|
+
spree_baseball_jersey => {
|
131
|
+
:sku => "SPR-00001",
|
132
|
+
:cost_price => 17
|
133
|
+
},
|
134
|
+
spree_stein => {
|
135
|
+
:sku => "SPR-00016",
|
136
|
+
:cost_price => 15
|
137
|
+
},
|
138
|
+
spree_jr_spaghetti => {
|
139
|
+
:sku => "SPR-00013",
|
140
|
+
:cost_price => 17
|
141
|
+
},
|
142
|
+
spree_mug => {
|
143
|
+
:sku => "SPR-00014",
|
144
|
+
:cost_price => 11
|
145
|
+
},
|
146
|
+
spree_ringer => {
|
147
|
+
:sku => "SPR-00015",
|
148
|
+
:cost_price => 17
|
149
|
+
},
|
150
|
+
spree_tote => {
|
151
|
+
:sku => "SPR-00011",
|
152
|
+
:cost_price => 13
|
153
|
+
},
|
154
|
+
spree_bag => {
|
155
|
+
:sku => "SPR-00012",
|
156
|
+
:cost_price => 21
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
Spree::Variant.create!(variants)
|
161
|
+
|
162
|
+
masters.each do |product, variant_attrs|
|
163
|
+
product.master.update_attributes!(variant_attrs)
|
164
|
+
end
|
data/db/samples.rb
ADDED
data/lib/spree/sample.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Spree
|
2
|
+
module Sample
|
3
|
+
def self.load_sample(file)
|
4
|
+
# If file exists within application it takes precendence.
|
5
|
+
if File.exists?(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
|
6
|
+
path = File.expand_path(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
|
7
|
+
else
|
8
|
+
# Otherwise we will use this gems default file.
|
9
|
+
path = File.expand_path(samples_path + "#{file}.rb")
|
10
|
+
end
|
11
|
+
# Check to see if the specified file has been loaded before
|
12
|
+
if !$LOADED_FEATURES.include?(path)
|
13
|
+
require path
|
14
|
+
puts "Loaded #{file.titleize} samples"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def self.samples_path
|
20
|
+
Pathname.new(File.join(File.dirname(__FILE__), '..', '..', 'db', 'samples'))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/spree_sample.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spree_core'
|
2
|
+
require 'spree/sample'
|
3
|
+
|
4
|
+
module SpreeSample
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
engine_name 'spree_sample'
|
7
|
+
|
8
|
+
# Needs to be here so we can access it inside the tests
|
9
|
+
def self.load_samples
|
10
|
+
Spree::Sample.load_sample("payment_methods")
|
11
|
+
Spree::Sample.load_sample("shipping_categories")
|
12
|
+
Spree::Sample.load_sample("shipping_methods")
|
13
|
+
Spree::Sample.load_sample("tax_categories")
|
14
|
+
Spree::Sample.load_sample("tax_rates")
|
15
|
+
|
16
|
+
Spree::Sample.load_sample("products")
|
17
|
+
Spree::Sample.load_sample("taxons")
|
18
|
+
Spree::Sample.load_sample("option_values")
|
19
|
+
Spree::Sample.load_sample("product_option_types")
|
20
|
+
Spree::Sample.load_sample("product_properties")
|
21
|
+
Spree::Sample.load_sample("prototypes")
|
22
|
+
Spree::Sample.load_sample("variants")
|
23
|
+
Spree::Sample.load_sample("stock")
|
24
|
+
Spree::Sample.load_sample("assets")
|
25
|
+
|
26
|
+
Spree::Sample.load_sample("orders")
|
27
|
+
Spree::Sample.load_sample("adjustments")
|
28
|
+
Spree::Sample.load_sample("payments")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'ffaker'
|
2
|
+
require 'pathname'
|
3
|
+
require 'spree/sample'
|
4
|
+
|
5
|
+
namespace :spree_sample do
|
6
|
+
desc 'Loads sample data'
|
7
|
+
task :load => :environment do
|
8
|
+
if ARGV.include?("db:migrate")
|
9
|
+
puts %Q{
|
10
|
+
Please run db:migrate separately from spree_sample:load.
|
11
|
+
|
12
|
+
Running db:migrate and spree_sample:load at the same time has been known to
|
13
|
+
cause problems where columns may be not available during sample data loading.
|
14
|
+
|
15
|
+
Migrations have been run. Please run "rake spree_sample:load" by itself now.
|
16
|
+
}
|
17
|
+
exit(1)
|
18
|
+
end
|
19
|
+
|
20
|
+
SpreeSample::Engine.load_samples
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_china_sample
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chuck.lei
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: spree_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
description: Required dependency for Spree
|
28
|
+
email: dilin.life@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- LICENSE
|
34
|
+
- db/samples.rb
|
35
|
+
- db/samples/addresses.rb
|
36
|
+
- db/samples/adjustments.rb
|
37
|
+
- db/samples/assets.rb
|
38
|
+
- db/samples/images/apache_baseball.png
|
39
|
+
- db/samples/images/ror_bag.jpeg
|
40
|
+
- db/samples/images/ror_baseball.jpeg
|
41
|
+
- db/samples/images/ror_baseball_back.jpeg
|
42
|
+
- db/samples/images/ror_baseball_jersey_back_blue.png
|
43
|
+
- db/samples/images/ror_baseball_jersey_back_green.png
|
44
|
+
- db/samples/images/ror_baseball_jersey_back_red.png
|
45
|
+
- db/samples/images/ror_baseball_jersey_blue.png
|
46
|
+
- db/samples/images/ror_baseball_jersey_green.png
|
47
|
+
- db/samples/images/ror_baseball_jersey_red.png
|
48
|
+
- db/samples/images/ror_jr_spaghetti.jpeg
|
49
|
+
- db/samples/images/ror_mug.jpeg
|
50
|
+
- db/samples/images/ror_mug_back.jpeg
|
51
|
+
- db/samples/images/ror_ringer.jpeg
|
52
|
+
- db/samples/images/ror_ringer_back.jpeg
|
53
|
+
- db/samples/images/ror_stein.jpeg
|
54
|
+
- db/samples/images/ror_stein_back.jpeg
|
55
|
+
- db/samples/images/ror_tote.jpeg
|
56
|
+
- db/samples/images/ror_tote_back.jpeg
|
57
|
+
- db/samples/images/ruby_baseball.png
|
58
|
+
- db/samples/images/spree_bag.jpeg
|
59
|
+
- db/samples/images/spree_jersey.jpeg
|
60
|
+
- db/samples/images/spree_jersey_back.jpeg
|
61
|
+
- db/samples/images/spree_mug.jpeg
|
62
|
+
- db/samples/images/spree_mug_back.jpeg
|
63
|
+
- db/samples/images/spree_ringer_t.jpeg
|
64
|
+
- db/samples/images/spree_ringer_t_back.jpeg
|
65
|
+
- db/samples/images/spree_spaghetti.jpeg
|
66
|
+
- db/samples/images/spree_stein.jpeg
|
67
|
+
- db/samples/images/spree_stein_back.jpeg
|
68
|
+
- db/samples/images/spree_tote_back.jpeg
|
69
|
+
- db/samples/images/spree_tote_front.jpeg
|
70
|
+
- db/samples/option_types.rb
|
71
|
+
- db/samples/option_values.rb
|
72
|
+
- db/samples/orders.rb
|
73
|
+
- db/samples/payment_methods.rb
|
74
|
+
- db/samples/payments.rb
|
75
|
+
- db/samples/product_option_types.rb
|
76
|
+
- db/samples/product_properties.rb
|
77
|
+
- db/samples/products.rb
|
78
|
+
- db/samples/prototypes.rb
|
79
|
+
- db/samples/shipping_categories.rb
|
80
|
+
- db/samples/shipping_methods.rb
|
81
|
+
- db/samples/stock.rb
|
82
|
+
- db/samples/tax_categories.rb
|
83
|
+
- db/samples/tax_rates.rb
|
84
|
+
- db/samples/taxonomies.rb
|
85
|
+
- db/samples/taxons.rb
|
86
|
+
- db/samples/variants.rb
|
87
|
+
- lib/spree/sample.rb
|
88
|
+
- lib/spree_sample.rb
|
89
|
+
- lib/tasks/sample.rake
|
90
|
+
homepage: https://github.com/seaify/spree_china_sample
|
91
|
+
licenses:
|
92
|
+
- BSD-3
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements:
|
109
|
+
- none
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.7
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Sample data (including images) for use in china with Spree.
|
115
|
+
test_files: []
|