ika3 0.2.0 → 0.2.1

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: a572e83ad59f0a82b67fbda676d4b47e791a5189a4fc36473f82678a9fb99ad4
4
- data.tar.gz: 744078f35dfce20ec01dcfead26416e37e5b2c04fd60ab82a5e80b629373454b
3
+ metadata.gz: 010310a4b067b39dfd3c92a4a43fd7b8af48ff9cc5d6f513d73c967df69e14fd
4
+ data.tar.gz: 410d4c6b446c85daf2675d06a611a4b8fc28f1653f62789843f4f8d94f7d18d4
5
5
  SHA512:
6
- metadata.gz: bb77522532eaa5fcbcf51575df616066a6dfa7a84404431678786106d4db2162534126763f23bd25e2975ea0c7513cbc1bde16dde1fa3d50dec343d1e6779501
7
- data.tar.gz: e671fb75b51fd41c0afd66999e0f63ad874603ac7780569d8728cc4006ff60585f3c55fc611585c0de08b8b9c94ab8a2ea53ce06d0e0948e759a7c5d212c2b07
6
+ metadata.gz: 2b13ba634e97b1c8ee57871cce0f6ee57f0373fcf4e552afb4467395e9ff65c5604847da8fba11edb69be7f5b1df0e6a50898f18117198468363fe0aed4eb050
7
+ data.tar.gz: ec349ce079c454f3e059aea4796839a06904e80ad0e1376008baac175e3472478d8dfce9ee3ecebcf4e8591c38e3a5aecbb733e4711e7a2fc48cb1e8532e7908
data/Gemfile.lock CHANGED
@@ -1,23 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ika3 (0.2.0)
4
+ ika3 (0.2.1)
5
5
  activesupport (>= 5.0.0)
6
+ faraday (>= 2.7.0)
6
7
  hashie (>= 2.0.5)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- activesupport (6.1.7)
12
+ activesupport (7.0.4.2)
12
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
14
  i18n (>= 1.6, < 2)
14
15
  minitest (>= 5.1)
15
16
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
17
  ast (2.4.2)
18
- concurrent-ruby (1.1.10)
18
+ concurrent-ruby (1.2.0)
19
19
  csv (3.2.5)
20
20
  diff-lcs (1.5.0)
21
+ faraday (2.7.4)
22
+ faraday-net_http (>= 2.0, < 3.1)
23
+ ruby2_keywords (>= 0.0.4)
24
+ faraday-net_http (3.0.2)
21
25
  ffi (1.15.5)
22
26
  fileutils (1.6.0)
23
27
  hashie (5.0.0)
@@ -29,7 +33,7 @@ GEM
29
33
  rb-fsevent (~> 0.10, >= 0.10.3)
30
34
  rb-inotify (~> 0.9, >= 0.9.10)
31
35
  logger (1.5.1)
32
- minitest (5.16.3)
36
+ minitest (5.17.0)
33
37
  parallel (1.22.1)
34
38
  parser (3.1.3.0)
35
39
  ast (~> 2.4.1)
@@ -38,7 +42,7 @@ GEM
38
42
  rb-fsevent (0.11.2)
39
43
  rb-inotify (0.10.1)
40
44
  ffi (~> 1.0)
41
- rbs (2.8.1)
45
+ rbs (2.8.4)
42
46
  rspec (3.12.0)
43
47
  rspec-core (~> 3.12.0)
44
48
  rspec-expectations (~> 3.12.0)
@@ -52,6 +56,7 @@ GEM
52
56
  diff-lcs (>= 1.2.0, < 2.0)
53
57
  rspec-support (~> 3.12.0)
54
58
  rspec-support (3.12.0)
59
+ ruby2_keywords (0.0.5)
55
60
  securerandom (0.2.0)
56
61
  steep (1.3.0)
57
62
  activesupport (>= 5.1)
@@ -74,7 +79,6 @@ GEM
74
79
  tzinfo (2.0.5)
75
80
  concurrent-ruby (~> 1.0)
76
81
  unicode-display_width (2.3.0)
77
- zeitwerk (2.6.6)
78
82
 
79
83
  PLATFORMS
80
84
  x86_64-linux
data/ika3.gemspec CHANGED
@@ -30,12 +30,10 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
+ spec.add_dependency "faraday", ">= 2.7.0"
33
34
  spec.add_dependency "activesupport", ">= 5.0.0"
34
35
  spec.add_dependency "hashie", ">= 2.0.5"
35
36
 
36
- # Uncomment to register a new dependency of your gem
37
- # spec.add_dependency "example-gem", "~> 1.0"
38
-
39
37
  # For more information and examples about making a new gem, check out our
40
38
  # guide at: https://bundler.io/guides/creating_gem.html
41
39
  end
@@ -0,0 +1,23 @@
1
+ module Ika3
2
+ class Response
3
+ def initialize(faraday_response)
4
+ @raw_body = faraday_response.body
5
+ @raw_headers = faraday_response.headers
6
+ @raw_status = faraday_response.status
7
+ end
8
+
9
+ def body
10
+ @raw_body
11
+ end
12
+
13
+ def headers
14
+ @headers ||= @raw_headers.inject({}) do |result, (key, value)|
15
+ result.merge(key.split("-").map(&:capitalize).join("-") => value)
16
+ end
17
+ end
18
+
19
+ def status
20
+ @raw_status
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,56 @@
1
+ class Hash
2
+ def method_missing(name)
3
+ return self[name].extend Hash if key? name
4
+
5
+ each { |k, v| return v if k.to_s.to_sym == name }
6
+ super.method_missing(name)
7
+ end
8
+ end
9
+
10
+ module Ika3
11
+ class Schedule
12
+ class << self
13
+ modes = ["regular", "bankara_challenge", "bankara_open", "x"]
14
+ schedules = ["now", "next"]
15
+
16
+ schedules.each do |schedule|
17
+ modes.each do |mode|
18
+ define_method("#{mode}_#{schedule}".to_sym) do
19
+ return instance_variable_get("@#{mode}_#{schedule}_obj") if instance_variable_defined?("@#{mode}_#{schedule}_obj")
20
+
21
+ instance_variable_set("@#{mode}_#{schedule}_obj", send_request(:get, "/api/#{mode.dasherize}/#{schedule}").body.results[0])
22
+ end
23
+ end
24
+
25
+ define_method("salmon_run_#{schedule}".to_sym) do
26
+ return instance_variable_get("@salmon_run_#{schedule}_obj") if instance_variable_defined?("@salmon_run_#{schedule}_obj")
27
+
28
+ instance_variable_set("@salmon_run_#{schedule}_obj", send_request(:get, "/api/coop-grouping/#{schedule}").body.results[0])
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def send_request(method, path, params = nil, headers = nil)
35
+ response = splat3_connection.send(method, path, params, headers)
36
+ Ika3::Response.new(response)
37
+ end
38
+
39
+ def api_url
40
+ "https://spla3.yuu26.com/"
41
+ end
42
+
43
+ def splat3_connection
44
+ @splat3_connection ||= Faraday::new(faraday_options) do |c|
45
+ c.request :json
46
+ c.response :json
47
+ c.adapter Faraday.default_adapter
48
+ end
49
+ end
50
+
51
+ def faraday_options
52
+ { url: api_url }
53
+ end
54
+ end
55
+ end
56
+ end
data/lib/ika3/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ika3
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/ika3.rb CHANGED
@@ -4,10 +4,14 @@ require "yaml"
4
4
  require "hashie"
5
5
 
6
6
  require "active_support/core_ext/hash/keys"
7
+ require "active_support/core_ext/string/inflections"
8
+ require "faraday"
7
9
 
8
10
  require "ika3/version"
9
11
  require "ika3/concerns/utils"
12
+ require "ika3/response"
10
13
  require "ika3/weapons"
14
+ require "ika3/schedule"
11
15
 
12
16
  module Ika3
13
17
  class Error < StandardError; end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ika3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - YutaGoto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-11 00:00:00.000000000 Z
11
+ date: 2023-01-27 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.0
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.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activesupport
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +72,8 @@ files:
58
72
  - ika3.gemspec
59
73
  - lib/ika3.rb
60
74
  - lib/ika3/concerns/utils.rb
75
+ - lib/ika3/response.rb
76
+ - lib/ika3/schedule.rb
61
77
  - lib/ika3/version.rb
62
78
  - lib/ika3/weapons.rb
63
79
  - rbs_collection.lock.yaml
@@ -71,7 +87,7 @@ licenses:
71
87
  metadata:
72
88
  homepage_uri: https://github.com/YutaGoto/ika3
73
89
  source_code_uri: https://github.com/YutaGoto/ika3
74
- post_install_message:
90
+ post_install_message:
75
91
  rdoc_options: []
76
92
  require_paths:
77
93
  - lib
@@ -86,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
102
  - !ruby/object:Gem::Version
87
103
  version: '0'
88
104
  requirements: []
89
- rubygems_version: 3.3.26
90
- signing_key:
105
+ rubygems_version: 3.4.3
106
+ signing_key:
91
107
  specification_version: 4
92
108
  summary: Splatoon3 weapons infomation library.
93
109
  test_files: []