psm_dead_simple_deployment_tools 0.1.1

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: 8e67bd260b3a3868eeeb98796ceac5024b16ea53f4c08ed61b58e2d5c8e3f009
4
+ data.tar.gz: d2658014805460b41b91560100b0698c88aa00f9bed48e5cc7e92a7bbdbe541a
5
+ SHA512:
6
+ metadata.gz: b152fa7047adad186f2a431080a0ba0a26d8f21e62da193d31311018c2b09ca28ca263b1fba219ec48e797639b94680757c5dabb726d357039f0c937d22a4dc8
7
+ data.tar.gz: aaca19de9aa286eb3a4f52a37ebc0eafb777d20923bd465cd0e576387ef05b20dde81f8af0e71463762153fd346c30db27d8d16fc1be61c99927c8d0b237c55a
@@ -0,0 +1,31 @@
1
+ name: Merge me!
2
+
3
+ on:
4
+ workflow_run:
5
+ types:
6
+ - completed
7
+ workflows:
8
+ - 'Verify'
9
+
10
+ jobs:
11
+ merge-me:
12
+ name: Merge me!
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - # It is often a desired behavior to merge only when a workflow execution
16
+ # succeeds. This can be changed as needed.
17
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
18
+ name: Merge me!
19
+ uses: ridedott/merge-me-action@v2
20
+ with:
21
+ # Depending on branch protection rules, a manually populated
22
+ # `GITHUB_TOKEN_WORKAROUND` secret with permissions to push to
23
+ # a protected branch must be used. This secret can have an arbitrary
24
+ # name, as an example, this repository uses `DOTTBOTT_TOKEN`.
25
+ #
26
+ # When using a custom token, it is recommended to leave the following
27
+ # comment for other developers to be aware of the reasoning behind it:
28
+ #
29
+ # This must be used as GitHub Actions token does not support pushing
30
+ # to protected branches.
31
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.1
14
+ bundler-cache: true
15
+ - name: Run the default task
16
+ env:
17
+ CI: true
18
+ run: bundle exec rake
@@ -0,0 +1,22 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ tags:
8
+ - v*
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v1
15
+
16
+ - name: Release Gem
17
+ if: contains(github.ref, 'refs/tags/v')
18
+ uses: personal-social-media/publish-rubygems-action@master
19
+ env:
20
+ GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
21
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
22
+ RELEASE_COMMAND: rake release
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-06-27
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 gore.sebyx@yahoo.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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in psm_dead_simple_deployment_tools.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ psm_dead_simple_deployment_tools (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ parallel (1.20.1)
12
+ parser (3.0.1.1)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (13.0.3)
16
+ regexp_parser (2.1.1)
17
+ rexml (3.2.5)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.2)
31
+ rubocop (1.17.0)
32
+ parallel (~> 1.10)
33
+ parser (>= 3.0.0.0)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8, < 3.0)
36
+ rexml
37
+ rubocop-ast (>= 1.7.0, < 2.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (>= 1.4.0, < 3.0)
40
+ rubocop-ast (1.7.0)
41
+ parser (>= 3.0.1.1)
42
+ ruby-progressbar (1.11.0)
43
+ unicode-display_width (2.0.0)
44
+
45
+ PLATFORMS
46
+ x86_64-linux
47
+
48
+ DEPENDENCIES
49
+ psm_dead_simple_deployment_tools!
50
+ rake (~> 13.0)
51
+ rspec (~> 3.0)
52
+ rubocop (~> 1.7)
53
+
54
+ BUNDLED WITH
55
+ 2.2.15
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 sebi
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,91 @@
1
+ # PsmDeadSimpleDeploymentTools
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/psm_dead_simple_deployment_tools`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'psm_dead_simple_deployment_tools'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install psm_dead_simple_deployment_tools
22
+
23
+ ## Usage
24
+
25
+ ### Files
26
+
27
+ ```ruby
28
+ include PsmDeadSimpleDeploymentTools::Files
29
+
30
+ # writing a file once
31
+ write("file_path") do # supports write("file_path", "template_path.erb")
32
+ "new content"
33
+ end
34
+
35
+ # appending to a file once
36
+ append("file_path") do # supports append("file_path", "template_path.erb")
37
+ "appended content"
38
+ end
39
+
40
+ # find and replace content from file
41
+ # match can be a String or Regexp
42
+ replace("file_path", /my-match/) do # supports replace("file_path", /my-match/, "template_path.erb")
43
+ "replaced content"
44
+ end
45
+ ```
46
+
47
+ #### How to use template.erb
48
+
49
+ ```ruby
50
+ # inside app.rb
51
+
52
+ def write_my_config_file
53
+ @hostname = `hostname`
54
+ write("tmp/my-hostname", "my_template_file.erb")
55
+ end
56
+ ```
57
+
58
+ ```text
59
+ # inside my_template_file
60
+ my hostname is: <%= @hostname %>
61
+ ```
62
+
63
+ ### Packages
64
+ ```ruby
65
+ #only apt support currently
66
+ include PsmDeadSimpleDeploymentTools::Packages
67
+
68
+ # updates package repo and installs packages
69
+ install_packages("vim", "libpq-dev")
70
+
71
+ # removes packages
72
+ remove_packages("vim", "libpq-dev")
73
+ ```
74
+
75
+ ## Development
76
+
77
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
+
79
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
80
+
81
+ ## Contributing
82
+
83
+ Bug reports and pull requests are welcome on GitHub at https://github.com/personal-social-media/psm_dead_simple_deployment_tools. 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/[USERNAME]/psm_dead_simple_deployment_tools/blob/master/CODE_OF_CONDUCT.md).
84
+
85
+ ## License
86
+
87
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88
+
89
+ ## Code of Conduct
90
+
91
+ Everyone interacting in the PsmDeadSimpleDeploymentTools project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/psm_dead_simple_deployment_tools/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec 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 "psm_dead_simple_deployment_tools"
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
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "erb"
5
+ require "forwardable"
6
+
7
+ require_relative "psm_dead_simple_deployment_tools/version"
8
+ require_relative "psm_dead_simple_deployment_tools/utills/erb_util"
9
+ require_relative "psm_dead_simple_deployment_tools/utills/run_command_as_sudo"
10
+ require_relative "psm_dead_simple_deployment_tools/files"
11
+ require_relative "psm_dead_simple_deployment_tools/packages"
12
+ require_relative "psm_dead_simple_deployment_tools/packages/package_manager"
13
+ require_relative "psm_dead_simple_deployment_tools/packages/apt_manager"
14
+
15
+ module PsmDeadSimpleDeploymentTools
16
+ class Error < StandardError; end
17
+ # Your code goes here...
18
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PsmDeadSimpleDeploymentTools
4
+ # include PsmDeadSimpleDeploymentTools::Files
5
+ # in order to manipulate files
6
+ module Files
7
+ class FileNotFound < StandardError; end
8
+
9
+ class InvalidType < StandardError; end
10
+
11
+ def write(path, template_path = nil)
12
+ content = if block_given?
13
+ yield
14
+ else
15
+ Utils::ErbUtil.new(template_path, binding).result
16
+ end
17
+
18
+ return :no_change if File.exist?(path) && File.read(path) == content
19
+
20
+ File.open(path, "w") do |f|
21
+ f.write(content)
22
+ end
23
+
24
+ :new
25
+ end
26
+
27
+ def append(path, template_path = nil, new_line: true) # rubocop:disable Metrics/MethodLength
28
+ raise FileNotFound, "file not found: #{path}" unless File.exist?(path)
29
+
30
+ text = if block_given?
31
+ yield
32
+ else
33
+ Utils::ErbUtil.new(template_path, binding).result
34
+ end
35
+
36
+ content = File.read(path)
37
+ return :no_change if content.include?(text)
38
+
39
+ File.open(path, "a") do |f|
40
+ f << "\n" if new_line
41
+
42
+ f << text
43
+ end
44
+
45
+ :new
46
+ end
47
+
48
+ def replace(path, match, template_path = nil) # rubocop:disable Metrics/MethodLength
49
+ raise FileNotFound, "file not found: #{path}" unless File.exist?(path)
50
+
51
+ text = if block_given?
52
+ yield
53
+ else
54
+ Utils::ErbUtil.new(template_path, binding).result
55
+ end
56
+
57
+ content = File.read(path)
58
+ case match
59
+ when String
60
+ return :no_change unless content.include?(match)
61
+ when Regexp
62
+ return :no_change unless match.match?(content)
63
+ else
64
+ raise InvalidType, "match must be String or Regexp"
65
+ end
66
+
67
+ new_content = content.gsub(match, text)
68
+
69
+ File.open(path, "w") do |f|
70
+ f.write(new_content)
71
+ end
72
+
73
+ :new
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PsmDeadSimpleDeploymentTools
4
+ # include PsmDeadSimpleDeploymentTools::Packages
5
+ # in order to manipulate files
6
+ module Packages
7
+ # Only supports apt package manager
8
+ def install_packages(*packages)
9
+ PackageManager.new.install_packages(*packages)
10
+ end
11
+
12
+ def remove_packages(*packages)
13
+ PackageManager.new.remove_packages(*packages)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PsmDeadSimpleDeploymentTools
4
+ # include PsmDeadSimpleDeploymentTools::Packages
5
+ # in order to manipulate files
6
+ module Packages
7
+ # nodoc
8
+ class AptManager
9
+ include Utils::RunCommandAsSudo
10
+ def install_packages(*packages)
11
+ update_repositories
12
+
13
+ run_command_as_sudo("apt-get install -y #{packages.join(" ")}")
14
+ end
15
+
16
+ def remove_packages(*packages)
17
+ run_command_as_sudo("apt-get remove -y #{packages.join(" ")}")
18
+ end
19
+
20
+ private
21
+
22
+ def update_repositories
23
+ run_command_as_sudo("apt-get update")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PsmDeadSimpleDeploymentTools
4
+ # include PsmDeadSimpleDeploymentTools::Packages
5
+ # in order to manipulate files
6
+ module Packages
7
+ # nodoc
8
+ class PackageManager
9
+ class UnknownPackageManager < StandardError; end
10
+ extend Forwardable
11
+ def_delegators :os_package_manager, :install_packages, :remove_packages
12
+
13
+ private
14
+
15
+ def os_package_manager
16
+ return @os_package_manager if defined? @os_package_manager
17
+
18
+ return @os_package_manager = AptManager.new if system("which apt")
19
+
20
+ raise UnknownPackageManager, "unknown package manager"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PsmDeadSimpleDeploymentTools
4
+ module Utils
5
+ # nodoc
6
+ class ErbUtil
7
+ class Error < StandardError; end
8
+ attr_reader :file_path, :ctx_binding
9
+
10
+ def initialize(file_path, binding)
11
+ @file_path = file_path
12
+ @ctx_binding = binding
13
+ end
14
+
15
+ def result
16
+ raise Error, "template path not found: #{file_path}" unless File.exist?(file_path)
17
+
18
+ template_content = File.read(file_path)
19
+ ERB.new(template_content).result(ctx_binding)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PsmDeadSimpleDeploymentTools
4
+ module Utils
5
+ # nodoc
6
+ module RunCommandAsSudo
7
+ def run_command_as_sudo(cmd)
8
+ run_command = RunCommandAsSudo.sudo_installed? ? "sudo #{cmd}" : cmd
9
+
10
+ system(run_command)
11
+ end
12
+
13
+ class << self
14
+ def sudo_installed?
15
+ return @sudo_installed if defined? @sudo_installed
16
+
17
+ @sudo_installed = !`which sudo`.nil?
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PsmDeadSimpleDeploymentTools
4
+ VERSION = "0.1.1"
5
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/psm_dead_simple_deployment_tools/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "psm_dead_simple_deployment_tools"
7
+ spec.version = PsmDeadSimpleDeploymentTools::VERSION
8
+ spec.authors = ["sebi"]
9
+ spec.email = ["gore.sebyx@yahoo.com"]
10
+
11
+ spec.summary = ""
12
+ spec.description = ""
13
+ spec.homepage = "https://github.com/personal-social-media/psm-dead-simple-deployment-tools"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/personal-social-media/psm-dead-simple-deployment-tools"
19
+ spec.metadata["changelog_uri"] = "https://github.com/personal-social-media/psm-dead-simple-deployment-tools/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Uncomment to register a new dependency of your gem
31
+ # spec.add_dependency "example-gem", "~> 1.0"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: psm_dead_simple_deployment_tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - sebi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-06-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ''
14
+ email:
15
+ - gore.sebyx@yahoo.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".github/workflows/auto-merge.yml"
21
+ - ".github/workflows/main.yml"
22
+ - ".github/workflows/release.yml"
23
+ - ".gitignore"
24
+ - ".rspec"
25
+ - ".rubocop.yml"
26
+ - CHANGELOG.md
27
+ - CODE_OF_CONDUCT.md
28
+ - Gemfile
29
+ - Gemfile.lock
30
+ - LICENSE.txt
31
+ - README.md
32
+ - Rakefile
33
+ - bin/console
34
+ - bin/setup
35
+ - lib/psm_dead_simple_deployment_tools.rb
36
+ - lib/psm_dead_simple_deployment_tools/files.rb
37
+ - lib/psm_dead_simple_deployment_tools/packages.rb
38
+ - lib/psm_dead_simple_deployment_tools/packages/apt_manager.rb
39
+ - lib/psm_dead_simple_deployment_tools/packages/package_manager.rb
40
+ - lib/psm_dead_simple_deployment_tools/utills/erb_util.rb
41
+ - lib/psm_dead_simple_deployment_tools/utills/run_command_as_sudo.rb
42
+ - lib/psm_dead_simple_deployment_tools/version.rb
43
+ - psm_dead_simple_deployment_tools.gemspec
44
+ homepage: https://github.com/personal-social-media/psm-dead-simple-deployment-tools
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://github.com/personal-social-media/psm-dead-simple-deployment-tools
49
+ source_code_uri: https://github.com/personal-social-media/psm-dead-simple-deployment-tools
50
+ changelog_uri: https://github.com/personal-social-media/psm-dead-simple-deployment-tools/CHANGELOG.md
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.7.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.2.15
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: ''
70
+ test_files: []