simple_seeds 0.0.4

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bf06237b43e9310425ea0bfbd6011ef59e47d89471f5e7f41e805cee9040709e
4
+ data.tar.gz: b91ea7a40a9d79f53104198deead1718060770fa7d160e619f1729b076aa846e
5
+ SHA512:
6
+ metadata.gz: 8c22681d784a00f9629cc0cd2d1add44c4e47df6d852c63037335b74da7bc70ce5c527199c2a7fdd1d6584290a8a847ebfebf560cc105d2d4fa6e1a1ee6f71f9
7
+ data.tar.gz: 31ff1bfdd0accaf999a1cc6dd4e03f17d04fe0d3b51a930a2cffe026c8b969a8e5fadf91ae09425e577239feee08bfd5afcc2a78a4a1db440d58d01b258ea561
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # Ignore Gemfile.lock
11
+ Gemfile.lock
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ Style/AndOr:
2
+ EnforcedStyle: always
3
+
4
+ Style/BracesAroundHashParameters:
5
+ Enabled: braces
6
+
7
+ Style/ClassAndModuleChildren:
8
+ EnforcedStyle: compact
9
+ AutoCorrect: true
10
+
11
+ Style/HashSyntax:
12
+ EnforcedStyle: ruby19
13
+
14
+
15
+ Layout/AlignHash:
16
+ EnforcedColonStyle: table
17
+ EnforcedHashRocketStyle: table
18
+
19
+ Layout/AlignParameters:
20
+ EnforcedStyle: with_first_parameter
21
+
22
+ # Metrics
23
+ Metrics/BlockLength:
24
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at freibuis@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in simple_seed.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Freibuis
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,80 @@
1
+ # SimpleSeed
2
+
3
+ Here at Simple were are well, quite simple. So we just love our tools simple.
4
+
5
+ This tool alls your project to load seed data (via ruby/rails logic) for diffrent rails environments (production,development,testing etc).. Simple....
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'simple_seeds'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install simple_seeds
23
+
24
+ ## Usage
25
+
26
+ ### Installation
27
+ To create the base setup for simple_seeds, simply run
28
+ ```bash
29
+ rails generate simple_seeds:setup
30
+ ```
31
+
32
+ this will create the following files and directories into your project <br />
33
+ `db/simple_seeds/README.md`<br />
34
+ `db/simple_seeds/simple_seeds.rb` this file loads custom confiruations required by your project accross environments
35
+
36
+ environments directories:
37
+ `db/simple_seeds/environments/all/` this is loaded for all environments<br />
38
+ `db/simple_seeds/environments/{Rails environments}/` each environment listed in your projects environments will be created
39
+
40
+
41
+ ### Running simple_seeds
42
+
43
+ when running `rails db:seed` simple_seeds will automatically run after the rails seed file has completed
44
+
45
+ if you want to run simple_seeds on its own just run
46
+ `rails db:simple_seeds`
47
+
48
+ ## Seed Files
49
+
50
+ seed files run in filename order from both the :all and your selected rails environment.
51
+ example: <br />
52
+ `all/001_users.rb `<br />
53
+ `development/001_users.rb` <br />
54
+
55
+ the `all/001_users.rb` file will run first
56
+
57
+ example: <br />
58
+ `all/002_users.rb` <br />
59
+ `development/001_users.rb` <br />
60
+
61
+ the `development/001_users.rb` will run first
62
+
63
+
64
+ ## Development
65
+
66
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/freibuis/simple_seeds. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
77
+
78
+ ## Code of Conduct
79
+
80
+ Everyone interacting in the SimpleSeed project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/simple_seeds/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "simple_seed"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Creates the directory required for where the simple seeds are read from
3
+
4
+ Example:
5
+ rails generate simple_seed:setup
6
+
7
+ This will create:
8
+ db/simple_seeds/
9
+ db/simple_seeds/README.md
@@ -0,0 +1,33 @@
1
+
2
+ # Generators for Simple Seeds
3
+ class SimpleSeeds::SetupGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('templates', __dir__)
5
+
6
+ def environments
7
+ ['all'] + Dir[File.join(Rails.root, 'config', 'environments', '*.rb')]
8
+ .collect { |f| File.basename(f, '.rb') }
9
+ end
10
+
11
+ # Create simple seeds confuration file
12
+ def create_configuration_file
13
+ template 'simple_seeds.rb', File.join(
14
+ 'db', 'simple_seeds', 'simple_seeds.rb'
15
+ )
16
+ end
17
+
18
+ # Creates simple Seeds base file
19
+ def create_simple_seed_directory
20
+ @environments = environments
21
+ template 'README.md', File.join('db', 'simple_seeds', 'README.md')
22
+ end
23
+
24
+ # Creates all enviroments based of this rails project
25
+ def create_simple_seed_environment_directory
26
+ environments.each do |environment|
27
+ @environment = environment
28
+ template('environment.README.md',
29
+ File.join('db', 'simple_seeds',
30
+ 'environments', environment, 'README.md'))
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ # Simple Seeds
2
+
3
+ Seed files in ordered file names with any ruby logic
4
+
5
+ ## usage:
6
+
7
+ just run rails seed command as this hooks into `db:seed`
8
+ ```bash
9
+ rails db:seed
10
+ ```
11
+ or only run `rails db:simple_seeds` to ignore simple seeds
12
+
13
+ ```bash
14
+ rails db:simple_seeds
15
+ ```
16
+ ### environments
17
+ <% environments.each do |environment| %>
18
+ [<%= environment %>](environments/<%= environment %>)
19
+ <% end %>
20
+ #### Order of precedance
21
+
22
+ Simple seeds loads seeds based on the [all/] environment and the current selected environment
23
+
24
+
25
+ this can be handy if you require the same seed to run over all environments
26
+
27
+ #### Example:
28
+ assuming :development environment
29
+ file1: `db/simple_seeds/environments/all/0001_users.rb`
30
+ file2: `db/simple_seeds/environments/development/0002_users.rb`
31
+ file3: `db/simple_seeds/environments/all/0003_posts.rb`
32
+ file4: `db/simple_seeds/environments/development/0004_posts.rb`
33
+
34
+ order => file1, file2, file3, file4
35
+
36
+ if an identical filename is found, then the :all environment will run first
@@ -0,0 +1,39 @@
1
+ # <%= @environment %> environment
2
+
3
+ ## Examples:
4
+
5
+ file `db/simple-seeds/<%= @environment %>/00001_users.rb`
6
+
7
+ ```ruby
8
+ # Create 10 Users
9
+ if Rails.env.<%= @environment %>?
10
+ 10.times
11
+ User.create([
12
+ {
13
+ first_name: Faker::Name.first_name,
14
+ last_name: Faker::Name.last_name),
15
+ user_email: Faker::Internet.email
16
+ }])
17
+ end
18
+ end
19
+ ```
20
+
21
+ file `db/simple-seeds/<%= @environment %>/00002_users_posts.rb`
22
+
23
+
24
+ ```ruby
25
+ # Create Random amount of posts per user
26
+ if Rails.env.<%= @environment %>?
27
+ users = User.all
28
+ users.each do |user|
29
+ Random.rand(11) + 1).times
30
+ Post.create([
31
+ {
32
+ user_id: user.id,
33
+ description: Faker::Loerm.paragraph
34
+ }])
35
+ end
36
+ end
37
+ end
38
+ ```
39
+
@@ -0,0 +1,15 @@
1
+ ################################################################
2
+ ##
3
+ # SIMPLE SEEDS CONFIGURATION FILE:
4
+ ##
5
+ ##
6
+ #
7
+ # This file is allows you to place instance variables or CONSTANTS that persist
8
+ # between Seed files when they load
9
+ #
10
+ # Example:
11
+ # @max_users = 100
12
+ # or
13
+ # MAX_USERS = 100.freeze
14
+ #
15
+ #################################################################
@@ -0,0 +1,7 @@
1
+ require 'simple_seeds/version'
2
+ require 'simple_seeds/railtie' if defined?(Rails)
3
+
4
+ # Simple Seeds
5
+ module SimpleSeed
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,6 @@
1
+ # Simple Seeds Rails Tasks
2
+ class SimpleSeeds::Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ load 'tasks/simple_seeds.rake'
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleSeeds
2
+ VERSION = '0.0.4'.freeze
3
+ end
@@ -0,0 +1,58 @@
1
+ namespace :db do
2
+ desc 'runs seed code from simple_seed directory'
3
+ task simple_seeds: :environment do
4
+ if defined?(Rails)
5
+
6
+ # All environments seed files
7
+ all_seeds = Dir[File.join(
8
+ Rails.root, 'db', 'simple_seeds',
9
+ 'environments', 'all', '**', '*.rb'
10
+ )].collect do |file|
11
+ {
12
+ environment: :all,
13
+ file: file,
14
+ filename: File.basename(file)
15
+ }
16
+ end
17
+
18
+ # Rails environment seed files
19
+ environment_seeds = Dir[File.join(
20
+ Rails.root, 'db', 'simple_seeds',
21
+ 'environments', Rails.env, '**', '*.rb'
22
+ )].collect do |file|
23
+ {
24
+ environment: Rails.env.to_sym,
25
+ file: file,
26
+ filename: File.basename(file)
27
+ }
28
+ end
29
+
30
+ # Sort the seed by filename
31
+ # This should make All env sort first. of course this would mean
32
+ # env: aaa would load first and break
33
+ #
34
+ # Retweak this later if more env's come before evn: all
35
+ seeds = (all_seeds + environment_seeds).sort_by do |seed_file|
36
+ seed_file[:filename]
37
+ end
38
+
39
+ # Run simple_seeds configuration first
40
+ # load all configurations here
41
+ # @max_users = 1
42
+ # this will then use max_users as 1 in all loaded seeds
43
+ seed_configuration_file = Rails.root.join(
44
+ 'db', 'simple_seeds', 'simple_seeds.rb'
45
+ )
46
+ load seed_configuration_file if File.exist?(seed_configuration_file)
47
+
48
+ # Load each seed file. simple
49
+ seeds.each do |seed_file|
50
+ load seed_file[:file]
51
+ end
52
+ end
53
+ end
54
+
55
+ Rake::Task['seed'].enhance do
56
+ Rake::Task[:simple_seeds].invoke
57
+ end
58
+ end
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "simple_seeds/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'simple_seeds'
8
+ spec.version = SimpleSeeds::VERSION
9
+ spec.authors = ['Freibuis']
10
+ spec.email = ['freibuis@gmail.com']
11
+ spec.summary = %q{Simple Rails Seeds.. Its that simple}
12
+ spec.homepage = 'https://github.com/freibuis/simple_seeds'
13
+ spec.license = 'MIT'
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_seeds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Freibuis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description:
56
+ email:
57
+ - freibuis@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - lib/generators/simple_seeds/setup/USAGE
74
+ - lib/generators/simple_seeds/setup/setup_generator.rb
75
+ - lib/generators/simple_seeds/setup/templates/README.md
76
+ - lib/generators/simple_seeds/setup/templates/environment.README.md
77
+ - lib/generators/simple_seeds/setup/templates/simple_seeds.rb
78
+ - lib/simple_seeds.rb
79
+ - lib/simple_seeds/railtie.rb
80
+ - lib/simple_seeds/version.rb
81
+ - lib/tasks/simple_seeds.rake
82
+ - simple_seeds.gemspec
83
+ homepage: https://github.com/freibuis/simple_seeds
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.7.3
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Simple Rails Seeds.. Its that simple
107
+ test_files: []