rails_seeds 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +4 -0
- data/lib/generators/rails_seeds/seed/seed_generator.rb +19 -0
- data/lib/rails_seeds.rb +5 -0
- data/lib/rails_seeds/railtie.rb +9 -0
- data/lib/rails_seeds/version.rb +5 -0
- data/lib/tasks/list.rake +8 -0
- data/lib/tasks/seeds.rake +39 -0
- data/rails_seeds.gemspec +18 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7c946daca5b604b31220a9f40dfd9cad909bb7806fa0223552cdd6333a741ca
|
4
|
+
data.tar.gz: 8f4aea96d83938e325256f12321eb706e8da4e65e20dfbd0b11cab3ad68ce1f0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01b0d5934c7fe6195282d2a288b1a51bacfc224d7ebf6a116eb459f2b932e72aaf875a7d9e8bfb7d476912cdd84093287e84f639c49d669b577e52df0a18e483
|
7
|
+
data.tar.gz: ab9ae8079055ba7241879f04ee6bc751a18c5ce6e83d487e9c45a95bb617085287c8be6368ffbe0b81d35c4c2bd20ad7f47cb9397f72e44a39b8c5e4a1fb939d
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rails_seeds (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
byebug (11.1.1)
|
11
|
+
childprocess (3.0.0)
|
12
|
+
iniparse (1.5.0)
|
13
|
+
jaro_winkler (1.5.4)
|
14
|
+
overcommit (0.52.1)
|
15
|
+
childprocess (>= 0.6.3, < 4)
|
16
|
+
iniparse (~> 1.4)
|
17
|
+
parallel (1.19.1)
|
18
|
+
parser (2.7.0.4)
|
19
|
+
ast (~> 2.4.0)
|
20
|
+
rainbow (3.0.0)
|
21
|
+
rexml (3.2.4)
|
22
|
+
rubocop (0.80.1)
|
23
|
+
jaro_winkler (~> 1.5.1)
|
24
|
+
parallel (~> 1.10)
|
25
|
+
parser (>= 2.7.0.1)
|
26
|
+
rainbow (>= 2.2.2, < 4.0)
|
27
|
+
rexml
|
28
|
+
ruby-progressbar (~> 1.7)
|
29
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
30
|
+
ruby-progressbar (1.10.1)
|
31
|
+
unicode-display_width (1.6.1)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
byebug
|
38
|
+
overcommit
|
39
|
+
rails_seeds!
|
40
|
+
rubocop
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Alpha
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Introduction
|
2
|
+
|
3
|
+
Simple gem for running specific seed files in db/seed.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rails_seeds'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install rails_seeds
|
23
|
+
```
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
- Generate seed file
|
28
|
+
|
29
|
+
```
|
30
|
+
rails g rails_seeds:seed <file name>
|
31
|
+
|
32
|
+
# rails g rails_seeds:seed add_new_role
|
33
|
+
```
|
34
|
+
|
35
|
+
- Run all seed files in db/seed
|
36
|
+
|
37
|
+
```
|
38
|
+
rake db:seeds:all
|
39
|
+
```
|
40
|
+
|
41
|
+
- Run specific files in db/seed
|
42
|
+
|
43
|
+
```
|
44
|
+
rake db:seeds <file name 1> <file name 2>
|
45
|
+
|
46
|
+
# rake db:seeds 20200303173019_add_new_role 20200303173040_add_new_product
|
47
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module RailsSeeds
|
2
|
+
module Generators
|
3
|
+
class SeedGenerator < ::Rails::Generators::Base
|
4
|
+
def create_seed
|
5
|
+
file = ARGV.first&.gsub(/.rb/, '')
|
6
|
+
seed_folder = File.join(Rails.root, 'db', 'seed')
|
7
|
+
|
8
|
+
return puts 'Must provide file name' if file.blank?
|
9
|
+
|
10
|
+
FileUtils.mkdir_p(seed_folder) unless File.exist?(seed_folder)
|
11
|
+
|
12
|
+
path = File.join(seed_folder, "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{file.snakecase}.rb")
|
13
|
+
FileUtils.touch(path)
|
14
|
+
|
15
|
+
puts "Create seed file #{path}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/rails_seeds.rb
ADDED
data/lib/tasks/list.rake
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc 'Run specific seed files in folder db/seed'
|
3
|
+
task :seeds do
|
4
|
+
seed_folder = File.join(Rails.root, 'db', 'seed')
|
5
|
+
_, *files = ARGV
|
6
|
+
|
7
|
+
files.each do |file|
|
8
|
+
file = "#{file}.rb"
|
9
|
+
path = File.join(seed_folder, file)
|
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}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
namespace :seeds do
|
24
|
+
desc 'Run all seed files in folder db/seed'
|
25
|
+
task :all do
|
26
|
+
Dir[File.join(Rails.root, 'db', 'seed', '*.rb')].each do |path|
|
27
|
+
unless File.file?(path)
|
28
|
+
puts "#{path} is invalid."
|
29
|
+
|
30
|
+
next
|
31
|
+
end
|
32
|
+
|
33
|
+
puts "Run seed #{path}."
|
34
|
+
|
35
|
+
exec "rails runner #{path}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/rails_seeds.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'rails_seeds/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rails_seeds'
|
9
|
+
spec.version = RailsSeeds::VERSION
|
10
|
+
spec.authors = ['Alpha']
|
11
|
+
spec.email = ['alphanolucifer@gmail.com']
|
12
|
+
spec.summary = 'Run seed data from individual file'
|
13
|
+
spec.description = 'Run seed data from individual file'
|
14
|
+
spec.licenses = ['MIT']
|
15
|
+
spec.files = Dir['{lib/**/*,[A-Z]*}']
|
16
|
+
spec.required_ruby_version = '>= 2.3'
|
17
|
+
spec.homepage = 'https://github.com/zgid123/rails_seeds'
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_seeds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alpha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Run seed data from individual file
|
14
|
+
email:
|
15
|
+
- alphanolucifer@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- Gemfile
|
21
|
+
- Gemfile.lock
|
22
|
+
- LICENSE.txt
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/generators/rails_seeds/seed/seed_generator.rb
|
26
|
+
- lib/rails_seeds.rb
|
27
|
+
- lib/rails_seeds/railtie.rb
|
28
|
+
- lib/rails_seeds/version.rb
|
29
|
+
- lib/tasks/list.rake
|
30
|
+
- lib/tasks/seeds.rake
|
31
|
+
- rails_seeds.gemspec
|
32
|
+
homepage: https://github.com/zgid123/rails_seeds
|
33
|
+
licenses:
|
34
|
+
- MIT
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '2.3'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.1.2
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Run seed data from individual file
|
55
|
+
test_files: []
|