Module: Neptuno::TTY::File
- Included in:
- CLI::Base, CLI::Execute, CLI::Init, CLI::Install, CLI::List, Services::Add, Config
- Defined in:
- lib/neptuno/tty/file.rb
Overview
Wrapper class for TTY gem
Constant Summary collapse
- TTY =
::TTY::File
- ABORT_MESSAGE =
"fatal: not a Neptuno repository (or any of the parent directories)"
Instance Method Summary collapse
- #file ⇒ Object
- #in_service? ⇒ Boolean
- #make_service_files(services) ⇒ Object
- #neptuno_path ⇒ Object
-
#project ⇒ Object
define path helpers.
- #service ⇒ Object
Instance Method Details
#file ⇒ Object
10 11 12 |
# File 'lib/neptuno/tty/file.rb', line 10 def file TTY end |
#in_service? ⇒ Boolean
19 20 21 |
# File 'lib/neptuno/tty/file.rb', line 19 def in_service? Dir.pwd.include?("#{neptuno_path}/services/") end |
#make_service_files(services) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/neptuno/tty/file.rb', line 39 def make_service_files(services) services.each do |service| `cd #{neptuno_path}/services/#{service} 2>/dev/null` if $?.exitstatus.zero? `cd #{neptuno_path}/services/#{service} 2>/dev/null && git add . 2>/dev/null` unless $?.exitstatus.zero? `cd #{neptuno_path}/services/#{service} 2>/dev/null && git submodule update --init --recursive #{neptuno_path}/services/#{service}` `cd #{neptuno_path}/services/#{service} 2>/dev/null && git checkout main 2>/dev/null` `cd #{neptuno_path}/services/#{service} 2>/dev/null && git checkout master 2>/dev/null` end end `cd #{neptuno_path} && mkdir -p environments/#{service} procfiles/#{service} dockerfiles/#{service}` `cd #{neptuno_path} && touch environments/#{service}/default` `cd #{neptuno_path} && touch dockerfiles/#{service}/Dockerfile` `cd #{neptuno_path} && touch dockerfiles/#{service}/entrypoint.sh` end end |
#neptuno_path ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/neptuno/tty/file.rb', line 27 def neptuno_path return @base_path if @base_path pwd = Dir.pwd loop do return pwd if pwd == "" return @base_path = pwd if Dir.children(pwd).include?("neptuno.yml") pwd = pwd.split("/")[0..-2].join("/") end end |
#project ⇒ Object
define path helpers
15 16 17 |
# File 'lib/neptuno/tty/file.rb', line 15 def project neptuno_path.split("/").last end |
#service ⇒ Object
23 24 25 |
# File 'lib/neptuno/tty/file.rb', line 23 def service ENV["PWD"].match(%r{services/([^/]*)})&.captures&.first end |