seed_builder 1.2.0 → 1.2.1
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/CHANGELOG.md +13 -4
- data/Gemfile.lock +1 -1
- data/lib/seed_builder/config.rb +6 -1
- data/lib/seed_builder/loader.rb +6 -3
- data/lib/seed_builder.rb +1 -1
- data/spec/seed_builder/loader_spec.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a607759220852d1d00fcfe17bce2c9d419446a3bfa066c446e85121a11e70f17
|
|
4
|
+
data.tar.gz: d02f1a778d953c5a48a6862a64b9bf4dd2dec73118c066865aec91399ff6b2e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c731f5ed5c7644f27a475122aedc0f48c32d17c27f3034473fc6b6a127808b25c5d016275ccdf4d36743414d7928706fad046e9d1704a6dc08de5a2dd8475c0
|
|
7
|
+
data.tar.gz: 90f6e27dd1bd7022f940261181a1308fe3ff8a2efd42b932914dd44419d438f2abafaf33650a68cd9b6ab8386235041add92ecc1126b6b74d39294139304adf3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
- Fix seed files to be loaded as `.rb` files
|
|
6
|
+
- Add `default_seeds_full_path` config option to control default seeds full path
|
|
7
|
+
- Fix files loading using absolute paths
|
|
8
|
+
- Improve test coverage
|
|
9
|
+
|
|
10
|
+
## 1.2.0
|
|
2
11
|
|
|
3
12
|
- Automatically configure loader for Rails seeds
|
|
4
13
|
- Add `use_seed_loader` config option to control loader usage
|
|
5
14
|
|
|
6
|
-
|
|
15
|
+
## 1.1.0
|
|
7
16
|
|
|
8
17
|
- Fix `seeds_path` to be relative to Rails root
|
|
9
18
|
- Improve test coverage for generator
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
## 1.0.1
|
|
12
21
|
|
|
13
22
|
- Fix boolean config options to properly handle `nil` and `false` values
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
## 1.0.0
|
|
16
25
|
|
|
17
26
|
- Initial version
|
data/Gemfile.lock
CHANGED
data/lib/seed_builder/config.rb
CHANGED
|
@@ -2,7 +2,12 @@ module SeedBuilder
|
|
|
2
2
|
class Config
|
|
3
3
|
attr_writer :default_seeds_path
|
|
4
4
|
def default_seeds_path
|
|
5
|
-
@default_seeds_path ||=
|
|
5
|
+
@default_seeds_path ||= "db/seeds.rb"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
attr_writer :default_seeds_full_path
|
|
9
|
+
def default_seeds_full_path
|
|
10
|
+
@default_seeds_full_path ||= Rails.root.join(default_seeds_path)
|
|
6
11
|
end
|
|
7
12
|
|
|
8
13
|
attr_writer :seeds_path
|
data/lib/seed_builder/loader.rb
CHANGED
|
@@ -9,17 +9,20 @@ module SeedBuilder
|
|
|
9
9
|
ActiveRecord::Base.connection.schema_cache.clear!
|
|
10
10
|
ActiveRecord::Base.descendants.each(&:reset_column_information)
|
|
11
11
|
|
|
12
|
-
default_seeds_rb = SeedBuilder.config.
|
|
12
|
+
default_seeds_rb = SeedBuilder.config.default_seeds_full_path
|
|
13
13
|
if File.exist?(default_seeds_rb) && SeedBuilder.config.load_default_seeds?
|
|
14
|
+
started_at = Time.current
|
|
15
|
+
puts "== #{SeedBuilder.config.default_seeds_path}: seeding"
|
|
14
16
|
require default_seeds_rb
|
|
17
|
+
puts "== #{SeedBuilder.config.default_seeds_path}: seeded (#{(Time.current - started_at).round(4)}s)"
|
|
15
18
|
end
|
|
16
19
|
|
|
17
|
-
base_path = SeedBuilder.config.
|
|
20
|
+
base_path = SeedBuilder.config.seeds_full_path
|
|
18
21
|
if File.exist?(base_path) && SeedBuilder.config.load_seeds?
|
|
19
22
|
Dir[SeedBuilder.config.seeds_path_glob]
|
|
20
23
|
.map { |f| File.basename(f, ".*") }
|
|
21
24
|
.each do |seed_path|
|
|
22
|
-
require "#{base_path}/#{seed_path}"
|
|
25
|
+
require "#{base_path}/#{seed_path}.rb"
|
|
23
26
|
timestamp, klass_name = seed_path.scan(/^([0-9]+)_(.+)$/).first
|
|
24
27
|
next if klass_name.blank?
|
|
25
28
|
|
data/lib/seed_builder.rb
CHANGED
|
@@ -19,8 +19,8 @@ describe SeedBuilder::Loader do
|
|
|
19
19
|
allow(Rails).to receive(:logger=)
|
|
20
20
|
|
|
21
21
|
SeedBuilder.configure do |config|
|
|
22
|
-
config.
|
|
23
|
-
config.
|
|
22
|
+
config.seeds_full_path = File.expand_path("../../fixtures/seeds", __FILE__)
|
|
23
|
+
config.default_seeds_full_path = File.expand_path("../../fixtures/seeds.rb", __FILE__)
|
|
24
24
|
config.load_default_seeds = load_default_seeds
|
|
25
25
|
config.load_seeds = load_seeds
|
|
26
26
|
end
|
|
@@ -29,6 +29,7 @@ describe SeedBuilder::Loader do
|
|
|
29
29
|
|
|
30
30
|
it "loads the seeds" do
|
|
31
31
|
expect(SeedUser.count).to eq 1
|
|
32
|
+
expect(SeedBuilderUser.count).to eq 1
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
end
|