ika3 0.2.0 → 0.3.0

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: 3940b718fc2ccc5f0627bda37240d1b80e6349d35f0e139ce50bcdb0a849ceb5
4
+ data.tar.gz: 9497b125ea065ddd1e95e4ee808e36d4ad2f3a231641d38d7d1610f8f10d5af4
5
5
  SHA512:
6
- metadata.gz: bb77522532eaa5fcbcf51575df616066a6dfa7a84404431678786106d4db2162534126763f23bd25e2975ea0c7513cbc1bde16dde1fa3d50dec343d1e6779501
7
- data.tar.gz: e671fb75b51fd41c0afd66999e0f63ad874603ac7780569d8728cc4006ff60585f3c55fc611585c0de08b8b9c94ab8a2ea53ce06d0e0948e759a7c5d212c2b07
6
+ metadata.gz: 2ba30b98a1ead55ae553c399603aa5a83c7dd9b816fb624e7bba77004081f99faa3f83930162d5031f73e4d5633e5af10e95de399e8acf9ff8870e1eb6925300
7
+ data.tar.gz: fb015aaa7b2d88c70595dc5ae778a92d8404e2eb427b53414be65542ad6a967f710977ccab87d88baef9ee0e6dec0b86ffdbbefa754f19ff06ae07f3d8836818
data/.codespellrc ADDED
@@ -0,0 +1,2 @@
1
+ [codespell]
2
+ skip = .gem_rbs_collection,.git
@@ -0,0 +1,3 @@
1
+ {
2
+ "cSpell.words": ["Splatoon"]
3
+ }
data/Gemfile.lock CHANGED
@@ -1,26 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ika3 (0.2.0)
4
+ ika3 (0.3.0)
5
5
  activesupport (>= 5.0.0)
6
- hashie (>= 2.0.5)
6
+ faraday (>= 2.7.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.7)
11
+ activesupport (7.0.4.2)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
15
15
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
16
  ast (2.4.2)
18
- concurrent-ruby (1.1.10)
17
+ concurrent-ruby (1.2.0)
19
18
  csv (3.2.5)
20
19
  diff-lcs (1.5.0)
20
+ faraday (2.7.4)
21
+ faraday-net_http (>= 2.0, < 3.1)
22
+ ruby2_keywords (>= 0.0.4)
23
+ faraday-net_http (3.0.2)
21
24
  ffi (1.15.5)
22
25
  fileutils (1.6.0)
23
- hashie (5.0.0)
24
26
  i18n (1.12.0)
25
27
  concurrent-ruby (~> 1.0)
26
28
  json (2.6.2)
@@ -29,7 +31,7 @@ GEM
29
31
  rb-fsevent (~> 0.10, >= 0.10.3)
30
32
  rb-inotify (~> 0.9, >= 0.9.10)
31
33
  logger (1.5.1)
32
- minitest (5.16.3)
34
+ minitest (5.17.0)
33
35
  parallel (1.22.1)
34
36
  parser (3.1.3.0)
35
37
  ast (~> 2.4.1)
@@ -38,7 +40,7 @@ GEM
38
40
  rb-fsevent (0.11.2)
39
41
  rb-inotify (0.10.1)
40
42
  ffi (~> 1.0)
41
- rbs (2.8.1)
43
+ rbs (2.8.4)
42
44
  rspec (3.12.0)
43
45
  rspec-core (~> 3.12.0)
44
46
  rspec-expectations (~> 3.12.0)
@@ -52,6 +54,7 @@ GEM
52
54
  diff-lcs (>= 1.2.0, < 2.0)
53
55
  rspec-support (~> 3.12.0)
54
56
  rspec-support (3.12.0)
57
+ ruby2_keywords (0.0.5)
55
58
  securerandom (0.2.0)
56
59
  steep (1.3.0)
57
60
  activesupport (>= 5.1)
@@ -74,7 +77,6 @@ GEM
74
77
  tzinfo (2.0.5)
75
78
  concurrent-ruby (~> 1.0)
76
79
  unicode-display_width (2.3.0)
77
- zeitwerk (2.6.6)
78
80
 
79
81
  PLATFORMS
80
82
  x86_64-linux
data/README.md CHANGED
@@ -17,7 +17,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
17
17
  ## Usage
18
18
 
19
19
  ```ruby
20
- reuqire "ika3"
20
+ require "ika3"
21
21
  ```
22
22
 
23
23
  ### Find Weapon data
@@ -44,6 +44,33 @@ splatbombs
44
44
  {:name=>"パブロ", :sub=>"スプラボム", :special=>"メガホンレーザー5.1ch"}]
45
45
  ```
46
46
 
47
+ ### Get Schedule
48
+
49
+ Initialize with your contact information. e.g. Twitter, GitHub, Homepage URL and so on.
50
+
51
+ ```ruby
52
+ ika3_schedule = Ika3::Schedule.new('GitHub@YutaGoto')
53
+ ika3_schedule.bankara_challenge_next
54
+ =>
55
+ {"start_time"=>"2023-02-07T13:00:00+09:00",
56
+ "end_time"=>"2023-02-07T15:00:00+09:00",
57
+ "rule"=>{"key"=>"LOFT", "name"=>"ガチヤグラ"},
58
+ "stages"=>
59
+ [{"id"=>9,
60
+ "name"=>"ヒラメが丘団地",
61
+ "image"=> "https://....."},
62
+ {"id"=>11,
63
+ "name"=>"キンメダイ美術館",
64
+ "image"=> "https://...."}],
65
+ "is_fest"=>false}
66
+ ```
67
+
68
+ ## Note
69
+
70
+ This gem is NOT related to Nintendo.
71
+
72
+ The Schedule is used an unofficial API. <https://spla3.yuu26.com/>
73
+
47
74
  ## Contributing
48
75
 
49
76
  Bug reports and pull requests are welcome on GitHub at https://github.com/YutaGoto/ika3.
data/Steepfile CHANGED
@@ -3,6 +3,5 @@ target :lib do
3
3
 
4
4
  check "lib"
5
5
  repo_path ".gem_rbs_collection"
6
- library "hashie"
7
6
  end
8
7
 
data/ika3.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["YutaGoto"]
9
9
  spec.email = ["you.goto.510@gmail.com"]
10
10
 
11
- spec.summary = "Splatoon3 weapons infomation library."
12
- spec.description = "Splatoon3 weapons infomation library. This gem provide weapon name, sub, and special. not official"
11
+ spec.summary = "Splatoon3 weapons information library."
12
+ spec.description = "Splatoon3 weapons information library. This gem provide weapon name, sub, and special. not official"
13
13
  spec.homepage = "https://github.com/YutaGoto/ika3"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.7.0"
@@ -30,11 +30,8 @@ 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
- spec.add_dependency "hashie", ">= 2.0.5"
35
-
36
- # Uncomment to register a new dependency of your gem
37
- # spec.add_dependency "example-gem", "~> 1.0"
38
35
 
39
36
  # For more information and examples about making a new gem, check out our
40
37
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -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,63 @@
1
+ class Hash
2
+ def method_missing(name)
3
+ return self[name] 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
+ def initialize(contact)
13
+ @contact = contact
14
+ end
15
+
16
+ modes = ["regular", "bankara_challenge", "bankara_open", "x"]
17
+ schedules = ["now", "next"]
18
+
19
+ schedules.each do |schedule|
20
+ modes.each do |mode|
21
+ define_method("#{mode}_#{schedule}".to_sym) do
22
+ return instance_variable_get("@#{mode}_#{schedule}_obj") if instance_variable_defined?("@#{mode}_#{schedule}_obj")
23
+
24
+ instance_variable_set("@#{mode}_#{schedule}_obj", send_request(:get, "/api/#{mode.dasherize}/#{schedule}").body.results[0])
25
+ end
26
+ end
27
+
28
+ define_method("salmon_run_#{schedule}".to_sym) do
29
+ return instance_variable_get("@salmon_run_#{schedule}_obj") if instance_variable_defined?("@salmon_run_#{schedule}_obj")
30
+
31
+ instance_variable_set("@salmon_run_#{schedule}_obj", send_request(:get, "/api/coop-grouping/#{schedule}").body.results[0])
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def send_request(method, path)
38
+ response = splat3_connection.send(method, path)
39
+ Ika3::Response.new(response)
40
+ end
41
+
42
+ def api_url
43
+ "https://spla3.yuu26.com/"
44
+ end
45
+
46
+ def splat3_connection
47
+ @splat3_connection ||= Faraday::new(faraday_options) do |c|
48
+ c.request :json
49
+ c.response :json
50
+ c.adapter Faraday.default_adapter
51
+ end
52
+ end
53
+
54
+ def faraday_options
55
+ {
56
+ url: api_url,
57
+ headers: {
58
+ 'User-Agent': "Ika3Gem/#{Ika3::VERSION}(#{@contact})"
59
+ }
60
+ }
61
+ end
62
+ end
63
+ 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.3.0"
5
5
  end
data/lib/ika3/weapons.rb CHANGED
@@ -1,13 +1,9 @@
1
1
  module Ika3
2
- class Weapon < Hash
3
- include Hashie::Extensions::MethodAccess
4
-
2
+ class Weapon
5
3
  ATTRIBUTES = [
6
4
  :name, :sub, :special
7
5
  ].freeze
8
6
 
9
- attr_accessor :io
10
-
11
7
  ATTRIBUTES.each do |attribute|
12
8
  define_method attribute do
13
9
  self[attribute]
@@ -23,7 +19,7 @@ module Ika3
23
19
  @cache ||= {}
24
20
  unless @cache[weapon_key]
25
21
  weapon_config = config[weapon_key] || {}
26
- @cache[weapon_key] = Ika3::Weapon[weapon_config].tap {|weapon| weapon.io = $stdout}
22
+ @cache[weapon_key] = weapon_config
27
23
  end
28
24
 
29
25
  @cache[weapon_key]
data/lib/ika3.rb CHANGED
@@ -1,13 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "yaml"
4
- require "hashie"
5
4
 
6
5
  require "active_support/core_ext/hash/keys"
6
+ require "active_support/core_ext/string/inflections"
7
+ require "faraday"
7
8
 
8
9
  require "ika3/version"
9
10
  require "ika3/concerns/utils"
11
+ require "ika3/response"
10
12
  require "ika3/weapons"
13
+ require "ika3/schedule"
11
14
 
12
15
  module Ika3
13
16
  class Error < StandardError; end
@@ -6,34 +6,42 @@ sources:
6
6
  repo_dir: gems
7
7
  path: ".gem_rbs_collection"
8
8
  gems:
9
- - name: hashie
10
- version: '5.0'
9
+ - name: activesupport
10
+ version: '7.0'
11
11
  source:
12
12
  type: git
13
13
  name: ruby/gem_rbs_collection
14
- revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
14
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
15
15
  remote: https://github.com/ruby/gem_rbs_collection.git
16
16
  repo_dir: gems
17
- - name: activesupport
18
- version: '6.0'
17
+ - name: ast
18
+ version: '2.4'
19
19
  source:
20
20
  type: git
21
21
  name: ruby/gem_rbs_collection
22
- revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
22
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
23
23
  remote: https://github.com/ruby/gem_rbs_collection.git
24
24
  repo_dir: gems
25
- - name: ast
26
- version: '2.4'
25
+ - name: concurrent-ruby
26
+ version: '1.1'
27
27
  source:
28
28
  type: git
29
29
  name: ruby/gem_rbs_collection
30
- revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
30
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
31
31
  remote: https://github.com/ruby/gem_rbs_collection.git
32
32
  repo_dir: gems
33
33
  - name: csv
34
34
  version: '0'
35
35
  source:
36
36
  type: stdlib
37
+ - name: faraday
38
+ version: '2.5'
39
+ source:
40
+ type: git
41
+ name: ruby/gem_rbs_collection
42
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
43
+ remote: https://github.com/ruby/gem_rbs_collection.git
44
+ repo_dir: gems
37
45
  - name: fileutils
38
46
  version: '0'
39
47
  source:
@@ -43,13 +51,9 @@ gems:
43
51
  source:
44
52
  type: git
45
53
  name: ruby/gem_rbs_collection
46
- revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
54
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
47
55
  remote: https://github.com/ruby/gem_rbs_collection.git
48
56
  repo_dir: gems
49
- - name: ika3
50
- version: 0.1.0
51
- source:
52
- type: rubygems
53
57
  - name: json
54
58
  version: '0'
55
59
  source:
@@ -59,7 +63,7 @@ gems:
59
63
  source:
60
64
  type: git
61
65
  name: ruby/gem_rbs_collection
62
- revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
66
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
63
67
  remote: https://github.com/ruby/gem_rbs_collection.git
64
68
  repo_dir: gems
65
69
  - name: logger
@@ -75,7 +79,7 @@ gems:
75
79
  source:
76
80
  type: git
77
81
  name: ruby/gem_rbs_collection
78
- revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
82
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
79
83
  remote: https://github.com/ruby/gem_rbs_collection.git
80
84
  repo_dir: gems
81
85
  - name: rainbow
@@ -83,7 +87,7 @@ gems:
83
87
  source:
84
88
  type: git
85
89
  name: ruby/gem_rbs_collection
86
- revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
90
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
87
91
  remote: https://github.com/ruby/gem_rbs_collection.git
88
92
  repo_dir: gems
89
93
  - name: securerandom
@@ -91,26 +95,26 @@ gems:
91
95
  source:
92
96
  type: stdlib
93
97
  - name: steep
94
- version: 1.2.1
98
+ version: 1.3.0
95
99
  source:
96
100
  type: rubygems
97
101
  - name: strscan
98
102
  version: '0'
99
103
  source:
100
104
  type: stdlib
101
- - name: monitor
105
+ - name: date
102
106
  version: '0'
103
107
  source:
104
108
  type: stdlib
105
- - name: date
109
+ - name: monitor
106
110
  version: '0'
107
111
  source:
108
112
  type: stdlib
109
- - name: singleton
113
+ - name: mutex_m
110
114
  version: '0'
111
115
  source:
112
116
  type: stdlib
113
- - name: mutex_m
117
+ - name: singleton
114
118
  version: '0'
115
119
  source:
116
120
  type: stdlib
@@ -118,11 +122,12 @@ gems:
118
122
  version: '0'
119
123
  source:
120
124
  type: stdlib
121
- - name: pathname
125
+ - name: forwardable
122
126
  version: '0'
123
127
  source:
124
128
  type: stdlib
125
- - name: forwardable
129
+ - name: uri
126
130
  version: '0'
127
131
  source:
128
132
  type: stdlib
133
+ gemfile_lock_path: Gemfile.lock
data/rbs_collection.yaml CHANGED
@@ -13,4 +13,3 @@ gems:
13
13
  # It's unnecessary if you don't use rbs as a library.
14
14
  - name: rbs
15
15
  ignore: true
16
- - name: hashie
@@ -0,0 +1,19 @@
1
+ class Hash[unchecked out K, unchecked out V] < Object
2
+ def method_missing: (name: String) -> untyped
3
+ end
4
+
5
+ module Ika3
6
+ class Schedule
7
+ def initialize: (contact: String) -> void
8
+
9
+ private
10
+
11
+ def send_request: (method: String, path: String) -> Object
12
+
13
+ def api_url: () -> "https://spla3.yuu26.com/"
14
+
15
+ def splat3_connection: () -> untyped
16
+
17
+ def faraday_options: () -> { url: String, headers: { :"User-Agent" => ::String } }
18
+ end
19
+ end
data/sig/ika3/weapon.rbs CHANGED
@@ -1,11 +1,7 @@
1
1
  module Ika3
2
- class Weapon < Hash
3
- include Hashie::Extensions::MethodAccess
4
-
2
+ class Weapon
5
3
  ATTRIBUTES: ::Array[:name | :sub | :special]
6
4
 
7
- attr_accessor io: untyped
8
-
9
5
  include Ika3::Concerns::Utils
10
6
 
11
7
  def self.find: (untyped weapon_key) -> untyped
metadata CHANGED
@@ -1,52 +1,54 @@
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.3.0
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-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
14
+ name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: 2.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0
26
+ version: 2.7.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: hashie
28
+ name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.5
33
+ version: 5.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.5
41
- description: Splatoon3 weapons infomation library. This gem provide weapon name, sub,
42
- and special. not official
40
+ version: 5.0.0
41
+ description: Splatoon3 weapons information library. This gem provide weapon name,
42
+ sub, and special. not official
43
43
  email:
44
44
  - you.goto.510@gmail.com
45
45
  executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - ".codespellrc"
49
50
  - ".rspec"
51
+ - ".vscode/settings.json"
50
52
  - Gemfile
51
53
  - Gemfile.lock
52
54
  - LICENSE.txt
@@ -58,12 +60,15 @@ files:
58
60
  - ika3.gemspec
59
61
  - lib/ika3.rb
60
62
  - lib/ika3/concerns/utils.rb
63
+ - lib/ika3/response.rb
64
+ - lib/ika3/schedule.rb
61
65
  - lib/ika3/version.rb
62
66
  - lib/ika3/weapons.rb
63
67
  - rbs_collection.lock.yaml
64
68
  - rbs_collection.yaml
65
69
  - sig/ika3.rbs
66
70
  - sig/ika3/concerns/utils.rbs
71
+ - sig/ika3/schedule.rbs
67
72
  - sig/ika3/weapon.rbs
68
73
  homepage: https://github.com/YutaGoto/ika3
69
74
  licenses:
@@ -71,7 +76,7 @@ licenses:
71
76
  metadata:
72
77
  homepage_uri: https://github.com/YutaGoto/ika3
73
78
  source_code_uri: https://github.com/YutaGoto/ika3
74
- post_install_message:
79
+ post_install_message:
75
80
  rdoc_options: []
76
81
  require_paths:
77
82
  - lib
@@ -86,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
91
  - !ruby/object:Gem::Version
87
92
  version: '0'
88
93
  requirements: []
89
- rubygems_version: 3.3.26
90
- signing_key:
94
+ rubygems_version: 3.4.6
95
+ signing_key:
91
96
  specification_version: 4
92
- summary: Splatoon3 weapons infomation library.
97
+ summary: Splatoon3 weapons information library.
93
98
  test_files: []