Class: RDockerize::Commands::Docker
- Defined in:
- lib/r_dockerize/commands/docker.rb
Constant Summary
Constants inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Docker
constructor
A new instance of Docker.
-
#parse(args) ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#run ⇒ Object
rubocop:enable Metrics/MethodLength.
Constructor Details
#initialize(args) ⇒ Docker
Returns a new instance of Docker.
10 11 12 13 14 15 16 |
# File 'lib/r_dockerize/commands/docker.rb', line 10 def initialize(args) @user_temp = false @show = false @standard = false @port = nil super(args) end |
Class Method Details
.run(args) ⇒ Object
6 7 8 |
# File 'lib/r_dockerize/commands/docker.rb', line 6 def self.run(args) new(args).run end |
Instance Method Details
#parse(args) ⇒ Object
rubocop:disable Metrics/MethodLength
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 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/r_dockerize/commands/docker.rb', line 19 def parse(args) @rv = RUBY_VERSION parser = opt_parser do |opts| opts. = opts.on("-s", "--show", "# Show assembled dockerfile") do @show = true end opts.on("-u", "--user", "# Use saved user's template") do @user_temp = true end opts.on("-j", "--javascript=JAVASCRIPT", "# Choose JavaScript approach [options: #{JAVASCRIPT_PM.join(", ")}]") do |val| prepare_js_pm(val) end opts.on("-r", "--ruby=RUBY_VERSION", "# Choose version of ruby") do |val| @rv = val end opts.on("-d", "--database=DATABASE", "# Choose database [options: #{DATABASE.join(", ")}]") do |val| prepare_db(val) end opts.on("--standard", "# Standard template") do @standard = true end opts.on("-p", "--port=PORT", "# Set port") do |val| @port = val end end parser.parse!(args) end |
#run ⇒ Object
rubocop:enable Metrics/MethodLength
58 59 60 61 62 63 64 |
# File 'lib/r_dockerize/commands/docker.rb', line 58 def run text = prepare_text return $stdout.puts text if @show File.open("Dockerfile", "w+") { |f| f.write(text) } end |