planter 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfa1e7b38b742bb8c31851ad06c330d2e7d49992b99b65d7a2237112747aa270
4
- data.tar.gz: 939d28bdbebd8b62c1e98336ba567fe448fb9483249fd1d4af047aa6e320a3d4
3
+ metadata.gz: 95ab85b49c50ea3b7ee077d4225083884558ae89c6fa5b2ea4e9410284f890eb
4
+ data.tar.gz: 2fd36b19ab5064d681323eb5f7e73a95cf710b7af8a587031c84b7175610cfbe
5
5
  SHA512:
6
- metadata.gz: 167c28a3afd2ae9249812ec60c528aab980380e98f22acd81ed660f6bc3dedeb15ff533935934c01d71f92d7300830342e44c67f86a85c8465c6069ed95565e2
7
- data.tar.gz: 9faf05d221dc68b52f3e1f0f9c4694b2c84e418361585aa9c69182ccd5d70a40bb33f51332b041b9e510a83460c46bc4a1f13c3ba2d0a2676ec07393ff9076a7
6
+ metadata.gz: fa74216b4529bcb3d21ccd697574c175ad7dd641d477921108ff9949e1ab9a9537cf6f4847b6e2aaadeb91e8aecedc6afec243c72250d9b77cce1da0e4926580
7
+ data.tar.gz: 9b9cb5dd5a29b8a66c8cd9a6c49d5192c1395a5d935a98628928f65babcd709c2a6480ed356bf2f575e0710856a214025efdf91942acf3fe034a39a1369f302a
data/README.md CHANGED
@@ -13,7 +13,7 @@ db:seed` task.
13
13
  Features include:
14
14
 
15
15
  - Seed tables from CSV files, an array of hashes, or custom methods.
16
- - Seed specific tables with `rails db:seed TABLES=users,addresses`.
16
+ - Call specific seeders with `rails db:seed SEEDERS=users,addresses`.
17
17
  - Control the number of records being created.
18
18
  - Seed associations.
19
19
 
@@ -42,14 +42,14 @@ $ gem install planter
42
42
  Let's assume you'd like to seed your `users` table.
43
43
 
44
44
  To get started, simply add the following to your `db/seeds.rb` file. Note that
45
- the `config.tables` should be an array of the tables to seed. They should be in
45
+ the `config.seeders` should be an array of the seeders to use. They should be in
46
46
  the correct order to successfully seed the tables when considering associations.
47
47
 
48
48
  ```ruby
49
49
  require 'planter'
50
50
 
51
51
  Planter.configure do |config|
52
- config.tables = %i[ users ]
52
+ config.seeders = %i[ users ]
53
53
  end
54
54
 
55
55
  Planter.seed
@@ -179,7 +179,7 @@ require 'planter'
179
179
  Planter.configure do |config|
180
180
  config.seeders_directory = 'db/seeder_classes'
181
181
  config.csv_files_directory = 'db/csvs'
182
- config.tables = %i[
182
+ config.seeders = %i[
183
183
  users
184
184
  addresses
185
185
  ]
data/lib/planter.rb CHANGED
@@ -93,7 +93,7 @@ module Planter
93
93
  #
94
94
  # @example
95
95
  # Planter.configure do |app_seeder|
96
- # app_seeder.tables = %i[users]
96
+ # app_seeder.seeders = %i[users]
97
97
  # app_seeder.seeders_directory = 'db/seeds'
98
98
  # app_seeder.csv_files_directory = 'db/seed_files'
99
99
  # end
@@ -102,18 +102,18 @@ module Planter
102
102
  end
103
103
 
104
104
  ##
105
- # This is the method to call from your +db/seeds.rb+. It seeds the tables
106
- # listed in +Planter.config.tables+. To seed specific tables at
107
- # runtime, you can set the +TABLES+ environmental variable to a
108
- # comma-separated list of tables.
105
+ # This is the method to call from your +db/seeds.rb+. It callse the seeders
106
+ # listed in +Planter.config.seeders+. To call specific seeders at
107
+ # runtime, you can set the +SEEDERS+ environmental variable to a
108
+ # comma-separated list of seeders.
109
109
  #
110
110
  # @example
111
- # rails db:seed TABLES=users,accounts
111
+ # rails db:seed SEEDERS=users,accounts
112
112
  def self.seed
113
- tables = ENV['TABLES']&.split(',') || config.tables&.map(&:to_s)
114
- raise RuntimeError, 'No tables specified; nothing to do' unless tables&.any?
113
+ seeders = ENV['SEEDERS']&.split(',') || config.seeders&.map(&:to_s)
114
+ raise RuntimeError, 'No seeders specified; nothing to do' unless seeders&.any?
115
115
 
116
- tables.each do |table|
116
+ seeders.each do |table|
117
117
  require Rails.root.join(config.seeders_directory, "#{table}_seeder.rb").to_s
118
118
  puts "Seeding #{table}" unless config.quiet
119
119
  "#{table.camelize}Seeder".constantize.new.seed
@@ -5,7 +5,7 @@ module Planter
5
5
  # Configure the application seeder.
6
6
  #
7
7
  # @example
8
- # Planter.configure { |seeder| seeder.tables = %i[users] }
8
+ # Planter.configure { |seeder| seeder.seeders = %i[users] }
9
9
  class Config
10
10
  ##
11
11
  # Tell the application where the seeder classes are kept. Must be a path
@@ -26,13 +26,13 @@ module Planter
26
26
  attr_accessor :csv_files_directory
27
27
 
28
28
  ##
29
- # Tell the application what tables to seed. Elements should be in the correct
30
- # order, and can be strings or symbols.
29
+ # Tell the application what seeders exist. Elements should be in the correct
30
+ # order to seed the tables successfully, and can be strings or symbols.
31
31
  #
32
- # @param [Array] tables
32
+ # @param [Array] seeders
33
33
  #
34
34
  # @return [Array]
35
- attr_accessor :tables
35
+ attr_accessor :seeders
36
36
 
37
37
  ##
38
38
  # When true, don't print output when seeding.
@@ -1,7 +1,54 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Planter
4
+ ##
5
+ # Module that contains all gem version information. Follows semantic
6
+ # versioning. Read: https://semver.org/
7
+ module Version
8
+ ##
9
+ # Major version.
10
+ #
11
+ # @return [Integer]
12
+ MAJOR = 0
13
+
14
+ ##
15
+ # Minor version.
16
+ #
17
+ # @return [Integer]
18
+ MINOR = 0
19
+
20
+ ##
21
+ # Patch version.
22
+ #
23
+ # @return [Integer]
24
+ PATCH = 6
25
+
26
+ ##
27
+ # Version as +[MAJOR, MINOR, PATCH]+
28
+ #
29
+ # @return [Array]
30
+ def self.to_a
31
+ [MAJOR, MINOR, PATCH]
32
+ end
33
+
34
+ ##
35
+ # Version as +MAJOR.MINOR.PATCH+
36
+ #
37
+ # @return [String]
38
+ def self.to_s
39
+ to_a.join('.')
40
+ end
41
+
42
+ ##
43
+ # Version as +{major: MAJOR, minor: MINOR, patch: PATCH}+
44
+ #
45
+ # @return [Hash]
46
+ def self.to_h
47
+ Hash[%i[major minor patch].zip(to_a)]
48
+ end
49
+ end
50
+
4
51
  ##
5
52
  # Gem version, semantic.
6
- VERSION = '0.0.5'.freeze
53
+ VERSION = Version.to_s.freeze
7
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: planter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Gray