ruby_ufc 0.2.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 +10 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/config/config.yml +2 -0
- data/lib/ruby_ufc.rb +8 -0
- data/lib/ruby_ufc/client.rb +43 -0
- data/lib/ruby_ufc/version.rb +3 -0
- data/ruby_ufc.gemspec +36 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87bdfb49c6c05ca46969b823e5273971d1be4afd
|
4
|
+
data.tar.gz: ad7c6ca48f49d2c1648129c0ab163e47d1f2711c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2dcd60332cf5d9acec4a8b3a2c190eaed5a9b61bdedd116eb66022ff3500f823637f5d28b95e6f483593fe8475a8513f8d0b769a92be5f304c09e2c0c462545
|
7
|
+
data.tar.gz: a9e4ebc2272801552da06f202109ce14883ebdb3ebd348b9ed9f8f918e28569b8bb456bd0eb2b9416614b83321d5b7a66c6dc24a71c441daf76fa877de7a89d2
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Kiriakos Velissariou
|
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,68 @@
|
|
1
|
+
# ruby_ufc
|
2
|
+
|
3
|
+
:warning: :construction: **Under heavy development** :warning: :construction:
|
4
|
+
|
5
|
+
[](https://travis-ci.org/kiriakosv/ruby_ufc)
|
6
|
+
[](https://coveralls.io/github/kiriakosv/ruby_ufc?branch=master)
|
7
|
+
[](https://codeclimate.com/github/kiriakosv/ruby_ufc/maintainability)
|
8
|
+
|
9
|
+
A simple Ruby wrapper to communicate with the UFC API.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'ruby_ufc'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install ruby_ufc
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Description and examples of the supported actions are below. Every action returns an Array of Hashes or an empty Array.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# Instantantiate
|
33
|
+
client = RubyUfc::Client.new
|
34
|
+
|
35
|
+
client.fighters # Returns an Array of Hashes with all the fighters
|
36
|
+
|
37
|
+
client.fighters(first_name: 'Conor') # Returns each fighter whose first name is Conor
|
38
|
+
|
39
|
+
client.fighters(first_name: 'SomeWeirdName') # Returns an empty Array
|
40
|
+
|
41
|
+
client.fighters(unknown_key: 'A value') # Returns an empty Array
|
42
|
+
```
|
43
|
+
|
44
|
+
Every supported action has the same behaviour as the action above. Currently
|
45
|
+
supported actions are:
|
46
|
+
* fighters
|
47
|
+
* octagon_girls
|
48
|
+
* events
|
49
|
+
* news
|
50
|
+
* media
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
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).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
In order to contribute to this project, follow the guidelines below:
|
61
|
+
* Fork the project
|
62
|
+
* Create a feature branch and pull request.
|
63
|
+
* Make your commits atomic and descriptive. You can find a nice guide for Git
|
64
|
+
best practices [here](https://github.com/agis/git-style-guide) .
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruby_ufc"
|
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/ruby_ufc.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUfc
|
4
|
+
# :nodoc:
|
5
|
+
class Client
|
6
|
+
ALLOWED_RESOURCES = %w[fighters octagon_girls events news media].freeze
|
7
|
+
|
8
|
+
attr_reader :base_end_point, :version
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
config_params = YAML.load_file('lib/config/config.yml')
|
12
|
+
@base_end_point = config_params['base_end_point']
|
13
|
+
@version = config_params['version']
|
14
|
+
end
|
15
|
+
|
16
|
+
ALLOWED_RESOURCES.each do |allowed_resource|
|
17
|
+
define_method(allowed_resource) do |args = {}|
|
18
|
+
url = construct_url(allowed_resource)
|
19
|
+
response = get_json_response(url)
|
20
|
+
response if args.empty?
|
21
|
+
filter_by_argument(response, args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def construct_url(name)
|
28
|
+
"#{@base_end_point}/#{@version}/#{name}.json"
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_json_response(url)
|
32
|
+
uri = URI(url)
|
33
|
+
response = Net::HTTP.get(uri)
|
34
|
+
JSON.parse(response)
|
35
|
+
end
|
36
|
+
|
37
|
+
def filter_by_argument(response, args)
|
38
|
+
key = args.keys.first
|
39
|
+
value = args[key]
|
40
|
+
response.select { |ans| ans[key.to_s] == value }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/ruby_ufc.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ruby_ufc/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby_ufc"
|
8
|
+
spec.version = RubyUfc::VERSION
|
9
|
+
spec.authors = ["Kiriakos Velissariou"]
|
10
|
+
spec.email = ["kir.velissariou@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A simple Ruby wrapper to communicate with the UFC API.}
|
13
|
+
spec.homepage = "https://github.com/kiriakosv/ruby_ufc"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
35
|
+
spec.add_development_dependency "coveralls", "~> 0.8"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_ufc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kiriakos Velissariou
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-20 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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- kir.velissariou@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- lib/config/config.yml
|
85
|
+
- lib/ruby_ufc.rb
|
86
|
+
- lib/ruby_ufc/client.rb
|
87
|
+
- lib/ruby_ufc/version.rb
|
88
|
+
- ruby_ufc.gemspec
|
89
|
+
homepage: https://github.com/kiriakosv/ruby_ufc
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata:
|
93
|
+
allowed_push_host: https://rubygems.org/
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.6.11
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: A simple Ruby wrapper to communicate with the UFC API.
|
114
|
+
test_files: []
|