Skip to content

Commit

Permalink
🏷️ add sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
YutaGoto committed Nov 28, 2022
1 parent b25c4ec commit 339e656
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

# rspec failure tracking
.rspec_status

# gem types
.gem_rbs_collection
8 changes: 8 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target :lib do
signature "sig"

check "lib"
repo_path ".gem_rbs_collection"
library "hashie"
end

4 changes: 0 additions & 4 deletions lib/ika3.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# frozen_string_literal: true

require "active_support/core_ext/array/wrap"
require "active_support/core_ext/hash/keys"

require "yaml"
require "hashie"
require "json"

require "ika3/version"
require "ika3/concerns/utils"
Expand Down
10 changes: 5 additions & 5 deletions lib/ika3/weapons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def find(weapon_key)
end

def find_by_name(weapon_name)
raise "unknown weapon: #{weapon_name}" unless weapon_names.values.include?(weapon_name)
raise "unknown weapon: #{weapon_name}" unless weapons.values.include?(weapon_name)

key = weapon_names.key(weapon_name)
key = weapons.key(weapon_name)
find(key)
end

def filter_by_sub(sub_name)
raise "unknown sub weapon: #{sub_name}" unless sub_weapon_names.values.include?(sub_name)
raise "unknown sub weapon: #{sub_name}" unless sub_weapons.values.include?(sub_name)

config.values.filter{|weapon| weapon[:sub] == sub_name}
end
Expand All @@ -56,7 +56,7 @@ def names
config.keys
end

def weapon_names
def weapons
@weapon_hash ||= {}
if @weapon_hash.empty?
config.each do |key, value|
Expand All @@ -66,7 +66,7 @@ def weapon_names
@weapon_hash
end

def sub_weapon_names
def sub_weapons
@sub_weapon_hash ||= {}
if @sub_weapon_hash.empty?
config_sub_weapons.each do |key, value|
Expand Down
128 changes: 128 additions & 0 deletions rbs_collection.lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
sources:
- name: ruby/gem_rbs_collection
remote: https://github.com/ruby/gem_rbs_collection.git
revision: main
repo_dir: gems
path: ".gem_rbs_collection"
gems:
- name: hashie
version: '5.0'
source:
type: git
name: ruby/gem_rbs_collection
revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: activesupport
version: '6.0'
source:
type: git
name: ruby/gem_rbs_collection
revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: ast
version: '2.4'
source:
type: git
name: ruby/gem_rbs_collection
revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: csv
version: '0'
source:
type: stdlib
- name: fileutils
version: '0'
source:
type: stdlib
- name: i18n
version: '1.10'
source:
type: git
name: ruby/gem_rbs_collection
revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: ika3
version: 0.1.0
source:
type: rubygems
- name: json
version: '0'
source:
type: stdlib
- name: listen
version: '3.2'
source:
type: git
name: ruby/gem_rbs_collection
revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: logger
version: '0'
source:
type: stdlib
- name: minitest
version: '0'
source:
type: stdlib
- name: parallel
version: '1.20'
source:
type: git
name: ruby/gem_rbs_collection
revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: rainbow
version: '3.0'
source:
type: git
name: ruby/gem_rbs_collection
revision: 0a45b6d56b0e1b089731f5eb007912a7c36be121
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: securerandom
version: '0'
source:
type: stdlib
- name: steep
version: 1.2.1
source:
type: rubygems
- name: strscan
version: '0'
source:
type: stdlib
- name: monitor
version: '0'
source:
type: stdlib
- name: date
version: '0'
source:
type: stdlib
- name: singleton
version: '0'
source:
type: stdlib
- name: mutex_m
version: '0'
source:
type: stdlib
- name: time
version: '0'
source:
type: stdlib
- name: pathname
version: '0'
source:
type: stdlib
- name: forwardable
version: '0'
source:
type: stdlib
16 changes: 16 additions & 0 deletions rbs_collection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Download sources
sources:
- name: ruby/gem_rbs_collection
remote: https://github.com/ruby/gem_rbs_collection.git
revision: main
repo_dir: gems

# A directory to install the downloaded RBSs
path: .gem_rbs_collection

gems:
# Skip loading rbs gem's RBS.
# It's unnecessary if you don't use rbs as a library.
- name: rbs
ignore: true
- name: hashie
2 changes: 0 additions & 2 deletions sig/ika3.rbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
module Ika3
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
end
7 changes: 7 additions & 0 deletions sig/ika3/concerns/utils.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Ika3
module Concerns
module Utils
def self?.load_yaml_file: (file: String) -> Object
end
end
end
33 changes: 33 additions & 0 deletions sig/ika3/weapon.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Ika3
class Weapon < Hash
include Hashie::Extensions::MethodAccess

ATTRIBUTES: ::Array[:name | :sub | :special]

attr_accessor io: untyped

include Ika3::Concerns::Utils

def self.find: (untyped weapon_key) -> untyped

def self.find_by_name: (untyped weapon_name) -> untyped

def self.filter_by_sub: (untyped sub_name) -> untyped

def self.reload_config!: () -> untyped

private

def self.names: () -> Array[Symbol]

def self.weapons: () -> Array[Object]

def self.sub_weapons: () -> Array[Object]

def self.config: () -> untyped

def self.config_sub_weapons: () -> untyped

def self.valid?: (untyped weapon_key) -> bool
end
end

0 comments on commit 339e656

Please sign in to comment.