seed_me_seymour 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 542497a0c99bb27e73dd4991e7f53c252f6efdd6
4
+ data.tar.gz: c8960f1aa383e4625b5b94f83716c3c70388c970
5
+ SHA512:
6
+ metadata.gz: 835e2545f641cff69dc6feb1417c2d8d22f6360f9ea31dd52e2e5143f261ee0f45212f46c0fd538103b2041038213724917c1b9ea6ae4a2b039eaa2b7b8f6c5a
7
+ data.tar.gz: aafea9dc196da89b3279957c4aac84ebb810b7300f678b0dbfed2715fb541b67d74f076fa1ddd0932be8769eebbd941013d727868bbb67bd11b189667099f013
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Brandon Manuel Garibaldi
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # seed_me_seymour
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
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'seed_me_seymour'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install seed_me_seymour
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Tony/seed_me_seymour.
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require_relative 'config/application'
2
+
3
+ Rails.application.load_tasks
@@ -0,0 +1,145 @@
1
+ require "seed_me_seymour/version"
2
+ require 'active_support/inflector'
3
+ require 'rails/engine'
4
+
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
141
+ end
142
+
143
+
144
+ # File.open(fi_le, 'a') { |file|
145
+ # file.puts "User.destroy_all"
@@ -0,0 +1,3 @@
1
+ module SeedMeSeymour
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+
3
+
4
+
5
+ lib = File.expand_path('../lib', __FILE__)
6
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
+ require 'seed_me_seymour/version'
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = "seed_me_seymour"
11
+ spec.version = '0.1.1'
12
+ spec.authors = ["Tony S.", "Brandon G." ]
13
+ spec.email = ["saric.tony@gmail.com\n", "bmg.oak@gmail.com\n"]
14
+ spec.licenses = ['MIT']
15
+ spec.summary = %q{This gem will analyze your current database and make a seed file with pre-populated seed information using faker}
16
+ spec.homepage = "https://github.com/antoniosaric/seed_me_seymour"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ # if spec.respond_to?(:metadata)
21
+ # spec.metadata['allowed_push_host'] = "https://rubygems.org"
22
+ # else
23
+ # raise "RubyGems 2.0 or newer is required to protect against " \
24
+ # "public gem pushes."
25
+ # end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.14"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ end
@@ -0,0 +1,145 @@
1
+ require_relative '../../config/application'
2
+
3
+ # Rails.application.load_tasks
4
+
5
+
6
+
7
+ namespace :seedme do
8
+ desc "seedme creates a seeds file based on an application's models and those model's column type "
9
+ task :go => :environment do
10
+ require 'active_support/inflector'
11
+ require 'rails/engine'
12
+
13
+ #determine the path to file
14
+ path = File.expand_path('../', __FILE__)
15
+ fil_e = File.join(path, '../../db/schema.rb')
16
+ fi_le = File.join(path, '../../db/seeds.rb')
17
+ s = File.open(fil_e)
18
+ #whipe everything from seed file
19
+ File.open(fi_le, 'w') {|file| file.truncate(0) }
20
+
21
+ # set faker code
22
+ boolean = "Faker::Boolean.boolean"
23
+ date = "Faker::Date.forward(23)"
24
+ decimal = "Faker::Number.decimal(2)"
25
+ float = "Faker::Number.decimal(2)"
26
+ integer = "Faker::Number.between(1, 10)"
27
+ #indx referes to references. User references to get index into schema.rb
28
+ indx = "Faker::Number.between(1, 10)"
29
+ string = "Faker::StarWars.character"
30
+ text = "Faker::Lorem.sentences(4)"
31
+ time = "Faker::Time.forward(23, :morning)"
32
+
33
+ #contigent email and password
34
+ email = "Faker::Internet.email"
35
+ password = "'password'"
36
+
37
+ #begin parse though each line of schema.rb
38
+ s.each do |line|
39
+ class_singular = ""
40
+ created_text = ""
41
+
42
+ #if line is a model class
43
+ if line.match(/(?<=create_table\s").*?(?=")/)
44
+ #set model class, singularize, and capitalize
45
+ classes = line.match(/(?<=create_table\s").*?(?=")/)[0]
46
+ class_singular = classes.singularize.capitalize
47
+ #appends to document
48
+ File.open(fi_le, 'a') { |file|
49
+ file.puts "10.times do \n " +
50
+ class_singular + ".create!({"
51
+ }
52
+
53
+ #if line has a t. and is not a date time
54
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/) && line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] != "datetime"
55
+ #set column name
56
+ column = line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1]
57
+ #if line is a string
58
+ if line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "string"
59
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "string"
60
+ type = string
61
+ #if column is an email
62
+ if line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1] == "email"
63
+ column = "email"
64
+ type = email
65
+ #if column is a password
66
+ elsif line.match(/\st.[a-z]{1,13}.*(?<=")(.*?)"/)[1] == "password"
67
+ column = "password"
68
+ type = password
69
+
70
+ end
71
+ #append to file
72
+ File.open(fi_le, 'a') { |file|
73
+ file.puts column + ": " + type + ", "
74
+ }
75
+ #being looking at the active record types inside individual table
76
+ #if type is a text
77
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "text"
78
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
79
+ type = text
80
+ File.open(fi_le, 'a') { |file|
81
+ file.puts column + ": " + type + ", "
82
+ }
83
+ #if type is a boolean
84
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "boolean"
85
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
86
+ type = boolean
87
+ File.open(fi_le, 'a') { |file|
88
+ file.puts column + ": " + type + ", "
89
+ }
90
+ #if type is a date
91
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "date"
92
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
93
+ type = date
94
+ File.open(fi_le, 'a') { |file|
95
+ file.puts column + ": " + type + ", "
96
+ }
97
+ #if type is a decimal
98
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "decimal"
99
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
100
+ type = decimal
101
+ File.open(fi_le, 'a') { |file|
102
+ file.puts column + ": " + type + ", "
103
+ }
104
+ #if type is a float
105
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "float"
106
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
107
+ type = float
108
+ File.open(fi_le, 'a') { |file|
109
+ file.puts column + ": " + type + ", "
110
+ }
111
+ #if type is an integer
112
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "integer"
113
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
114
+ type = integer
115
+ File.open(fi_le, 'a') { |file|
116
+ file.puts column + ": " + type + ", "
117
+ }
118
+ #if type is a references
119
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "index"
120
+ column = line.match(/\s[t.index].*(?<=")(?<=\s\[")(([a-z]+.\id))/)[1]
121
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
122
+ type = indx
123
+ File.open(fi_le, 'a') { |file|
124
+ file.puts column + ": " + type + ", "
125
+ }
126
+ #if type is a time
127
+ elsif line.match(/((?<=\s\st.)[a-z]{1,13})/)[0] == "time"
128
+ type = line.match(/((?<=\s\st.)[a-z]{1,13})/)[0]
129
+ type = time
130
+ File.open(fi_le, 'a') { |file|
131
+ file.puts column + ": " + type + ", "
132
+ }
133
+
134
+ end
135
+ #locates the end and appends the correct end to the seed file
136
+ elsif line.match(/\s\s(end)/)
137
+ File.open(fi_le, 'a') { |file|
138
+ file.puts "})
139
+ end
140
+ \n"
141
+ }
142
+
143
+ end
144
+ end
145
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seed_me_seymour
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Tony S.
8
+ - Brandon G.
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2017-04-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.14'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.14'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ description:
43
+ email:
44
+ - 'saric.tony@gmail.com
45
+
46
+ '
47
+ - 'bmg.oak@gmail.com
48
+
49
+ '
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - ".gitignore"
55
+ - LICENSE
56
+ - README.md
57
+ - Rakefile
58
+ - lib/seed_me_seymour.rb
59
+ - lib/seed_me_seymour/version.rb
60
+ - seed_me_seymour.gemspec
61
+ - tasks/seed_me_seymour.rake
62
+ homepage: https://github.com/antoniosaric/seed_me_seymour
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.5.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: This gem will analyze your current database and make a seed file with pre-populated
86
+ seed information using faker
87
+ test_files: []