spec_fill 0.1.1 → 0.1.2
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/bin/names.txt +33 -0
- data/lib/spec_fill.rb +65 -51
- data/lib/spec_fill/cli.rb +45 -12
- data/lib/spec_fill/version.rb +1 -1
- data/spec_fill-0.1.1.gem +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b0eda93bcae2732cf93da79b3373dbe0b64753f443b42591435e7bb378cfb8e
|
4
|
+
data.tar.gz: 1e3ac451aab22876defe5a6980f77b43962dee06b6a3ba0510dee64a8ee63363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3574d8729d618a76a4bba1bbd36b474aa89462f80eab48f14c5d2f1612c7d2c1a12df62c85d63e7bdb1a7f0a640f10f47b095a6afc67e2edd95fb936044e4d61
|
7
|
+
data.tar.gz: dc3eff9938f82d6d98ac273f71c2d8ab874738af82f2d608920b51c0bfcf7d7713c912d892da6b67dff88b196cc457be0b50a2030577b7d7df818baee182e29e
|
data/bin/names.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
city, Address
|
2
|
+
street_name, Address
|
3
|
+
street_address, Address
|
4
|
+
secondary_address, Address
|
5
|
+
building_number, Address
|
6
|
+
community, Address
|
7
|
+
zip_code, Address
|
8
|
+
zip, Address
|
9
|
+
postcode, Address
|
10
|
+
time_zone, Address
|
11
|
+
street_suffix, Address
|
12
|
+
city_suffix, Address
|
13
|
+
city_prefix, Address
|
14
|
+
state, Address
|
15
|
+
state_abbr, Address
|
16
|
+
country, Address
|
17
|
+
country_code, Address
|
18
|
+
latitude, Address
|
19
|
+
longitude, Address
|
20
|
+
full_address, Address
|
21
|
+
god, Ancient
|
22
|
+
primordial, Ancient
|
23
|
+
titan, Ancient
|
24
|
+
hero, Ancient
|
25
|
+
brand,Beer
|
26
|
+
name,Beer
|
27
|
+
style,Beer
|
28
|
+
hop,Beer
|
29
|
+
yeast,Beer
|
30
|
+
malts,Beer
|
31
|
+
ibu,Beer
|
32
|
+
alcohol,Beer
|
33
|
+
blg,Beer
|
data/lib/spec_fill.rb
CHANGED
@@ -1,51 +1,65 @@
|
|
1
|
-
require "spec_fill/version"
|
2
|
-
|
3
|
-
module SpecFill
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
# require "spec_fill/version"
|
2
|
+
#
|
3
|
+
# module SpecFill
|
4
|
+
# class Error < StandardError; end
|
5
|
+
# def fill_factory(column, factory_name='')
|
6
|
+
#
|
7
|
+
# class_name = column.split('_').map(&:capitalize).join
|
8
|
+
# line_array = []
|
9
|
+
# next_line = false
|
10
|
+
#
|
11
|
+
# File.foreach('db/schema.rb') do |line|
|
12
|
+
# if line.chomp.empty? && next_line == true
|
13
|
+
# break
|
14
|
+
# end
|
15
|
+
# if next_line
|
16
|
+
# line_array << line
|
17
|
+
# end
|
18
|
+
# if line.include?(column)
|
19
|
+
# line_array << line unless line.include?('add_index')
|
20
|
+
# next_line = true
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# File.open("spec/factories/#{column}.rb", 'w') do |file|
|
25
|
+
# unless factory_name.empty?
|
26
|
+
# file.print("FactoryGirl.define do\n\tfactory :#{factory_name}, class: #{class_name} do\n")
|
27
|
+
# else
|
28
|
+
# file.print("FactoryGirl.define do\n\tfactory :#{column} do\n")
|
29
|
+
# end
|
30
|
+
# if line_array[0].include?('primary_key')
|
31
|
+
# file.print("\t\t# It looks like your primary key isn't the record ID.\n")
|
32
|
+
# file.print("\t\t# Don't forget to pass in your primary key when you're creating\n")
|
33
|
+
# file.print("\t\t# the test object (e.g., create(:object, primary_key: column_name)).\n")
|
34
|
+
# end
|
35
|
+
# line_array.shift
|
36
|
+
# get_attributes(line_array).each do |attr|
|
37
|
+
# file.print "\t\t#{attr}\n"
|
38
|
+
# end
|
39
|
+
# file.print("\tend\n")
|
40
|
+
# file.print('end')
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# def get_attributes(ary)
|
45
|
+
# stripped_ary = []
|
46
|
+
# ary.each do |char|
|
47
|
+
# stripped_ary << char.scan(/"([^"]*)"/)
|
48
|
+
# end
|
49
|
+
# stripped_ary.flatten
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# def check_spec(*lorem)
|
53
|
+
# File.foreach('db/beer.txt') do |line|
|
54
|
+
# if line.to_s.include?('ibu')
|
55
|
+
# File.open("db/beer_terms.rb", 'w') do |file|
|
56
|
+
# file.print line
|
57
|
+
# end
|
58
|
+
# else
|
59
|
+
# File.open("db/beer_terms.rb", 'w') do |file|
|
60
|
+
# file.puts "DID NOT FIND #{line}"
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# end
|
data/lib/spec_fill/cli.rb
CHANGED
@@ -8,34 +8,42 @@ module SpecFill
|
|
8
8
|
class_name = column.split('_').map(&:capitalize).join
|
9
9
|
line_array = []
|
10
10
|
next_line = false
|
11
|
+
faker_terms = 'vendor/bundle/ruby/2.6.0/gems/spec_fill-0.1.0/lib/faker_terms.txt'
|
12
|
+
skip_spaces = indent_length(faker_terms)
|
11
13
|
|
12
14
|
File.foreach('db/schema.rb') do |line|
|
13
|
-
if line.chomp.empty? && next_line == true
|
14
|
-
|
15
|
-
end
|
16
|
-
if next_line
|
17
|
-
line_array << line
|
18
|
-
end
|
15
|
+
break if line.chomp.empty? && next_line == true
|
16
|
+
line_array << line if next_line
|
19
17
|
if line.include?(column)
|
20
18
|
line_array << line unless line.include?('add_index')
|
21
19
|
next_line = true
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
23
|
+
not_a_colum(line_array)
|
24
|
+
|
25
25
|
File.open("spec/factories/#{column}.rb", 'w') do |file|
|
26
26
|
unless factory_name.empty?
|
27
27
|
file.print("FactoryGirl.define do\n\tfactory :#{factory_name}, class: #{class_name} do\n")
|
28
28
|
else
|
29
29
|
file.print("FactoryGirl.define do\n\tfactory :#{column} do\n")
|
30
30
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
file.print("\t\t# the test object (e.g., create(:object, primary_key: column_name)).\n")
|
35
|
-
end
|
31
|
+
|
32
|
+
reminder if line_array[0].include?('primary_key')
|
33
|
+
|
36
34
|
line_array.shift
|
37
35
|
get_attributes(line_array).each do |attr|
|
38
|
-
|
36
|
+
finished = false
|
37
|
+
File.foreach(faker_terms) do |line|
|
38
|
+
if line.to_s.include?(attr)
|
39
|
+
meth = line.split(',')
|
40
|
+
file.print "\t\t#{attr}\t\t\tFaker::#{meth[1].chomp}.#{meth[0]}\n"
|
41
|
+
finished = true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
if finished == false
|
45
|
+
file.print "\t\t#{attr}\n"
|
46
|
+
end
|
39
47
|
end
|
40
48
|
file.print("\tend\n")
|
41
49
|
file.print('end')
|
@@ -56,7 +64,32 @@ module SpecFill
|
|
56
64
|
puts "\nSpecFill!"
|
57
65
|
puts "version: " + SpecFill::VERSION
|
58
66
|
puts "author: Publicover\n"
|
67
|
+
end
|
59
68
|
|
69
|
+
desc 'reminder', 'Puts reminder about primary keys in the file'
|
70
|
+
def reminder
|
71
|
+
file.print("\t\t# It looks like your primary key isn't the record ID.\n")
|
72
|
+
file.print("\t\t# Don't forget to pass in your primary key when you're creating\n")
|
73
|
+
file.print("\t\t# the test object (e.g., create(:object, primary_key: column_name)).\n")
|
74
|
+
end
|
75
|
+
|
76
|
+
desc 'indent_length |schema|', 'A helper method for #fill(column)'
|
77
|
+
def indent_length(schema)
|
78
|
+
num = 0
|
79
|
+
File.foreach(schema) do |line|
|
80
|
+
if line.to_i > num
|
81
|
+
num = line.to_i
|
82
|
+
end
|
83
|
+
end
|
84
|
+
num
|
85
|
+
end
|
86
|
+
|
87
|
+
desc 'not_a_column |column|', 'A helper method for #fill(column)'
|
88
|
+
def not_a_colum(ary)
|
89
|
+
if ary.empty?
|
90
|
+
puts 'That is not a column in your db'
|
91
|
+
return false
|
92
|
+
end
|
60
93
|
end
|
61
94
|
end
|
62
95
|
end
|
data/lib/spec_fill/version.rb
CHANGED
data/spec_fill-0.1.1.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spec_fill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Publicover
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -86,12 +86,14 @@ files:
|
|
86
86
|
- README.md
|
87
87
|
- Rakefile
|
88
88
|
- bin/console
|
89
|
+
- bin/names.txt
|
89
90
|
- bin/setup
|
90
91
|
- exe/spec_fill
|
91
92
|
- lib/spec_fill.rb
|
92
93
|
- lib/spec_fill/cli.rb
|
93
94
|
- lib/spec_fill/version.rb
|
94
95
|
- spec_fill-0.1.0.gem
|
96
|
+
- spec_fill-0.1.1.gem
|
95
97
|
- spec_fill.gemspec
|
96
98
|
- vendor/bundle/ruby/2.6.0/bin/htmldiff
|
97
99
|
- vendor/bundle/ruby/2.6.0/bin/ldiff
|