rails_seeds 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +28 -20
- data/lib/generators/rails_seeds/seed/seed_generator.rb +1 -1
- data/lib/rails_seeds/helpers.rb +31 -0
- data/lib/rails_seeds/version.rb +1 -1
- data/lib/rails_seeds.rb +1 -0
- data/lib/tasks/list.rake +1 -1
- data/lib/tasks/seeds.rake +12 -21
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1150c999700f280118cc9e5d1835e8569fd1102f0f6ebea0687b631d74efc47d
|
4
|
+
data.tar.gz: 2d5a3aca9919f290c8f70301502a77c019047b39090161cc0add6eedce2434be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e97ac728814bae27a845fffa65602ac8c31efb4b6296d4e50bfc5462585c265b3d551fc72817aada7c0fb1b0c95d73378a08b6fd39e5ccb053ed27435f6ecb
|
7
|
+
data.tar.gz: 2458f994ed29fd2879daa964fef0bd26fcf7febe9c678eeb3cf57470fbec3aea4bab9afc26ed4f3ac7ebc7f4040785bffc8eae57e6152c86f18fa6df039ddbf6
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_seeds (0.1.
|
4
|
+
rails_seeds (0.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
byebug (11.1.
|
11
|
-
childprocess (
|
9
|
+
ast (2.4.2)
|
10
|
+
byebug (11.1.3)
|
11
|
+
childprocess (4.1.0)
|
12
12
|
iniparse (1.5.0)
|
13
|
-
|
14
|
-
overcommit (0.
|
15
|
-
childprocess (>= 0.6.3, <
|
13
|
+
json (2.6.3)
|
14
|
+
overcommit (0.60.0)
|
15
|
+
childprocess (>= 0.6.3, < 5)
|
16
16
|
iniparse (~> 1.4)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
rexml (~> 3.2)
|
18
|
+
parallel (1.23.0)
|
19
|
+
parser (3.2.2.3)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
racc
|
22
|
+
racc (1.7.0)
|
23
|
+
rainbow (3.1.1)
|
24
|
+
regexp_parser (2.8.1)
|
25
|
+
rexml (3.2.5)
|
26
|
+
rubocop (1.50.2)
|
27
|
+
json (~> 2.3)
|
24
28
|
parallel (~> 1.10)
|
25
|
-
parser (>= 2.
|
29
|
+
parser (>= 3.2.0.0)
|
26
30
|
rainbow (>= 2.2.2, < 4.0)
|
27
|
-
|
31
|
+
regexp_parser (>= 1.8, < 3.0)
|
32
|
+
rexml (>= 3.2.5, < 4.0)
|
33
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
28
34
|
ruby-progressbar (~> 1.7)
|
29
|
-
unicode-display_width (>=
|
30
|
-
|
31
|
-
|
35
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
36
|
+
rubocop-ast (1.29.0)
|
37
|
+
parser (>= 3.2.1.0)
|
38
|
+
ruby-progressbar (1.13.0)
|
39
|
+
unicode-display_width (2.4.2)
|
32
40
|
|
33
41
|
PLATFORMS
|
34
42
|
ruby
|
@@ -40,4 +48,4 @@ DEPENDENCIES
|
|
40
48
|
rubocop
|
41
49
|
|
42
50
|
BUNDLED WITH
|
43
|
-
2.
|
51
|
+
2.1.4
|
@@ -9,7 +9,7 @@ module RailsSeeds
|
|
9
9
|
|
10
10
|
FileUtils.mkdir_p(seed_folder) unless File.exist?(seed_folder)
|
11
11
|
|
12
|
-
path = File.join(seed_folder, "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{file.
|
12
|
+
path = File.join(seed_folder, "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{file.underscore}.rb")
|
13
13
|
FileUtils.touch(path)
|
14
14
|
|
15
15
|
puts "Create seed file #{path}"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RailsSeeds
|
2
|
+
class << self
|
3
|
+
def retrieve_path(file)
|
4
|
+
File.join(seed_folder, file)
|
5
|
+
end
|
6
|
+
|
7
|
+
def valid_file?(file)
|
8
|
+
path = retrieve_path(file)
|
9
|
+
|
10
|
+
return true if File.file?(path)
|
11
|
+
|
12
|
+
puts "#{path} is invalid."
|
13
|
+
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(file, method = :system)
|
18
|
+
path = RailsSeeds.retrieve_path(file)
|
19
|
+
|
20
|
+
puts "Run seed #{path}"
|
21
|
+
|
22
|
+
send(method, "rails runner #{path}")
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def seed_folder
|
28
|
+
@seed_folder ||= File.join(Rails.root, 'db', 'seed')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/rails_seeds/version.rb
CHANGED
data/lib/rails_seeds.rb
CHANGED
data/lib/tasks/list.rake
CHANGED
data/lib/tasks/seeds.rake
CHANGED
@@ -1,39 +1,30 @@
|
|
1
1
|
namespace :db do
|
2
2
|
desc 'Run specific seed files in folder db/seed'
|
3
3
|
task :seeds do
|
4
|
-
seed_folder = File.join(Rails.root, 'db', 'seed')
|
5
4
|
_, *files = ARGV
|
5
|
+
*files, last_file = files.select { |f| RailsSeeds.valid_file?("#{f}.rb") }
|
6
6
|
|
7
7
|
files.each do |file|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
unless File.file?(path)
|
12
|
-
puts "#{path} is invalid."
|
13
|
-
|
14
|
-
next
|
15
|
-
end
|
16
|
-
|
17
|
-
puts "Run seed #{path}."
|
18
|
-
|
19
|
-
exec "rails runner #{path}"
|
8
|
+
Rake::Task['db:seeds:exec'].reenable
|
9
|
+
Rake::Task['db:seeds:exec'].invoke(file)
|
20
10
|
end
|
11
|
+
|
12
|
+
RailsSeeds.run("#{last_file}.rb", :exec) if last_file.present?
|
21
13
|
end
|
22
14
|
|
23
15
|
namespace :seeds do
|
24
16
|
desc 'Run all seed files in folder db/seed'
|
25
17
|
task :all do
|
26
18
|
Dir[File.join(Rails.root, 'db', 'seed', '*.rb')].each do |path|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
19
|
+
Rake::Task['db:seeds:exec'].reenable
|
20
|
+
Rake::Task['db:seeds:exec'].invoke(File.basename(path, '.rb'))
|
21
|
+
end
|
22
|
+
end
|
32
23
|
|
33
|
-
|
24
|
+
task :exec, :seed do |_, args|
|
25
|
+
file = "#{args[:seed]}.rb"
|
34
26
|
|
35
|
-
|
36
|
-
end
|
27
|
+
RailsSeeds.run(file)
|
37
28
|
end
|
38
29
|
end
|
39
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_seeds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alpha
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Run seed data from individual file
|
14
14
|
email:
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- Rakefile
|
25
25
|
- lib/generators/rails_seeds/seed/seed_generator.rb
|
26
26
|
- lib/rails_seeds.rb
|
27
|
+
- lib/rails_seeds/helpers.rb
|
27
28
|
- lib/rails_seeds/railtie.rb
|
28
29
|
- lib/rails_seeds/version.rb
|
29
30
|
- lib/tasks/list.rake
|
@@ -33,7 +34,7 @@ homepage: https://github.com/zgid123/rails_seeds
|
|
33
34
|
licenses:
|
34
35
|
- MIT
|
35
36
|
metadata: {}
|
36
|
-
post_install_message:
|
37
|
+
post_install_message:
|
37
38
|
rdoc_options: []
|
38
39
|
require_paths:
|
39
40
|
- lib
|
@@ -48,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
49
|
- !ruby/object:Gem::Version
|
49
50
|
version: '0'
|
50
51
|
requirements: []
|
51
|
-
rubygems_version: 3.1
|
52
|
-
signing_key:
|
52
|
+
rubygems_version: 3.0.3.1
|
53
|
+
signing_key:
|
53
54
|
specification_version: 4
|
54
55
|
summary: Run seed data from individual file
|
55
56
|
test_files: []
|