Class: Kosmos::Package

Inherits:
Object
  • Object
show all
Includes:
PackageAttrs, PackageDsl
Defined in:
lib/kosmos/package.rb

Direct Known Subclasses

AIESAerospace, AMOKDynamicsStuffA, Achievements, ActiveTextureManagementAggressive, ActiveTextureManagementBasic, AdvancedAnimator, AdvancedJetEngine, AerojetKerbodyne, AmbientLightAdjustment, AntennaRange, AsmisECLSSMod, AstronomersVisualPackDefault, AstronomersVisualPackHigh, AstronomersVisualPackHigher, AstronomersVisualPackLow, AstronomersVisualPackPushIt, AtmosphericSoundEnhancement, AutoAsparagus, AutoUnlockPartModels, AviationLights, B9Aerospace0235Fix, B9AerospaceModZeroFix, B9AerospacePack, B9IVAExtension, B9S2CockpitExtended2RearSeats, BahaExtraplanetaryParts, BetterAtmospheresHighDef, BetterAtmospheresLowDef, BetterAtmospheresMediumDef, BetterRoveMates, BetterThanStartingManned, BobCatindSovietAmericanPacks, BoltOnMissionProbe, CELSSGreenhouse, Cacteye, CargoTransferBags, CelestialBodyScienceMultiplierEditor, Chatterer, CoffeeIndustriesModularAirliner, ConicsConfigurator, ConnectedLivingSpaceAPI, ConstellationEssentials, CoolRockets, CrossFeedEnabler, CustomAsteroids, DMagicOrbitalScienceProbeandRoverSciencePack, DangIt, DarkMultiPlayer, DavonSupply, DavonThrottleControlsystems, DeadlyReentry, DistantObjectEnhancement, DockingPortAlignmentIndicator, DownUnderAerospacePartySuppliesContinued, ECLSS, EditorExtensions, EditorPartHighlighter, EngineIgnitor, EnhancedNavball, EnvironmentalVisualEnhancementsHighRes, EnvironmentalVisualEnhancementsLowRes, FASA, FASAGeminiAlternateIVA, FerramAerospaceResearch, Firespitter, FlightManagerforReusableStages, FusTekStationParts, Fusebox, GimbalAutoTrim, GingerCorpStockalikeStationHubs, GlowStrips, HGRNewsphericalpodavailable, HabitatPack, HangarExtender, HooliganLabsAirships, HooliganLabsSquidLandingLegs, HooliganLabsSubmarines, HotRockets, HullcamVDS, Hyperedit, ImprovedChaseCamera, InfernalRobotics, KSPInterstellar, KWRocketry, KerbalAlarmClock, KerbalAttachmentSystem, KerbalEngineerRedux, KerbalEngineerReduxPatch, KerbalJointReinforcement, KerbalStockParteXpansion, KethanePack, LaunchCountDown, MechJeb, Mk2CockpitInterior, ModularFuelTanks, ModuleManager, NearFuturePropulsion, NearFuturePropulsionLowDef, NovaPunch, PartCatalog, PlanetaryEditingTools, PreciseNode, ProceduralFairings, RcsBuildAid, RealChute, RemoteTech2, SafeChute, Scansat, ScienceAlert, ServiceCompartmentTubes, SpacePlanePlus, TACFuelBalancer, TACLifeSupport, TextureReplacer, Toolbar, TweakScale, TweakableEverything, VanguardTechnologies, VanguardTechnologiesEVAParachutes, VesselOrbitalInformationalDisplay

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PackageDsl

#merge_directory

Instance Attribute Details

#download_dirObject (readonly)

Returns the value of attribute download_dir.



12
13
14
# File 'lib/kosmos/package.rb', line 12

def download_dir
  @download_dir
end

#ksp_pathObject (readonly)

Returns the value of attribute ksp_path.



12
13
14
# File 'lib/kosmos/package.rb', line 12

def ksp_path
  @ksp_path
end

Class Method Details

.download!Object



43
44
45
# File 'lib/kosmos/package.rb', line 43

def download!
  PackageDownloads.download_package(self)
end

.find(name) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/kosmos/package.rb', line 60

def find(name)
  @@packages.find do |package|
    package.names.any? do |candidate_name|
      normalize_for_find(candidate_name) == normalize_for_find(name)
    end
  end
end

.inherited(package) ⇒ Object

a callback for when a subclass of this class is created



48
49
50
# File 'lib/kosmos/package.rb', line 48

def inherited(package)
  (@@packages ||= []) << package
end

.normalize_for_find(name) ⇒ Object



52
53
54
# File 'lib/kosmos/package.rb', line 52

def normalize_for_find(name)
  name.downcase.gsub(' ', "-")
end

.normalized_titleObject



56
57
58
# File 'lib/kosmos/package.rb', line 56

def normalized_title
  normalize_for_find(title)
end

.search(name) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/kosmos/package.rb', line 68

def search(name)
  @@packages.min_by do |package|
    package.names.map do |candidate_name|
      DamerauLevenshtein.distance(name, candidate_name)
    end.min
  end
end

.unzip!Object



39
40
41
# File 'lib/kosmos/package.rb', line 39

def unzip!
  PackageDownloads.download_and_unzip_package(self)
end

Instance Method Details

#install!(ksp_path) ⇒ Object

Internal version of the ‘install` method, which handles procedures commong to all packages, such as saving work before and after installation, as well as downloading and unzipping packages and running post-processors.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kosmos/package.rb', line 17

def install!(ksp_path)
  @ksp_path = ksp_path

  install_prerequisites!

  @download_dir = self.class.unzip!

  Util.log "Saving your work before installing ..."
  Versioner.mark_preinstall(ksp_path, self)

  Util.log "Installing #{title} ..."
  install

  Util.log "Cleaning up ..."
  Util.run_post_processors!(ksp_path)

  Versioner.mark_postinstall(ksp_path, self)

  install_postrequisites!
end