data_builder 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +33 -24
- data/.hound.yml +6 -0
- data/Gemfile +2 -1
- data/{LICENSE.txt → LICENSE.md} +2 -2
- data/README.md +35 -9
- data/Rakefile +1 -0
- data/data_builder.gemspec +2 -1
- data/lib/data_builder.rb +62 -6
- data/lib/data_builder/core_ext/hash.rb +5 -0
- data/lib/data_builder/core_ext/integer.rb +11 -0
- data/lib/data_builder/core_ext/string.rb +7 -0
- data/lib/data_builder/generation.rb +13 -0
- data/lib/data_builder/generation_date.rb +41 -0
- data/lib/data_builder/generation_standard.rb +223 -0
- data/lib/data_builder/version.rb +1 -1
- metadata +27 -8
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38ab44128293206daf0e094a73036fb1317ea971
|
4
|
+
data.tar.gz: c9cd869a2144e970290a9833cdabad471bcf814d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b22c0008029a53d113811afffd71ef785ba0af3b9b276fe8cf017c9eaf537145dd83cdc15bbbf739da6ffe11899e5b6e08088eb7f2f24adf9ba23e427c92a30
|
7
|
+
data.tar.gz: ff250a2359122a694544c199142fc369c903f6f6a9f81828ae6027d330d7f8b1498a3130782a0d5602902456e6806c201718d54883c8b9b865158368dce34396
|
data/.gitignore
CHANGED
@@ -1,40 +1,49 @@
|
|
1
|
-
# Ruby
|
1
|
+
# Ruby Generated
|
2
2
|
|
3
|
+
/Gemfile.lock
|
3
4
|
/.bundle/
|
4
5
|
/.yardoc
|
5
|
-
/Gemfile.lock
|
6
6
|
/_yardoc/
|
7
|
-
|
8
|
-
# Ouput-Specific
|
9
|
-
|
10
7
|
/coverage/
|
11
8
|
/doc/
|
12
9
|
/pkg/
|
13
10
|
/spec/reports/
|
11
|
+
/spec/coverage/
|
14
12
|
/tmp/
|
15
|
-
*.log
|
16
|
-
*.tmp
|
17
|
-
*.swp
|
18
|
-
*.bak
|
19
13
|
|
20
|
-
#
|
14
|
+
# Generated Reports
|
15
|
+
reports/
|
21
16
|
|
22
|
-
|
23
|
-
.settings
|
24
|
-
.project
|
25
|
-
.classpath
|
26
|
-
*.iws
|
17
|
+
# Rspec Failure Tracking
|
27
18
|
|
28
|
-
|
19
|
+
.rspec_status
|
29
20
|
|
30
|
-
|
21
|
+
# IDE Files
|
31
22
|
|
32
|
-
|
33
|
-
|
34
|
-
*.
|
35
|
-
|
23
|
+
.idea/
|
24
|
+
*.iml
|
25
|
+
*.iws
|
26
|
+
*.ipr
|
27
|
+
.vscode/
|
28
|
+
.settings/
|
29
|
+
.metadata
|
30
|
+
.classpath
|
31
|
+
.loadpath
|
32
|
+
.buildpath
|
33
|
+
.project
|
36
34
|
|
37
|
-
#
|
35
|
+
# OS Files
|
38
36
|
|
39
|
-
.
|
40
|
-
.
|
37
|
+
.DS_Store
|
38
|
+
.DS_Store?
|
39
|
+
._*
|
40
|
+
.Spotlight-V100
|
41
|
+
.Trashes
|
42
|
+
ehthumbs.db
|
43
|
+
Thumbs.db
|
44
|
+
$RECYCLE.BIN/
|
45
|
+
Desktop.ini
|
46
|
+
*.tmp
|
47
|
+
*.bak
|
48
|
+
*.swp
|
49
|
+
*~.nib
|
data/.hound.yml
CHANGED
data/Gemfile
CHANGED
data/{LICENSE.txt → LICENSE.md}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
The MIT License (MIT)
|
1
|
+
**The MIT License (MIT)**
|
2
2
|
|
3
|
-
Copyright
|
3
|
+
Copyright © 2016-2019 Jeff Nyman
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# DataBuilder
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/data_builder.svg)](http://badge.fury.io/rb/data_builder)
|
4
|
-
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jeffnyman/data_builder/blob/master/LICENSE.
|
5
|
-
|
6
|
-
[![Dependency Status](https://gemnasium.com/jeffnyman/data_builder.png)](https://gemnasium.com/jeffnyman/data_builder)
|
4
|
+
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jeffnyman/data_builder/blob/master/LICENSE.md)
|
7
5
|
|
8
6
|
The goal of DataBuilder is to apply an expressive means of constructing a data set based on information stored in YAML files.
|
9
7
|
|
@@ -15,13 +13,23 @@ To get the latest stable release, add this line to your application's Gemfile:
|
|
15
13
|
gem 'data_builder'
|
16
14
|
```
|
17
15
|
|
18
|
-
|
16
|
+
To get the latest code:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'data_builder', git: 'https://github.com/jeffnyman/data_builder'
|
20
|
+
```
|
21
|
+
|
22
|
+
After doing one of the above, execute the following command:
|
19
23
|
|
20
|
-
|
24
|
+
```
|
25
|
+
$ bundle
|
26
|
+
```
|
21
27
|
|
22
28
|
You can also install DataBuilder just as you would any other gem:
|
23
29
|
|
24
|
-
|
30
|
+
```
|
31
|
+
$ gem install data_builder
|
32
|
+
```
|
25
33
|
|
26
34
|
## Usage
|
27
35
|
|
@@ -137,7 +145,7 @@ data = testing.data_about(:alpha_centauri)
|
|
137
145
|
### Default Files
|
138
146
|
|
139
147
|
You might wonder how DataBuilder knew to look for `default.yml` since I didn't use a `load` method in these examples. If you do not specify a filename the logic will attempt to use a file named `default.yml` in the specific data path you have specified or in the default path of `data`.
|
140
|
-
|
148
|
+
|
141
149
|
Another option is that you can set an environment variable called `DATA_BUILDER_SOURCE`. When this variable exists and is set, the value it is set to will be used instead of the `default.yml` file. Keep in mind that the "data source" here refers to the file, not the keys within a file.
|
142
150
|
|
143
151
|
### Namespaced Data
|
@@ -167,9 +175,27 @@ Given the examples, you can see that `data_about` was chosen as the method name
|
|
167
175
|
|
168
176
|
The reason for these aliases is, again, to make the logic expressive about its intent. This is particularly nice if you fit DataBuilder in with the context of a fluent API.
|
169
177
|
|
178
|
+
### Scenarios in Cucumber
|
179
|
+
|
180
|
+
If you are using Cucumber, there is another to specify the data file to load. You can apply a _tag_ to a given scenario. The tag should take the form of `@databuilder_NAME` where `NAME` is replaced with the name of the data file you want to be loaded for the scenario.
|
181
|
+
|
182
|
+
As an example, if you add the tag `@databuilder_stars` then the file `stars.yml` will be loaded. If you want to use the tags you have to add the following code in a hook:
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
Before do |scenario|
|
186
|
+
DataBuilder.data_files_for(scenario)
|
187
|
+
end
|
188
|
+
```
|
189
|
+
|
190
|
+
You can use `data_for_scenario` in place of `data_files_for` if you feel that reads better.
|
191
|
+
|
170
192
|
## Development
|
171
193
|
|
172
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec:all` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
194
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec:all` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
195
|
+
|
196
|
+
The default `rake` command will run all tests as well as a RuboCop analysis.
|
197
|
+
|
198
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
173
199
|
|
174
200
|
## Contributing
|
175
201
|
|
@@ -194,4 +220,4 @@ This code is loosely based upon the [DataMagic](https://github.com/cheezy/data_m
|
|
194
220
|
## License
|
195
221
|
|
196
222
|
DataBuilder is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
|
197
|
-
See the [LICENSE](https://github.com/jeffnyman/data_builder/blob/master/LICENSE.
|
223
|
+
See the [LICENSE](https://github.com/jeffnyman/data_builder/blob/master/LICENSE.md) file for details.
|
data/Rakefile
CHANGED
data/data_builder.gemspec
CHANGED
@@ -21,13 +21,14 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler", "~>
|
24
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
27
|
spec.add_development_dependency "rubocop"
|
28
28
|
spec.add_development_dependency "pry"
|
29
29
|
|
30
30
|
spec.add_runtime_dependency "data_reader"
|
31
|
+
spec.add_runtime_dependency "faker"
|
31
32
|
|
32
33
|
spec.post_install_message = %{
|
33
34
|
(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
data/lib/data_builder.rb
CHANGED
@@ -1,12 +1,34 @@
|
|
1
|
+
require "data_builder/core_ext/hash"
|
2
|
+
require "data_builder/core_ext/integer"
|
3
|
+
require "data_builder/core_ext/string"
|
1
4
|
require "data_builder/version"
|
5
|
+
require "data_builder/generation"
|
6
|
+
require "data_builder/generation_date"
|
7
|
+
require "data_builder/generation_standard"
|
2
8
|
|
3
9
|
require "data_reader"
|
10
|
+
require "faker"
|
4
11
|
|
5
12
|
module DataBuilder
|
6
13
|
extend DataReader
|
14
|
+
extend DateGeneration
|
15
|
+
extend StandardGeneration
|
16
|
+
|
17
|
+
attr_reader :parent
|
18
|
+
|
19
|
+
if I18n.respond_to? :enforce_available_locales
|
20
|
+
I18n.enforce_available_locales = false
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.included(caller)
|
24
|
+
@parent = caller
|
25
|
+
generators.each do |generator|
|
26
|
+
Generation.send :include, generator
|
27
|
+
end
|
28
|
+
end
|
7
29
|
|
8
30
|
class << self
|
9
|
-
attr_accessor :
|
31
|
+
attr_accessor :data_contents
|
10
32
|
|
11
33
|
def default_data_path
|
12
34
|
'data'
|
@@ -18,6 +40,16 @@ module DataBuilder
|
|
18
40
|
t.gsub('@databuilder_', '').to_sym
|
19
41
|
end
|
20
42
|
end
|
43
|
+
|
44
|
+
alias data_for_scenario data_files_for
|
45
|
+
|
46
|
+
def locale=(value)
|
47
|
+
Faker::Config.locale = value
|
48
|
+
end
|
49
|
+
|
50
|
+
def generators
|
51
|
+
@generators || []
|
52
|
+
end
|
21
53
|
end
|
22
54
|
|
23
55
|
def data_about(key, specified = {})
|
@@ -26,13 +58,15 @@ module DataBuilder
|
|
26
58
|
DataBuilder.load("#{file}.yml")
|
27
59
|
else
|
28
60
|
record = key.to_s
|
29
|
-
DataBuilder.load(builder_source) unless DataBuilder.
|
61
|
+
DataBuilder.load(builder_source) unless DataBuilder.data_contents
|
30
62
|
end
|
31
63
|
|
32
|
-
data = DataBuilder.
|
64
|
+
data = DataBuilder.data_contents[record]
|
33
65
|
raise ArgumentError, "Undefined key for data: #{key}" unless data
|
34
66
|
|
35
|
-
|
67
|
+
# rubocop:disable Metrics/LineLength
|
68
|
+
process_data(data.merge(specified.key?(record) ? specified[record] : specified).deep_copy)
|
69
|
+
# rubocop:enable Metrics/LineLength
|
36
70
|
end
|
37
71
|
|
38
72
|
alias data_from data_about
|
@@ -44,13 +78,35 @@ module DataBuilder
|
|
44
78
|
original_data_path = DataBuilder.data_path
|
45
79
|
DataBuilder.data_path = data_location
|
46
80
|
data_files = data_files_for(scenario)
|
47
|
-
DataBuilder.load("#{data_files.last}.yml") if data_files.count
|
81
|
+
DataBuilder.load("#{data_files.last}.yml") if data_files.count.positive?
|
48
82
|
DataBuilder.data_path = original_data_path
|
49
83
|
end
|
50
84
|
|
51
85
|
private
|
52
86
|
|
87
|
+
def process_data(data)
|
88
|
+
case data
|
89
|
+
when Hash
|
90
|
+
data.each { |key, value| data[key] = process_data(value) }
|
91
|
+
when Array
|
92
|
+
data.each_with_index { |value, i| data[i] = process_data(value) }
|
93
|
+
when String
|
94
|
+
return generate(data[1..-1]) if data[0, 1] == "~"
|
95
|
+
end
|
96
|
+
data
|
97
|
+
end
|
98
|
+
|
99
|
+
def generate(value)
|
100
|
+
generation.send :process, value
|
101
|
+
rescue StandardError => e
|
102
|
+
fail "Failed to generate: #{value}\n Reason: #{e.message}\n"
|
103
|
+
end
|
104
|
+
|
105
|
+
def generation
|
106
|
+
@generation ||= Generation.new parent
|
107
|
+
end
|
108
|
+
|
53
109
|
def builder_source
|
54
|
-
ENV['DATA_BUILDER_SOURCE']
|
110
|
+
ENV['DATA_BUILDER_SOURCE'] || 'default.yml'
|
55
111
|
end
|
56
112
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module DataBuilder
|
2
|
+
module DateGeneration
|
3
|
+
def today(format = '%D')
|
4
|
+
Date.today.strftime(format)
|
5
|
+
end
|
6
|
+
|
7
|
+
def tomorrow(format = '%D')
|
8
|
+
tomorrow = Date.today + 1
|
9
|
+
tomorrow.strftime(format)
|
10
|
+
end
|
11
|
+
|
12
|
+
def yesterday(format = '%D')
|
13
|
+
yesterday = Date.today - 1
|
14
|
+
yesterday.strftime(format)
|
15
|
+
end
|
16
|
+
|
17
|
+
def month
|
18
|
+
randomize(Date::MONTHNAMES[1..-1])
|
19
|
+
end
|
20
|
+
|
21
|
+
def month_abbr
|
22
|
+
randomize(Date::ABBR_MONTHNAMES[1..-1])
|
23
|
+
end
|
24
|
+
|
25
|
+
def day_of_week
|
26
|
+
randomize(Date::DAYNAMES)
|
27
|
+
end
|
28
|
+
|
29
|
+
def day_of_week_abbr
|
30
|
+
randomize(Date::ABBR_DAYNAMES)
|
31
|
+
end
|
32
|
+
|
33
|
+
alias db_today today
|
34
|
+
alias dn_tomorrow tomorrow
|
35
|
+
alias db_yesterday yesterday
|
36
|
+
alias db_month month
|
37
|
+
alias db_month_abbr month_abbr
|
38
|
+
alias db_day_of_week day_of_week
|
39
|
+
alias db_day_of_week_abbr day_of_week_abbr
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
module DataBuilder
|
2
|
+
module StandardGeneration
|
3
|
+
attr_reader :parent
|
4
|
+
|
5
|
+
def full_name
|
6
|
+
Faker::Name.name
|
7
|
+
end
|
8
|
+
|
9
|
+
def first_name
|
10
|
+
Faker::Name.first_name
|
11
|
+
end
|
12
|
+
|
13
|
+
def last_name
|
14
|
+
Faker::Name.last_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def name_prefix
|
18
|
+
Faker::Name.prefix
|
19
|
+
end
|
20
|
+
|
21
|
+
def name_suffix
|
22
|
+
Faker::Name.suffix
|
23
|
+
end
|
24
|
+
|
25
|
+
def title
|
26
|
+
Faker::Name.title
|
27
|
+
end
|
28
|
+
|
29
|
+
def street_address(include_secondary = false)
|
30
|
+
Faker::Address.street_address(include_secondary: include_secondary)
|
31
|
+
end
|
32
|
+
|
33
|
+
def secondary_address
|
34
|
+
Faker::Address.secondary_address
|
35
|
+
end
|
36
|
+
|
37
|
+
def city
|
38
|
+
Faker::Address.city
|
39
|
+
end
|
40
|
+
|
41
|
+
def state
|
42
|
+
Faker::Address.state
|
43
|
+
end
|
44
|
+
|
45
|
+
def state_abbr
|
46
|
+
Faker::Address.state_abbr
|
47
|
+
end
|
48
|
+
|
49
|
+
def zip_code
|
50
|
+
Faker::Address.zip
|
51
|
+
end
|
52
|
+
|
53
|
+
def country
|
54
|
+
Faker::Address.country
|
55
|
+
end
|
56
|
+
|
57
|
+
def credit_card_number
|
58
|
+
Faker::Business.credit_card_number
|
59
|
+
end
|
60
|
+
|
61
|
+
def credit_card_type
|
62
|
+
Faker::Business.credit_card_type
|
63
|
+
end
|
64
|
+
|
65
|
+
def phone_number
|
66
|
+
value = Faker::PhoneNumber.phone_number
|
67
|
+
remove_extension(value)
|
68
|
+
end
|
69
|
+
|
70
|
+
def cell_phone
|
71
|
+
value = Faker::PhoneNumber.cell_phone
|
72
|
+
remove_extension(value)
|
73
|
+
end
|
74
|
+
|
75
|
+
def company_name
|
76
|
+
Faker::Company.name
|
77
|
+
end
|
78
|
+
|
79
|
+
def catch_phrase
|
80
|
+
Faker::Company.catch_phrase
|
81
|
+
end
|
82
|
+
|
83
|
+
def words(number = 3)
|
84
|
+
Faker::Lorem.words(number: number).join(' ')
|
85
|
+
end
|
86
|
+
|
87
|
+
def sentence(min_word_count = 4)
|
88
|
+
Faker::Lorem.sentence(word_count: min_word_count)
|
89
|
+
end
|
90
|
+
|
91
|
+
def sentences(sentence_count = 3)
|
92
|
+
Faker::Lorem.sentences(number: sentence_count).join(' ')
|
93
|
+
end
|
94
|
+
|
95
|
+
def paragraphs(paragraph_count = 3)
|
96
|
+
Faker::Lorem.paragraphs(number: paragraph_count).join('\n\n')
|
97
|
+
end
|
98
|
+
|
99
|
+
def characters(character_count = 255)
|
100
|
+
Faker::Lorem.characters(number: character_count)
|
101
|
+
end
|
102
|
+
|
103
|
+
def email_address(name = nil)
|
104
|
+
Faker::Internet.email(name: name)
|
105
|
+
end
|
106
|
+
|
107
|
+
def domain_name
|
108
|
+
Faker::Internet.domain_name
|
109
|
+
end
|
110
|
+
|
111
|
+
def user_name
|
112
|
+
Faker::Internet.user_name
|
113
|
+
end
|
114
|
+
|
115
|
+
def url
|
116
|
+
Faker::Internet.url
|
117
|
+
end
|
118
|
+
|
119
|
+
alias db_first_name first_name
|
120
|
+
alias db_full_name full_name
|
121
|
+
alias db_last_name last_name
|
122
|
+
alias db_name_prefix name_prefix
|
123
|
+
alias db_name_suffix name_suffix
|
124
|
+
alias db_title title
|
125
|
+
alias db_street_address street_address
|
126
|
+
alias db_secondary_address secondary_address
|
127
|
+
alias db_city city
|
128
|
+
alias db_state state
|
129
|
+
alias db_state_abbr state_abbr
|
130
|
+
alias db_zip_code zip_code
|
131
|
+
alias db_country country
|
132
|
+
alias db_credit_card_number credit_card_number
|
133
|
+
alias db_credit_card_type credit_card_type
|
134
|
+
alias db_phone_number phone_number
|
135
|
+
alias db_cell_phone cell_phone
|
136
|
+
alias db_company_name company_name
|
137
|
+
alias db_catch_phrase catch_phrase
|
138
|
+
alias db_words words
|
139
|
+
alias db_sentence sentence
|
140
|
+
alias db_sentences sentences
|
141
|
+
alias db_paragraphs paragraphs
|
142
|
+
alias db_characters characters
|
143
|
+
alias db_email_address email_address
|
144
|
+
alias db_domain_name domain_name
|
145
|
+
alias db_user_name user_name
|
146
|
+
alias db_url url
|
147
|
+
|
148
|
+
def randomize(value)
|
149
|
+
case value
|
150
|
+
when Array then value[rand(value.size)]
|
151
|
+
when Range then rand((value.last + 1) - value.first) + value.first
|
152
|
+
else value
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def sequence(value)
|
157
|
+
index = index_variable_for(value)
|
158
|
+
index = (index ? index + 1 : 0)
|
159
|
+
index = 0 if index == value.length
|
160
|
+
set_index_variable(value, index)
|
161
|
+
value[index]
|
162
|
+
end
|
163
|
+
|
164
|
+
def mask(value)
|
165
|
+
result = ''
|
166
|
+
|
167
|
+
value.each_char do |ch|
|
168
|
+
result += case ch
|
169
|
+
when '#' then randomize(0..9).to_s
|
170
|
+
when 'A' then ('A'..'Z').to_a[rand(26)]
|
171
|
+
when 'a' then ('a'..'z').to_a[rand(26)]
|
172
|
+
else ch
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
result
|
177
|
+
end
|
178
|
+
|
179
|
+
alias db_randomize randomize
|
180
|
+
alias db_sequence sequence
|
181
|
+
alias db_mask mask
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
def process(value)
|
186
|
+
# rubocop:disable Security/Eval
|
187
|
+
eval value
|
188
|
+
# rubocop:enable Security/Eval
|
189
|
+
end
|
190
|
+
|
191
|
+
def remove_extension(phone)
|
192
|
+
index = phone.index('x')
|
193
|
+
phone = phone[0, (index - 1)] if index
|
194
|
+
phone
|
195
|
+
end
|
196
|
+
|
197
|
+
def set_index_variable(ary, value)
|
198
|
+
index_hash[index_name(ary)] = value
|
199
|
+
end
|
200
|
+
|
201
|
+
def index_variable_for(ary)
|
202
|
+
value = index_hash[index_name(ary)]
|
203
|
+
index_hash[index_name(ary)] = -1 unless value
|
204
|
+
index_hash[index_name(ary)]
|
205
|
+
end
|
206
|
+
|
207
|
+
def index_hash
|
208
|
+
dh = data_hash[parent]
|
209
|
+
data_hash[parent] = {} unless dh
|
210
|
+
data_hash[parent]
|
211
|
+
end
|
212
|
+
|
213
|
+
def index_name(ary)
|
214
|
+
"#{ary[0]}#{ary[1]}_index".gsub(' ', '_').downcase
|
215
|
+
end
|
216
|
+
|
217
|
+
def data_hash
|
218
|
+
# rubocop:disable Style/GlobalVars
|
219
|
+
$data_builder_data_hash ||= {}
|
220
|
+
# rubocop:enable Style/GlobalVars
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
data/lib/data_builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Nyman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faker
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Provides expressive data set handling from YAML files.
|
98
112
|
email:
|
99
113
|
- jeffnyman@gmail.com
|
@@ -105,10 +119,9 @@ files:
|
|
105
119
|
- ".hound.yml"
|
106
120
|
- ".rspec"
|
107
121
|
- ".rubocop.yml"
|
108
|
-
- ".travis.yml"
|
109
122
|
- CODE_OF_CONDUCT.md
|
110
123
|
- Gemfile
|
111
|
-
- LICENSE.
|
124
|
+
- LICENSE.md
|
112
125
|
- README.md
|
113
126
|
- Rakefile
|
114
127
|
- bin/console
|
@@ -117,13 +130,19 @@ files:
|
|
117
130
|
- data/default.yml
|
118
131
|
- data_builder.gemspec
|
119
132
|
- lib/data_builder.rb
|
133
|
+
- lib/data_builder/core_ext/hash.rb
|
134
|
+
- lib/data_builder/core_ext/integer.rb
|
135
|
+
- lib/data_builder/core_ext/string.rb
|
136
|
+
- lib/data_builder/generation.rb
|
137
|
+
- lib/data_builder/generation_date.rb
|
138
|
+
- lib/data_builder/generation_standard.rb
|
120
139
|
- lib/data_builder/version.rb
|
121
140
|
homepage: https://github.com/jeffnyman/data_builder
|
122
141
|
licenses:
|
123
142
|
- MIT
|
124
143
|
metadata: {}
|
125
144
|
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
|
126
|
-
\ DataBuilder
|
145
|
+
\ DataBuilder 2.0.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::)
|
127
146
|
(::) (::) (::) (::)\n "
|
128
147
|
rdoc_options: []
|
129
148
|
require_paths:
|
@@ -140,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
159
|
version: '0'
|
141
160
|
requirements: []
|
142
161
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.5.2
|
144
163
|
signing_key:
|
145
164
|
specification_version: 4
|
146
165
|
summary: Provides expressive data set handling from YAML files.
|