monsanto 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/monsanto/railtie.rb +13 -0
- data/lib/monsanto/rake_colorizer.rb +13 -0
- data/lib/monsanto/rake_prettifier.rb +18 -0
- data/lib/monsanto/tsortable.rb +14 -0
- data/lib/monsanto/version.rb +3 -0
- data/lib/monsanto.rb +9 -0
- data/lib/tasks/db.rake +15 -0
- data/lib/tasks/populate.rake +63 -0
- data/monsanto-0.1.0.gem +0 -0
- data/monsanto-0.1.1.gem +0 -0
- data/monsanto.gemspec +24 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 26aac1f6d8419b3694ba3ef7a666c6aa4bc22cab
|
4
|
+
data.tar.gz: 4974a6b9252efcb420e02acb9f4ddd17f4977cb9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63c4af28e5cb97e4a6fd6c737b6161230d9afa9ef56971ba5aed835b2af2a9b16456ebf746c65b31775d2c5347656dbb16e2e58dc5c3479f00a1dff3688033b6
|
7
|
+
data.tar.gz: 83b71be06839b84e6b996f5385c0af976fafe2e0bbaba40b1e5fa1c52c9734413fc9ad584fd47752787e326c9988718ba04f5a56eadfb1936087db7e189130a0
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 schadenfred
|
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,48 @@
|
|
1
|
+
# Monsanto
|
2
|
+
|
3
|
+
Similar to [Seedbank](https://github.com/james2m/seedbank "Title"), but with automatic dependency sorting.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your Rails 4+ application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'monsanto'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Create a directory strucure for your rake tasks that looks like this:
|
20
|
+
|
21
|
+
/lib/tasks/populate/
|
22
|
+
|
23
|
+
Inside the populate directory, create another directory to tell Monsanto the environment you'd like to populate. If you'd like to populate your development environment, do:
|
24
|
+
|
25
|
+
/lib/tasks/populate/development/
|
26
|
+
|
27
|
+
If your application has wine reviews, with each review belonging to both a reviewer of class "User" and a wine, and with each wine belonging to a winery, create populators for each of these models, like so:
|
28
|
+
|
29
|
+
/lib/tasks/populate/development/users.populator.rb
|
30
|
+
/lib/tasks/populate/development/reviews.populator.rb
|
31
|
+
/lib/tasks/populate/development/wine.populator.rb
|
32
|
+
/lib/tasks/populate/development/wineries.populator.rb
|
33
|
+
|
34
|
+
Use the same syntax and conventions you'd use in a standard Rails seed.rb file. Once you run rake db:populate:development, Monsanto will use ActiveRecord reflection and tsort to run them in the correct order.
|
35
|
+
|
36
|
+
## Development
|
37
|
+
|
38
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
39
|
+
|
40
|
+
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it ( https://github.com/[my-github-username]/monsanto/fork )
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "monsanto"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module RakeColorizer
|
2
|
+
|
3
|
+
def colorize(text, color_code)
|
4
|
+
"\e[#{color_code}m#{text}\e[0m"
|
5
|
+
end
|
6
|
+
|
7
|
+
def red(text); colorize(text, 31); end
|
8
|
+
def green(text); colorize(text, 32); end
|
9
|
+
def yellow(text); colorize(text, 33); end
|
10
|
+
def purple(text); colorize(text, 34); end
|
11
|
+
def magenta(text); colorize(text, 35); end
|
12
|
+
def cyan(text); colorize(text, 36); end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RakePrettifier
|
2
|
+
|
3
|
+
def inflect(method)
|
4
|
+
method.gsub("make", "making")
|
5
|
+
end
|
6
|
+
|
7
|
+
def big_notice(task)
|
8
|
+
puts green("==>") + " " + task.name
|
9
|
+
end
|
10
|
+
|
11
|
+
def medium_notice(task)
|
12
|
+
puts green(" -->") + " " + task
|
13
|
+
end
|
14
|
+
|
15
|
+
def small_notice(subject)
|
16
|
+
puts green(" ~-") + " Making " + subject
|
17
|
+
end
|
18
|
+
end
|
data/lib/monsanto.rb
ADDED
data/lib/tasks/db.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Dir[Rails.root.join("lib/tasks/populate/support/*.rb")].each {|f| require f}
|
2
|
+
|
3
|
+
require 'faker/stoked'
|
4
|
+
require 'faker/bloocher'
|
5
|
+
require 'monsanto/tsortable'
|
6
|
+
|
7
|
+
|
8
|
+
# task aliases
|
9
|
+
|
10
|
+
desc "Alias for db:populate:development"
|
11
|
+
task "db:populate" => ["db:populate:development"]
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
namespace 'db' do
|
2
|
+
|
3
|
+
namespace 'populate' do
|
4
|
+
|
5
|
+
def populators(environment_path)
|
6
|
+
populators = []
|
7
|
+
populator_paths = Dir.glob(environment_path + "*.populator.rb")
|
8
|
+
populator_paths.each do |populator_path|
|
9
|
+
populators << populator_path.split("/").last.split(".").first
|
10
|
+
end
|
11
|
+
populators
|
12
|
+
end
|
13
|
+
|
14
|
+
def ordered_populators(environment_path)
|
15
|
+
dependency_hash = Monsanto::TsortableHash[]
|
16
|
+
|
17
|
+
|
18
|
+
pops = populators(environment_path)
|
19
|
+
pops.each do |populator|
|
20
|
+
klass = populator.classify.constantize
|
21
|
+
parents = []
|
22
|
+
klass.reflect_on_all_associations(:belongs_to).each do |parent|
|
23
|
+
unless parent.options[:polymorphic]
|
24
|
+
|
25
|
+
parents << parent.table_name.singularize.to_sym
|
26
|
+
end
|
27
|
+
end
|
28
|
+
dependency_hash[populator.singularize.to_sym] = parents
|
29
|
+
end
|
30
|
+
dependency_hash.tsort
|
31
|
+
end
|
32
|
+
|
33
|
+
environment_paths = Dir.glob("lib/tasks/populate/*/").split("/").last
|
34
|
+
environment_paths.each do |environment_path|
|
35
|
+
environment = environment_path.split("/").last
|
36
|
+
unless ["support", "common"].include? environment
|
37
|
+
namespace environment.to_sym do
|
38
|
+
|
39
|
+
populators(environment_path).each do |populator|
|
40
|
+
|
41
|
+
desc "Populate #{environment} db with #{populator} populator"
|
42
|
+
task populator => :environment do
|
43
|
+
populator_file = File.read("lib/tasks/populate/#{environment}/#{populator}.populator.rb")
|
44
|
+
eval(populator_file)
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Populate #{environment} db"
|
51
|
+
|
52
|
+
task environment.to_sym => :environment do
|
53
|
+
Rake::Task["db:drop"].invoke
|
54
|
+
Rake::Task["db:create"].invoke
|
55
|
+
Rake::Task["db:migrate"].invoke
|
56
|
+
ordered_populators(environment_path).each do |populator|
|
57
|
+
Rake::Task["db:populate:#{environment}:#{populator.to_s.pluralize}"].invoke
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/monsanto-0.1.0.gem
ADDED
Binary file
|
data/monsanto-0.1.1.gem
ADDED
Binary file
|
data/monsanto.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'monsanto/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "monsanto"
|
8
|
+
spec.version = Monsanto::VERSION
|
9
|
+
spec.authors = ["schadenfred"]
|
10
|
+
spec.email = ["fred.schoeneman@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Populate your database.}
|
13
|
+
spec.description = %q{Similar to Seedbank, but with automatic dependency sorting and, as of now, no tests. Your Mileage may vary.}
|
14
|
+
spec.homepage = "https://github.com/schadenfred/monsanto.git"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: monsanto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- schadenfred
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-25 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.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
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
|
+
description: Similar to Seedbank, but with automatic dependency sorting and, as of
|
42
|
+
now, no tests. Your Mileage may vary.
|
43
|
+
email:
|
44
|
+
- fred.schoeneman@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- lib/monsanto.rb
|
58
|
+
- lib/monsanto/railtie.rb
|
59
|
+
- lib/monsanto/rake_colorizer.rb
|
60
|
+
- lib/monsanto/rake_prettifier.rb
|
61
|
+
- lib/monsanto/tsortable.rb
|
62
|
+
- lib/monsanto/version.rb
|
63
|
+
- lib/tasks/db.rake
|
64
|
+
- lib/tasks/populate.rake
|
65
|
+
- monsanto-0.1.0.gem
|
66
|
+
- monsanto-0.1.1.gem
|
67
|
+
- monsanto.gemspec
|
68
|
+
homepage: https://github.com/schadenfred/monsanto.git
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.8
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Populate your database.
|
92
|
+
test_files: []
|