fortnite_experience 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a65e409cd28a2f7ecdcfb86f1d900a8d045257ae02342ea924e056f8aa3479dd
4
+ data.tar.gz: 53d4273b22d69373fd01be14068bfa345d207a1b8328c81b211a4afb4a3e2a1f
5
+ SHA512:
6
+ metadata.gz: 6ce198c8e8e62fd5aba440421c523bb56926c51222ce4582a890f14fe9e14f5cd1d021eb4809390e221a9c6505992635fcf8814d463eb0ef7633d12d0f153fa2
7
+ data.tar.gz: 0fa04040e048004629a1246d234595998ec31eed775fc6870b3d681f1aebf46eaeef6c2a3443ebdb5d3543d376dd2dafaf010ad3285709e9d322d63f84bfdf59
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # gem builds
14
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ Style/Documentation:
4
+ Enabled: false
5
+
6
+ Metrics/LineLength:
7
+ Max: 99
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
@@ -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 francoprud@gmail.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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fortnite_experience.gemspec
4
+ gemspec
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fortnite_experience (0.1.0)
5
+ httparty (~> 0.13.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.1)
13
+ byebug (2.7.0)
14
+ columnize (~> 0.3)
15
+ debugger-linecache (~> 1.2)
16
+ columnize (0.9.0)
17
+ crack (0.4.4)
18
+ debugger-linecache (1.2.0)
19
+ diff-lcs (1.4.4)
20
+ hashdiff (1.0.1)
21
+ httparty (0.13.7)
22
+ json (~> 1.8)
23
+ multi_xml (>= 0.5.2)
24
+ json (1.8.6)
25
+ multi_xml (0.6.0)
26
+ parser (2.7.1.4)
27
+ ast (~> 2.4.1)
28
+ powerpack (0.1.2)
29
+ public_suffix (4.0.6)
30
+ rainbow (2.2.2)
31
+ rake
32
+ rake (11.3.0)
33
+ rspec (3.9.0)
34
+ rspec-core (~> 3.9.0)
35
+ rspec-expectations (~> 3.9.0)
36
+ rspec-mocks (~> 3.9.0)
37
+ rspec-core (3.9.2)
38
+ rspec-support (~> 3.9.3)
39
+ rspec-expectations (3.9.2)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.9.0)
42
+ rspec-mocks (3.9.1)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.9.0)
45
+ rspec-support (3.9.3)
46
+ rubocop (0.42.0)
47
+ parser (>= 2.3.1.1, < 3.0)
48
+ powerpack (~> 0.1)
49
+ rainbow (>= 1.99.1, < 3.0)
50
+ ruby-progressbar (~> 1.7)
51
+ unicode-display_width (~> 1.0, >= 1.0.1)
52
+ ruby-progressbar (1.10.1)
53
+ unicode-display_width (1.7.0)
54
+ webmock (2.3.2)
55
+ addressable (>= 2.3.6)
56
+ crack (>= 0.3.2)
57
+ hashdiff
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ byebug (~> 2.1)
64
+ fortnite_experience!
65
+ rake (~> 11.2, >= 11.2.2)
66
+ rspec (~> 3.5)
67
+ rubocop (~> 0.42.0)
68
+ webmock (~> 2.1)
69
+
70
+ BUNDLED WITH
71
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Franco Prudhomme
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.
@@ -0,0 +1,61 @@
1
+ # FortniteExperience
2
+
3
+ This gem provides a class to group the total experience of the current Fortnite season weekly challenges by Point Of Interest (POI). It uses [FortniteApi.io](https://fortniteapi.io/) API to retrieve the information about POIs and weekly challenges.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fortnite_experience'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fortnite_experience
20
+
21
+ ## Usage
22
+
23
+ To use this gem, you need to be registered at [FortniteApi.io](https://fortniteapi.io/) and have a developer key (`FORTNITE_API_IO_KEY`).
24
+
25
+ ```ruby
26
+ require 'fortnite_experience'
27
+
28
+ # Initialize with a valid FortniteApi.io key
29
+ fortnite_calculator = FortniteExperience::Calculator.new('FORTNITE_API_IO_KEY')
30
+ fortnite_calculator.experience_by_pois #=> { 'CRAGGY CLIFFS' => 50_000, 'CATTY CORNER' => 25_000 }
31
+
32
+ # Initialize with an invalid FortniteApi.io key
33
+ fortnite_calculator = FortniteExperience::Calculator.new('INVALID_KEY')
34
+ fortnite_calculator.experience_by_pois #=> *** FortniteExperience::Services::FortniteAPI::APIKeyNotValidError
35
+ ```
36
+
37
+ ## Development
38
+
39
+ 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.
40
+
41
+ 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).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/francoprud/fortnite_experience. 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/francoprud/fortnite_experience/blob/master/CODE_OF_CONDUCT.md).
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Run rubocop (`bundle exec rubocop Gemfile lib spec`)
51
+ 5. Run rspec (`bundle exec rspec`)
52
+ 6. Push your branch (`git push origin my-new-feature`)
53
+ 7. Create a new Pull Request
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
58
+
59
+ ## Code of Conduct
60
+
61
+ Everyone interacting in the FortniteExperience project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fortnite_experience/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'fortnite_experience'
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ require_relative 'lib/fortnite_experience/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'fortnite_experience'
5
+ spec.version = FortniteExperience::VERSION
6
+ spec.authors = ['prudi']
7
+
8
+ spec.summary = 'Gem that groups by POIs the amount of experience from weekly challenges.'
9
+ spec.description = 'Groups POIs with the xp points from weekly challenges. Use FortniteAPI.io.'
10
+ spec.homepage = 'https://github.com/francoprud/fortnite_experience'
11
+ spec.license = 'MIT'
12
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
13
+
14
+ spec.metadata['homepage_uri'] = spec.homepage
15
+ spec.metadata['source_code_uri'] = 'https://github.com/francoprud/fortnite_experience'
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_development_dependency 'rake', '~> 11.2', '>= 11.2.2'
27
+ spec.add_development_dependency 'rspec', '~> 3.5'
28
+ spec.add_development_dependency 'rubocop', '~> 0.42.0'
29
+ spec.add_development_dependency 'webmock', '~> 2.1'
30
+ spec.add_development_dependency 'byebug', '~> 2.1'
31
+
32
+ spec.add_runtime_dependency 'httparty', '~> 0.13.7'
33
+ end
@@ -0,0 +1,6 @@
1
+ require 'fortnite_experience/services/fortnite_api'
2
+ require 'fortnite_experience/calculator'
3
+ require 'fortnite_experience/version'
4
+
5
+ module FortniteExperience
6
+ end
@@ -0,0 +1,21 @@
1
+ module FortniteExperience
2
+ class Calculator
3
+ def initialize(api_key)
4
+ @api_key = api_key
5
+ end
6
+
7
+ def experience_by_pois
8
+ result = {}
9
+
10
+ Services::FortniteAPI.get_poi_names(@api_key).each do |poi|
11
+ Services::FortniteAPI.get_weekly_challenges(@api_key).each do |challenge|
12
+ if challenge['title'].match?(/#{poi}/i)
13
+ result[poi] = (result[poi] || 0) + challenge['xp']
14
+ end
15
+ end
16
+ end
17
+
18
+ result
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,36 @@
1
+ require 'httparty'
2
+
3
+ module FortniteExperience
4
+ module Services
5
+ class FortniteAPI
6
+ class DailyRequestLimitExceededError < StandardError; end
7
+ class APIKeyNotValidError < StandardError; end
8
+
9
+ BASE_URI = -'https://fortniteapi.io'
10
+ POI_URI = -"#{BASE_URI}/game/poi?lang=en"
11
+ WEEKLY_CHALLENGES_URI = -"#{BASE_URI}/v1/challenges?season=current&lang=en"
12
+
13
+ class << self
14
+ def get_poi_names(api_key)
15
+ response = HTTParty.get(POI_URI, headers: { 'Authorization' => api_key })
16
+ verify(response)
17
+ response.parsed_response['list'].map { |poi| poi['name'] }
18
+ end
19
+
20
+ def get_weekly_challenges(api_key)
21
+ response = HTTParty.get(WEEKLY_CHALLENGES_URI, headers: { 'Authorization' => api_key })
22
+ verify(response)
23
+ response.parsed_response['weeks'].values.map { |week| week['challenges'] }.flatten
24
+ end
25
+
26
+ private
27
+
28
+ def verify(response)
29
+ raise APIKeyNotValidError if response['code'] == 'INVALID_API_KEY'
30
+ # TODO: verify response code for DailyRequestLimitExceededError
31
+ raise DailyRequestLimitExceededError if response['code'] == 'TBD'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module FortniteExperience
2
+ VERSION = -'0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fortnite_experience
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - prudi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '11.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 11.2.2
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '11.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 11.2.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.5'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rubocop
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.42.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.42.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: webmock
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.1'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.1'
75
+ - !ruby/object:Gem::Dependency
76
+ name: byebug
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: httparty
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.13.7
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.13.7
103
+ description: Groups POIs with the xp points from weekly challenges. Use FortniteAPI.io.
104
+ email:
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - ".rubocop.yml"
112
+ - ".travis.yml"
113
+ - CODE_OF_CONDUCT.md
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - LICENSE.txt
117
+ - README.md
118
+ - Rakefile
119
+ - bin/console
120
+ - bin/setup
121
+ - fortnite_experience.gemspec
122
+ - lib/fortnite_experience.rb
123
+ - lib/fortnite_experience/calculator.rb
124
+ - lib/fortnite_experience/services/fortnite_api.rb
125
+ - lib/fortnite_experience/version.rb
126
+ homepage: https://github.com/francoprud/fortnite_experience
127
+ licenses:
128
+ - MIT
129
+ metadata:
130
+ homepage_uri: https://github.com/francoprud/fortnite_experience
131
+ source_code_uri: https://github.com/francoprud/fortnite_experience
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 2.3.0
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubygems_version: 3.1.2
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Gem that groups by POIs the amount of experience from weekly challenges.
151
+ test_files: []