source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
capistrano-systemd-multiservice.gemspec
Ruby
mit
46
master
1,175
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'capistrano/systemd/multiservice/version' Gem::Specification.new do |spec| spec.name = "capistrano-systemd-multiservice" spec.version = Capistrano::Systemd::MultiService::VERSIO...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
lib/capistrano/tasks/systemd/multiservice/system_service.rake
Ruby
mit
46
master
1,160
# This trick lets us access the Capistrano::Systemd::MultiService plugin within `on` blocks svc = self namespace :systemd do namespace svc.nsp do { setup: "Setup %{app} systemd unit file", remove: "Remove %{app} systemd unit file", validate: "Validate %{...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
lib/capistrano/systemd/multiservice.rb
Ruby
mit
46
master
671
require "capistrano/systemd/multiservice/version" require "capistrano/systemd/multiservice/system_service" require "capistrano/systemd/multiservice/user_service" module Capistrano module Systemd module MultiService SERVICE_TYPES = %w[system user].freeze class ServiceTypeError < RuntimeError; end ...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
lib/capistrano/systemd/multiservice/system_service.rb
Ruby
mit
46
master
3,816
require "erb" require "stringio" require "capistrano/plugin" module Capistrano module Systemd module MultiService class SystemService < ::Capistrano::Plugin attr_reader :app def initialize(app) @app = app super() end def nsp @app.to_sym ...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
lib/capistrano/systemd/multiservice/user_service.rb
Ruby
mit
46
master
596
require_relative './system_service' module Capistrano module Systemd module MultiService class UserService < SystemService def systemctl(*args) args.unshift :systemctl, '--user' backend.execute(*args) end def remove backend.execute :rm, '-f', '--', fet...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/spec_helper.rb
Ruby
mit
46
master
460
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) require "rspec" require "mocha/api" require "capistrano/systemd/multiservice" require "capistrano/systemd/multiservice/system_service" require "capistrano/systemd/multiservice/user_service" RSpec.configure do |config| config.raise_errors_for_deprecations! ...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/multiservice_spec.rb
Ruby
mit
46
master
911
require "spec_helper" describe Capistrano::Systemd::MultiService do it "has a version number" do expect(described_class::VERSION).not_to be nil end describe ".new_service" do context "with 'example' argument" do subject { described_class.new_service('example') } it do expect(subject...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/multiservice/system_service_spec.rb
Ruby
mit
46
master
3,431
require "spec_helper" describe Capistrano::Systemd::MultiService::SystemService do let(:systemd_dir) { "/etc/systemd/system" } let(:systemctl_command) { %i[sudo systemctl] } include_context "setup" context do include_context "with config/systemd/example1.service.erb" describe "#setup" do it "s...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/multiservice/user_service_spec.rb
Ruby
mit
46
master
2,774
require "spec_helper" describe Capistrano::Systemd::MultiService::UserService do let(:systemd_dir) { "/home/user/.config/systemd/user" } let(:systemctl_command) { [:systemctl, "--user"] } include_context "setup" before { env.set :user, "user" } context do include_context "with config/systemd/example1....
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/shared/example1.rb
Ruby
mit
46
master
2,271
RSpec.shared_context "with config/systemd/example1.service.erb" do subject { described_class.new("example1") } before do env.install_plugin subject, load_immediately: true Dir.expects(:[]).with("config/systemd/example1{,@}.*.erb").returns(["config/systemd/example1.service.erb"]).at_most_once end descr...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/shared/example3.rb
Ruby
mit
46
master
2,560
RSpec.shared_context 'with config/systemd/example3@.service.erb' do subject { described_class.new("example3") } before do env.install_plugin subject, load_immediately: true env.set :systemd_example3_instances, ["bar", "baz", "qux"] Dir.expects(:[]).with("config/systemd/example3{,@}.*.erb").returns(["co...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/shared/example2.rb
Ruby
mit
46
master
2,629
RSpec.shared_context "with config/systemd/example2.service.erb, example2@.service.erb" do subject { described_class.new("example2") } before do env.install_plugin subject, load_immediately: true Dir.expects(:[]).with("config/systemd/example2{,@}.*.erb").returns(["config/systemd/example2.service.erb", "conf...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/shared/setup.rb
Ruby
mit
46
master
1,418
RSpec.shared_context "setup" do subject { described_class.new("example") } # This allows us to easily use `set`, `fetch`, etc. in the examples. let(:env){ Capistrano::Configuration.env } # Stub the SSHKit backend so we can set up expectations without the plugin # actually executing any commands. let(:back...
github
groovenauts/capistrano-systemd-multiservice
https://github.com/groovenauts/capistrano-systemd-multiservice
spec/capistrano/systemd/shared/without_config_file.rb
Ruby
mit
46
master
1,909
name = 'without config file' RSpec.shared_examples name do context name do subject { described_class.new("example4") } before do env.install_plugin subject, load_immediately: true env.set :systemd_example4_service, "example4.service" Dir.expects(:[]).with("config/systemd/example4{,@}.*.erb"...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
Rakefile
Ruby
mit
46
master
357
require 'bundler' Bundler::GemHelper.install_tasks namespace :box do desc 'Adds test vagrant box.' task :add do sh 'bundle exec vagrant box add --name vultr ./box/vultr.box' end desc 'Removes testing vagrant box.' task :remove do sh 'bundle exec vagrant box remove vultr' end end require 'cucumber...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
vagrant-vultr.gemspec
Ruby
mit
46
master
837
$LOAD_PATH.push File.expand_path('../lib', __FILE__) Gem::Specification.new do |spec| spec.name = 'vagrant-vultr' spec.version = '0.1.3' spec.author = 'Alex Rodionov' spec.email = 'p0deje@gmail.com' spec.homepage = 'http://github.com/p0deje/vagrant-vultr' spec.summary = 'Vultr ...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr.rb
Ruby
mit
46
master
236
require 'vagrant' require 'vagrant-vultr/action' require 'vagrant-vultr/plugin' module VagrantPlugins module Vultr def self.source_root @source_root ||= Pathname.new(File.expand_path('../../', __FILE__)) end end end
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/provider.rb
Ruby
mit
46
master
1,084
require 'vagrant-vultr/helpers/client' module VagrantPlugins module Vultr class Provider < Vagrant.plugin(2, :provider) include Helpers::Client def initialize(machine) @machine = machine @client = client end def action(name) return unless Action.respond_to?(name)...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action.rb
Ruby
mit
46
master
3,684
require 'vagrant-vultr/action/check_state' require 'vagrant-vultr/action/create' require 'vagrant-vultr/action/destroy' require 'vagrant-vultr/action/power_off' require 'vagrant-vultr/action/power_on' require 'vagrant-vultr/action/reload' require 'vagrant-vultr/action/setup_ssh_key' module VagrantPlugins module Vult...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/config.rb
Ruby
mit
46
master
2,121
module VagrantPlugins module Vultr class Config < Vagrant.plugin(2, :config) attr_accessor :token attr_accessor :region attr_accessor :os attr_accessor :snapshot attr_accessor :plan attr_accessor :enable_ipv6 attr_accessor :enable_private_network attr_accessor :labe...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/plugin.rb
Ruby
mit
46
master
363
module VagrantPlugins module Vultr class Plugin < Vagrant.plugin(2) name 'vagrant-vultr' description 'Plugin allows to use Vultr as provider' config(:vultr, :provider) do require_relative 'config' Config end provider(:vultr) do require_relative 'provider' ...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action/setup_ssh_key.rb
Ruby
mit
46
master
862
require 'vagrant-vultr/helpers/client' module VagrantPlugins module Vultr module Action class SetupSSHKey include Helpers::Client NAME = 'vagrant'.freeze def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger =...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action/power_on.rb
Ruby
mit
46
master
748
require 'vagrant-vultr/helpers/client' module VagrantPlugins module Vultr module Action class PowerOn include Helpers::Client def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::vultr::p...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action/power_off.rb
Ruby
mit
46
master
522
require 'vagrant-vultr/helpers/client' module VagrantPlugins module Vultr module Action class PowerOff include Helpers::Client def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::vultr::...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action/reload.rb
Ruby
mit
46
master
791
require 'vagrant-vultr/helpers/client' module VagrantPlugins module Vultr module Action class Reload include Helpers::Client def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::vultr::re...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action/destroy.rb
Ruby
mit
46
master
665
require 'vagrant-vultr/helpers/client' module VagrantPlugins module Vultr module Action class Destroy include Helpers::Client def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::vultr::d...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action/create.rb
Ruby
mit
46
master
2,302
require 'vagrant-vultr/helpers/client' module VagrantPlugins module Vultr module Action class Create include Helpers::Client def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::vultr::cr...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/action/check_state.rb
Ruby
mit
46
master
453
module VagrantPlugins module Vultr module Action class CheckState def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::vultr::check_state') end def call(env) env[:machine_state] = @machine.state.id...
github
p0deje/vagrant-vultr
https://github.com/p0deje/vagrant-vultr
lib/vagrant-vultr/helpers/client.rb
Ruby
mit
46
master
4,503
require 'vultr' require 'vagrant/util/retryable' module VagrantPlugins module Vultr module Helpers module Client def client @client ||= ApiClient.new(@machine.provider_config.token) end end class ApiClient include Vagrant::Util::Retryable TimeoutErro...
github
railsware/skypekit
https://github.com/railsware/skypekit
skypekit.gemspec
Ruby
mit
46
master
682
# -*- encoding: utf-8 -*- Gem::Specification.new do |gem| gem.authors = ["Andriy Yanko"] gem.email = ["andriy.yanko@gmail.com"] gem.description = %q{Ruby FFI interface to libskypekit C library} gem.summary = %q{Ruby FFI interface to libskypekit C library} gem.homepage = "https://gi...
github
railsware/skypekit
https://github.com/railsware/skypekit
examples/ping_pong.rb
Ruby
mit
46
master
745
require "skypekit" $skype = Skypekit::Skype.new(:keyfile => ENV['SK_KEY']) $skype.start $skype.login(ENV['SK_USER'], ENV['SK_PASS']) def terminate puts "Terminating" $skype.stop exit end trap('INT') do terminate end loop do event = $skype.get_event unless event sleep 5 next end case event....
github
railsware/skypekit
https://github.com/railsware/skypekit
lib/skypekit.rb
Ruby
mit
46
master
232
# # Copyright (c) 2012 Railsware (www.railsware.com) # require "ffi" require "skypekit/ffi" require "skypekit/ffi/event" require "skypekit/ffi/account_status_data" require "skypekit/ffi/chat_message_data" require "skypekit/skype"
github
railsware/skypekit
https://github.com/railsware/skypekit
lib/skypekit/ffi.rb
Ruby
mit
46
master
3,770
# # Copyright (c) 2012 Railsware (www.railsware.com) # module Skypekit module FFI extend ::FFI::Library # # @see https://github.com/railsware/libskypekit/blob/master/include/skypekit.h # #ffi_lib File.expand_path("../../../../libskypekit/lib/libskypekit.so", __FILE__) ffi_lib "skypekit" ...
github
railsware/skypekit
https://github.com/railsware/skypekit
lib/skypekit/skype.rb
Ruby
mit
46
master
1,295
# # Copyright (c) 2012 Railsware (www.railsware.com) # module Skypekit class Skype def self.release(pointer) Skypekit::FFI.skypekit_skype_free(pointer) end def initialize(options = {}) @keyfile = options[:keyfile] || "skypekit.pem" @host = options[:host] || "127.0.0.1" @port ...
github
railsware/skypekit
https://github.com/railsware/skypekit
lib/skypekit/ffi/chat_message_data.rb
Ruby
mit
46
master
907
# # Copyright (c) 2012 Railsware (www.railsware.com) # module Skypekit module FFI class ChatMessageData < ::FFI::Struct layout \ :convo_id, :string, :convo_guid, :string, :author, :string, :author_displayname, :string, :body_xml, :string, :timestamp, :time_t, ...
github
railsware/skypekit
https://github.com/railsware/skypekit
lib/skypekit/ffi/event.rb
Ruby
mit
46
master
963
# # Copyright (c) 2012 Railsware (www.railsware.com) # module Skypekit module FFI class Event < ::FFI::ManagedStruct def self.release(pointer) FFI.skypekit_event_free(pointer) end layout \ :type, FFI::EventType, :timestamp, :time_t, :data, :pointer, :nex...
github
railsware/skypekit
https://github.com/railsware/skypekit
lib/skypekit/ffi/account_status_data.rb
Ruby
mit
46
master
705
# # Copyright (c) 2012 Railsware (www.railsware.com) # module Skypekit module FFI class AccountStatusData < ::FFI::Struct layout \ :status, FFI::AccountStatusType, :reason, FFI::AccountLogoutReasonType, :skypename, :string, :payload, :pointer def status self[:s...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
Rakefile
Ruby
mit
46
master
5,463
require "pathname" require "fileutils" require "date" class Date # Default inspect is just really stupid def inspect "Date.new(#{year}, #{month}, #{day})" end def to_s "%04d.%d.%d" % [year, month, day] end end def trash(*paths) paths.each do |path| next unless Pathname(path).exist? system...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus_building_bonus.rb
Ruby
mit
46
master
5,367
class FocusBuildingBonus attr_reader :tooltip, :reward def initialize(type, number, flag=nil) @tooltip = [] @reward = [] @type = type @number = number @flag = flag case @type when "arms_factory", "industrial_complex" add_regular_building! when "dockyard" add_dockyard! ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus_tree.rb
Ruby
mit
46
master
747
class FocusTree attr_reader :focuses def initialize(name, tag, focuses) @name = name @tag = tag @focuses = focuses end def self.[](name) @repo ||= {} @repo[name] end def self.[]=(name, val) @repo ||= {} @repo[name] = val end def focus_tree_id @name.downcase.gsub(" ", "...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/simple_terrain_map_mod.rb
Ruby
mit
46
master
6,247
require_relative "../lib/paradox" require_relative "../lib/paradox_mod_builder" class Image def initialize(builder, name) @name = name @builder = builder @data = @builder.resolve("map/#{name}").open("rb", &:read) @pixel_offset = @data[10,4].unpack("l")[0] @bits_per_pixel = @data[0x1c, 2].unpack("...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus_research_bonus.rb
Ruby
mit
46
master
3,144
class FocusResearchBonus def initialize(focus_name, bonus_name, uses: 1, bonus: nil, ahead: nil) raise "Must have some bonus for #{focus_name}" unless bonus or ahead @uses = uses @bonus = bonus @ahead = ahead @bonus_name = bonus_name.to_s @technologies = [] @categories = [] case @bon...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus_icon.rb
Ruby
mit
46
master
993
class FocusIcon attr_reader :icon def initialize(focus_name, icon_name) @icon = case icon_name when *%W[ air_bomber air_doctrine air_fighter air_naval_bomber army_artillery army_artillery2 army_doctrines army_motorized army_tanks build_navy b...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus.rb
Ruby
mit
46
master
984
class Focus attr_reader :id, :name def initialize(name, id, x:, y:, reward:, prerequisites:, icon:, mutually_exclusive:, available:, bypass:, ai:, tooltip:) @name = name @id = id @x = x @y = y @available = available @reward = reward @tooltip = tooltip @prerequisites = prerequisites ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus_tree_builder.rb
Ruby
mit
46
master
404
class FocusTreeBuilder def initialize(name, tag, &block) @name = name @tag = tag @focuses = [] instance_eval(&block) end def focus(*args, &block) @focuses << FocusBuilder.new(@tag, *args, &block).build end def build FocusTree.new(@name, @tag, @focuses) end end def focus_tree(name,...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus_builder.rb
Ruby
mit
46
master
3,620
class FocusBuilder def initialize(prefix, name, icon:, x:, y:, &block) @prefix = prefix @name = name @x = x @y = y @icon = FocusIcon.new(name, icon).icon @available = nil @prerequisites = [] @mutually_exclusive = [] @reward = PropertyList[] @tooltip = PropertyList[] @bypass...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4/focus_trees/generic.rb
Ruby
mit
46
master
6,077
# This reimplements Generic Focus tree just to test the DSL focus_tree "Generic 2", "SWE" do focus "Army Effort", x: 1, y: 0, icon: "infantry" do army_xp 5 research_bonus :land_doc, bonus: 0.5 end focus "Equipment Effort", x: 0, y: 1, icon: "small_arms" do req "Army Effort" research_bonus :infant...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
ck2/character.rb
Ruby
mit
46
master
1,367
class Character attr_reader :id, :node, :father, :mother, :dynasty, :spouses attr_reader :children, :titles def initialize(id, node) @id = id @node = node @children = [] @titles = [] end def link! @father = Character[@node["fat"]] @mother = Character[@node["mot"]] @father.children...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
ck2/title.rb
Ruby
mit
46
master
958
class Title attr_reader :id, :node, :liege, :holder, :vassals def initialize(id, node) @id = id @node = node @vassals = [] end def to_s @node["name"] || @id end def inspect "Title<#{to_s}>" end def tier unless @tier t = %W[b c d k e].index(@id[0]) if t @ti...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
ck2/dynasty.rb
Ruby
mit
46
master
428
class Dynasty attr_reader :node, :name, :culture, :religion def initialize(node) @node = node @name = node["name"] @culture = node["culture"] @religion = node["religion"] end def to_s "#{name}" end class << self def each(&block) @db.each(&block) end def [](id) ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
ck2/ck2_analyses.rb
Ruby
mit
46
master
7,945
require "set" require_relative "character" require_relative "dynasty" require_relative "title" require_relative "../lib/paradox" module Ck2Analyses def default_map @default_map ||= parse("map/default.map") end def land_province_ids @land_province_ids ||= begin (1...default_map["max_provinces"]).to...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
ck2_modpack_tianxia/Rakefile
Ruby
mit
46
master
8,260
require "pathname" require "pathname-glob" require "pry" require "shellwords" # Explicit include list @included_mods = [ # # UI only # "!bigger_lists", # this is expected conflict with arumbamodpack but I don"t want to complicate things # "animeportraits", # "biggerinterface", # in arumbamodpack "blueduke", ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
test/multi_range_test.rb
Ruby
mit
46
master
2,280
require_relative "test_helper" class MultiRangeTest < MiniTest::Test def test_init assert_equal [], MultiRange.new().to_ranges assert_equal [], MultiRange.new(2..2).to_ranges assert_equal [2..3], MultiRange.new(2..3).to_ranges assert_equal [2..4], MultiRange.new(2..3, 3..4).to_ranges end def tes...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
test/paradox_mod_file_test.rb
Ruby
mit
46
master
10,055
require_relative "test_helper" class ParadoxModFileTest < MiniTest::Test def assert_parse_tree(number, expected) parsed = ParadoxModFile.new(path: "#{__dir__}/sample_#{number}.txt").parse! assert_equal parsed, expected end def test_sample_1 assert_parse_tree 1, PropertyList[ "country_decisions...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
test/date_test.rb
Ruby
mit
46
master
249
require_relative "test_helper" class DateTest < MiniTest::Test def test_to_s assert_equal "1939.9.1", Date.parse("1 Sep 1939").to_s end def test_inspect assert_equal "Date.new(1939, 9, 1)", Date.parse("1 Sep 1939").inspect end end
github
taw/paradox-tools
https://github.com/taw/paradox-tools
test/property_test.rb
Ruby
mit
46
master
1,300
require_relative "test_helper" class PropeltyTest < MiniTest::Test def test_eq a1 = Property["foo", "bar"] a2 = Property["foo", "bar"] b = Property["foo", "fail"] assert_equal a1, a2 refute_equal a1, b end def test_constructors assert_equal Property["NOT", PropertyList["foo", "bar", "hel...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
test/property_list_test.rb
Ruby
mit
46
master
8,000
require_relative "test_helper" class PropeltyListTest < MiniTest::Test def test_to_h str = ParadoxModFile.new(string: " government = merchant_republic mercantilism = 0.25 primary_culture = lombard religion = catholic add_accepted_culture = greek add_accepted_culture = croatian...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
test/paradox_mod_file_serializer_test.rb
Ruby
mit
46
master
3,134
require_relative "test_helper" class ParadoxModFileSerializerTest < MiniTest::Test def assert_reserialization(number, expected) parsed = ParadoxModFile.new(path: "#{__dir__}/sample_#{number}.txt").parse! serialized = ParadoxModFileSerializer.serialize(parsed) assert_equal serialized, expected end de...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
test/fake_yaml_test.rb
Ruby
mit
46
master
3,788
require_relative "test_helper" class MultiRangeTest < MiniTest::Test def sample(name) "#{__dir__}/sample_yaml/#{name}.yml" end # EU4 up to 1.16.x def test_old assert_equal({ "shiva"=>"Shiva", "ganesha"=>"Ganesha", "surya"=>"Surya", "ganga"=>"Ganga", "shakti"=>"Shakti", ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
eu4_idea_explorer/lib/importer.rb
Ruby
mit
46
master
4,491
require "pathname" require "json" require_relative "../../lib/paradox_game" def json_normalize(data) if data.is_a?(Array) data.map do |elem| json_normalize(elem) end elsif data.is_a?(Hash) Hash[data.map{|k,v| [k, json_normalize(v)] }.sort] else data end end class Importer < Par...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
eu4_trade_graph/trade_graph.rb
Ruby
mit
46
master
2,490
require_relative "../lib/paradox_mod_file_serializer" require "rgl/adjacency" require "rgl/connected_components" require "rgl/topsort" class TradeGraph attr_reader :node def initialize(node) @node = node end def nodes @node.keys end def edges result = [] @node.each do |from, trade_node| ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
eu4/partial_evaluator.rb
Ruby
mit
46
master
1,855
class PartialEvaluator def call(node) case node when PropertyList node.map{|x| call(x) } when Property eval_property(node) else node end end private def always_true Property["always", true] end def always_false Property["always", false] end def eval_prop...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_hoi4/ledger/equipment_archetype.rb
Ruby
mit
46
master
1,323
class EquipmentArchetype attr_reader :name def initialize(name) @name = name @equipment = {} @lookup = {} end def add!(equipment, subgroup) @equipment[subgroup] ||= [] @equipment[subgroup] << equipment @lookup[equipment] = [subgroup, @equipment[subgroup].size-1] end def default_lev...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_hoi4/ledger/information_tables.rb
Ruby
mit
46
master
654
class InformationTables def summarize_equipment_table Hash[ @equipment.map do |archetype, details| [@ledger.localization(archetype.name), archetype.format_equipment_details(details)] end.sort ] end def equipment_categories result = {} @equipment.each do |archetype, details| ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_hoi4/ledger/war_information.rb
Ruby
mit
46
master
883
class WarInformation attr_reader :name def initialize(ledger, war) @ledger = ledger @attackers = war["attackers"] @defenders = war["defenders"] @attacker_casualties = 0 @defender_casualties = 0 # Removed in 1.5.0, use ID so at least file names differ @name = war["name"] || war["id"]["id...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_hoi4/ledger/country_information.rb
Ruby
mit
46
master
5,367
class CountryInformation < InformationTables attr_reader :tag, :name attr_reader :divisions, :manpower, :ships, :equipment, :ic, :resources, :research_cost attr_accessor :faction def initialize(ledger, tag, country) @ledger = ledger @tag = tag @original_tag = country["original_tag"] || @tag @res...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_hoi4/ledger/faction_information.rb
Ruby
mit
46
master
1,248
class FactionInformation < InformationTables def initialize(ledger, name) @ledger = ledger @name = name @countries = [] @resources = Hash.new(0) @ic = Hash.new(0) @divisions = 0 @manpower = Hash.new(0) @ships = Hash.new(0) @equipment = {} end def add_country!(country) @div...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_hoi4/ledger/equipment.rb
Ruby
mit
46
master
1,094
class Equipment attr_reader :name, :archetype, :cost, :category def initialize(name, archetype, node, archetype_node) @name = name @archetype = archetype @cost = node["build_cost_ic"] || archetype_node["build_cost_ic"] interface_category = node["interface_category"] || archetype_node["interface_cate...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/Rakefile
Ruby
mit
46
master
639
desc "Run tests" task "test" do sh "rspec" end desc "Run importer - Vanilla" task "import" do sh "rescue ./bin/import_data vanilla ~/hoi4" end desc "Run importer - Millennium Dawn" task "import:md" do sh "rescue ./bin/import_data millennium_dawn ~/px/source/MD-1.9.1" end desc "Run importer - Kaiserreich" task ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/spec/division_spec.rb
Ruby
mit
46
master
18,222
describe Division do let(:db) { Database.new("vanilla") } let(:country) { db.country(tech) } # Just lowest level equipment, no bonuses let(:tech_year) { nil } let(:doctrine) { nil } let(:tech) do if tech_year db.techs_up_to(tech_year) else %W[infantry_weapons gw_artillery motorised_infan...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/spec/equipment_spec.rb
Ruby
mit
46
master
1,621
describe Equipment do let(:db) { Database.new("vanilla") } let(:equipment_type) { db.equipment_types[type] } let(:base_equipment) { Equipment.new(db, equipment_type, {}) } let(:variant_equipment) { Equipment.new(db, equipment_type, upgrades) } let(:variant_bonus) { variant_equipment.variant_bonus } let(:act...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/spec/millennium_dawn_spec.rb
Ruby
mit
46
master
307
describe Division do let(:db) { Database.new("millennium_dawn") } it "does not include impossible equipments" do expect(db.equipment_types["CAS_equipment_2"]).to be_nil end it "does not include impossible units" do expect(db.unit_types["heavy_tank_destroyer_brigade"]).to be_nil end end
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/spec/country_spec.rb
Ruby
mit
46
master
6,095
describe Country do let(:db) { Database.new("vanilla") } let(:country) { db.country(tech) } let(:equipment_map) { country.equipment_map.map{|k,v| [k, v.key]}.to_h } let(:available_units) { country.available_units.map(&:key) } describe "no techs" do let(:tech) { [] } it do expect(equipment...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/spec/technology_spec.rb
Ruby
mit
46
master
560
describe Technology do let(:db) { Database.new("vanilla") } it "groups unit bonuses, terrain bonuses, and paths" do expect(db.technology["tech_engineers3"].effects).to eq({ "categories"=>["support_tech", "engineers_tech"], "unit_bonuses" => { "engineer"=>{ "entrenchment"=>2, ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/spec/cli_spec.rb
Ruby
mit
46
master
1,099
describe "CLI" do let(:bin) { Pathname("#{__dir__}/../bin") } it "available_doctrines" do expect(`#{bin}/available_doctrines`).to include "Superior Firepower / Dispersed Support / Shock & Awe" end it "available_units" do expect(`#{bin}/available_units kaiserreich`).to include "Medium SP Artillery [med...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/importer/importer.rb
Ruby
mit
46
master
2,140
require "pathname" require "json" require "memoist" require_relative "../../lib/paradox_game" require_relative "equipment_data" require_relative "equipment_renames" require_relative "technology_data" require_relative "units_data" require_relative "doctrine_data" require_relative "upgrade_data" def jsonify(obj) retur...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/importer/equipment_data.rb
Ruby
mit
46
master
2,195
class EquipmentData extend Memoist def initialize(game) @game = game end def each_equipment @game.glob("common/units/equipment/*.txt").each do |path| node = @game.parse(path) next if node.empty? node["equipments"].each do |name, equipment| yield(name, jsonify(equipment).merge...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/importer/upgrade_data.rb
Ruby
mit
46
master
514
class UpgradeData extend Memoist def initialize(game) @game = game end def each_upgrade @game.glob("common/units/equipment/upgrades/*.txt").each do |path| data = @game.parse(path) next unless data["upgrades"] data["upgrades"].each do |key, upgrade| yield key, jsonify(upgrade)...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/importer/equipment_renames.rb
Ruby
mit
46
master
287
# We assume this is sorted ASCIIbetically and this is generally false # This is a nasty hack EquipmentRenames = { "gw_armored_car_equipment" => "armored_car_equipment_0", "armored_car_at_equipment" => "armored_car_equipment_3", # "gw_tank_equipment" => "light_tank_equipment_1", }
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/importer/technology_data.rb
Ruby
mit
46
master
3,919
class TechnologyData extend Memoist def initialize(game) @game = game end def each_technology @game.glob("common/technologies/*.txt").each do |path| node = @game.parse(path) (node["technologies"] || []).each do |key, tech| next if key =~ /\A@/ and tech.is_a?(Integer) yield(...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/importer/units_data.rb
Ruby
mit
46
master
2,523
class UnitsData def initialize(game) @game = game end def each_unit @game.glob("common/units/*.txt").each do |path| node = @game.parse(path) next if node.empty? node["sub_units"].each do |name, unit| yield(name, jsonify(unit).merge("name" => @game.localization(name))) end ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/importer/doctrine_data.rb
Ruby
mit
46
master
1,731
class DoctrineData extend Memoist def initialize(game) @game = game end memoize def land_doctrine_tech @game.technology.land_doctrines end memoize def dependencies result = [] land_doctrine_tech.each do |k, v| v["leads_to"].each do |vv| result << [k, vv] end end ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/division_designer.rb
Ruby
mit
46
master
1,114
require "json" require "memoist" require "pathname" require_relative "country" require_relative "database" require_relative "division" require_relative "equipment_type" require_relative "equipment" require_relative "technology" require_relative "unit_type" require_relative "unit" module Enumerable def avg return...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/database.rb
Ruby
mit
46
master
2,243
class Database extend Memoist attr_reader :unit_types, :equipment_types, :technology, :doctrines, :upgrades def initialize(mod) path = Database.mod_path_for(mod) db = JSON.parse(path.read) @unit_types = db["units"].map do |name, stats| [name, UnitType.new(name, stats)] end.to_h @equi...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/technology.rb
Ruby
mit
46
master
1,261
class Technology extend Memoist attr_reader :key, :effects def initialize(database, key, effects) @database = database @key = key @effects = effects end def name @effects["name"] end def enable_subunits @effects["enable_subunits"] || [] end def enable_equipments @effects["e...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/division.rb
Ruby
mit
46
master
5,033
class Division extend Memoist def initialize(country, *units) @country = country @units = units end def manpower @units.map(&:manpower).sum end def training_time @units.map(&:training_time).max end def combat_width @units.map(&:combat_width).sum end def hp @units.map(&:h...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/equipment.rb
Ruby
mit
46
master
1,575
class Equipment extend Memoist def initialize(database, equipment_type, upgrades) @database = database @equipment_type = equipment_type @upgrades = upgrades || {} valid_upgrades = (@equipment_type.available_upgrades || {}).keys bad_upgrades = @upgrades.keys - valid_upgrades unless bad_upgr...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/country.rb
Ruby
mit
46
master
2,249
class Country extend Memoist attr_reader :database def initialize(database, technologies) @database = database @technologies = technologies @upgrades = {} end def equipment_map # Making a silly assumption that they're sorted asciibetically # It seems to be right, as they're all X0, X1, ...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/unit.rb
Ruby
mit
46
master
4,493
class Unit extend Memoist attr_reader :unit_type, :missing_equipment def initialize(unit_type, country) @database = country.database @unit_type = unit_type @country = country @equipment = {} @missing_equipment = Set.new @unit_type.equipment.each do |name, count| equipment = @country...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/equipment_type.rb
Ruby
mit
46
master
310
class EquipmentType < OpenStruct def initialize(database, key, stats) @database = database super(stats.merge("key" => key)) end def inspect "EquipmentType<#{key}>" end def available_upgrades return unless upgrades @database.upgrades.select{|k,v| upgrades.include?(k)} end end
github
taw/paradox-tools
https://github.com/taw/paradox-tools
hoi4_division_designer/lib/unit_type.rb
Ruby
mit
46
master
419
class UnitType < OpenStruct def initialize(key, stats) super(stats.merge("key" => key)) end def inspect "Equipment<#{key}>" end def frontline? combat_width != 0 end def special_forces? !!special_forces end def can_be_parachuted? !!can_be_parachuted end def active? !!ac...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
save_game_scripts/save_game.rb
Ruby
mit
46
master
2,619
require "strscan" class Node include Enumerable attr_reader :key, :content def initialize(key, content) @key = key @content = content end def [](key) return nil unless @content.is_a?(Array) @content.each do |n| return n if n.is_a?(Node) and n.key == key end nil end def inspe...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
save_game_scripts/localization.rb
Ruby
mit
46
master
398
warn "This is obsolete API" require_relative "../lib/paradox_game" require "pathname" module Localization class << self attr_accessor :eu4_dir def eu4 @eu4 ||= ParadoxGame.new(@eu4_dir) end def [](key) eu4.localization(key) end end end Localization.eu4_dir = Pathname("#{ENV['HOME'...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_eu4/bonus_scoring.rb
Ruby
mit
46
master
54,877
# It starts with 139 different bonuses, need to filter them down to manageable levels class BonusScoring def initialize(mods={}) @ht = Hash.new(0) mods.each do |k,v| send(k, v) end end def round! @ht.each do |k,v| @ht[k] = v.round(6) if v.is_a?(Float) end end def to_h rou...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
analysis_eu4/eu4_analysis.rb
Ruby
mit
46
master
285
require_relative "../lib/paradox_game" require "set" require "pry" class EU4Analysis < ParadoxGame def self.new_from_argv unless ARGV.size >= 1 STDERR.puts "Usage: #{$0} <root> [<mod1> <mod2> ... ] # non-compressed save only" exit 1 end new(*ARGV) end end
github
taw/paradox-tools
https://github.com/taw/paradox-tools
lib/paradox_mod_file_serializer.rb
Ruby
mit
46
master
2,882
class ParadoxModFileSerializer attr_reader :output def initialize @output = "" @indent = 0 end def line!(str) @output << " " * @indent << str << "\n" end def primitive?(val) case val when TrueClass, FalseClass, Numeric, String, Date, Symbol true else false end en...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
lib/paradox_game.rb
Ruby
mit
46
master
3,756
require "csv" require_relative "fake_yaml" require_relative "paradox_mod_file" class Pathname def glob(pattern) Dir.chdir(self){ Pathname::glob(pattern) } end end class ParadoxGame # Root can be either directory or .mod file (with same name as directory in it) def initialize(*root_paths) raise "At lea...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
lib/paradox.rb
Ruby
mit
46
master
561
require "pp" require "date" require "pathname" require_relative "property" require_relative "property_list" require_relative "paradox_game" require_relative "paradox_mod_file" require_relative "paradox_mod_builder" require_relative "multi_range" class Date # Default inspect is just really stupid def inspect "D...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
lib/property.rb
Ruby
mit
46
master
1,777
class Property attr_reader :key, :val def initialize(key, val) @key = key @val = val end def self.[](key, val) new(key, val) end def eql?(other) other.is_a?(Property) and key == other.key and val == other.val end def hash [self.class, key, val].hash end module OR def self...
github
taw/paradox-tools
https://github.com/taw/paradox-tools
lib/paradox_mod_builder.rb
Ruby
mit
46
master
4,853
require "yaml" require "pathname" require "set" require_relative "paradox_game" require_relative "paradox_mod_file_serializer" require_relative "paradox_game_modification" class ParadoxModBuilder def initialize(game, target) @game = game @target = Pathname(target) @localization = {} end def compare_...