dgd-tools 0.1.4 → 0.1.5

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: '0025088ef0df415ef00766a3bfeb9416938e236f771f2bba67a3a9527116c009'
4
- data.tar.gz: da1493ee48cf879fa86b24c9a551c19edb6ed9d99c11df6c28592361aad97909
3
+ metadata.gz: 7248b5e9b0f257568633b8f83c166430e1451da62c0d84acfa468f48a6bf4196
4
+ data.tar.gz: 435dfa244ae63087b45acd18f9220267cf4facf560f2c1a235392d6ec9fe00f6
5
5
  SHA512:
6
- metadata.gz: 6b9d8e75885bed1f6f102bb7b8edd608c7ff72ae0ab68aecb153785cfe734ee3c446d58f0511e48b0e4aba4c5fdc73b98a7f4fd6578054524bdfa59a98c9bf34
7
- data.tar.gz: 9d0aa1bd573057eb89be293ef43f5dab2f0228907455c489c00a1bab7a9971a872ee4cf5919cad2ae359363de8c51597e292f90d3740299dde38f55a06c7fa6f
6
+ metadata.gz: 0f6534cced478794994f6a85ebf10277d6c0455d095708a49901b3527bea1534a9d18b2c5dc6bffc5b3a03bf5949fd352644b019148f541f1e6f98660aee060b
7
+ data.tar.gz: 86c72de588f15ce2f1804068771e46a6ca71f707399fc807b74bdca02c52ef173dab11058eb24475e387852443de79c59cd553d9902a79611240a39f1ae72431
@@ -0,0 +1,41 @@
1
+ <object program="/base/obj/thing">
2
+ <Base:Thing>
3
+ <Ur:UrObject/>
4
+ <Base:Bulk immobile="false" mass="1" density="1"/>
5
+ <Base:Container flexible="false" transparent-container="false" public-container="false" tight="false" capacity="0" maxweight="0"/>
6
+ <Base:Misc gender="neuter" volition="false" weapon="false" default_stance="none" combinable="false" discrete="false" by_weight="false" tight="false" scriptrunner="false">
7
+ <Base:Edible value="false"/>
8
+ <Base:Potable value="false"/>
9
+ <Base:DrinkMessageFirst/>
10
+ <Base:DrinkMessageThird/>
11
+ <Base:Transparency value="false"/>
12
+ <Base:Unsafe value="false"/>
13
+ <Base:Safe value="false"/>
14
+ <Base:ClothesExpected value="false"/>
15
+ <Base:DieMessageFirst/>
16
+ <Base:DieMessageThird/>
17
+ </Base:Misc>
18
+ <Base:Details/>
19
+ <Base:Combat>
20
+ <Base:Strength value="1"/>
21
+ <Base:MaxFatigue value="1"/>
22
+ </Base:Combat>
23
+ <Base:Clothing>
24
+ <Base:SingleWear value="false"/>
25
+ </Base:Clothing>
26
+ <Base:Crafting see_level="0" do_level="0" time="0" attention="false" held="false">
27
+ <Base:Ingredients/>
28
+ <Base:Tools/>
29
+ <Base:CraftVerbs/>
30
+ </Base:Crafting>
31
+ <Base:InitialContents/>
32
+ <Base:InitialProperties/>
33
+ <Core:Properties>
34
+ <Core:Property property="revisions">
35
+ (\{ 1065557891, "the_exiled", "E" \})
36
+ </Core:Property>
37
+ <Core:Property property="skill:fatigue">1.0</Core:Property>
38
+ </Core:Properties>
39
+ <Notes:Notes/>
40
+ </Base:Thing>
41
+ </object>
@@ -0,0 +1,42 @@
1
+ <object program="/base/obj/thing" owner="bobo">
2
+ <Base:Thing>
3
+ <Ur:UrObject/>
4
+ <Base:Bulk immobile="false" mass="1" density="1"/>
5
+ <Base:Container flexible="false" transparent-container="false" public-container="false" tight="false" capacity="0" maxweight="0"/>
6
+ <Base:Misc gender="neuter" volition="false" weapon="false" default_stance="none" combinable="false" discrete="false" by_weight="false" tight="false" scriptrunner="false" bogusfield="nope">
7
+ <Base:Edible value="false"/>
8
+ <Base:Potable value="false"/>
9
+ <Base:DrinkMessageFirst/>
10
+ <Base:DrinkMessageThird/>
11
+ <Base:Transparency value="false"/>
12
+ <Base:Unsafe value="false"/>
13
+ <Base:Safe value="false"/>
14
+ <Base:ClothesExpected value="false"/>
15
+ <Base:DieMessageFirst/>
16
+ <Base:DieMessageThird/>
17
+ <Base:DieMessageFortySecond/>
18
+ </Base:Misc>
19
+ <Base:Details/>
20
+ <Base:Combat>
21
+ <Base:Strength value="1"/>
22
+ <Base:MaxFatigue value="1"/>
23
+ </Base:Combat>
24
+ <Base:Clothing>
25
+ <Base:SingleWear value="false"/>
26
+ </Base:Clothing>
27
+ <Base:Crafting see_level="0" do_level="0" time="0" attention="false" held="false">
28
+ <Base:Ingredients/>
29
+ <Base:Tools/>
30
+ <Base:CraftVerbs/>
31
+ </Base:Crafting>
32
+ <Base:InitialContents/>
33
+ <Base:InitialProperties/>
34
+ <Core:Properties>
35
+ <Core:Property property="revisions">
36
+ (\{ 1065557891, "the_exiled", "E" \})
37
+ </Core:Property>
38
+ <Core:Property property="skill:fatigue">1.0</Core:Property>
39
+ </Core:Properties>
40
+ <Notes:Notes/>
41
+ </Base:Thing>
42
+ </object>
@@ -6,7 +6,20 @@ if ARGV.size == 0
6
6
  ARGV.push "install"
7
7
  end
8
8
 
9
+ if ARGV == ["--version"]
10
+ puts "dgd-tools version #{DGD::VERSION}"
11
+ exit
12
+ end
13
+
9
14
  case ARGV[0]
15
+ when "new"
16
+ unless ARGV.size == 2
17
+ puts "Usage: dgd-manifest new [project name]"
18
+ raise "Must supply exactly one argument to dgd-manifest new!"
19
+ end
20
+ appdir = DGD::Manifest::AppDirectory.new(File.expand_path ARGV[1])
21
+ appdir.name = ARGV[1]
22
+ appdir.create!
10
23
  when "test"
11
24
  unless File.exist?("dgd.manifest")
12
25
  raise "I don't see a dgd.manifest file in this directory!"
@@ -233,7 +233,7 @@ CONTENTS
233
233
  @path = path
234
234
  @repo = repo
235
235
  raise("No such dgd.manifest file as #{path.inspect}!") unless File.exist?(path)
236
- contents = JSON.load(File.read(path))
236
+ contents = AppFile.parse_manifest_file(path)
237
237
 
238
238
  read_manifest_file(contents)
239
239
 
@@ -263,6 +263,23 @@ CONTENTS
263
263
  nil
264
264
  end
265
265
 
266
+ # Load the JSON and then remove comments
267
+ def self.parse_manifest_file(path)
268
+ contents = JSON.parse(File.read path)
269
+ remove_comments!(contents)
270
+ contents
271
+ end
272
+
273
+ def self.remove_comments!(items)
274
+ if items.is_a?(Hash)
275
+ items.delete_if { |k, v| k[0] == "#" }
276
+ items.values.each { |v| remove_comments!(v) }
277
+ elsif items.is_a?(Array)
278
+ items.delete_if { |i| i.is_a?(String) && i[0] == "#" }
279
+ items.each { |i| remove_comments!(i) }
280
+ end
281
+ end
282
+
266
283
  def read_manifest_file(contents)
267
284
  raise "Expected a top-level JSON object in dgd.manifest!" unless contents.is_a?(Hash)
268
285
 
@@ -331,4 +348,98 @@ CONTENTS
331
348
  @paths = cleaned_paths
332
349
  end
333
350
  end
351
+
352
+ class AppDirectory
353
+ attr_reader :location
354
+ attr_accessor :name
355
+
356
+ DEFAULT_FILE_LOCATIONS = {
357
+ "manifest" => "dgd.manifest",
358
+ "gitignore" => ".gitignore",
359
+ "gems_rb" => "gems.rb",
360
+ }
361
+ DEFAULT_EMPTY_DIRS = [ "app", "state" ]
362
+
363
+ def initialize(directory)
364
+ @location = directory
365
+ end
366
+
367
+ def gitignore_contents
368
+ <<~FILE_CONTENTS
369
+ # DGD Manifest files
370
+ .root
371
+ dgd.config
372
+ state/*
373
+ FILE_CONTENTS
374
+ end
375
+
376
+ def manifest_contents
377
+ <<FILE_CONTENTS
378
+ {
379
+ "name": "#{@name}",
380
+ "version": "0.1.0",
381
+ "description": "TODO: put description here",
382
+ "app_root": "app",
383
+ "goods": [
384
+ "# This is an example goods file - substitute your own.",
385
+ "https://raw.githubusercontent.com/noahgibbs/dgd-tools/main/goods/skotos_httpd.goods"
386
+ ],
387
+ "unbundled_goods": [
388
+ {
389
+ "#": "this is an example of unbundled goods - substitute your own",
390
+ "name": "kernellib",
391
+ "git": {
392
+ "url": "https://github.com/ChatTheatre/kernellib.git",
393
+ "branch": "master"
394
+ },
395
+ "paths": {
396
+ "src/doc/kernel": "doc/kernel",
397
+ "src/include/kernel": "include/kernel",
398
+ "src/include/*.h": "include",
399
+ "src/kernel": "kernel"
400
+ }
401
+ }
402
+ ]
403
+ }
404
+ FILE_CONTENTS
405
+ end
406
+
407
+ def gems_rb_contents
408
+ <<~FILE_CONTENTS
409
+ source "https://rubygems.org"
410
+
411
+ gem "dgd-tools", ">= #{DGD::VERSION}"
412
+ FILE_CONTENTS
413
+ end
414
+
415
+ def create!
416
+ if File.exist?(@location) && (!File.directory?(@location) || Dir["#{@location}/**"].size != 0)
417
+ raise "Cannot create a new DGD manifest project over a file or in an existing non-empty directory!"
418
+ end
419
+
420
+ puts "Creating new DGD manifest project at #{@location}..."
421
+ FileUtils.mkdir_p @location
422
+ Dir.chdir @location do
423
+ DEFAULT_FILE_LOCATIONS.each do |file_desc, file_location|
424
+ File.open(file_location, "wb") do |f|
425
+ contents = send("#{file_desc}_contents")
426
+ f.write(contents)
427
+ end
428
+ end
429
+
430
+ DEFAULT_EMPTY_DIRS.each do |dir|
431
+ FileUtils.mkdir dir
432
+ FileUtils.touch File.join(dir, ".keep")
433
+ end
434
+
435
+ result = system "bundle"
436
+ raise("Could not run bundler to install dgd-tools for #{@location}!") unless result
437
+
438
+ result = system "bundle exec dgd-manifest install"
439
+ raise("Error when running dgd-manifest for #{@location}!") unless result
440
+ end
441
+
442
+ puts "Successfully created project at #{@location}."
443
+ end
444
+ end
334
445
  end
@@ -1,3 +1,3 @@
1
1
  module DGD
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dgd-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Gibbs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-11 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -49,6 +49,8 @@ files:
49
49
  - example_xml/PropertyTypes.xml
50
50
  - example_xml/Thing.xml
51
51
  - example_xml/Thing2.xml
52
+ - example_xml/t1/Thing.xml
53
+ - example_xml/t2/Thing.xml
52
54
  - exe/dgd-manifest
53
55
  - exe/skotos-xml-diff
54
56
  - goods/skotos_httpd.goods