Class: DGD::Manifest::AppDirectory
- Inherits:
-
Object
- Object
- DGD::Manifest::AppDirectory
- Defined in:
- lib/dgd-tools/manifest.rb
Constant Summary collapse
- DEFAULT_FILE_LOCATIONS =
{ "manifest" => "dgd.manifest", "gitignore" => ".gitignore", "gems_rb" => "gems.rb", }
- DEFAULT_EMPTY_DIRS =
[ "app", "state" ]
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #create! ⇒ Object
- #gems_rb_contents ⇒ Object
- #gitignore_contents ⇒ Object
-
#initialize(directory) ⇒ AppDirectory
constructor
A new instance of AppDirectory.
- #manifest_contents ⇒ Object
Constructor Details
#initialize(directory) ⇒ AppDirectory
Returns a new instance of AppDirectory.
431 432 433 |
# File 'lib/dgd-tools/manifest.rb', line 431 def initialize(directory) @location = directory end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
421 422 423 |
# File 'lib/dgd-tools/manifest.rb', line 421 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
422 423 424 |
# File 'lib/dgd-tools/manifest.rb', line 422 def name @name end |
Instance Method Details
#create! ⇒ Object
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/dgd-tools/manifest.rb', line 490 def create! if File.exist?(@location) && (!File.directory?(@location) || Dir["#{@location}/**"].size != 0) raise "Cannot create a new DGD manifest project over a file or in an existing non-empty directory!" end puts "Creating new DGD manifest project at #{@location}..." FileUtils.mkdir_p @location Dir.chdir @location do DEFAULT_FILE_LOCATIONS.each do |file_desc, file_location| File.open(file_location, "wb") do |f| contents = send("#{file_desc}_contents") f.write(contents) end end DEFAULT_EMPTY_DIRS.each do |dir| FileUtils.mkdir dir FileUtils.touch File.join(dir, ".keep") end result = system "bundle" raise("Could not run bundler to install dgd-tools for #{@location}!") unless result result = system "bundle exec dgd-manifest install" raise("Error when running dgd-manifest for #{@location}!") unless result end puts "Successfully created project at #{@location}." end |
#gems_rb_contents ⇒ Object
482 483 484 485 486 487 488 |
# File 'lib/dgd-tools/manifest.rb', line 482 def gems_rb_contents <<~FILE_CONTENTS source "https://rubygems.org" gem "dgd-tools", ">= #{DGD::VERSION}" FILE_CONTENTS end |
#gitignore_contents ⇒ Object
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
# File 'lib/dgd-tools/manifest.rb', line 435 def gitignore_contents <<~FILE_CONTENTS # DGD Manifest files .root dgd.config state/* wafer websocket-to-tcp-tunnel dgd log/* skotos.database skotos.database.old .repos/** FILE_CONTENTS end |
#manifest_contents ⇒ Object
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/dgd-tools/manifest.rb', line 451 def manifest_contents <<FILE_CONTENTS { "name": "#{@name}", "version": "0.1.0", "description": "TODO: put description here", "app_root": "app", "goods": [ "# This is an example goods file - substitute your own.", "https://raw.githubusercontent.com/ChatTheatre/dgd-tools/main/goods/skotos_httpd.goods" ], "unbundled_goods": [ { "#": "this is an example of unbundled goods - substitute your own", "name": "kernellib", "git": { "url": "https://github.com/ChatTheatre/kernellib.git", "branch": "master" }, "paths": { "src/doc/kernel": "doc/kernel", "src/include/kernel": "include/kernel", "src/include/*.h": "include", "src/kernel": "kernel" } } ] } FILE_CONTENTS end |