Class: RDockerize::Commands::Dco
- Defined in:
- lib/r_dockerize/commands/dco.rb
Overview
rubocop disable:Style/IfUnlessModifier
Constant Summary
Constants inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Dco
constructor
A new instance of Dco.
- #parse(args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Dco
Returns a new instance of Dco.
11 12 13 14 15 16 |
# File 'lib/r_dockerize/commands/dco.rb', line 11 def initialize(args) @show = false @subservices = [] @user_temp = false super(args) end |
Class Method Details
.run(args) ⇒ Object
7 8 9 |
# File 'lib/r_dockerize/commands/dco.rb', line 7 def self.run(args) new(args).run end |
Instance Method Details
#parse(args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/r_dockerize/commands/dco.rb', line 18 def parse(args) # TODO: sqlite not generated!!! @db = "sqlite" parser = opt_parser do |opts| opts. = opts.on("-s", "--show", "# Show assembled docker-compose file") do @show = true end opts.on("-u", "--user", "# Use saved user's template") do @user_temp = true end opts.on("-d", "--database=DATABASE", "# Choose database [options: #{DATABASE.join(", ")}]") do |val| prepare_db(val) end opts.on("-b", "--subservice=SUBSERVICE", "# Choose subservice [options: #{SUBSERVICES.join(", ")}]") do |val| prepare_subservices(val) end end parser.parse!(args) end |
#run ⇒ Object
45 46 47 48 49 50 |
# File 'lib/r_dockerize/commands/dco.rb', line 45 def run text = prepare_text return $stdout.puts text if @show File.open("docker-compose.yml", "w+") { |f| f.write(text) } end |