warframe 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +5 -0
- data/.yardopts +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +103 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/Rakefile +12 -0
- data/lib/warframe/client_wrapper.rb +36 -0
- data/lib/warframe/models/alert.rb +29 -0
- data/lib/warframe/models/attributes/active.rb +31 -0
- data/lib/warframe/models/attributes/description.rb +14 -0
- data/lib/warframe/models/attributes/eta.rb +14 -0
- data/lib/warframe/models/attributes/expiry.rb +30 -0
- data/lib/warframe/models/attributes/id.rb +14 -0
- data/lib/warframe/models/attributes/reward_types.rb +14 -0
- data/lib/warframe/models/attributes/start_string.rb +14 -0
- data/lib/warframe/models/attributes/translations.rb +18 -0
- data/lib/warframe/models/base.rb +36 -0
- data/lib/warframe/models/global_upgrade.rb +40 -0
- data/lib/warframe/models/invasion.rb +70 -0
- data/lib/warframe/models/news.rb +53 -0
- data/lib/warframe/models/nightwave.rb +39 -0
- data/lib/warframe/rest/api/alerts.rb +23 -0
- data/lib/warframe/rest/api/global_upgrades.rb +23 -0
- data/lib/warframe/rest/api/invasions.rb +23 -0
- data/lib/warframe/rest/api/news.rb +23 -0
- data/lib/warframe/rest/api/nightwave.rb +23 -0
- data/lib/warframe/rest/api.rb +25 -0
- data/lib/warframe/rest/client.rb +42 -0
- data/lib/warframe/rest/request.rb +55 -0
- data/lib/warframe/rest/utils.rb +19 -0
- data/lib/warframe/version.rb +6 -0
- data/lib/warframe.rb +7 -0
- data/warframe.gemspec +46 -0
- metadata +243 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './base'
|
4
|
+
require_relative './attributes/id'
|
5
|
+
require_relative './attributes/expiry'
|
6
|
+
require_relative './attributes/active'
|
7
|
+
require_relative './attributes/eta'
|
8
|
+
require_relative './attributes/description'
|
9
|
+
require_relative './attributes/reward_types'
|
10
|
+
require_relative './attributes/start_string'
|
11
|
+
|
12
|
+
module Warframe
|
13
|
+
module Models
|
14
|
+
# Invasion data model.
|
15
|
+
class Invasion < Warframe::Models::Base
|
16
|
+
include Warframe::Models::Attributes::ID
|
17
|
+
include Warframe::Models::Attributes::Activation
|
18
|
+
include Warframe::Models::Attributes::Expiry
|
19
|
+
include Warframe::Models::Attributes::ETA
|
20
|
+
include Warframe::Models::Attributes::Description
|
21
|
+
include Warframe::Models::Attributes::RewardTypes
|
22
|
+
include Warframe::Models::Attributes::StartString
|
23
|
+
|
24
|
+
# Attacking faction data.
|
25
|
+
# @return [OpenStruct]
|
26
|
+
attr_reader :attacker
|
27
|
+
|
28
|
+
# The rewards for helping the attacking faction.
|
29
|
+
# @return [OpenStruct]
|
30
|
+
attr_reader :attacker_reward
|
31
|
+
|
32
|
+
# Attacking Faction Name
|
33
|
+
# @return [String]
|
34
|
+
attr_reader :attacking_faction
|
35
|
+
|
36
|
+
# Whether or not the invasion has been completed.
|
37
|
+
# @return [Boolean]
|
38
|
+
attr_reader :completed
|
39
|
+
alias completed? completed
|
40
|
+
|
41
|
+
# The status of completion of the invasion.
|
42
|
+
# @return [Array<Float>]
|
43
|
+
attr_reader :completion
|
44
|
+
|
45
|
+
# Defending faction data.
|
46
|
+
# @return [OpenStruct]
|
47
|
+
attr_reader :defender
|
48
|
+
|
49
|
+
# The rewards for helping the defending faction.
|
50
|
+
# @return [OpenStruct]
|
51
|
+
attr_reader :defender_reward
|
52
|
+
|
53
|
+
# The name of the defending faction.
|
54
|
+
# @return [String]
|
55
|
+
attr_reader :defending_faction
|
56
|
+
|
57
|
+
# The name of the node of the invasion.
|
58
|
+
# @return [String]
|
59
|
+
attr_reader :node
|
60
|
+
|
61
|
+
# The key of the node.
|
62
|
+
# @return [String]
|
63
|
+
attr_reader :node_key
|
64
|
+
|
65
|
+
# The amount of runs required for completion.
|
66
|
+
# @return [Integer]
|
67
|
+
attr_reader :required_runs
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './base'
|
4
|
+
require_relative './attributes/translations'
|
5
|
+
require_relative './attributes/eta'
|
6
|
+
require_relative './attributes/id'
|
7
|
+
|
8
|
+
module Warframe
|
9
|
+
module Models
|
10
|
+
# Model for the response of {https://api.warframestat.us/pc/news /:platform/news}
|
11
|
+
class News < Warframe::Models::Base
|
12
|
+
include Warframe::Models::Attributes::Translations
|
13
|
+
include Warframe::Models::Attributes::ETA
|
14
|
+
include Warframe::Models::Attributes::ID
|
15
|
+
|
16
|
+
# The date the news was released.
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :date
|
19
|
+
|
20
|
+
# The image link from the news page.
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :image_link
|
23
|
+
|
24
|
+
# Link for more information on this news.
|
25
|
+
# @return [String]
|
26
|
+
attr_reader :link
|
27
|
+
|
28
|
+
# Whether or not the news has to do with Prime Access.
|
29
|
+
# @return [Boolean]
|
30
|
+
attr_reader :prime_access
|
31
|
+
alias prime_access? prime_access
|
32
|
+
|
33
|
+
# Whether or not a DEV stream is available.
|
34
|
+
# @return [Boolean]
|
35
|
+
attr_reader :stream
|
36
|
+
alias stream? stream
|
37
|
+
|
38
|
+
# Whether or not this news is regarding an update.
|
39
|
+
# @return [Boolean]
|
40
|
+
attr_reader :update
|
41
|
+
alias update? update
|
42
|
+
|
43
|
+
# Whether or not this news is of priority.
|
44
|
+
# @return [Boolean]
|
45
|
+
attr_reader :priority
|
46
|
+
alias priority? priority
|
47
|
+
|
48
|
+
# The entire response as a long string.
|
49
|
+
# @return [String]
|
50
|
+
attr_reader :as_string
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './base'
|
4
|
+
require_relative './attributes/active'
|
5
|
+
require_relative './attributes/id'
|
6
|
+
require_relative './attributes/expiry'
|
7
|
+
require_relative './attributes/reward_types'
|
8
|
+
|
9
|
+
module Warframe
|
10
|
+
module Models
|
11
|
+
# Model for the response of {https://api.warframestat.us/pc/nightwave /:platform/nightwave}
|
12
|
+
class Nightwave < Warframe::Models::Base
|
13
|
+
include Warframe::Models::Attributes::Activation
|
14
|
+
include Warframe::Models::Attributes::ID
|
15
|
+
include Warframe::Models::Attributes::Expiry
|
16
|
+
include Warframe::Models::Attributes::RewardTypes
|
17
|
+
|
18
|
+
# The current phase of this event.
|
19
|
+
# @return [Integer]
|
20
|
+
attr_reader :phase
|
21
|
+
|
22
|
+
# The current Nightwave Tag
|
23
|
+
# @return [String]
|
24
|
+
attr_reader :tag
|
25
|
+
|
26
|
+
# The current Nightwave Season
|
27
|
+
# @return [Integer]
|
28
|
+
attr_reader :season
|
29
|
+
|
30
|
+
# List of all possible challenges.
|
31
|
+
# @return [Array<OpenStruct>]
|
32
|
+
attr_reader :possible_challenges
|
33
|
+
|
34
|
+
# Active Challenges for this event.
|
35
|
+
# @return [Array<OpenStruct>]
|
36
|
+
attr_reader :active_challenges
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'warframe/models/alert'
|
4
|
+
require_relative '../utils'
|
5
|
+
|
6
|
+
module Warframe
|
7
|
+
module REST
|
8
|
+
module API
|
9
|
+
# API endpoint for getting information on current Alerts data.
|
10
|
+
#
|
11
|
+
# {https://api.warframestat.us/pc/alerts Example Response}
|
12
|
+
module Alerts
|
13
|
+
include Warframe::REST::Utils
|
14
|
+
|
15
|
+
# Gets the current Alerts data.
|
16
|
+
# @return [Array<[Warframe::Models::Alert]>]
|
17
|
+
def alerts
|
18
|
+
get('/alerts', Warframe::Models::Alert)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'warframe/models/global_upgrade'
|
4
|
+
require_relative '../utils'
|
5
|
+
|
6
|
+
module Warframe
|
7
|
+
module REST
|
8
|
+
module API
|
9
|
+
# API endpoint for getting information on current Global Upgrades data.
|
10
|
+
#
|
11
|
+
# {https://api.warframestat.us/pc/globalUpgrades Example Response}
|
12
|
+
module GlobalUpgrades
|
13
|
+
include Warframe::REST::Utils
|
14
|
+
|
15
|
+
# Gets the current Global Upgrades data.
|
16
|
+
# @return [Array<[Warframe::Models::GlobalUpgrade]>]
|
17
|
+
def global_upgrades
|
18
|
+
get('/globalUpgrades', Warframe::Models::GlobalUpgrade)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'warframe/models/invasion'
|
4
|
+
require_relative '../utils'
|
5
|
+
|
6
|
+
module Warframe
|
7
|
+
module REST
|
8
|
+
module API
|
9
|
+
# API endpoint for getting information on current Invasions data.
|
10
|
+
#
|
11
|
+
# {https://api.warframestat.us/pc/invasions Example Response}
|
12
|
+
module Invasions
|
13
|
+
include Warframe::REST::Utils
|
14
|
+
|
15
|
+
# Gets the current Invasions data.
|
16
|
+
# @return [Array<[Warframe::Models::Invasion]>]
|
17
|
+
def invasions
|
18
|
+
get('/invasions', Warframe::Models::Invasion)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'warframe/models/news'
|
4
|
+
require_relative '../utils'
|
5
|
+
|
6
|
+
module Warframe
|
7
|
+
module REST
|
8
|
+
module API
|
9
|
+
# API endpoint for getting information from the News route.
|
10
|
+
#
|
11
|
+
# {https://api.warframestat.us/pc/news Example Response}
|
12
|
+
module News
|
13
|
+
include Warframe::REST::Utils
|
14
|
+
|
15
|
+
# Gets the current news data.
|
16
|
+
# @return [Array<Warframe::Models::News>]
|
17
|
+
def news
|
18
|
+
get('/news', Warframe::Models::News)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'warframe/models/nightwave'
|
4
|
+
require_relative '../utils'
|
5
|
+
|
6
|
+
module Warframe
|
7
|
+
module REST
|
8
|
+
module API
|
9
|
+
# API endpoint for getting information from the Nightwave route.
|
10
|
+
#
|
11
|
+
# {https://api.warframestat.us/pc/nightwave Example Response}
|
12
|
+
module Nightwave
|
13
|
+
include Warframe::REST::Utils
|
14
|
+
|
15
|
+
# Gets the current Nightwave Mission data.
|
16
|
+
# @return [Warframe::Models::Nightwave]
|
17
|
+
def nightwave
|
18
|
+
get('/nightwave', Warframe::Models::Nightwave)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'api/nightwave'
|
4
|
+
require_relative 'api/news'
|
5
|
+
require_relative 'api/alerts'
|
6
|
+
require_relative 'api/invasions'
|
7
|
+
require_relative 'api/global_upgrades'
|
8
|
+
|
9
|
+
module Warframe
|
10
|
+
# A REST-ful API service, provided by https://api.warframestat.us
|
11
|
+
module REST
|
12
|
+
# The API Router for getting live data.
|
13
|
+
#
|
14
|
+
# Attempting to have every accessible route from {https://docs.warframestat.us Warframe Stat}.
|
15
|
+
#
|
16
|
+
# Module names are 'routes' to this API. See {Warframe::REST::API::Alerts Alerts} for example.
|
17
|
+
module API
|
18
|
+
include Warframe::REST::API::Alerts
|
19
|
+
include Warframe::REST::API::GlobalUpgrades
|
20
|
+
include Warframe::REST::API::Invasions
|
21
|
+
include Warframe::REST::API::News
|
22
|
+
include Warframe::REST::API::Nightwave
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'warframe/client_wrapper'
|
4
|
+
require_relative './api'
|
5
|
+
|
6
|
+
module Warframe
|
7
|
+
module REST
|
8
|
+
# The main application Client for access live feed data.
|
9
|
+
#
|
10
|
+
# == Example Usage
|
11
|
+
#
|
12
|
+
# client = Warframe::REST::Client.new
|
13
|
+
# client.nightwave.tag # => 'Radio Legion Intermission'
|
14
|
+
#
|
15
|
+
# == Accepted Platforms
|
16
|
+
#
|
17
|
+
# default = 'pc'
|
18
|
+
# all_platorms = [ 'pc', 'ps4', 'xb1', 'swi' ]
|
19
|
+
#
|
20
|
+
# client = Waframe::REST::Client.new(platform: 'ps4')
|
21
|
+
# client.platform # => 'ps4'
|
22
|
+
# client.language # => 'en'
|
23
|
+
#
|
24
|
+
# == Accepted Languages
|
25
|
+
#
|
26
|
+
# default = 'en'
|
27
|
+
# all_languages = [ 'de', 'es', 'en', 'fr', 'it', 'ko', 'pl', 'pt', 'ru', 'zh' ]
|
28
|
+
#
|
29
|
+
# client = Warframe::REST::Client.new(language: 'fr')
|
30
|
+
# client.language # => 'fr'
|
31
|
+
# client.platform # => 'pc'
|
32
|
+
#
|
33
|
+
# == Setting both Platform and Language
|
34
|
+
#
|
35
|
+
# client = Warframe::REST::Client.new(platform: 'ps4', language: 'de')
|
36
|
+
# client.platform # => 'ps4'
|
37
|
+
# client.language # => 'de'
|
38
|
+
class Client < Warframe::ClientWrapper
|
39
|
+
include Warframe::REST::API
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Warframe
|
7
|
+
module REST
|
8
|
+
# A request to send to the Warframe Stat API.
|
9
|
+
class Request
|
10
|
+
# @return [Warframe::REST::Client]
|
11
|
+
attr_reader :client
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
attr_reader :path
|
15
|
+
|
16
|
+
# Instantiate a Request
|
17
|
+
#
|
18
|
+
# @param client [Warframe::REST::Client]
|
19
|
+
# @param path [String]
|
20
|
+
# @param klass [Warframe::Models]
|
21
|
+
# @return [Warframe:REST:Request]
|
22
|
+
def initialize(client, path, klass)
|
23
|
+
@client = client
|
24
|
+
@path = client.base_url + path + "?language=#{@client.language}"
|
25
|
+
@klass = klass
|
26
|
+
end
|
27
|
+
|
28
|
+
# Sends an HTTP request with the attached parameters and headers.
|
29
|
+
# Will either return the Model, or collection of Models.
|
30
|
+
# @return [Warframe::Models, Array<[Warframe::Models]>]
|
31
|
+
def send
|
32
|
+
uri = URI(path)
|
33
|
+
req = Net::HTTP::Get.new(uri)
|
34
|
+
return_parsed get_response uri, req
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# Returns the parsed JSON response in the form of a [Warframe::Models] or an array of [Warframe::Models]
|
40
|
+
# @param resp [Net::HTTP.get]
|
41
|
+
# @return [Warframe::Models, Array<[Warframe::Models]>]
|
42
|
+
def return_parsed(resp)
|
43
|
+
parsed = JSON.parse(resp)
|
44
|
+
@klass.new parsed
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_response(uri, req)
|
48
|
+
Net::HTTP.get(uri) do |http|
|
49
|
+
http.use_ssl = true
|
50
|
+
http.request req
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './request'
|
4
|
+
|
5
|
+
module Warframe
|
6
|
+
module REST
|
7
|
+
# Private REST Utilities
|
8
|
+
module Utils
|
9
|
+
private
|
10
|
+
|
11
|
+
# Performs a get operation on the requested path, and returns a mapped response of the requested model.
|
12
|
+
# @param path [String]
|
13
|
+
# @param klass [Warframe::Models]
|
14
|
+
def get(path, klass)
|
15
|
+
Warframe::REST::Request.new(@client || self, path, klass).send
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/warframe.rb
ADDED
data/warframe.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/warframe/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
# Required
|
7
|
+
spec.name = 'warframe'
|
8
|
+
spec.version = Warframe::VERSION
|
9
|
+
spec.authors = ['A.J. Romaniello']
|
10
|
+
|
11
|
+
# Descriptive
|
12
|
+
spec.summary = 'A Ruby interface to the WarframeStat API.'
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.homepage = 'https://github.com/aj-rom/warframe-ruby'
|
16
|
+
|
17
|
+
# MetaData
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/aj-rom/warframe-ruby'
|
19
|
+
spec.metadata['bug_tracker_uri'] = "#{spec.metadata['source_code_uri']}/issues"
|
20
|
+
spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}"
|
21
|
+
|
22
|
+
# Executables / Files
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# Dependencies
|
36
|
+
spec.required_ruby_version = '>= 2.5.0'
|
37
|
+
spec.add_dependency 'fast_underscore', '~> 0.3.2'
|
38
|
+
spec.add_dependency 'http', '~> 5.0', '>= 5.0.4'
|
39
|
+
spec.add_dependency 'json', '~> 2.6', '>= 2.6.1'
|
40
|
+
spec.add_development_dependency 'activesupport', '~> 5.0', '>= 5.0.0.1'
|
41
|
+
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.2.31'
|
42
|
+
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
43
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
44
|
+
spec.add_development_dependency 'rubocop', '~> 1.22', '>= 1.22.3'
|
45
|
+
spec.add_development_dependency 'yard', '~> 0.9.26'
|
46
|
+
end
|