seed_me_seymour 0.1.9 → 0.1.10

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
  SHA1:
3
- metadata.gz: 8df3f105ff26b2b64e82274489ad49fc953205a1
4
- data.tar.gz: 22c20503d40a7f8977afd00a4786cf22e6371cd1
3
+ metadata.gz: cff3cbcb82d394e379f3f380e31ee79c1c24fe1f
4
+ data.tar.gz: ecad1cca0296ee086ae8f0dfe1b6343ad91f9d27
5
5
  SHA512:
6
- metadata.gz: d3a371b5823929b7077208aae7c0c741a04e5ebace52fa492537947abfe6f759712cd77bce56f08196429fc4ca5e890fd3ef580fde40215bed6e48e552682997
7
- data.tar.gz: a452fa6a9b7a74d63e076ad3c10385e93096254b902810e2f9734feb0988f223ff472b956492cbd083ddc5d5a46535ef8d445d229ec662d95e60fb6262cb4081
6
+ metadata.gz: 9a8edc7b7ce028ba234b1dbb6bb0ac0b3494873a34541df4dc2163b89f6059dd02e825f18971d1d824e4c9019683f99685dcc2132ec172e4dddd73ea193e19e1
7
+ data.tar.gz: 3a67eafa83f665ba6051f8452e080b3dd77a68b39b057f52375372afcaa6c4fedaeb5db01c2dd7a9348c2d4c2dc1121b14f620befc0030c7300266211b748e1f
@@ -1,3 +1,3 @@
1
1
  module SeedMeSeymour
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require "seed_me_seymour/version"
2
2
  require 'active_support/inflector'
3
3
  require 'rails/engine'
4
- Rails.application.load_tasks
5
- # require_relative '../tasks/seed_me_seymour'
4
+ # Rails.application.load_tasks
5
+ require_relative '../tasks/seed_me_seymour.rake'
6
6
 
7
7
 
8
8
  module SeedMeSeymour
@@ -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.9'
11
+ spec.version = '0.1.10'
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']
@@ -0,0 +1,141 @@
1
+ require_relative '../../config/application'
2
+ # Rails.application.load_tasks
3
+ namespace :seedme do
4
+ desc "seedme creates a seeds file based on an application's models and those model's column type "
5
+ task :go => :environment do
6
+ require 'active_support/inflector'
7
+ require 'rails/engine'
8
+
9
+ #determine the path to file
10
+ path = File.expand_path('../', __FILE__)
11
+ fil_e = File.join(path, '../../db/schema.rb')
12
+ fi_le = File.join(path, '../../db/seeds.rb')
13
+ s = File.open(fil_e)
14
+ #whipe everything from seed file
15
+ File.open(fi_le, 'w') {|file| file.truncate(0) }
16
+
17
+ # set faker code
18
+ boolean = "Faker::Boolean.boolean"
19
+ date = "Faker::Date.forward(23)"
20
+ decimal = "Faker::Number.decimal(2)"
21
+ float = "Faker::Number.decimal(2)"
22
+ integer = "Faker::Number.between(1, 10)"
23
+ #indx referes to references. User references to get index into schema.rb
24
+ indx = "Faker::Number.between(1, 10)"
25
+ string = "Faker::StarWars.character"
26
+ text = "Faker::Lorem.sentences(4)"
27
+ time = "Faker::Time.forward(23, :morning)"
28
+
29
+ #contigent email and password
30
+ email = "Faker::Internet.email"
31
+ password = "'password'"
32
+
33
+ #begin parse though each line of schema.rb
34
+ s.each do |line|
35
+ class_singular = ""
36
+ created_text = ""
37
+
38
+ #if line is a model class
39
+ if line.match(/(?<=create_table\s").*?(?=")/)
40
+ #set model class, singularize, and capitalize
41
+ classes = line.match(/(?<=create_table\s").*?(?=")/)[0]
42
+ class_singular = classes.singularize.capitalize
43
+ #appends to document
44
+ File.open(fi_le, 'a') { |file|
45
+ file.puts "10.times do \n " +
46
+ class_singular + ".create!({"
47
+ }
48
+
49
+ #if line has a t. and is not a date time
50
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/) && line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] != "datetime"
51
+ #set column name
52
+ column = line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1]
53
+ #if line is a string
54
+ if line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "string"
55
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "string"
56
+ type = string
57
+ #if column is an email
58
+ if line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1] == "email"
59
+ column = "email"
60
+ type = email
61
+ #if column is a password
62
+ elsif line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1] == "password"
63
+ column = "password"
64
+ type = password
65
+
66
+ end
67
+ #append to file
68
+ File.open(fi_le, 'a') { |file|
69
+ file.puts column + ": " + type + ", "
70
+ }
71
+ #being looking at the active record types inside individual table
72
+ #if type is a text
73
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "text"
74
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
75
+ type = text
76
+ File.open(fi_le, 'a') { |file|
77
+ file.puts column + ": " + type + ", "
78
+ }
79
+ #if type is a boolean
80
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "boolean"
81
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
82
+ type = boolean
83
+ File.open(fi_le, 'a') { |file|
84
+ file.puts column + ": " + type + ", "
85
+ }
86
+ #if type is a date
87
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "date"
88
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
89
+ type = date
90
+ File.open(fi_le, 'a') { |file|
91
+ file.puts column + ": " + type + ", "
92
+ }
93
+ #if type is a decimal
94
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "decimal"
95
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
96
+ type = decimal
97
+ File.open(fi_le, 'a') { |file|
98
+ file.puts column + ": " + type + ", "
99
+ }
100
+ #if type is a float
101
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "float"
102
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
103
+ type = float
104
+ File.open(fi_le, 'a') { |file|
105
+ file.puts column + ": " + type + ", "
106
+ }
107
+ #if type is an integer
108
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "integer"
109
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
110
+ type = integer
111
+ File.open(fi_le, 'a') { |file|
112
+ file.puts column + ": " + type + ", "
113
+ }
114
+ #if type is a references
115
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "index"
116
+ column = line.match(/\s[t.index].*(?<=")(?<=\s\[")(([a-z]+.\id))/)[1]
117
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
118
+ type = indx
119
+ File.open(fi_le, 'a') { |file|
120
+ file.puts column + ": " + type + ", "
121
+ }
122
+ #if type is a time
123
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "time"
124
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
125
+ type = time
126
+ File.open(fi_le, 'a') { |file|
127
+ file.puts column + ": " + type + ", "
128
+ }
129
+
130
+ end
131
+ #locates the end and appends the correct end to the seed file
132
+ elsif line.match(/\s\s(end)/)
133
+ File.open(fi_le, 'a') { |file|
134
+ file.puts "})
135
+ end
136
+ \n"
137
+ }
138
+
139
+ end
140
+ end
141
+ end
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.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony S.
@@ -58,6 +58,7 @@ files:
58
58
  - lib/seed_me_seymour.rb
59
59
  - lib/seed_me_seymour/version.rb
60
60
  - seed_me_seymour.gemspec
61
+ - tasks/_seed_me_seymour.OLDrake
61
62
  - tasks/seed_me_seymour.rake
62
63
  homepage: https://github.com/antoniosaric/seed_me_seymour
63
64
  licenses: