active_seed 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/README.rdoc +123 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/active_seed.gemspec +59 -0
- data/lib/active_seed.rb +1 -0
- data/lib/active_seed/engine.rb +6 -0
- data/lib/active_seed/seed_csv.rb +76 -0
- data/lib/generators/active_seed/example_html_colors_generator.rb +38 -0
- data/lib/generators/active_seed/install_generator.rb +20 -0
- data/lib/generators/active_seed/templates/development.yml +8 -0
- data/lib/generators/active_seed/templates/example_html_colors/create_html_colors.rb +22 -0
- data/lib/generators/active_seed/templates/example_html_colors/html_color.rb +44 -0
- data/lib/generators/active_seed/templates/example_html_colors/html_color_family.rb +3 -0
- data/lib/generators/active_seed/templates/example_html_colors/html_colors.yml +8 -0
- data/lib/generators/active_seed/templates/example_html_colors/html_colors/html_color_families.csv +11 -0
- data/lib/generators/active_seed/templates/example_html_colors/html_colors/html_colors.csv +144 -0
- data/lib/tasks/active_seed_tasks.rake +24 -0
- metadata +115 -0
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "bundler", "~> 1.0.0"
|
10
|
+
gem "jeweler", "~> 1.5.2"
|
11
|
+
end
|
data/README.rdoc
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
= ActiveSeed
|
2
|
+
|
3
|
+
Although the inbuilt support for seeding in Rails works well for basic seeding. There are times when a little more versatility is required. ActiveSeed enables organisation of seed files so that seeding for different environments or even seeding new data to a live project is straight forward.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
Simple add the following to your Gemfile
|
8
|
+
|
9
|
+
gem 'active_seed', :git => "git://github.com/intrica/active_seed.git"
|
10
|
+
|
11
|
+
Then run:
|
12
|
+
|
13
|
+
bundle install
|
14
|
+
|
15
|
+
To create the basic seeding template run
|
16
|
+
|
17
|
+
rails g active_seed:install
|
18
|
+
|
19
|
+
== Quick Example
|
20
|
+
|
21
|
+
If you would like an example of usage, you can use the following generator. Be aware this will create models in your project.
|
22
|
+
|
23
|
+
rails g active_seed:example_html_colors
|
24
|
+
rake db:migrate
|
25
|
+
rake db:active_seed set=html_colors
|
26
|
+
|
27
|
+
== Usage
|
28
|
+
|
29
|
+
The basic usage of ActiveSeed is to run
|
30
|
+
|
31
|
+
rake db:active_seed
|
32
|
+
|
33
|
+
This will seed a set based on the current RAILS_ENV. If you want to specify a set, run
|
34
|
+
|
35
|
+
rake db:active_seed set=html_colors
|
36
|
+
|
37
|
+
The concepts of sets and seed data are explained below.
|
38
|
+
|
39
|
+
=== Creating a Set
|
40
|
+
|
41
|
+
The purpose of a set file is to define a "set" of seed files. A set is defined in a YML file and stored in the RAILS_ROOT/db/active_seed. You can create a sample development set file by running the command:
|
42
|
+
|
43
|
+
rails g active_seed
|
44
|
+
|
45
|
+
When seeding, the default set file used will be one named after the current RAILS_ENV. So in devleopment mode it will use the file
|
46
|
+
|
47
|
+
RAILS_ROOT/db/active_seed/development.yml
|
48
|
+
|
49
|
+
The contents of the set file are fairly straight forward, take this example
|
50
|
+
|
51
|
+
# Example seeding file
|
52
|
+
|
53
|
+
# Each line referes to the model object to be created and the file that contains the data
|
54
|
+
|
55
|
+
# Make sure that the files are seeded in order by using !omap
|
56
|
+
--- !omap
|
57
|
+
# This will seed User items from the file db/seed/data/production_users.csv
|
58
|
+
- User: production_users
|
59
|
+
# This will seed User items from the file db/seed/data/development_users.csv
|
60
|
+
- User: development_users
|
61
|
+
|
62
|
+
Notice the "--- !omap" line and the fact that each line is started with a "-" character. This ensures that the seeding is done in the order specified.
|
63
|
+
Each entry in this file simple corresponds to a model, and then the seed file assosiated with it.
|
64
|
+
Note also that in this example, User is being seeded from two separate files. This is quite handy as you can have development include both the real users and some nice sample data whereas in production.yml you could include only the production data.
|
65
|
+
|
66
|
+
|
67
|
+
=== Creating the seed data
|
68
|
+
|
69
|
+
The seed data files are csv files. A simple example is shown below:
|
70
|
+
|
71
|
+
username,first_name,password,password_confirmation,active
|
72
|
+
david,summer,summer,true
|
73
|
+
vincent,autumn,autumn,true
|
74
|
+
luke,winter,winter,true
|
75
|
+
tim,spring,spring,true
|
76
|
+
|
77
|
+
Records are created from this data by creating a new Active Record model of the appropriate type and assigning these attributes to it. By seeding this way, all validations and callbacks are executed. This is why the password_confirmation field is present as otherwise the validation would fail.
|
78
|
+
|
79
|
+
It would be nicer however if we could lose the duplication and also the fact that every user needs to have "true" for the active field.
|
80
|
+
|
81
|
+
==== Static assignment
|
82
|
+
|
83
|
+
Static assignment allows you to specify the value of a column in the header of the csv file, eliminating the need for that column to appear in the data below. Here is a version of the above example using static assignment:
|
84
|
+
|
85
|
+
username,first_name,password,password_confirmation,active=true
|
86
|
+
david,David,summer,summer
|
87
|
+
vincent,Vincent,autumn,autumn
|
88
|
+
luke,Luke,winter,winter
|
89
|
+
tim,Tim,spring,spring
|
90
|
+
|
91
|
+
This simplifies the data by not requiring the active column to be defined for every record.
|
92
|
+
|
93
|
+
==== Self Referencing
|
94
|
+
|
95
|
+
Any static assignment can contain valid ruby code. Within this code, the variable "model" refers to the model being constructed. So the above example could again be simplified by doing this:
|
96
|
+
|
97
|
+
username,first_name,password,password_confirmation=model.password,active=true
|
98
|
+
david,David,summer
|
99
|
+
vincent,Vincent,autumn
|
100
|
+
luke,Luke,winter
|
101
|
+
tim,Tim,spring
|
102
|
+
|
103
|
+
And simplified again by doing this:
|
104
|
+
|
105
|
+
first_name,username=model.first_name.downcase,password,password_confirmation=model.password,active=true
|
106
|
+
David,summer
|
107
|
+
Vincent,autumn
|
108
|
+
Luke,winter
|
109
|
+
Tim,spring
|
110
|
+
|
111
|
+
As the attributes are set in order, you will notice that in the header in the example above, first_name now appears before username.
|
112
|
+
|
113
|
+
==== Evaluations
|
114
|
+
|
115
|
+
Evaluations are handy if you want to interpret data in the column rather than just assign it verbatim. Say for example we wanted a user to have a date of birth and be asigned to the appropriate role in the database. The role requires an id which belongs to another model. Here is an example of how to do both of these things:
|
116
|
+
|
117
|
+
first_name,username=model.first_name.downcase,password,password_confirmation=model.password,active=true,role_id=Role.find_by_name(?),birthday=DateTime.parse(?)
|
118
|
+
David,summer,Admins,"17 April 1979"
|
119
|
+
Vincent,autumn,Users,"9th July 1976"
|
120
|
+
|
121
|
+
As you can see, wherever the ? appears in the header, it is replaced with the value of the corresponding column.
|
122
|
+
|
123
|
+
== Potential Issues
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "active_seed"
|
16
|
+
gem.homepage = "http://github.com/intrica/active_seed"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = "Seeds data using activerecord."
|
19
|
+
gem.description = "ActiveSeed Gives the ability to seed data by inserting it via activerecord. Also allows you to manage sets of data and seed based on the current environment."
|
20
|
+
gem.email = "david.monagle@intrica.com.au"
|
21
|
+
gem.authors = ["David Monagle"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rake/rdoctask'
|
31
|
+
Rake::RDocTask.new do |rdoc|
|
32
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
33
|
+
|
34
|
+
rdoc.rdoc_dir = 'rdoc'
|
35
|
+
rdoc.title = "active_seed #{version}"
|
36
|
+
rdoc.rdoc_files.include('README*')
|
37
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.3
|
data/active_seed.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{active_seed}
|
8
|
+
s.version = "1.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["David Monagle"]
|
12
|
+
s.date = %q{2011-04-12}
|
13
|
+
s.description = %q{ActiveSeed Gives the ability to seed data by inserting it via activerecord. Also allows you to manage sets of data and seed based on the current environment.}
|
14
|
+
s.email = %q{david.monagle@intrica.com.au}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"Gemfile",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"active_seed.gemspec",
|
24
|
+
"lib/active_seed.rb",
|
25
|
+
"lib/active_seed/engine.rb",
|
26
|
+
"lib/active_seed/seed_csv.rb",
|
27
|
+
"lib/generators/active_seed/example_html_colors_generator.rb",
|
28
|
+
"lib/generators/active_seed/install_generator.rb",
|
29
|
+
"lib/generators/active_seed/templates/development.yml",
|
30
|
+
"lib/generators/active_seed/templates/example_html_colors/create_html_colors.rb",
|
31
|
+
"lib/generators/active_seed/templates/example_html_colors/html_color.rb",
|
32
|
+
"lib/generators/active_seed/templates/example_html_colors/html_color_family.rb",
|
33
|
+
"lib/generators/active_seed/templates/example_html_colors/html_colors.yml",
|
34
|
+
"lib/generators/active_seed/templates/example_html_colors/html_colors/html_color_families.csv",
|
35
|
+
"lib/generators/active_seed/templates/example_html_colors/html_colors/html_colors.csv",
|
36
|
+
"lib/tasks/active_seed_tasks.rake"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/intrica/active_seed}
|
39
|
+
s.licenses = ["MIT"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.5.3}
|
42
|
+
s.summary = %q{Seeds data using activerecord.}
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/lib/active_seed.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "active_seed/engine"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
3
|
+
def seed_csv(modelname, filename)
|
4
|
+
data = CSV.read(filename)
|
5
|
+
if data.size < 2
|
6
|
+
puts "No data found in file " << filename
|
7
|
+
return
|
8
|
+
end
|
9
|
+
header = data[0];
|
10
|
+
processed_header = Array.new
|
11
|
+
evaluations = Array.new
|
12
|
+
statics = Array.new
|
13
|
+
header.each do |h|
|
14
|
+
# Check if the header field has an assignment
|
15
|
+
if h.include? "="
|
16
|
+
c = h.split "="
|
17
|
+
h = c[0] # Replace the header with just the field name
|
18
|
+
c.delete_at(0) # Remove the field name
|
19
|
+
evaluation = c.join("=") # Rejoin the rest of the evaluation (if there was another =)
|
20
|
+
# If there is no question mark in the evaluation string then we set this column to be
|
21
|
+
# static.
|
22
|
+
unless evaluation.include? "?"
|
23
|
+
statics.push(h + "=" + evaluation)
|
24
|
+
else
|
25
|
+
processed_header.push(h)
|
26
|
+
evaluations.push(evaluation)
|
27
|
+
end
|
28
|
+
else
|
29
|
+
evaluations.push(nil)
|
30
|
+
processed_header.push(h)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
header = processed_header
|
34
|
+
data.delete_at(0);
|
35
|
+
puts "Seeding " + data.size.to_s + " record" + (data.size > 1 ? "s" : "")
|
36
|
+
line = 1
|
37
|
+
data.each do |d|
|
38
|
+
line+=1
|
39
|
+
if d.size == header.size
|
40
|
+
code = "model = " + modelname + ".new\n"
|
41
|
+
for count in 0..(header.size - 1) do
|
42
|
+
unless (header[count].strip == "nil")
|
43
|
+
value = d[count]
|
44
|
+
value = "" if value.nil?
|
45
|
+
value = "'" + value.strip.gsub(/'/, "\\\\'") + "'"
|
46
|
+
if evaluations[count].nil?
|
47
|
+
assignment = value
|
48
|
+
else
|
49
|
+
assignment = evaluations[count].split("?")
|
50
|
+
assignment = assignment.join(value)
|
51
|
+
end
|
52
|
+
code += "model." + header[count].strip + "=" + assignment + "\n"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
# Add in the statics
|
56
|
+
statics.each do |s|
|
57
|
+
code += "model." + s + "\n"
|
58
|
+
end
|
59
|
+
code += "unless model.save\n"
|
60
|
+
code += "print_errors(model.errors, " + line.to_s + ")"
|
61
|
+
code += "end\n"
|
62
|
+
eval code
|
63
|
+
#puts (line - 1).to_s + "/" + data.size.to_s
|
64
|
+
else
|
65
|
+
puts "Skipping line " + line.to_s + " with mismatch in number of fields (" + d.size.to_s + ")"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
puts " Done"
|
69
|
+
end
|
70
|
+
|
71
|
+
def print_errors(errors, line)
|
72
|
+
puts "\nThere were errors on line " + line.to_s
|
73
|
+
errors.each do |e|
|
74
|
+
puts e.to_s
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module ActiveSeed
|
5
|
+
module Generators
|
6
|
+
class ExampleHtmlColorsGenerator < Rails::Generators::Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
def self.source_root
|
10
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates', 'example_html_colors')
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.next_migration_number(dirname)
|
14
|
+
if ActiveRecord::Base.timestamped_migrations
|
15
|
+
@add = @add.nil? ? 0.0 : @add + 0.1
|
16
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S").to_f + @add
|
17
|
+
else
|
18
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_files
|
23
|
+
install_dir = File.join('db', 'active_seed')
|
24
|
+
directory 'html_colors', File.join(install_dir, "data", "html_colors")
|
25
|
+
copy_file 'html_colors.yml', File.join(install_dir, 'html_colors.yml')
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_models
|
29
|
+
copy_file 'html_color.rb', File.join("app", "models", 'html_color.rb')
|
30
|
+
copy_file 'html_color_family.rb', File.join("app", "models", 'html_color_family.rb')
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_migrations
|
34
|
+
migration_template 'create_html_colors.rb', File.join("db", "migrate", "create_html_colors.rb")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module ActiveSeed
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
def self.source_root
|
7
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_files
|
11
|
+
install_dir = File.join('db', 'active_seed')
|
12
|
+
copy_file 'development.yml', File.join(install_dir, 'development.yml')
|
13
|
+
copy_file 'development.yml', File.join(install_dir, 'production.yml')
|
14
|
+
copy_file 'development.yml', File.join(install_dir, 'test.yml')
|
15
|
+
empty_directory File.join(install_dir, 'data')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Example seeding file
|
2
|
+
|
3
|
+
# Each line referes to the model object to be created and the file that contains the data
|
4
|
+
|
5
|
+
# Make sure that the files are seeded in order by using !omap
|
6
|
+
--- !omap
|
7
|
+
# This will seed User items from the file db/seed/data/production_users.csv
|
8
|
+
# - User: production_users
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreateHtmlColors < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :html_color_families do |t|
|
4
|
+
t.string :name
|
5
|
+
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
|
9
|
+
create_table :html_colors do |t|
|
10
|
+
t.string :name
|
11
|
+
t.string :hex_code
|
12
|
+
t.references :html_color_family
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.down
|
19
|
+
drop_table :html_colors
|
20
|
+
drop_table :html_color_families
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class HtmlColor < ActiveRecord::Base
|
2
|
+
belongs_to :html_color_family
|
3
|
+
|
4
|
+
def luminosity_contrast(compare)
|
5
|
+
lum1 = 0.2126 * (self.red/255 ** 2.2)
|
6
|
+
+ 0.7152 * (self.green/255 ** 2.2)
|
7
|
+
+ 0.0722 * (self.blue/255 ** 2.2)
|
8
|
+
|
9
|
+
lum2 = 0.2126 * (compare.red/255 ** 2.2)
|
10
|
+
+ 0.7152 * (compare.green/255 ** 2.2)
|
11
|
+
+ 0.0722 * (compare.blue/255 ** 2.2)
|
12
|
+
|
13
|
+
if(lum1 > lum2)
|
14
|
+
return (lum1+0.05) / (lum2+0.05);
|
15
|
+
else
|
16
|
+
return (lum2+0.05) / (lum1+0.05);
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def best_contrast(colors)
|
21
|
+
best_contrast = 0;
|
22
|
+
return_color = "000000"
|
23
|
+
colors.each do |c|
|
24
|
+
contrast = self.luminosity_contrast(c)
|
25
|
+
if contrast > best_contrast
|
26
|
+
best_contrast = contrast
|
27
|
+
return_color = c.hex_code
|
28
|
+
end
|
29
|
+
end
|
30
|
+
return_color
|
31
|
+
end
|
32
|
+
|
33
|
+
def red
|
34
|
+
(self.hex_code.to_i(16) >> 16) & 255
|
35
|
+
end
|
36
|
+
|
37
|
+
def green
|
38
|
+
(self.hex_code.to_i(16) >> 8) & 255
|
39
|
+
end
|
40
|
+
|
41
|
+
def blue
|
42
|
+
self.hex_code.to_i(16) & 255
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Example seeding file
|
2
|
+
|
3
|
+
# Each line referes to the model object to be created and the file that contains the data
|
4
|
+
|
5
|
+
# Make sure that the files are seeded in order by using !omap
|
6
|
+
--- !omap
|
7
|
+
- HtmlColorFamily: html_colors/html_color_families
|
8
|
+
- HtmlColor: html_colors/html_colors
|
@@ -0,0 +1,144 @@
|
|
1
|
+
name,hex_code,html_color_family=HtmlColorFamily.find_by_name(?)
|
2
|
+
IndianRed,CD5C5C,Red
|
3
|
+
LightCoral,F08080,Red
|
4
|
+
Salmon,FA8072,Red
|
5
|
+
DarkSalmon,E9967A,Red
|
6
|
+
LightSalmon,FFA07A,Red
|
7
|
+
Crimson,DC143C,Red
|
8
|
+
Red,FF0000,Red
|
9
|
+
FireBrick,B22222,Red
|
10
|
+
DarkRed,8B0000,Red
|
11
|
+
Pink,FFC0CB,Pink
|
12
|
+
LightPink,FFB6C1,Pink
|
13
|
+
HotPink,FF69B4,Pink
|
14
|
+
DeepPink,FF1493,Pink
|
15
|
+
MediumVioletRed,C71585,Pink
|
16
|
+
PaleVioletRed,DB7093,Pink
|
17
|
+
LightSalmon,FFA07A,Orange
|
18
|
+
Coral,FF7F50,Orange
|
19
|
+
Tomato,FF6347,Orange
|
20
|
+
OrangeRed,FF4500,Orange
|
21
|
+
DarkOrange,FF8C00,Orange
|
22
|
+
Orange,FFA500,Orange
|
23
|
+
Gold,FFD700,Yellow
|
24
|
+
Yellow,FFFF00,Yellow
|
25
|
+
LightYellow,FFFFE0,Yellow
|
26
|
+
LemonChiffon,FFFACD,Yellow
|
27
|
+
LightGoldenrodYellow,FAFAD2,Yellow
|
28
|
+
PapayaWhip,FFEFD5,Yellow
|
29
|
+
Moccasin,FFE4B5,Yellow
|
30
|
+
PeachPuff,FFDAB9,Yellow
|
31
|
+
PaleGoldenrod,EEE8AA,Yellow
|
32
|
+
Khaki,F0E68C,Yellow
|
33
|
+
DarkKhaki,BDB76B,Yellow
|
34
|
+
Lavender,E6E6FA,Purple
|
35
|
+
Thistle,D8BFD8,Purple
|
36
|
+
Plum,DDA0DD,Purple
|
37
|
+
Violet,EE82EE,Purple
|
38
|
+
Orchid,DA70D6,Purple
|
39
|
+
Fuchsia,FF00FF,Purple
|
40
|
+
Magenta,FF00FF,Purple
|
41
|
+
MediumOrchid,BA55D3,Purple
|
42
|
+
MediumPurple,9370DB,Purple
|
43
|
+
Amethyst,9966CC,Purple
|
44
|
+
BlueViolet,8A2BE2,Purple
|
45
|
+
DarkViolet,9400D3,Purple
|
46
|
+
DarkOrchid,9932CC,Purple
|
47
|
+
DarkMagenta,8B008B,Purple
|
48
|
+
Purple,800080,Purple
|
49
|
+
Indigo,4B0082,Purple
|
50
|
+
SlateBlue,6A5ACD,Purple
|
51
|
+
DarkSlateBlue,483D8B,Purple
|
52
|
+
MediumSlateBlue,7B68EE,Purple
|
53
|
+
GreenYellow,ADFF2F,Green
|
54
|
+
Chartreuse,7FFF00,Green
|
55
|
+
LawnGreen,7CFC00,Green
|
56
|
+
Lime,00FF00,Green
|
57
|
+
LimeGreen,32CD32,Green
|
58
|
+
PaleGreen,98FB98,Green
|
59
|
+
LightGreen,90EE90,Green
|
60
|
+
MediumSpringGreen,00FA9A,Green
|
61
|
+
SpringGreen,00FF7F,Green
|
62
|
+
MediumSeaGreen,3CB371,Green
|
63
|
+
SeaGreen,2E8B57,Green
|
64
|
+
ForestGreen,228B22,Green
|
65
|
+
Green,008000,Green
|
66
|
+
DarkGreen,006400,Green
|
67
|
+
YellowGreen,9ACD32,Green
|
68
|
+
OliveDrab,6B8E23,Green
|
69
|
+
Olive,808000,Green
|
70
|
+
DarkOliveGreen,556B2F,Green
|
71
|
+
MediumAquamarine,66CDAA,Green
|
72
|
+
DarkSeaGreen,8FBC8F,Green
|
73
|
+
LightSeaGreen,20B2AA,Green
|
74
|
+
DarkCyan,008B8B,Green
|
75
|
+
Teal,008080,Green
|
76
|
+
Aqua,00FFFF,Blue
|
77
|
+
Cyan,00FFFF,Blue
|
78
|
+
LightCyan,E0FFFF,Blue
|
79
|
+
PaleTurquoise,AFEEEE,Blue
|
80
|
+
Aquamarine,7FFFD4,Blue
|
81
|
+
Turquoise,40E0D0,Blue
|
82
|
+
MediumTurquoise,48D1CC,Blue
|
83
|
+
DarkTurquoise,00CED1,Blue
|
84
|
+
CadetBlue,5F9EA0,Blue
|
85
|
+
SteelBlue,4682B4,Blue
|
86
|
+
LightSteelBlue,B0C4DE,Blue
|
87
|
+
PowderBlue,B0E0E6,Blue
|
88
|
+
LightBlue,ADD8E6,Blue
|
89
|
+
SkyBlue,87CEEB,Blue
|
90
|
+
LightSkyBlue,87CEFA,Blue
|
91
|
+
DeepSkyBlue,00BFFF,Blue
|
92
|
+
DodgerBlue,1E90FF,Blue
|
93
|
+
CornflowerBlue,6495ED,Blue
|
94
|
+
MediumSlateBlue,7B68EE,Blue
|
95
|
+
RoyalBlue,4169E1,Blue
|
96
|
+
Blue,0000FF,Blue
|
97
|
+
MediumBlue,0000CD,Blue
|
98
|
+
DarkBlue,00008B,Blue
|
99
|
+
Navy,000080,Blue
|
100
|
+
MidnightBlue,191970,Blue
|
101
|
+
Cornsilk,FFF8DC,Brown
|
102
|
+
BlanchedAlmond,FFEBCD,Brown
|
103
|
+
Bisque,FFE4C4,Brown
|
104
|
+
NavajoWhite,FFDEAD,Brown
|
105
|
+
Wheat,F5DEB3,Brown
|
106
|
+
BurlyWood,DEB887,Brown
|
107
|
+
Tan,D2B48C,Brown
|
108
|
+
RosyBrown,BC8F8F,Brown
|
109
|
+
SandyBrown,F4A460,Brown
|
110
|
+
Goldenrod,DAA520,Brown
|
111
|
+
DarkGoldenrod,B8860B,Brown
|
112
|
+
Peru,CD853F,Brown
|
113
|
+
Chocolate,D2691E,Brown
|
114
|
+
SaddleBrown,8B4513,Brown
|
115
|
+
Sienna,A0522D,Brown
|
116
|
+
Brown,A52A2A,Brown
|
117
|
+
Maroon,800000,Brown
|
118
|
+
White,FFFFFF,White
|
119
|
+
Snow,FFFAFA,White
|
120
|
+
Honeydew,F0FFF0,White
|
121
|
+
MintCream,F5FFFA,White
|
122
|
+
Azure,F0FFFF,White
|
123
|
+
AliceBlue,F0F8FF,White
|
124
|
+
GhostWhite,F8F8FF,White
|
125
|
+
WhiteSmoke,F5F5F5,White
|
126
|
+
Seashell,FFF5EE,White
|
127
|
+
Beige,F5F5DC,White
|
128
|
+
OldLace,FDF5E6,White
|
129
|
+
FloralWhite,FFFAF0,White
|
130
|
+
Ivory,FFFFF0,White
|
131
|
+
AntiqueWhite,FAEBD7,White
|
132
|
+
Linen,FAF0E6,White
|
133
|
+
LavenderBlush,FFF0F5,White
|
134
|
+
MistyRose,FFE4E1,White
|
135
|
+
Gainsboro,DCDCDC,Gray
|
136
|
+
LightGrey,D3D3D3,Gray
|
137
|
+
Silver,C0C0C0,Gray
|
138
|
+
DarkGray,A9A9A9,Gray
|
139
|
+
Gray,808080,Gray
|
140
|
+
DimGray,696969,Gray
|
141
|
+
LightSlateGray,778899,Gray
|
142
|
+
SlateGray,708090,Gray
|
143
|
+
DarkSlateGray,2F4F4F,Gray
|
144
|
+
Black,000000,Gray
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc "Load seed files (from db/seeds) into the current environment's database."
|
3
|
+
task :active_seed => :environment do
|
4
|
+
require "active_seed/seed_csv"
|
5
|
+
set = ENV["set"]
|
6
|
+
set = ::Rails.env unless !set.nil?
|
7
|
+
set_file = File.join(::Rails.root.to_s, "db", "active_seed", set + ".yml")
|
8
|
+
if !File.exists?(set_file)
|
9
|
+
puts "Set file doesn't exist: " << set_file
|
10
|
+
return
|
11
|
+
end
|
12
|
+
puts "Seeding from set '" + set + "'"
|
13
|
+
fixture_list = YAML::load_file(set_file)
|
14
|
+
fixture_list.each do |model, sf|
|
15
|
+
seed_file = File.join(::Rails.root.to_s, "db", "active_seed", "data", sf + ".csv")
|
16
|
+
if !File.exists?(seed_file)
|
17
|
+
puts "Seed file doesn't exist: " << seed_file
|
18
|
+
else
|
19
|
+
puts "Seeding '" + seed_file + "'..."
|
20
|
+
seed_csv(model, seed_file)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_seed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- David Monagle
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-12 00:00:00 +10:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bundler
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 23
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 0
|
33
|
+
version: 1.0.0
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
requirement: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: jeweler
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 7
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 5
|
48
|
+
- 2
|
49
|
+
version: 1.5.2
|
50
|
+
prerelease: false
|
51
|
+
type: :development
|
52
|
+
requirement: *id002
|
53
|
+
description: ActiveSeed Gives the ability to seed data by inserting it via activerecord. Also allows you to manage sets of data and seed based on the current environment.
|
54
|
+
email: david.monagle@intrica.com.au
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README.rdoc
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- README.rdoc
|
64
|
+
- Rakefile
|
65
|
+
- VERSION
|
66
|
+
- active_seed.gemspec
|
67
|
+
- lib/active_seed.rb
|
68
|
+
- lib/active_seed/engine.rb
|
69
|
+
- lib/active_seed/seed_csv.rb
|
70
|
+
- lib/generators/active_seed/example_html_colors_generator.rb
|
71
|
+
- lib/generators/active_seed/install_generator.rb
|
72
|
+
- lib/generators/active_seed/templates/development.yml
|
73
|
+
- lib/generators/active_seed/templates/example_html_colors/create_html_colors.rb
|
74
|
+
- lib/generators/active_seed/templates/example_html_colors/html_color.rb
|
75
|
+
- lib/generators/active_seed/templates/example_html_colors/html_color_family.rb
|
76
|
+
- lib/generators/active_seed/templates/example_html_colors/html_colors.yml
|
77
|
+
- lib/generators/active_seed/templates/example_html_colors/html_colors/html_color_families.csv
|
78
|
+
- lib/generators/active_seed/templates/example_html_colors/html_colors/html_colors.csv
|
79
|
+
- lib/tasks/active_seed_tasks.rake
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/intrica/active_seed
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
requirements: []
|
108
|
+
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.5.3
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: Seeds data using activerecord.
|
114
|
+
test_files: []
|
115
|
+
|