mapr 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 +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +41 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mapr.rb +49 -0
- data/lib/mapr/version.rb +3 -0
- data/mapr.gemspec +28 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ef30f4168e7239418fe52f48e29e4187f062bef34565a01d371c8851a909ac42
|
4
|
+
data.tar.gz: 343572a8053985aec8f96eec48bd7452bbaefd3897814cfade198b24487b9a2c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e551dc3e0bcc7acb7c10a490f05f9dd1daa6dbeb3400407619181c45be440cb48399af0a53573973f932815a0dd01c6465899a15e0fb9d8f9b067928d461c7c9
|
7
|
+
data.tar.gz: 8e464dd768078816e3a047fd47abfa15599322c945331b1b4cc1e1ad7344ea524f94e77c1107e23b4468cc77228fdccfb127e3a154a580c5183daed7906dd5ba
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mapr (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.3)
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
method_source (1.0.0)
|
12
|
+
pry (0.13.1)
|
13
|
+
coderay (~> 1.1)
|
14
|
+
method_source (~> 1.0)
|
15
|
+
rake (12.3.3)
|
16
|
+
rspec (3.10.0)
|
17
|
+
rspec-core (~> 3.10.0)
|
18
|
+
rspec-expectations (~> 3.10.0)
|
19
|
+
rspec-mocks (~> 3.10.0)
|
20
|
+
rspec-core (3.10.0)
|
21
|
+
rspec-support (~> 3.10.0)
|
22
|
+
rspec-expectations (3.10.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-mocks (3.10.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-support (3.10.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
x86_64-linux
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
mapr!
|
36
|
+
pry
|
37
|
+
rake (~> 12.0)
|
38
|
+
rspec (~> 3.0)
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Mapr
|
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/mapr`. 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 'mapr'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install mapr
|
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. Then, run `rake spec` to run the tests. 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/[USERNAME]/mapr.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mapr"
|
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
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/mapr.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "mapr/version"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module Mapr
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
module_function
|
8
|
+
|
9
|
+
CONSTANT_PREFIX = /\A\+/
|
10
|
+
|
11
|
+
def map(schema, data)
|
12
|
+
YAML.load(schema)
|
13
|
+
.transform_values do |path|
|
14
|
+
dig(data, path)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def dig(data, path)
|
19
|
+
case path
|
20
|
+
when CONSTANT_PREFIX
|
21
|
+
path.gsub(CONSTANT_PREFIX, "")
|
22
|
+
else
|
23
|
+
data.dig(*parse_path(path))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_path(path)
|
28
|
+
case path
|
29
|
+
when Array
|
30
|
+
path
|
31
|
+
when String
|
32
|
+
path.split("/")
|
33
|
+
.map(&method(:transform_path_token))
|
34
|
+
when Integer
|
35
|
+
[path]
|
36
|
+
else
|
37
|
+
raise Mapr::Error, "Path has to be a string or integer path was of type: '#{path.class}' (#{path})"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def transform_path_token(path_token)
|
42
|
+
if path_token =~ /\A\d+\Z/
|
43
|
+
path_token.to_i
|
44
|
+
else
|
45
|
+
path_token
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/lib/mapr/version.rb
ADDED
data/mapr.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'lib/mapr/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "mapr"
|
5
|
+
spec.version = Mapr::VERSION
|
6
|
+
spec.authors = ["Khaja Minhajuddin"]
|
7
|
+
spec.email = ["minhajuddin.k@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Provides a simple DSL to map one hash to another}
|
10
|
+
spec.description = %q{Provides a simple DSL to map one hash to another using YAML schemas}
|
11
|
+
spec.homepage = "https://github.com/minhajuddin/mapr"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/minhajuddin/mapr"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/minhajuddin/mapr"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mapr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Khaja Minhajuddin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provides a simple DSL to map one hash to another using YAML schemas
|
14
|
+
email:
|
15
|
+
- minhajuddin.k@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".travis.yml"
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- bin/console
|
28
|
+
- bin/setup
|
29
|
+
- lib/mapr.rb
|
30
|
+
- lib/mapr/version.rb
|
31
|
+
- mapr.gemspec
|
32
|
+
homepage: https://github.com/minhajuddin/mapr
|
33
|
+
licenses: []
|
34
|
+
metadata:
|
35
|
+
allowed_push_host: https://rubygems.org
|
36
|
+
homepage_uri: https://github.com/minhajuddin/mapr
|
37
|
+
source_code_uri: https://github.com/minhajuddin/mapr
|
38
|
+
changelog_uri: https://github.com/minhajuddin/mapr
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.3.0
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubygems_version: 3.1.4
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Provides a simple DSL to map one hash to another
|
58
|
+
test_files: []
|