Skip to content

Commit

Permalink
feat: everything added
Browse files Browse the repository at this point in the history
  • Loading branch information
dysonreturns committed Jan 12, 2024
1 parent 4465299 commit 2713e90
Show file tree
Hide file tree
Showing 98 changed files with 76,362 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .fasterer.yml
@@ -0,0 +1,6 @@
exclude_paths:
- 'spec/**/*.rb'
- 'sorbet/**/*'
- 'exec/**/*'
- 'data/**/*'
- 'bin/**/*'
3 changes: 3 additions & 0 deletions .rspec
@@ -0,0 +1,3 @@
--format documentation
--color
--require spec_helper
23 changes: 22 additions & 1 deletion .standard.yml
@@ -1 +1,22 @@
ruby_version: 3.3
ruby_version: 3.3

ignore: # default: []
- 'data/**/*'
# Testing by hand
- 'outside_*.rb'
- 'test/**/*'
# Auto generated files
- 'lib/sc2ai/protocol/*.rb'
- 'lib/sc2ai/api/ability_id.rb'
- 'lib/sc2ai/api/buff_id.rb'
- 'lib/sc2ai/api/effect_id.rb'
- 'lib/sc2ai/api/tech_tree.rb'
- 'lib/sc2ai/api/tech_tree_data.rb'
- 'lib/sc2ai/api/unit_type_id.rb'
- 'lib/sc2ai/api/upgrade_id.rb'

plugins: # default: []
- standard-custom
- standard-performance


6 changes: 5 additions & 1 deletion Rakefile
@@ -1,6 +1,10 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

require "standard/rake"

task default: :standard
task default: %w[spec standard:fix]
10 changes: 10 additions & 0 deletions bin/download_techtree
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This was used to download updated techtree data. In reality we generate our own now.

# Thanks Burny <3
# https://github.com/BurnySc2/sc2-techtree/blob/develop/data/data.json

require "net/http"
File.write("data/data.json", Net::HTTP.get(URI.parse("https://raw.githubusercontent.com/dysonreturns/sc2-techtree/develop/data/data.json")))
38 changes: 38 additions & 0 deletions bin/extract_proto
@@ -0,0 +1,38 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This command is used to update lib/../protocol/*_pb.rb files, which shouldn't ever happen again.

require "fileutils"

output_path = "lib/"
proto_base_path = "data/"
proto_relative_path = "sc2ai/protocol/"

# Create output dir
FileUtils.mkdir_p output_path

# Fix .proto file paths which result in: require "sc2clientprotocol/"
# Do this by replacing the weird import path prefix "sc2clientprotocol/"
proto_files = Dir.glob("#{proto_base_path}#{proto_relative_path}*.proto")

proto_files.each do |proto_file|
text = File.read(proto_file)
text = text.gsub('import "s2clientprotocol/', "import \"#{proto_relative_path}")
text = text.gsub("package SC2APIProtocol", "package Api")
File.open(proto_file, "w") { |file| file.puts text }
end

puts "extracting ruby..."
cmd = "protoc --proto_path=#{proto_base_path} --ruby_out=#{output_path} #{proto_files.map do |f|
f.partition(proto_base_path).last
end.join(" ")}"
puts cmd
Kernel.exec(cmd)

# puts "extracting rbi..."
# cmd = "protoc --proto_path=#{proto_base_path} --rbi_out=grpc:false:sorbet/rbi #{proto_files.map do |f|
# f.partition(proto_base_path).last
# end.join(" ")}"
# puts cmd
Kernel.exec(cmd)

0 comments on commit 2713e90

Please sign in to comment.