r_dockerize 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba9604da9f5b4557a8b762578fc99f42d7c9efcd26d197313ce38cbf6024cf2f
4
- data.tar.gz: d0da7d0675f684e500b7d8f2d91a3e3f320f1d3b67b4a9968cab39b332e409fe
3
+ metadata.gz: 150ba14ca5eda083ea568d40b5b897f21eaca257d3e9c37210f5c15a6d9cd077
4
+ data.tar.gz: 6a84c3b339ef7309190eefcc951a8dbafe09f1bd367d46297968ccc9866158db
5
5
  SHA512:
6
- metadata.gz: 6960309e002b6fe7813c7e2ebbd9b845e0f569d30902864325c8463a317480d5c49db9cb664500d3a613742a296500f9186dcd1a62e5260dc3e8c764ebaeea82
7
- data.tar.gz: ffa1b4a96057d64c7f71ac5393a411125c56bddc9ea2c6e02384168e733cb2410ae346e030ae0272da5980675e44296892ed92c060fe37e4bb8e39d7d68d9bb0
6
+ metadata.gz: 947daf45247848128be71e6cf58fc40f869256f9f3ae024cbd43cc1c5c8db9290703fb075a97eb7a2bbaefe911072d47ef7c4a44135a37a13aee65ae8679236c
7
+ data.tar.gz: 5e46bbbc0583445c95aecbfd5d3bd473318b5a69fc20646dcc7829121ae9ec9059788d6f268bfe44ee90d30909b51fb08798bcac9dfb7a1671bfdf5d5aaae240
data/README.md CHANGED
@@ -34,9 +34,10 @@ Options:
34
34
  -u, --user # Use saved user's template
35
35
  -j, --javascript=JAVASCRIPT # Choose JavaScript approach [options: npm, yarn]
36
36
  -r, --ruby=RUBY_VERSION # Choose version of ruby
37
- -d, --database=DATABASE # Choose database [options: sqlite]
37
+ -d, --database=DATABASE # Choose database [options: postgresql, mysql, mongodb sqlite]
38
38
  --standard # Standard template
39
39
  -h, --help # Print help for command
40
+ -p, --port # Set port for expose
40
41
  ```
41
42
  2. `r_dockerize dco ` / `compose`/ `docker-compose [options]` - for create docker-compose.yml
42
43
  ```bash
@@ -48,15 +49,15 @@ Usage:
48
49
  Options:
49
50
  -s, --show # Show assembled docker-compose file
50
51
  -u, --user # Use saved user's template
51
- -d, --database=DATABASE # Choose database [options: sqlite]
52
+ -d, --database=DATABASE # Choose database [options: postgresql, mysql, mongodb, sqlite]
52
53
  -b, --subservice=SUBSERVICE # Choose subservice [options: redis rabbitmq sidekiq]
53
54
  -h, --help # Print help for command
54
55
 
55
56
  ```
56
- 3. `r_dockerize dockerize [options]` - for create both (Dockerfie and docker-compose.yml)
57
+ 3. `r_dockerize dockerize` - for create both (Dockerfie and docker-compose.yml)
57
58
  ```bash
58
59
  Usage:
59
- rdockerize dockerize [options]
60
+ rdockerize dockerize
60
61
  ```
61
62
 
62
63
  ## Development
@@ -51,6 +51,7 @@
51
51
  COPY ./ $APP_PATH
52
52
  %{db_option}%{js_pm_option}
53
53
  RUN bundle install
54
+ %{port}
54
55
  :db:
55
56
  :sqlite: |
56
57
  RUN apt-get update -qq && \
@@ -4,9 +4,10 @@ require "optionparser"
4
4
 
5
5
  module RDockerize
6
6
  class CLI
7
+ # Available commands
7
8
  COMMANDS = {
8
- "dco" => "RDockerize::Commands::Dco",
9
- "compose" => "RDockerize::Commands::Dco",
9
+ "dco" => "RDockerize::Commands::Dco", # alias for docker-compose
10
+ "compose" => "RDockerize::Commands::Dco", # alias for docker-compose
10
11
  "docker-compose" => "RDockerize::Commands::Dco",
11
12
  "docker" => "RDockerize::Commands::Docker",
12
13
  "dockerize" => "RDockerize::Commands::Dockerize",
@@ -18,6 +19,7 @@ module RDockerize
18
19
  @print_help = false
19
20
  end
20
21
 
22
+ # Build necessary class using command's pull of constants
21
23
  def run(args = ARGV)
22
24
  command = parse_command(args)
23
25
 
@@ -40,6 +42,7 @@ module RDockerize
40
42
 
41
43
  private
42
44
 
45
+ # Initialize base options for r_dockerize command
43
46
  def option_parser
44
47
  @option_parser ||= OptionParser.new do |opts|
45
48
  opts.banner = banner
@@ -4,7 +4,9 @@ require "optionparser"
4
4
 
5
5
  module RDockerize
6
6
  module Commands
7
+ # Abstract class for all commands
7
8
  class Base
9
+ # Base key for access i18n templates
8
10
  BASE_KEY = "r_dockerize"
9
11
 
10
12
  def self.run(args)
@@ -4,8 +4,6 @@ module RDockerize
4
4
  module Commands
5
5
  # rubocop disable:Style/IfUnlessModifier
6
6
  class Dco < Base
7
- attr_reader :db, :js, :subservices, :volumes
8
-
9
7
  def self.run(args)
10
8
  new(args).run
11
9
  end
@@ -18,6 +16,7 @@ module RDockerize
18
16
  end
19
17
 
20
18
  def parse(args)
19
+ # TODO: sqlite not generated!!!
21
20
  @db = "sqlite"
22
21
 
23
22
  parser = opt_parser do |opts|
@@ -31,11 +30,11 @@ module RDockerize
31
30
  @user_temp = true
32
31
  end
33
32
 
34
- opts.on("-d", "--database=DATABASE", "# Choose database [options: sqlite]") do |val|
33
+ opts.on("-d", "--database=DATABASE", "# Choose database [options: #{DATABASE.join(", ")}]") do |val|
35
34
  prepare_db(val)
36
35
  end
37
36
 
38
- opts.on("-b", "--subservice=SUBSERVICE", "# Choose subservice [options: redis rabbitmq sidekiq]") do |val|
37
+ opts.on("-b", "--subservice=SUBSERVICE", "# Choose subservice [options: #{SUBSERVICES.join(", ")}]") do |val|
39
38
  prepare_subservices(val)
40
39
  end
41
40
  end
@@ -83,6 +82,7 @@ module RDockerize
83
82
  @subservices << option
84
83
  end
85
84
 
85
+ # Create final text for docker-compose.yml file
86
86
  def prepare_text
87
87
  return I18n.t("#{BASE_KEY}.dco.user_template") if @user_temp
88
88
 
@@ -3,8 +3,6 @@
3
3
  module RDockerize
4
4
  module Commands
5
5
  class Docker < Base
6
- attr_reader :db, :js_pm, :rv
7
-
8
6
  def self.run(args)
9
7
  new(args).run
10
8
  end
@@ -13,6 +11,7 @@ module RDockerize
13
11
  @user_temp = false
14
12
  @show = false
15
13
  @standard = false
14
+ @port = nil
16
15
  super(args)
17
16
  end
18
17
 
@@ -31,7 +30,7 @@ module RDockerize
31
30
  @user_temp = true
32
31
  end
33
32
 
34
- opts.on("-j", "--javascript=JAVASCRIPT", "# Choose JavaScript approach [options: npm, yarn]") do |val|
33
+ opts.on("-j", "--javascript=JAVASCRIPT", "# Choose JavaScript approach [options: #{JAVASCRIPT_PM.join(", ")}]") do |val|
35
34
  prepare_js_pm(val)
36
35
  end
37
36
 
@@ -39,13 +38,17 @@ module RDockerize
39
38
  @rv = val
40
39
  end
41
40
 
42
- opts.on("-d", "--database=DATABASE", "# Choose database [options: sqlite]") do |val|
41
+ opts.on("-d", "--database=DATABASE", "# Choose database [options: #{DATABASE.join(", ")}]") do |val|
43
42
  prepare_db(val)
44
43
  end
45
44
 
46
45
  opts.on("--standard", "# Standard template") do
47
46
  @standard = true
48
47
  end
48
+
49
+ opts.on("-p", "--port=PORT", "# Set port") do |val|
50
+ @port = val
51
+ end
49
52
  end
50
53
 
51
54
  parser.parse!(args)
@@ -57,6 +60,7 @@ module RDockerize
57
60
  return $stdout.puts text if @show
58
61
 
59
62
  File.open("Dockerfile", "w+") { |f| f.write(text) }
63
+
60
64
  end
61
65
 
62
66
  protected
@@ -86,15 +90,17 @@ module RDockerize
86
90
  @db = option
87
91
  end
88
92
 
93
+ # Create final text for Dockerfile file
89
94
  def prepare_text
90
95
  return I18n.t("#{BASE_KEY}.docker.user_template") if @user_temp
91
96
  return I18n.t("#{BASE_KEY}.docker.standard", ruby_version: @rv) if @standard
92
97
 
93
98
  js_pm_text = I18n.t("#{BASE_KEY}.docker.js_pm.#{@js_pm}") if @js_pm
94
99
  db_text = I18n.t("#{BASE_KEY}.docker.db.#{@db}") if @db
100
+ port_text = "EXPOSE #{@port}" if @port
95
101
 
96
102
  I18n.t("#{BASE_KEY}.docker.template",
97
- ruby_version: @rv, js_pm_option: js_pm_text, db_option: db_text)
103
+ ruby_version: @rv, js_pm_option: js_pm_text, db_option: db_text, port: port_text)
98
104
  end
99
105
  end
100
106
  end
@@ -7,9 +7,10 @@ module RDockerize
7
7
  new(args)
8
8
  end
9
9
 
10
+ # Create docker-compose file and Dockerfile
10
11
  def parse(args)
11
- RDockerize::Commands::Dco.run(args)
12
12
  RDockerize::Commands::Docker.run(args)
13
+ RDockerize::Commands::Dco.run(args)
13
14
  end
14
15
 
15
16
  protected
@@ -4,11 +4,9 @@ require "i18n"
4
4
  require "yaml"
5
5
 
6
6
  module RDockerize
7
- VERSION = "0.1.0"
8
-
9
7
  DEBUG = false
10
8
 
11
- STANDARD_COMPOSE_VERSION = 3.5
9
+ STANDARD_COMPOSE_VERSION = 3.5.freeze
12
10
 
13
11
  DATABASE = %w[postgresql mysql mongodb sqlite].freeze
14
12
 
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RDockerize
4
+ VERSION = "0.1.1"
5
+ end
6
+
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r_dockerize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keallar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-23 00:00:00.000000000 Z
11
+ date: 2024-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.14.1
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.14.1
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -83,6 +83,7 @@ files:
83
83
  - lib/r_dockerize/errors/docker_filename_error.rb
84
84
  - lib/r_dockerize/errors/js_not_found.rb
85
85
  - lib/r_dockerize/errors/subservice_not_found.rb
86
+ - lib/r_dockerize/version.rb
86
87
  - lib/rdockerize.rb
87
88
  homepage: https://github.com/Keallar/r_dockerize
88
89
  licenses:
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  - !ruby/object:Gem::Version
106
107
  version: '0'
107
108
  requirements: []
108
- rubygems_version: 3.5.5
109
+ rubygems_version: 3.5.6
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: CLI app for creating ruby and rails Dockerfile and docker-compose.yml.