data_builder 0.1.0
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 +7 -0
- data/.gitignore +40 -0
- data/.hound.yml +62 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +166 -0
- data/Rakefile +31 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/data_builder.gemspec +37 -0
- data/lib/data_builder/version.rb +3 -0
- data/lib/data_builder.rb +41 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7a104b8ca0cab66dd4af88df664789da0f29738
|
4
|
+
data.tar.gz: 70896d546ce15ebd607cee7110171845ff3690bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6613cff274038ce424c85841d690ae60688f77e365de5fccb0db8f266bb6a705e5caa8895b7afa61d6934e86f7a9a20e394e6dfd3a338fb29db60c5e40d3a34
|
7
|
+
data.tar.gz: 57effa8bcfc6c8d852821440f3abc2f93ba641ebc4a08517bda1a0dbda30d2b1e528e93ec9e5bc9df2e0e59db3b896d170e8126459f54102250126766c08c734
|
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Ruby-Specific
|
2
|
+
|
3
|
+
/.bundle/
|
4
|
+
/.yardoc
|
5
|
+
/Gemfile.lock
|
6
|
+
/_yardoc/
|
7
|
+
|
8
|
+
# Ouput-Specific
|
9
|
+
|
10
|
+
/coverage/
|
11
|
+
/doc/
|
12
|
+
/pkg/
|
13
|
+
/spec/reports/
|
14
|
+
/tmp/
|
15
|
+
*.log
|
16
|
+
*.tmp
|
17
|
+
*.swp
|
18
|
+
*.bak
|
19
|
+
|
20
|
+
# IDE-Specific
|
21
|
+
|
22
|
+
.idea
|
23
|
+
.settings
|
24
|
+
.project
|
25
|
+
.classpath
|
26
|
+
*.iws
|
27
|
+
|
28
|
+
# Windows-Specific
|
29
|
+
|
30
|
+
Thumbs.db
|
31
|
+
|
32
|
+
# Mac OS-Specific
|
33
|
+
|
34
|
+
*.DS_Store
|
35
|
+
._*
|
36
|
+
|
37
|
+
# Linux-Specific
|
38
|
+
|
39
|
+
.directory
|
40
|
+
.Trash-*
|
data/.hound.yml
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- data_builder.gemspec
|
4
|
+
- test/*.rb
|
5
|
+
- spec/**/*
|
6
|
+
|
7
|
+
# Removing need for frozen string literal comment.
|
8
|
+
Style/FrozenStringLiteralComment:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
# Removing the preference for string single quotes.
|
12
|
+
Style/StringLiterals:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
# Missing top-level module documentation comment.
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
# Prefer reduce over inject.
|
20
|
+
Style/CollectionMethods:
|
21
|
+
PreferredMethods:
|
22
|
+
reduce: 'inject'
|
23
|
+
|
24
|
+
# Use each_with_object instead of inject.
|
25
|
+
Style/EachWithObject:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
# Prefer fail over raise.
|
29
|
+
Style/SignalException:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# This never works for validations.
|
33
|
+
Style/AlignHash:
|
34
|
+
EnforcedLastArgumentHashStyle: ignore_implicit
|
35
|
+
|
36
|
+
# Align multi-line params with previous line.
|
37
|
+
Style/AlignParameters:
|
38
|
+
EnforcedStyle: with_fixed_indentation
|
39
|
+
|
40
|
+
# Indent `when` clause one step from `case`.
|
41
|
+
Style/CaseIndentation:
|
42
|
+
IndentOneStep: true
|
43
|
+
|
44
|
+
# Don't force bad var names for reduce/inject loops.
|
45
|
+
Style/SingleLineBlockParams:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# For method chains, keep the dot with the method name.
|
49
|
+
Style/DotPosition:
|
50
|
+
EnforcedStyle: leading
|
51
|
+
|
52
|
+
# Stop nesting so hard.
|
53
|
+
Metrics/BlockNesting:
|
54
|
+
Max: 2
|
55
|
+
|
56
|
+
# Encourage short methods.
|
57
|
+
Metrics/MethodLength:
|
58
|
+
Max: 10
|
59
|
+
|
60
|
+
# Encourage fewer parameters.
|
61
|
+
Metrics/ParameterLists:
|
62
|
+
Max: 4
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at jeffnyman@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jeff Nyman
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
# DataBuilder
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/data_builder)
|
4
|
+
[](https://github.com/jnyman/data_builder/blob/master/LICENSE.txt)
|
5
|
+
|
6
|
+
[](https://gemnasium.com/jnyman/data_builder)
|
7
|
+
|
8
|
+
The goal of DataBuilder is to apply an expressive means of constructing a data set based on information stored in YAML files.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
To get the latest stable release, add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'data_builder'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then include it in your bundle:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
You can also install DataBuilder just as you would any other gem:
|
23
|
+
|
24
|
+
$ gem install data_builder
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
DataBuilder is using my [DataReader gem](https://github.com/jnyman/data_reader) to provide base-level functionality. Unlike DataReader, DataBuilder will assume some defaults. For example, you could do something as simple as this:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require "data_builder"
|
32
|
+
|
33
|
+
data = DataBuilder.load 'default.yml'
|
34
|
+
|
35
|
+
puts data
|
36
|
+
```
|
37
|
+
|
38
|
+
Here I'm relying on the fact that DataBuilder applies a default directory of `data`. I then use the `load` method of DataReader to call up a file in that directory. I could set my own data path with DataBuilder as such:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
require "data_builder"
|
42
|
+
|
43
|
+
DataBuilder.data_path = 'config/data'
|
44
|
+
data = DataBuilder.load 'default.yml'
|
45
|
+
|
46
|
+
puts data
|
47
|
+
```
|
48
|
+
|
49
|
+
Here you can inform DataBuilder where it can find the data files using `data_path`. As you've seen, if you don't specify a directory then DataBuilder will default to using a directory named `data`.
|
50
|
+
|
51
|
+
After setting the directory you must load a file. This can be accomplished by calling the `load` method.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
DataBuilder.load 'default.yml'
|
55
|
+
```
|
56
|
+
|
57
|
+
However, these approaches are really just using DataBuilder as an overlay for DataReader.
|
58
|
+
|
59
|
+
Where DataBuilder steps in is when you want to use the data. DataBuilder provides a `data_about` method that will return the data for a specific key from any data files that have been loaded.
|
60
|
+
|
61
|
+
The most common way to use this is to include or extend the DataBuilder module. Let's say that you have a `data` directory and in that directory you have a file called `default.yml`. The YAML file has the following contents:
|
62
|
+
|
63
|
+
```yaml
|
64
|
+
alpha centauri:
|
65
|
+
warpFactor: 1
|
66
|
+
velocity: 2
|
67
|
+
distance: 4.3
|
68
|
+
|
69
|
+
epsilon eridani:
|
70
|
+
warpFactor: 1
|
71
|
+
velocity: 2
|
72
|
+
distance: 10.5
|
73
|
+
```
|
74
|
+
|
75
|
+
Now let's use DataBuilder to get the information from it.
|
76
|
+
|
77
|
+
### Extending DataBuilder
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
class Testing
|
81
|
+
extend DataBuilder
|
82
|
+
end
|
83
|
+
|
84
|
+
data = Testing.data_about('alpha centauri')
|
85
|
+
```
|
86
|
+
|
87
|
+
### Including DataBuilder
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
class Testing
|
91
|
+
include DataBuilder
|
92
|
+
end
|
93
|
+
|
94
|
+
testing = Testing.new
|
95
|
+
data = testing.data_about('alpha centauri')
|
96
|
+
```
|
97
|
+
|
98
|
+
### The Data Key
|
99
|
+
|
100
|
+
In both cases of extending or including, I'm using a variable to store the results of the call. Those results will be the data pulled from the `default.yml` file. Of note, however, is that all that will be pulled is the data from the "alpha centauri" key because that is what you specified in the call to `data_about`.
|
101
|
+
|
102
|
+
In these examples, I'm using a string because the value "alpha centauri" has a space in it. However, if that was not the case -- if the key were, say, alpha_centauri -- then you could use a symbol instead, like this:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
data = testing.data_about(:alpha_centauri)
|
106
|
+
```
|
107
|
+
|
108
|
+
### Default Files
|
109
|
+
|
110
|
+
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 data path you have specified or in the default path of `data`.
|
111
|
+
|
112
|
+
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.
|
113
|
+
|
114
|
+
### Namespaced Data
|
115
|
+
|
116
|
+
To organize your data into a rough equivalent of namespaces, and to load that data accordingly, you can do something like this:
|
117
|
+
|
118
|
+
```
|
119
|
+
class Testing
|
120
|
+
include DataBuilder
|
121
|
+
end
|
122
|
+
|
123
|
+
testing = Testing.new
|
124
|
+
|
125
|
+
data = testing.data_about('stars/epsilon eridani')
|
126
|
+
```
|
127
|
+
|
128
|
+
When DataBuilder sees this kind of construct, it will take the first part (before the /) as a filename and the second part as the key to look up in that file. So the above command would look for a file called `stars.yml` in the data path provided and then grab the data from the key entry labeled "epislon eridani".
|
129
|
+
|
130
|
+
### Aliases
|
131
|
+
|
132
|
+
Given the examples, you can see that `data_about` was chosen as the method name to make what's occurring a bit more expressive. You can use the following aliases for `data_about`:
|
133
|
+
|
134
|
+
* `data_from`
|
135
|
+
* `data_for`
|
136
|
+
* `using_data_for`
|
137
|
+
* `using_data_from`
|
138
|
+
|
139
|
+
## Development
|
140
|
+
|
141
|
+
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. To install this gem onto your local machine, run `bundle exec rake install`.
|
142
|
+
|
143
|
+
## Contributing
|
144
|
+
|
145
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/jnyman/data_builder](https://github.com/jnyman/data_builder). The testing ecosystem of Ruby is very large and this project is intended to be a welcoming arena for collaboration on yet another testing tool. As such, contributors are very much welcome but are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
146
|
+
|
147
|
+
To contribute to DataBuilder:
|
148
|
+
|
149
|
+
1. [Fork the project](http://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
|
150
|
+
2. Create your feature branch. (`git checkout -b my-new-feature`)
|
151
|
+
3. Commit your changes. (`git commit -am 'new feature'`)
|
152
|
+
4. Push the branch. (`git push origin my-new-feature`)
|
153
|
+
5. Create a new [pull request](https://help.github.com/articles/using-pull-requests).
|
154
|
+
|
155
|
+
## Author
|
156
|
+
|
157
|
+
* [Jeff Nyman](http://testerstories.com)
|
158
|
+
|
159
|
+
## Credits
|
160
|
+
|
161
|
+
This code is loosely based upon the [DataMagic](https://github.com/cheezy/data_magic) gem. I created a new version largely to avoid the name "magic", which I don't think any tool should be promoting. I'm also cleaning up the code and documentation.
|
162
|
+
|
163
|
+
## License
|
164
|
+
|
165
|
+
DataReader is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
|
166
|
+
See the [LICENSE](https://github.com/jnyman/data_builder/blob/master/LICENSE.txt) file for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rdoc/task"
|
4
|
+
require "rubocop/rake_task"
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
|
7
|
+
RuboCop::RakeTask.new
|
8
|
+
|
9
|
+
namespace :spec do
|
10
|
+
desc 'Clean all generated reports'
|
11
|
+
task :clean do
|
12
|
+
system('rm -rf spec/reports')
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec::Core::RakeTask.new(all: :clean) do |config|
|
16
|
+
options = %w(--color)
|
17
|
+
options += %w(--format documentation)
|
18
|
+
options += %w(--format html --out spec/reports/unit-test-report.html)
|
19
|
+
|
20
|
+
config.rspec_opts = options
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Rake::RDocTask.new do |rdoc|
|
25
|
+
rdoc.rdoc_dir = 'doc'
|
26
|
+
rdoc.main = 'README.md'
|
27
|
+
rdoc.title = "DataBuilder #{DataBuilder::VERSION}"
|
28
|
+
rdoc.rdoc_files.include('README*', 'lib/**/*.rb')
|
29
|
+
end
|
30
|
+
|
31
|
+
task default: ['spec:all', :rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "data_builder"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
require "pry"
|
10
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'data_builder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "data_builder"
|
8
|
+
spec.version = DataBuilder::VERSION
|
9
|
+
spec.authors = ["Jeff Nyman"]
|
10
|
+
spec.email = ["jeffnyman@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Provides expressive data set handling from YAML files.}
|
13
|
+
spec.description = %q{Provides expressive data set handling from YAML files.}
|
14
|
+
spec.homepage = "https://github.com/jnyman/data_builder"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "rubocop"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
|
30
|
+
spec.add_runtime_dependency "data_reader"
|
31
|
+
|
32
|
+
spec.post_install_message = %{
|
33
|
+
(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
34
|
+
DataBuilder #{DataBuilder::VERSION} has been installed.
|
35
|
+
(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
36
|
+
}
|
37
|
+
end
|
data/lib/data_builder.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "data_builder/version"
|
2
|
+
|
3
|
+
require "data_reader"
|
4
|
+
|
5
|
+
module DataBuilder
|
6
|
+
extend DataReader
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :data_source
|
10
|
+
|
11
|
+
def default_data_path
|
12
|
+
'data'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def data_about(key, specified = {})
|
17
|
+
if key.is_a?(String) && key.match(%r{/})
|
18
|
+
file, record = key.split('/')
|
19
|
+
DataBuilder.load("#{file}.yml")
|
20
|
+
else
|
21
|
+
record = key.to_s
|
22
|
+
DataBuilder.load(builder_source) unless DataBuilder.data_source
|
23
|
+
end
|
24
|
+
|
25
|
+
data = DataBuilder.data_source[record]
|
26
|
+
raise ArgumentError, "Undefined key for data: #{key}" unless data
|
27
|
+
|
28
|
+
data.merge(specified).clone
|
29
|
+
end
|
30
|
+
|
31
|
+
alias data_from data_about
|
32
|
+
alias data_for data_about
|
33
|
+
alias using_data_for data_about
|
34
|
+
alias using_data_from data_about
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def builder_source
|
39
|
+
ENV['DATA_BUILDER_SOURCE'] ? ENV['DATA_BUILDER_SOURCE'] : 'default.yml'
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: data_builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Nyman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: data_reader
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Provides expressive data set handling from YAML files.
|
98
|
+
email:
|
99
|
+
- jeffnyman@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".hound.yml"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".travis.yml"
|
109
|
+
- CODE_OF_CONDUCT.md
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- data_builder.gemspec
|
117
|
+
- lib/data_builder.rb
|
118
|
+
- lib/data_builder/version.rb
|
119
|
+
homepage: https://github.com/jnyman/data_builder
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
|
124
|
+
\ DataBuilder 0.1.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::)
|
125
|
+
(::) (::) (::) (::)\n "
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.5.1
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Provides expressive data set handling from YAML files.
|
145
|
+
test_files: []
|