pony_breeds 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe1fbb3134c21c7dbb01dfd837470e1cf3bf262cc687f198eb931317ecc9a182
4
- data.tar.gz: 4f937de719c8fbb986acad2df2b3f4177f4b983454309b6042b9589c7c57b957
3
+ metadata.gz: 7c991b91a54fba64f1481f87d154d9c8ecc45963f9b5ccab7c38494e2d5671b8
4
+ data.tar.gz: 752340eec51381762a3dc39b6d5045a4eb2c9c1e0d8f61d2dbb704f8074370c1
5
5
  SHA512:
6
- metadata.gz: 1d49570b7c879ce31d3739fd6116910feab8f310af510c18b7a3321676996bfd27e7fb692de5014de3387c6c9dd9d6f41c17e1687dcfb6f948915aa2a1fee22e
7
- data.tar.gz: e3fb4e637cfd1979634599b8fdf232eab9ed11c419628b260d16d00fd4e1d00770a8bab46a9ae376ea4b455a8d53cb95d7387e8abe8c2b75a9f6f2e1a57c3a33
6
+ metadata.gz: 6b1a928e00eca054f3460e08ad07adaf3ffeca95ffb15e7dfc10950d5b5c6d3b075d4d15fe09486a1ab523a60d804a406c3dfd0e43d74d8c9d87ed6a1a6df5d3
7
+ data.tar.gz: 5398f7b55625cf380ef5532bef1153ffc965c53983a505a44d9bec1201b312e5a9e0c44d7fbc86d60a2151daae2ae2d7b2e8c0907de0929c21ea032d75057dd4
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
+ SuggestExtensions: false
4
+ NewCops: disable
3
5
 
4
6
  # ------------------------------------------------------- Layout -------------------------------------------------------
5
7
 
@@ -26,3 +28,8 @@ Style/ClassAndModuleChildren:
26
28
  Style/StringLiteralsInInterpolation:
27
29
  Enabled: true
28
30
  EnforcedStyle: double_quotes
31
+
32
+ # ------------------------------------------------------- Metrics ------------------------------------------------------
33
+
34
+ Metrics/BlockLength:
35
+ Enabled: false
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- # PonyBreeds
1
+ # PonyBreeds :horse:
2
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/pony_breeds`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ The `pony_breeds` gem provides informations for 76 pony breeds. You can easily integrate the gem
4
+ into your project and use the data coming from it.
4
5
 
5
6
  ## Installation
6
7
 
@@ -20,6 +21,9 @@ Get the pony data by the symbolized JSON key
20
21
  Get the pony data by the actual name of the pony
21
22
  `Pony::Breeds::ReadPonyData.new.get_pony_by_name('Actual Pony Name')`
22
23
 
24
+ Get a random pony data
25
+ `Pony::Breeds::ReadPonyData.new.retrieve_random_pony`
26
+
23
27
  ## Development
24
28
 
25
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.
@@ -28,12 +32,19 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
32
 
29
33
  ## Contributing
30
34
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/napster235/pony_breeds. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/pony_breeds/blob/master/CODE_OF_CONDUCT.md).
35
+ Contributions are welcomed to this project!
36
+ If you have an idea for a new feature or find a bug, please open an issue in this repository.
32
37
 
33
- ## License
38
+ To contribute code to the project, follow these steps:
34
39
 
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+ 1. Fork this repo
41
+ 2. Create a new branch for your changes
42
+ 3. Make the necessary changes and commit them to your branch
43
+ 4. Push your branch to your forked repository
44
+ 5. Open a pull request from your branch to this repository
36
45
 
37
- ## Code of Conduct
46
+ I review your changes and merge them into the project if they are approved.
38
47
 
39
- Everyone interacting in the PonyBreeds project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pony_breeds/blob/master/CODE_OF_CONDUCT.md).
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/lib/breeds.rb CHANGED
@@ -4,6 +4,10 @@ require_relative 'pony/breeds/version'
4
4
 
5
5
  module Pony
6
6
  module Breeds
7
+ AWS_BUCKET_URL = 'https://s3.eu-central-1.amazonaws.com/ponybreeds/pony_breeds.json'
8
+
9
+ private_constant :AWS_BUCKET_URL
10
+
7
11
  class Error < StandardError; end
8
12
  end
9
13
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'json'
4
4
  require 'active_support/core_ext/hash/keys'
5
+ require 'faraday'
6
+ require 'breeds'
5
7
 
6
8
  module Pony
7
9
  module Breeds
@@ -12,7 +14,7 @@ module Pony
12
14
  # @param key [Symbol] the symbolized key used to retrieve data for a specific pony
13
15
  #
14
16
  # @return [Hash] the hash containing the data for the pony
15
- def get_pony_by_key(key)
17
+ def self.get_pony_by_key(key)
16
18
  read_ponies[key.to_sym]
17
19
  end
18
20
 
@@ -21,21 +23,32 @@ module Pony
21
23
  # @param name [String] the actual name of the pony
22
24
  #
23
25
  # @return [Hash] the hash containing the data for the pony
24
- def get_pony_by_name(name)
26
+ def self.get_pony_by_name(name)
27
+ return unless name.is_a?(String)
28
+
25
29
  key = name&.split&.join('_')&.downcase
26
- get_pony_by_key(key.to_sym)
30
+ get_pony_by_key(key)
27
31
  end
28
32
 
29
- private
33
+ # Get data related to a pony by a random JSON key
34
+ #
35
+ # @return [Hash] the hash containing the data for the pony
36
+ def self.retrieve_random_pony
37
+ arr = []
38
+
39
+ read_ponies.each_key { |pony_name| arr << pony_name }
40
+ get_pony_by_key(arr.sample)
41
+ end
30
42
 
31
43
  # Read and parse the JSON file
32
44
  #
33
45
  # @return [Hash] the data from the json file
34
- def read_ponies
35
- file_location = File.dirname(__FILE__)
36
- load_pony_breeds = File.join(file_location, 'pony_breeds.json')
37
- JSON.parse(File.read(load_pony_breeds)).deep_symbolize_keys
46
+ def self.read_ponies
47
+ json_response = Faraday.get(AWS_BUCKET_URL)
48
+ JSON.parse(json_response.body).deep_symbolize_keys
38
49
  end
50
+
51
+ private_class_method :read_ponies
39
52
  end
40
53
  end
41
54
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pony
4
4
  module Breeds
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pony_breeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - napster235
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-27 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '5.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: A small little gem that offers the capability of reading pony breeds.
28
56
  email:
29
57
  - dragomir.tuddor@gmail.com
@@ -34,12 +62,10 @@ files:
34
62
  - ".idea/.gitignore"
35
63
  - ".rspec"
36
64
  - ".rubocop.yml"
37
- - CODE_OF_CONDUCT.md
38
65
  - LICENSE.txt
39
66
  - README.md
40
67
  - Rakefile
41
68
  - lib/breeds.rb
42
- - lib/pony/breeds/pony_breeds.json
43
69
  - lib/pony/breeds/read_pony_data.rb
44
70
  - lib/pony/breeds/version.rb
45
71
  homepage: https://github.com/napster235/pony_breeds
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at Tudor.Dragomir@cerner.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
@@ -1,17 +0,0 @@
1
- {
2
- "american_shetland_pony": {
3
- "name": "American Shetland Pony",
4
- "description": "The American Shetland Pony is an American breed of pony. It derives from the traditional Shetland Pony from the Shetland Isles of Scotland, but as a result of cross-breeding with other horse and pony breeds, is taller and more elegant",
5
- "wiki_url": "https://en.wikipedia.org/wiki/American_Shetland_Pony"
6
- },
7
- "american_walking_pony": {
8
- "name": "American Walking Pony",
9
- "description": "The American Walking Pony is a modern American breed of gaited riding pony. It was created by crossbreeding of the Tennessee Walking Horse and the Welsh Pony.",
10
- "wiki_url": "https://en.wikipedia.org/wiki/American_Walking_Pony"
11
- },
12
- "andalou_pony": {
13
- "name": "Andalou Pony",
14
- "description":"The Anadolu Pony is descended from crosses of Turkoman, Arabian, Persian, Karabakh, Akhal-Teke, Karbada, Deliboz, Mongolian and the ancient Anatolia horse. Some books refer to this small pony as the Native Turkish Pony, or Turk, but Professors Salahattin Batu and M. Nurettin Aral made a distinction in types between the horses in Anatolia as Anadolu and East and Southeast Anadolu.",
15
- "wiki_url": "https://en.wikipedia.org/wiki/Anadolu_Pony"
16
- }
17
- }