galadriel 0.0.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 +7 -0
- data/.gitignore +118 -0
- data/LICENSE +21 -0
- data/README.md +6 -0
- data/galadriel.gemspec +23 -0
- data/lib/galadriel.rb +59 -0
- data/lib/galadriel/version.rb +8 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b53a6fa08561e247506c72981a29b4e981a57cb
|
4
|
+
data.tar.gz: ebdf5fe38751561cdcae535878a694f6f945cb4f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8bc599624059b4df155de5633f4c8480575866ddbbb20681918a49eed5273474fb74aa6db6753c0dbbb3df8d2202e1991559b9df6282812f792b828119f50570
|
7
|
+
data.tar.gz: f3eaa6fdcbfea89001bbd7204b87058f5cbedad63a5a8bd06c6e1656edd170531ce5e5954ac8992a3f30b598e6d0783e2ae4fdb8a55d9bb12fb14edc77363339
|
data/.gitignore
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
|
2
|
+
# Created by https://www.gitignore.io/api/ruby,rubymine
|
3
|
+
|
4
|
+
### Ruby ###
|
5
|
+
*.gem
|
6
|
+
*.rbc
|
7
|
+
/.config
|
8
|
+
/coverage/
|
9
|
+
/InstalledFiles
|
10
|
+
/pkg/
|
11
|
+
/spec/reports/
|
12
|
+
/spec/examples.txt
|
13
|
+
/test/tmp/
|
14
|
+
/test/version_tmp/
|
15
|
+
/tmp/
|
16
|
+
|
17
|
+
# Used by dotenv library to load environment variables.
|
18
|
+
# .env
|
19
|
+
|
20
|
+
## Specific to RubyMotion:
|
21
|
+
.dat*
|
22
|
+
.repl_history
|
23
|
+
build/
|
24
|
+
*.bridgesupport
|
25
|
+
build-iPhoneOS/
|
26
|
+
build-iPhoneSimulator/
|
27
|
+
|
28
|
+
## Specific to RubyMotion (use of CocoaPods):
|
29
|
+
#
|
30
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
31
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
32
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
33
|
+
#
|
34
|
+
# vendor/Pods/
|
35
|
+
|
36
|
+
## Documentation cache and generated files:
|
37
|
+
/.yardoc/
|
38
|
+
/_yardoc/
|
39
|
+
/doc/
|
40
|
+
/rdoc/
|
41
|
+
|
42
|
+
## Environment normalization:
|
43
|
+
/.bundle/
|
44
|
+
/vendor/bundle
|
45
|
+
/lib/bundler/man/
|
46
|
+
|
47
|
+
# for a library or gem, you might want to ignore these files since the code is
|
48
|
+
# intended to run in multiple environments; otherwise, check them in:
|
49
|
+
# Gemfile.lock
|
50
|
+
# .ruby-version
|
51
|
+
# .ruby-gemset
|
52
|
+
|
53
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
54
|
+
.rvmrc
|
55
|
+
|
56
|
+
### RubyMine ###
|
57
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
58
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
59
|
+
|
60
|
+
# User-specific stuff:
|
61
|
+
.idea/**/workspace.xml
|
62
|
+
.idea/**/tasks.xml
|
63
|
+
.idea/dictionaries
|
64
|
+
|
65
|
+
# Sensitive or high-churn files:
|
66
|
+
.idea/**/dataSources/
|
67
|
+
.idea/**/dataSources.ids
|
68
|
+
.idea/**/dataSources.xml
|
69
|
+
.idea/**/dataSources.local.xml
|
70
|
+
.idea/**/sqlDataSources.xml
|
71
|
+
.idea/**/dynamic.xml
|
72
|
+
.idea/**/uiDesigner.xml
|
73
|
+
|
74
|
+
# Gradle:
|
75
|
+
.idea/**/gradle.xml
|
76
|
+
.idea/**/libraries
|
77
|
+
|
78
|
+
# CMake
|
79
|
+
cmake-build-debug/
|
80
|
+
|
81
|
+
# Mongo Explorer plugin:
|
82
|
+
.idea/**/mongoSettings.xml
|
83
|
+
|
84
|
+
## File-based project format:
|
85
|
+
*.iws
|
86
|
+
|
87
|
+
## Plugin-specific files:
|
88
|
+
|
89
|
+
# IntelliJ
|
90
|
+
/out/
|
91
|
+
|
92
|
+
# mpeltonen/sbt-idea plugin
|
93
|
+
.idea_modules/
|
94
|
+
|
95
|
+
# JIRA plugin
|
96
|
+
atlassian-ide-plugin.xml
|
97
|
+
|
98
|
+
# Cursive Clojure plugin
|
99
|
+
.idea/replstate.xml
|
100
|
+
|
101
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
102
|
+
com_crashlytics_export_strings.xml
|
103
|
+
crashlytics.properties
|
104
|
+
crashlytics-build.properties
|
105
|
+
fabric.properties
|
106
|
+
|
107
|
+
### RubyMine Patch ###
|
108
|
+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
109
|
+
|
110
|
+
# *.iml
|
111
|
+
# modules.xml
|
112
|
+
# .idea/misc.xml
|
113
|
+
# *.ipr
|
114
|
+
|
115
|
+
# Sonarlint plugin
|
116
|
+
.idea/sonarlint
|
117
|
+
|
118
|
+
# End of https://www.gitignore.io/api/ruby,rubymine
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 MOi Solutions
|
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
data/galadriel.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/galadriel/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'galadriel'
|
7
|
+
s.version = Galadriel::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.date = '2017-08-16'
|
10
|
+
s.summary = "Convert parameter array to a hash array"
|
11
|
+
s.description = "Gem for handling parameter arrays."
|
12
|
+
s.authors = ["Paulo McNally"]
|
13
|
+
s.email = 'paulomcnallyz@moi-solutions.com'
|
14
|
+
s.homepage = 'https://github.com/moi-solutions/galadriel'
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.required_ruby_version = '>= 2.1.0'
|
21
|
+
|
22
|
+
s.add_dependency("railties", ">= 4.1.0", "< 5.2")
|
23
|
+
end
|
data/lib/galadriel.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Galadriel
|
4
|
+
|
5
|
+
class << self
|
6
|
+
attr_accessor :hash_array
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse(params_value, debug = false)
|
10
|
+
|
11
|
+
# initialize hash array to array
|
12
|
+
self.hash_array = []
|
13
|
+
|
14
|
+
# to generate hash array
|
15
|
+
create_hash_array(params_value)
|
16
|
+
|
17
|
+
# to assign values to hash array
|
18
|
+
assign_values(params_value)
|
19
|
+
|
20
|
+
show_debug(debug)
|
21
|
+
|
22
|
+
self.hash_array
|
23
|
+
end
|
24
|
+
|
25
|
+
# Assign values to hash array
|
26
|
+
# Require hash array created
|
27
|
+
# Work if value dont is nested value
|
28
|
+
def self.assign_values(hash)
|
29
|
+
hash.each_pair do |key, values|
|
30
|
+
values.each_with_index do |value, index|
|
31
|
+
self.hash_array[index][key.to_sym] = value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create hash array based hash with null values using create_hash
|
37
|
+
def self.create_hash_array(hash)
|
38
|
+
hash.each_pair do |key, values|
|
39
|
+
values.each do |value|
|
40
|
+
self.hash_array.push(create_hash(hash))
|
41
|
+
end
|
42
|
+
break
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Create an has with all keys based params keys
|
47
|
+
def self.create_hash(hash)
|
48
|
+
new_hash = Hash.new
|
49
|
+
hash.each_pair do |key|
|
50
|
+
new_hash[key] = nil
|
51
|
+
end
|
52
|
+
new_hash.symbolize_keys
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.show_debug(show)
|
56
|
+
puts JSON.pretty_generate(self.hash_array) if show
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: galadriel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paulo McNally
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.1.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.2'
|
33
|
+
description: Gem for handling parameter arrays.
|
34
|
+
email: paulomcnallyz@moi-solutions.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- ".gitignore"
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- galadriel.gemspec
|
43
|
+
- lib/galadriel.rb
|
44
|
+
- lib/galadriel/version.rb
|
45
|
+
homepage: https://github.com/moi-solutions/galadriel
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.1.0
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.6.8
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Convert parameter array to a hash array
|
69
|
+
test_files: []
|