seed_me_seymour 0.1.2 → 0.1.3

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: 49c51f597df137fc9756e22f0417477c9dcc27f2
4
- data.tar.gz: df8fc4854cdd9240343a365e6648ca6d0ed10ad5
3
+ metadata.gz: 7ed6fce6a415a226512ba3b5480f97213f1e6e6f
4
+ data.tar.gz: 2ed99771f95b34e2c3e3adda1a6a69415bc47eae
5
5
  SHA512:
6
- metadata.gz: 7d3de2e34e7691e0d81e76f004601e2b9d1842133c6b0daf9b4558ff28064b6575d72b90f5f66ef8500f1bca11738af045cc21b8c51a2a2c193286c170aae062
7
- data.tar.gz: ff7f12b69fb56b6028132de91a9148713a054e3c2d13d6119d8b8dd3a4cd9865ea4bcc381df6e2d1caa7fd63c8b605ac2236625332444c5a5e04ca74266ed633
6
+ metadata.gz: d4abda7af090b275a08aa4e4f253dc13d54d44685771b60be0f8c2a158beb9111db7baa0fd712474ab4ef22fe3cd93cf68904a60a52f0bb93012c9aad02d5424
7
+ data.tar.gz: 40866f6615251509605be3a2d821a784716329787b5d46355db668af537bad6bdbcb1215c95d991caeee84a9a3ea75207fe8a05d750019036bcf38200a236b35
@@ -1,3 +1,3 @@
1
1
  module SeedMeSeymour
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -3,141 +3,148 @@ require 'active_support/inflector'
3
3
  require 'rails/engine'
4
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
- # #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
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
+
44
+ #if line is a model class
45
+ if line.match(/(?<=create_table\s").*?(?=")/)
46
+ #set model class, singularize, and capitalize
47
+ classes = line.match(/(?<=create_table\s").*?(?=")/)[0]
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
+ }
144
+
145
+ end
146
+ end
147
+ end
141
148
  end
142
149
 
143
150
 
@@ -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.2'
11
+ spec.version = '0.1.3'
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony S.