mysql_in_docker 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5ac0312b549e92f648616d877774298b1e77f3c57bfd6ba70b5629b2265ae583
4
+ data.tar.gz: 49d06429bb62a25712fc9cf67febd09b668266551948da54b2e400c0025b3542
5
+ SHA512:
6
+ metadata.gz: 66411132d72aee2a6d7527125037ebbfc8d218b308c1597ad00a24c202c465d510e7738a8b5f89be6d0197446ca1bf7fe1cd134f0c7751326655e05a0079b57e
7
+ data.tar.gz: b2c6ee8fedc5b7f2bd013bf5ed52ca34520ba7132d9f1cb7e7b1cc3102252282a014d39a3cce08ee3efe63e31543fc590aebd89aa04f53eb93cd90471dc45c4e
data/.bundle/config ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ BUNDLE_PATH: "vendor/bundle"
3
+ BUNDLE_JOBS: "4"
4
+ BUNDLE_BIN: "vendor/bundle/bin"
data/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_size = 2
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ inherit_from: .rubocop_todo.yml
2
+ require:
3
+ - rubocop-performance
4
+ - rubocop-minitest
5
+ - rubocop-rake
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 3.0
9
+ NewCops: enable
10
+
11
+ Style/StringLiterals:
12
+ Enabled: true
13
+ EnforcedStyle: double_quotes
14
+
15
+ Style/Documentation:
16
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,22 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2021-12-23 13:46:28 UTC using RuboCop version 1.24.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'mysql_in_docker.gemspec'
15
+
16
+ # Offense count: 1
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: EnforcedStyle.
19
+ # SupportedStyles: always, always_true, never
20
+ Style/FrozenStringLiteralComment:
21
+ Exclude:
22
+ - 'exe/mysql_in_docker'
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-12-23
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sijiaoh@outlook.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in mysql_in_docker.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
13
+ gem "rubocop-minitest"
14
+ gem "rubocop-performance"
15
+ gem "rubocop-rake"
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mysql_in_docker (0.0.0)
5
+ thor
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ minitest (5.15.0)
12
+ parallel (1.21.0)
13
+ parser (3.0.3.2)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.0.0)
16
+ rake (13.0.6)
17
+ regexp_parser (2.2.0)
18
+ rexml (3.2.5)
19
+ rubocop (1.24.0)
20
+ parallel (~> 1.10)
21
+ parser (>= 3.0.0.0)
22
+ rainbow (>= 2.2.2, < 4.0)
23
+ regexp_parser (>= 1.8, < 3.0)
24
+ rexml
25
+ rubocop-ast (>= 1.15.0, < 2.0)
26
+ ruby-progressbar (~> 1.7)
27
+ unicode-display_width (>= 1.4.0, < 3.0)
28
+ rubocop-ast (1.15.0)
29
+ parser (>= 3.0.1.1)
30
+ rubocop-minitest (0.17.0)
31
+ rubocop (>= 0.90, < 2.0)
32
+ rubocop-performance (1.12.0)
33
+ rubocop (>= 1.7.0, < 2.0)
34
+ rubocop-ast (>= 0.4.0)
35
+ rubocop-rake (0.6.0)
36
+ rubocop (~> 1.0)
37
+ ruby-progressbar (1.11.0)
38
+ thor (1.1.0)
39
+ unicode-display_width (2.1.0)
40
+
41
+ PLATFORMS
42
+ x86_64-linux
43
+
44
+ DEPENDENCIES
45
+ minitest (~> 5.0)
46
+ mysql_in_docker!
47
+ rake (~> 13.0)
48
+ rubocop (~> 1.21)
49
+ rubocop-minitest
50
+ rubocop-performance
51
+ rubocop-rake
52
+
53
+ BUNDLED WITH
54
+ 2.2.32
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Sijia Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # mysql_in_docker
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'mysql_in_docker'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mysql_in_docker
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ mysql_in_docker help
23
+ ```
24
+
25
+ ## Contributing
26
+
27
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sijiaoh/mysql_in_docker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sijiaoh/mysql_in_docker/blob/main/CODE_OF_CONDUCT.md).
28
+
29
+ ## License
30
+
31
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
32
+
33
+ ## Code of Conduct
34
+
35
+ Everyone interacting in the MysqlInDocker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sijiaoh/mysql_in_docker/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "mysql_in_docker"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/test ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ENV=test bundle exec ruby ./test/index.rb $1
data/envrc.sample ADDED
@@ -0,0 +1,2 @@
1
+ PATH_add vendor/bundle/bin
2
+ PATH_add bin
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "mysql_in_docker"
data/lib/commands.rb ADDED
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require "open3"
5
+
6
+ module MysqlInDocker
7
+ class Commands < Thor
8
+ def self.exit_on_failure?
9
+ true
10
+ end
11
+
12
+ desc "start ID VERSION PORT MYSQL_ROOT_PASSWORD", "Prepare mysql in docker."
13
+ def start(id, version, port, mysql_root_password)
14
+ status = docker_command "start #{get_container_name(id)}"
15
+ if status[:successed]
16
+ p "#{get_container_name(id)} running on #{port}."
17
+ return
18
+ end
19
+
20
+ command = up_command id, version, port, mysql_root_password
21
+ status = docker_command(command)
22
+ raise_if_status_failed status
23
+
24
+ p "Created #{get_container_name(id)} on #{port}."
25
+ end
26
+
27
+ desc "stop ID", "Remove mysql container."
28
+ def stop(id)
29
+ status = docker_command "rm -f #{get_container_name(id)}"
30
+ if status[:stderr].include? "No such container:"
31
+ p "Container not found."
32
+ else
33
+ p "Removed container."
34
+ end
35
+ end
36
+
37
+ desc "rm ID", "Remove mysql container and volume."
38
+ def rm(id)
39
+ stop id
40
+
41
+ status = docker_command "volume rm #{get_container_name(id)}"
42
+ if status[:stderr].include? "No such volume:"
43
+ p "Volume not found."
44
+ else
45
+ p "Removed volume."
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def raise_if_status_failed(status)
52
+ raise Error, status[:stderr] unless status[:successed]
53
+ end
54
+
55
+ def docker_command(command)
56
+ o, e, s = Open3.capture3("docker #{command}")
57
+ { stdout: o, stderr: e, status: s, successed: s.success? }
58
+ end
59
+
60
+ def get_container_name(id)
61
+ "mysql_in_docker_#{id}"
62
+ end
63
+
64
+ def up_command(id, version, port, mysql_root_password) # rubocop:disable Metrics/MethodLength
65
+ [
66
+ "run",
67
+ "--name", get_container_name(id),
68
+ "--env",
69
+ "MYSQL_ROOT_PASSWORD=#{mysql_root_password}",
70
+ "--publish",
71
+ "#{port}:3306",
72
+ "--volume",
73
+ "#{get_container_name(id)}:/var/lib/mysql",
74
+ "-d",
75
+ "mysql:#{version}"
76
+ ].join(" ")
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MysqlInDocker
4
+ VERSION = "0.0.0"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "mysql_in_docker/version"
4
+ require "./lib/commands"
5
+
6
+ module MysqlInDocker
7
+ class Error < StandardError; end
8
+
9
+ Commands.start(ARGV) unless ENV["ENV"] == "test"
10
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/mysql_in_docker/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "mysql_in_docker"
7
+ spec.version = MysqlInDocker::VERSION
8
+ spec.authors = ["Sijia Wang"]
9
+ spec.email = ["sijiaoh@outlook.com"]
10
+
11
+ spec.summary = "Easly use mysql with docker."
12
+ spec.homepage = "https://github.com/sijiaoh/mysql_in_docker"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ # spec.add_dependency "example-gem", "~> 1.0"
33
+ spec.add_dependency "thor"
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+
38
+ spec.metadata = {
39
+ "rubygems_mfa_required" => "true"
40
+ }
41
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mysql_in_docker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sijia Wang
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-12-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - sijiaoh@outlook.com
30
+ executables:
31
+ - mysql_in_docker
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".bundle/config"
36
+ - ".editorconfig"
37
+ - ".rubocop.yml"
38
+ - ".rubocop_todo.yml"
39
+ - CHANGELOG.md
40
+ - CODE_OF_CONDUCT.md
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - bin/console
47
+ - bin/setup
48
+ - bin/test
49
+ - envrc.sample
50
+ - exe/mysql_in_docker
51
+ - lib/commands.rb
52
+ - lib/mysql_in_docker.rb
53
+ - lib/mysql_in_docker/version.rb
54
+ - mysql_in_docker.gemspec
55
+ homepage: https://github.com/sijiaoh/mysql_in_docker
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ rubygems_mfa_required: 'true'
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.2.32
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Easly use mysql with docker.
79
+ test_files: []