seed_me_seymour 0.1.4 → 0.1.5
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 +4 -4
- data/README.md +21 -2
- data/lib/seed_me_seymour/version.rb +1 -1
- data/lib/seed_me_seymour.rb +5 -142
- data/seed_me_seymour.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a9e14f770cfb7de62a16560b1e4d3af14ce38f6
|
|
4
|
+
data.tar.gz: d1ab9ba2cfccda6e78925e3852e2265b98bfd1d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f216c0f701091464911c2e68f17e780f6c16996196066420e56d511b6069c9109aea6e05ba676888731927f4107d88fe645b0577fd377d42f29af6e5c8fe7fc
|
|
7
|
+
data.tar.gz: 962ff2c483bfe3862a6c8a621f575b27d2ec6c17d02bfd51420477344682d7862f9de19168249c1009ecd7c30bf7b9249a910d46c448216264021d4a858a843c
|
data/README.md
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
# seed_me_seymour
|
|
2
2
|
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/seed_me_seymour`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
2017/04/26 - working the kinks out
|
|
5
|
+
|
|
6
|
+
Hi all - apologies to anyone that has downloaded our gem while this message is still up. This is our first gem and it isn't behaving the same as a gem as it did
|
|
7
|
+
while it was just local code. So please bear with us and check back soon for updates letting you know all is working as expected! Thanks!
|
|
8
|
+
|
|
9
|
+
SeedMeSeymour will analyze your schema and create a basic seed file based on its tables and column types. We expect future releases to work with more complicated Activerecord setups
|
|
10
|
+
by analyzing models and associations, creating a seed file that addresses unconventional name associations, like:
|
|
11
|
+
|
|
12
|
+
class Employee < ApplicationRecord
|
|
13
|
+
|
|
14
|
+
has_many :subordinates, class_name: "Employee",
|
|
15
|
+
|
|
16
|
+
foreign_key: "manager_id"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
belongs_to :manager, class_name: "Employee"
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
|
|
7
26
|
## Installation
|
|
8
27
|
|
data/lib/seed_me_seymour.rb
CHANGED
|
@@ -1,151 +1,14 @@
|
|
|
1
1
|
require "seed_me_seymour/version"
|
|
2
2
|
require 'active_support/inflector'
|
|
3
3
|
require 'rails/engine'
|
|
4
|
+
require_relative '../tasks/seed_me_seymour'
|
|
4
5
|
|
|
5
|
-
module SeedMeSeymour
|
|
6
|
-
# puts "The code for the SMS's main functionality is commented below. It is current as of 2017/24/04 and is meant to be
|
|
7
|
-
# initiated from the rake task - lib/tasks/seed_me_seymour.rake. This gem is in developement, but works on a basic level based on column types
|
|
8
|
-
# in your schema. Future releases will create seed data based on basic fields/tables and more complicated associations."
|
|
9
|
-
namespace :seedme do
|
|
10
|
-
desc "seedme creates a seeds file based on an application's models and those model's column type "
|
|
11
|
-
task :go => :environment do
|
|
12
|
-
# require 'active_support/inflector'
|
|
13
|
-
# require 'rails/engine'
|
|
14
|
-
|
|
15
|
-
#determine the path to file
|
|
16
|
-
path = File.expand_path('../', __FILE__)
|
|
17
|
-
fil_e = File.join(path, '../../db/schema.rb')
|
|
18
|
-
fi_le = File.join(path, '../../db/seeds.rb')
|
|
19
|
-
s = File.open(fil_e)
|
|
20
|
-
#whipe everything from seed file
|
|
21
|
-
File.open(fi_le, 'w') {|file| file.truncate(0) }
|
|
22
|
-
|
|
23
|
-
# set faker code
|
|
24
|
-
boolean = "Faker::Boolean.boolean"
|
|
25
|
-
date = "Faker::Date.forward(23)"
|
|
26
|
-
decimal = "Faker::Number.decimal(2)"
|
|
27
|
-
float = "Faker::Number.decimal(2)"
|
|
28
|
-
integer = "Faker::Number.between(1, 10)"
|
|
29
|
-
#indx referes to references. User references to get index into schema.rb
|
|
30
|
-
indx = "Faker::Number.between(1, 10)"
|
|
31
|
-
string = "Faker::StarWars.character"
|
|
32
|
-
text = "Faker::Lorem.sentences(4)"
|
|
33
|
-
time = "Faker::Time.forward(23, :morning)"
|
|
34
|
-
|
|
35
|
-
#contigent email and password
|
|
36
|
-
email = "Faker::Internet.email"
|
|
37
|
-
password = "'password'"
|
|
38
|
-
|
|
39
|
-
#begin parse though each line of schema.rb
|
|
40
|
-
s.each do |line|
|
|
41
|
-
class_singular = ""
|
|
42
|
-
created_text = ""
|
|
43
6
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class_singular = classes.singularize.capitalize
|
|
49
|
-
#appends to document
|
|
50
|
-
File.open(fi_le, 'a') { |file|
|
|
51
|
-
file.puts "10.times do \n " +
|
|
52
|
-
class_singular + ".create!({"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
#if line has a t. and is not a date time
|
|
56
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/) && line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] != "datetime"
|
|
57
|
-
#set column name
|
|
58
|
-
column = line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1]
|
|
59
|
-
#if line is a string
|
|
60
|
-
if line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "string"
|
|
61
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "string"
|
|
62
|
-
type = string
|
|
63
|
-
#if column is an email
|
|
64
|
-
if line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1] == "email"
|
|
65
|
-
column = "email"
|
|
66
|
-
type = email
|
|
67
|
-
#if column is a password
|
|
68
|
-
elsif line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1] == "password"
|
|
69
|
-
column = "password"
|
|
70
|
-
type = password
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
#append to file
|
|
74
|
-
File.open(fi_le, 'a') { |file|
|
|
75
|
-
file.puts column + ": " + type + ", "
|
|
76
|
-
}
|
|
77
|
-
#being looking at the active record types inside individual table
|
|
78
|
-
#if type is a text
|
|
79
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "text"
|
|
80
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
81
|
-
type = text
|
|
82
|
-
File.open(fi_le, 'a') { |file|
|
|
83
|
-
file.puts column + ": " + type + ", "
|
|
84
|
-
}
|
|
85
|
-
#if type is a boolean
|
|
86
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "boolean"
|
|
87
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
88
|
-
type = boolean
|
|
89
|
-
File.open(fi_le, 'a') { |file|
|
|
90
|
-
file.puts column + ": " + type + ", "
|
|
91
|
-
}
|
|
92
|
-
#if type is a date
|
|
93
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "date"
|
|
94
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
95
|
-
type = date
|
|
96
|
-
File.open(fi_le, 'a') { |file|
|
|
97
|
-
file.puts column + ": " + type + ", "
|
|
98
|
-
}
|
|
99
|
-
#if type is a decimal
|
|
100
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "decimal"
|
|
101
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
102
|
-
type = decimal
|
|
103
|
-
File.open(fi_le, 'a') { |file|
|
|
104
|
-
file.puts column + ": " + type + ", "
|
|
105
|
-
}
|
|
106
|
-
#if type is a float
|
|
107
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "float"
|
|
108
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
109
|
-
type = float
|
|
110
|
-
File.open(fi_le, 'a') { |file|
|
|
111
|
-
file.puts column + ": " + type + ", "
|
|
112
|
-
}
|
|
113
|
-
#if type is an integer
|
|
114
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "integer"
|
|
115
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
116
|
-
type = integer
|
|
117
|
-
File.open(fi_le, 'a') { |file|
|
|
118
|
-
file.puts column + ": " + type + ", "
|
|
119
|
-
}
|
|
120
|
-
#if type is a references
|
|
121
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "index"
|
|
122
|
-
column = line.match(/\s[t.index].*(?<=")(?<=\s\[")(([a-z]+.\id))/)[1]
|
|
123
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
124
|
-
type = indx
|
|
125
|
-
File.open(fi_le, 'a') { |file|
|
|
126
|
-
file.puts column + ": " + type + ", "
|
|
127
|
-
}
|
|
128
|
-
#if type is a time
|
|
129
|
-
elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "time"
|
|
130
|
-
type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
|
|
131
|
-
type = time
|
|
132
|
-
File.open(fi_le, 'a') { |file|
|
|
133
|
-
file.puts column + ": " + type + ", "
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
end
|
|
137
|
-
#locates the end and appends the correct end to the seed file
|
|
138
|
-
elsif line.match(/\s\s(end)/)
|
|
139
|
-
File.open(fi_le, 'a') { |file|
|
|
140
|
-
file.puts "})
|
|
141
|
-
end
|
|
142
|
-
\n"
|
|
143
|
-
}
|
|
7
|
+
module SeedMeSeymour
|
|
8
|
+
puts "The code for the SMS's main functionality is commented below. It is current as of 2017/24/04 and is meant to be
|
|
9
|
+
initiated from the rake task - lib/tasks/seed_me_seymour.rake. This gem is in developement, but works on a basic level based on column types
|
|
10
|
+
in your schema. Future releases will create seed data based on basic fields/tables and more complicated associations."
|
|
144
11
|
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
12
|
end
|
|
150
13
|
|
|
151
14
|
|
data/seed_me_seymour.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ require 'seed_me_seymour/version'
|
|
|
8
8
|
|
|
9
9
|
Gem::Specification.new do |spec|
|
|
10
10
|
spec.name = "seed_me_seymour"
|
|
11
|
-
spec.version = '0.1.
|
|
11
|
+
spec.version = '0.1.5'
|
|
12
12
|
spec.authors = ["Tony S.", "Brandon G." ]
|
|
13
13
|
spec.email = ["saric.tony@gmail.com\n", "bmg.oak@gmail.com\n"]
|
|
14
14
|
spec.licenses = ['MIT']
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: seed_me_seymour
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tony S.
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-04-
|
|
12
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|