Class: Arb::Cli::WorkingDirectory
- Inherits:
-
Object
- Object
- Arb::Cli::WorkingDirectory
- Defined in:
- lib/arb/cli/shared/working_directory.rb
Constant Summary collapse
- FILES =
{ ".gitignore" => <<~FILE, ".ruby-version" => "3.3.0\n", "Gemfile" => <<~FILE, File.join("spec", "spec_helper.rb") => <<~FILE require "debug" Dir[File.join(__dir__, "..", "src", "**", "*.rb")].each do |file| require file end FILE }
Class Method Summary collapse
- .default_editor_command ⇒ Object
- .env_keys ⇒ Object
- .prepare! ⇒ Object
- .refresh_aoc_cookie! ⇒ Object
Class Method Details
.default_editor_command ⇒ Object
28 |
# File 'lib/arb/cli/shared/working_directory.rb', line 28 def self.default_editor_command = "code" |
.env_keys ⇒ Object
27 |
# File 'lib/arb/cli/shared/working_directory.rb', line 27 def self.env_keys = ["EDITOR_COMMAND", "AOC_COOKIE"] |
.prepare! ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/arb/cli/shared/working_directory.rb', line 30 def self.prepare! files_created = [] existing_dotenv = Dotenv.parse(".env") unless env_keys.all? { existing_dotenv.has_key?(_1) } create_dotenv!(existing_dotenv) files_created << :dotenv end Dotenv.load Dotenv.require_keys(*env_keys) files_created += create_other_files! if files_created.any? puts "✅ Initial files created and committed to a new Git repository." puts end end |
.refresh_aoc_cookie! ⇒ Object
49 50 51 52 53 54 |
# File 'lib/arb/cli/shared/working_directory.rb', line 49 def self. print "Uh oh, your Advent of Code session cookie has expired or was " \ "incorrectly entered. " ENV["AOC_COOKIE"] = File.write(".env", generate_dotenv) end |