yurl 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.aka.yaml +4 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/yurl +3 -0
- data/exe/yurl +3 -0
- data/lib/yurl.rb +4 -0
- data/lib/yurl/aka.rb +75 -0
- data/lib/yurl/api.rb +64 -0
- data/lib/yurl/cli.rb +56 -0
- data/lib/yurl/config.rb +3 -0
- data/lib/yurl/engine.rb +96 -0
- data/lib/yurl/version.rb +3 -0
- data/yurl.gemspec +43 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7642406a5d5ba49452d1094c67596ffa723229cf
|
4
|
+
data.tar.gz: d35ee4c59e422ff37cda92ae99b1d1b9be324302
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9b36788efa2a5f8247271d7d10dcbeaa14f666db081a3c345210d31237eaf329c62183e4ba37cef7cbabae4ce12db34f3c685540fddf67d1e14984e67790a16
|
7
|
+
data.tar.gz: 69c2c9b70861bb13bfae31f77790ba97b4f33317f790428232ba2d94690413b123b508a26e74c1188f106b28e225b710616d0de4c97708119b4bc35745789a4c
|
data/.aka.yaml
ADDED
data/.gitignore
ADDED
data/.rspec
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 abellawal@yahoo.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) 2017 Abel Lawal
|
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,49 @@
|
|
1
|
+
# Yurl
|
2
|
+
|
3
|
+
Welcome to yurl, a ruby gem inspired by a problem and a conversation. The problem - the abundance of YAML files in Rails, Cloud Foundry, Docker and whatever your favorite tool is. I wanted a way to easily access the information in these files, without having to have multiple tabs open in my text editor. After looking at vault.io (way too much overhead) and creating config servers in both Spring and Node-red (boo java && javascript), a conversation with an intern (Thanks Nick T) led me to a much simpler solution (KISS always works). Yurl (Yaml Url) is a command line tool that attempts to mirror the curl/REST interface to query information from YAML files.
|
4
|
+
|
5
|
+
Yurl is both my first ruby gem and open source project of any kind, it was and continues to be a great learning experience. I plan to refactor and implement new features so please excuse the bugs, weird commits and bad code(lol) and feel free to contribute.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'yurl'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install yurl
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Given a directory with yaml file named "info.yaml" with contents:
|
26
|
+
Production:
|
27
|
+
Database:
|
28
|
+
Username: foo
|
29
|
+
password : bar
|
30
|
+
|
31
|
+
Running yurl get --path=<path to directory>/info.yaml "Production/Database/Username" yields "foo"
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
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.
|
36
|
+
|
37
|
+
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).
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yurl. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
46
|
+
|
47
|
+
## Code of Conduct
|
48
|
+
|
49
|
+
Everyone interacting in the Yurl project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/yurl/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'yurl'
|
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/bin/yurl
ADDED
data/exe/yurl
ADDED
data/lib/yurl.rb
ADDED
data/lib/yurl/aka.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# The Class To Handle Adding, Deleting and Modifying AkAs
|
2
|
+
module Yurl
|
3
|
+
# Maybe Change This To A Config Variable
|
4
|
+
AKA_PATH = '.aka.yaml'.freeze
|
5
|
+
class AKA
|
6
|
+
attr_accessor :aka_list
|
7
|
+
def self.init_list(aka_file)
|
8
|
+
unless File.exist?(aka_file)
|
9
|
+
begin
|
10
|
+
file = File.open(aka_file, 'w')
|
11
|
+
file.write('AKA List: "Add Some AKAs"')
|
12
|
+
rescue IOError => e
|
13
|
+
return e.message
|
14
|
+
ensure
|
15
|
+
file.close unless file.nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.load_list(aka_file)
|
22
|
+
return 'Unable To Initalize AKA List' unless AKA.init_list(aka_file) == true
|
23
|
+
yurl_object = Yurl::Engine.load_file(aka_file)
|
24
|
+
return yurl_object unless yurl_object.respond_to?(:has_key?)
|
25
|
+
@aka_list = yurl_object
|
26
|
+
@aka_list
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.check_list(aka_file)
|
30
|
+
return nil unless AKA.load_list(aka_file).respond_to?('each')
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.add(aka_file, aka_elem, path)
|
35
|
+
return 'Error Adding To AKA List - Cannot Load List' unless
|
36
|
+
AKA.check_list(aka_file) == true
|
37
|
+
return "Error - Can't add Non YAML Files To AKA List" unless
|
38
|
+
Yurl::Engine.check_load_params(path) == true
|
39
|
+
return 'Aka Key Already Exists' if @aka_list.key?(aka_elem)
|
40
|
+
@aka_list[aka_elem] = path
|
41
|
+
AKA.save_list(aka_file)
|
42
|
+
"Added AKA - #{aka_elem} with path #{path}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.remove(aka_file, aka_elem)
|
46
|
+
return 'Error Adding To AKA List - Cannot Load List' unless
|
47
|
+
AKA.check_list(aka_file) == true
|
48
|
+
return "Cannot find AKA #{aka_elem} in AKA List" unless
|
49
|
+
@aka_list.key?(aka_elem)
|
50
|
+
@aka_list.delete(aka_elem)
|
51
|
+
AKA.save_list(aka_file)
|
52
|
+
"Deleted AKA - #{aka_elem}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.print_list(aka_file)
|
56
|
+
return 'Error Printing List - Cannot Load List' if
|
57
|
+
AKA.check_list(aka_file).nil?
|
58
|
+
@aka_list
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.save_list(aka_file)
|
62
|
+
File.open(aka_file, 'w') do |file|
|
63
|
+
file.write(Psych.dump(@aka_list))
|
64
|
+
end
|
65
|
+
rescue Exception => e
|
66
|
+
return "Unhandled Exception #{e.class} Occurred"
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.get_aka(aka_file, aka_elem)
|
70
|
+
return 'Error Adding To AKA List - Cannot Load List' unless AKA.check_list(aka_file) == true
|
71
|
+
return "Cannot find AKA #{aka_elem} in AKA List" unless @aka_list.key?(aka_elem.to_s)
|
72
|
+
@aka_list[aka_elem]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/yurl/api.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# The API Class for Yurl
|
2
|
+
# This will be the middle layer that the front end (CLI) calls in order to interact
|
3
|
+
# with the engine and aka.
|
4
|
+
# Options will be passed in order followed by parameters
|
5
|
+
require 'yurl'
|
6
|
+
require_relative 'engine'
|
7
|
+
require_relative 'aka'
|
8
|
+
|
9
|
+
module Yurl
|
10
|
+
class API
|
11
|
+
def self.dump(path, aka, pp, yaml)
|
12
|
+
pp ||= false
|
13
|
+
unless path.nil?
|
14
|
+
yurl_object = Yurl::Engine.load_file(path)
|
15
|
+
return yurl_object unless yurl_object.respond_to?(:has_key?)
|
16
|
+
return Yurl::API.return_yurl(yurl_object, pp)
|
17
|
+
end
|
18
|
+
unless aka.nil?
|
19
|
+
yurl_object = Yurl::Engine.load_file(
|
20
|
+
Yurl::AKA.get_aka(Yurl::AKA_PATH, aka)
|
21
|
+
)
|
22
|
+
return Yurl::API.return_yurl(yurl_object, pp)
|
23
|
+
end
|
24
|
+
return Yurl::API.return_yurl(yaml, pp) unless yaml.nil?
|
25
|
+
'No YAML found for yurl to process'
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get(path, aka, pp, yaml_url)
|
29
|
+
pp ||= false
|
30
|
+
unless path.nil?
|
31
|
+
haystack = Yurl::Engine.load_file(path)
|
32
|
+
return haystack unless haystack.respond_to?(:has_key?)
|
33
|
+
temp = Yurl::Engine.find(yaml_url, haystack)
|
34
|
+
return Yurl::API.return_yurl(temp, pp)
|
35
|
+
end
|
36
|
+
unless aka.nil?
|
37
|
+
haystack = Yurl::Engine.load_file(
|
38
|
+
Yurl::AKA.get_aka(Yurl::AKA_PATH, aka)
|
39
|
+
)
|
40
|
+
return haystack unless haystack.respond_to?(:has_key?)
|
41
|
+
temp = Yurl::Engine.find(yaml_url, haystack)
|
42
|
+
return Yurl::API.return_yurl(temp, pp)
|
43
|
+
end
|
44
|
+
"No Values found at specified location - #{yaml_url}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.list
|
48
|
+
Yurl::AKA.print_list(Yurl::AKA_PATH)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.add(aka, path)
|
52
|
+
Yurl::AKA.add(Yurl::AKA_PATH, aka, path)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.remove(aka)
|
56
|
+
Yurl::AKA.remove(Yurl::AKA_PATH, aka)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.return_yurl(yurl_object, pp)
|
60
|
+
return Yurl::Engine.pretty_print_yaml(yurl_object) if pp == true
|
61
|
+
Yurl::Engine.dump_yaml(yurl_object)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/yurl/cli.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'pp'
|
3
|
+
require_relative 'aka'
|
4
|
+
require_relative 'api'
|
5
|
+
require 'yurl'
|
6
|
+
|
7
|
+
module Yurl
|
8
|
+
class CLI < Thor
|
9
|
+
desc 'hello', 'Writes Hello World At Command Line'
|
10
|
+
def hello
|
11
|
+
puts 'Hello World!!'
|
12
|
+
end
|
13
|
+
|
14
|
+
######################## Engine ############################
|
15
|
+
|
16
|
+
desc 'dump YAML', 'Dumps Yaml Passed To Method'
|
17
|
+
option :path
|
18
|
+
option :aka
|
19
|
+
option :pp, type: :boolean
|
20
|
+
def dump(yaml = nil)
|
21
|
+
puts Yurl::API.dump(options[:path], options[:aka], options[:pp], yaml)
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'searches YAML @ Path/aka for NEEDLE', 'Searches Yaml For a Parameter'
|
25
|
+
option :path
|
26
|
+
option :aka
|
27
|
+
option :pp, type: :boolean
|
28
|
+
def get(needle)
|
29
|
+
puts Yurl::API.get(options[:path], options[:aka], options[:pp], needle)
|
30
|
+
end
|
31
|
+
|
32
|
+
######################### AKA ############################
|
33
|
+
|
34
|
+
desc 'List Everything in AKA', 'Dumps Aka'
|
35
|
+
def list
|
36
|
+
puts Yurl::API.list
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Add AKA and paths', 'Inserts Elements To AKA'
|
40
|
+
def add(aka, path)
|
41
|
+
puts Yurl::API.add(aka, path)
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Remove AKA', 'Removes AKA From AKA List'
|
45
|
+
def remove(aka)
|
46
|
+
puts Yurl::API.remove(aka)
|
47
|
+
end
|
48
|
+
|
49
|
+
######################### CLI ############################
|
50
|
+
|
51
|
+
desc 'List version of yurl gem', 'Lists version'
|
52
|
+
def version
|
53
|
+
puts Yurl::VERSION
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/yurl/config.rb
ADDED
data/lib/yurl/engine.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Class File To Implement Yurl Engine
|
2
|
+
require 'psych'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module Yurl
|
6
|
+
class Engine
|
7
|
+
attr_accessor :secret_ruby, :file_name
|
8
|
+
|
9
|
+
######################################### Instance Variables ##########################################
|
10
|
+
|
11
|
+
# Constructor for Engine Class
|
12
|
+
def initialize(yml_file)
|
13
|
+
@file_name = yml_file
|
14
|
+
@secret_ruby = Engine.load_file(yml_file)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Method To Find Nodes With Specific Values
|
18
|
+
def find(query)
|
19
|
+
query_list = Engine.process_query_string(query)
|
20
|
+
ret = find_nested(query_list)
|
21
|
+
return "Parameter Not Found At Path - #{query}" if ret.nil?
|
22
|
+
ret
|
23
|
+
end
|
24
|
+
|
25
|
+
################################ Class Methods #################################
|
26
|
+
|
27
|
+
# Method to Follow String to Yaml Node.
|
28
|
+
def self.find(needle_string, haystack)
|
29
|
+
query_list = Engine.process_query_string(needle_string)
|
30
|
+
ret_val = Engine.find_nested(query_list, haystack)
|
31
|
+
return "Parameter Not Found At Path - #{needle_string}" if ret_val.nil?
|
32
|
+
ret_val
|
33
|
+
end
|
34
|
+
|
35
|
+
# Method To Follow Array Path To Find Yaml Target
|
36
|
+
def self.find_nested(needle_array, haystack)
|
37
|
+
ret_val = haystack
|
38
|
+
loop do
|
39
|
+
param = needle_array.pop
|
40
|
+
break if ret_val.nil? || param.nil?
|
41
|
+
ret_val = Engine.find_internal(param, ret_val)
|
42
|
+
end
|
43
|
+
ret_val
|
44
|
+
end
|
45
|
+
|
46
|
+
# Method To Check If Param Is A Key In The Array
|
47
|
+
def self.find_internal(param, hash)
|
48
|
+
return nil unless hash.class == Hash && !hash[param].nil?
|
49
|
+
hash[param]
|
50
|
+
end
|
51
|
+
|
52
|
+
# Method to Parse Query List in Query Array
|
53
|
+
def self.process_query_string(needle)
|
54
|
+
query_list = needle.split('/')
|
55
|
+
raise ArgumentError, 'Query String In Wrong Format' unless query_list.respond_to?('each')
|
56
|
+
query_list.reverse
|
57
|
+
end
|
58
|
+
|
59
|
+
# Self File Loader For Engine Class
|
60
|
+
# Need to put in logic about an empty yaml file / non - existent YAML File
|
61
|
+
def self.load_file(yml_file)
|
62
|
+
file_check = Engine.check_load_params(yml_file)
|
63
|
+
return file_check unless file_check == true
|
64
|
+
Psych.parse_file(yml_file).to_ruby
|
65
|
+
end
|
66
|
+
|
67
|
+
# Loading Yaml From Directly Passed Yaml Text
|
68
|
+
def self.load_yaml(yml)
|
69
|
+
raise ArgumentError, 'Attempted To Process Null Object' if yml.nil?
|
70
|
+
ret_val = Psych.parse(yml).to_ruby
|
71
|
+
ret_val
|
72
|
+
end
|
73
|
+
|
74
|
+
# Dump The Yaml File - Yaml to Hash
|
75
|
+
def self.dump_yaml(yaml_hash)
|
76
|
+
yaml_hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# Pretty Print The YAML File - Yaml To String
|
80
|
+
def self.pretty_print_yaml(yaml_hash)
|
81
|
+
yaml_hash.pretty_inspect
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.check_load_params(yml_file)
|
85
|
+
begin
|
86
|
+
raise ArgumentError, 'Attempted To Process Nil File Object' if yml_file.nil?
|
87
|
+
raise ArgumentError, 'Attempted To Process Non YAML File' unless (File.extname(yml_file) == '.yml') || (File.extname(yml_file) == '.yaml')
|
88
|
+
raise IOError, 'Attempted To Process Non-Existent YAML File' unless File.exist?(yml_file)
|
89
|
+
raise ArgumentError, 'Attempted To Process Empty YAML File' if Psych.parse_file(yml_file).to_ruby == false
|
90
|
+
rescue StandardError => e
|
91
|
+
return "Exception raised with message - #{e.message}"
|
92
|
+
end
|
93
|
+
true
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/yurl/version.rb
ADDED
data/yurl.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'yurl/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'yurl'
|
9
|
+
spec.version = Yurl::VERSION
|
10
|
+
spec.authors = ['Abel Lawal']
|
11
|
+
spec.email = ['abellawal@yahoo.com']
|
12
|
+
|
13
|
+
spec.summary = 'An application to query data from a YAML file trying to mirror curl functionality'
|
14
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
15
|
+
spec.homepage = 'https://github.com/abll/yurl'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
# if spec.respond_to?(:metadata)
|
21
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
22
|
+
# else
|
23
|
+
# raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
|
+
# 'public gem pushes.'
|
25
|
+
# end
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
35
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
+
spec.add_development_dependency 'cucumber', '~> 2.4'
|
38
|
+
spec.add_development_dependency 'aruba', '~> 0.4'
|
39
|
+
spec.add_development_dependency 'thor', '~>0.19'
|
40
|
+
|
41
|
+
# Gem Dependencies
|
42
|
+
spec.add_dependency 'psych', '~> 2.2'
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yurl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Abel Lawal
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-28 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.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
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: cucumber
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aruba
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.19'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.19'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: psych
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.2'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.2'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- abellawal@yahoo.com
|
114
|
+
executables:
|
115
|
+
- yurl
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".aka.yaml"
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CODE_OF_CONDUCT.md
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- bin/yurl
|
131
|
+
- exe/yurl
|
132
|
+
- lib/yurl.rb
|
133
|
+
- lib/yurl/aka.rb
|
134
|
+
- lib/yurl/api.rb
|
135
|
+
- lib/yurl/cli.rb
|
136
|
+
- lib/yurl/config.rb
|
137
|
+
- lib/yurl/engine.rb
|
138
|
+
- lib/yurl/version.rb
|
139
|
+
- yurl.gemspec
|
140
|
+
homepage: https://github.com/abll/yurl
|
141
|
+
licenses:
|
142
|
+
- MIT
|
143
|
+
metadata: {}
|
144
|
+
post_install_message:
|
145
|
+
rdoc_options: []
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 2.6.8
|
161
|
+
signing_key:
|
162
|
+
specification_version: 4
|
163
|
+
summary: An application to query data from a YAML file trying to mirror curl functionality
|
164
|
+
test_files: []
|