pbmenv 0.1.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: e8dc67105ea7fe29bcbac78e0c9cdebf6392113e392da9007c6ae0e44a9c7a61
4
+ data.tar.gz: 0f496a0a230b481650f115f94b9e8557930548fec2d72f52c9b2dbb13baebe66
5
+ SHA512:
6
+ metadata.gz: 4ce6fc89439dbdf1e22e884997dd0271d6ac3c00babddf280fae284efbcf49adbb45a31a596e2b6f9c7e7a14f130794c5bb93c28935022b901b15d744386d991
7
+ data.tar.gz: c69a318d18164520af09769678a88eb081826c8e91af64ac658e322b34336eee792c2b7d6a0945b553c256a26a482a60ada116ad7180b3b322f8509f66e7ebb4
@@ -0,0 +1,45 @@
1
+ version: 2.1
2
+
3
+ executors:
4
+ ruby:
5
+ parameters:
6
+ tag:
7
+ type: string
8
+ default: "latest"
9
+ docker:
10
+ - image: ruby:<< parameters.tag >>
11
+ environment:
12
+ BUNDLE_PATH: vendor/bundle
13
+ BUNDLE_JOBS: 4
14
+ working_directory: ~/app
15
+
16
+ jobs:
17
+ rspec:
18
+ parameters:
19
+ version:
20
+ type: string
21
+ executor:
22
+ name: ruby
23
+ tag: << parameters.version >>
24
+ steps:
25
+ - checkout
26
+ - run: ruby --version
27
+ - run: bundle --version
28
+ - run: gem --version
29
+ - run: gem install bundler
30
+ - run: bundle install --jobs 4
31
+ - run: bundle exec rspec
32
+
33
+ build_jobs: &build_jobs
34
+ - rspec:
35
+ matrix:
36
+ parameters:
37
+ version:
38
+ - "2.5"
39
+ - "2.6"
40
+ - "2.7"
41
+ - "3.0"
42
+ workflows:
43
+ version: 2
44
+ build:
45
+ jobs: *build_jobs
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-09-11
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 n905i.1214@gmail.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/Dockerfile ADDED
@@ -0,0 +1,6 @@
1
+ FROM ruby:2.5
2
+
3
+ WORKDIR /pbmenv
4
+
5
+ ADD docker/Gemfile .
6
+ RUN gem i bundler && bundle install
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in pbmenv.gemspec
6
+ gemspec
7
+
8
+ gem "rake"
9
+ gem "rspec"
10
+ gem "pry"
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pbmenv (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.3)
10
+ diff-lcs (1.4.4)
11
+ method_source (1.0.0)
12
+ pry (0.14.1)
13
+ coderay (~> 1.1)
14
+ method_source (~> 1.0)
15
+ rake (13.0.6)
16
+ rspec (3.10.0)
17
+ rspec-core (~> 3.10.0)
18
+ rspec-expectations (~> 3.10.0)
19
+ rspec-mocks (~> 3.10.0)
20
+ rspec-core (3.10.1)
21
+ rspec-support (~> 3.10.0)
22
+ rspec-expectations (3.10.1)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-mocks (3.10.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-support (3.10.2)
29
+
30
+ PLATFORMS
31
+ aarch64-linux
32
+ arm64-darwin-20
33
+
34
+ DEPENDENCIES
35
+ pbmenv!
36
+ pry
37
+ rake
38
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 jiikko
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,43 @@
1
+ # Pbmenv
2
+
3
+ * https://github.com/splaplapla/procon_bypass_man のバージョンマネージャー
4
+ * Raspberry Pi OSでの実行を想定しています
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'pbmenv'
12
+ ```
13
+
14
+ ## Usage
15
+ * pbmenv commands
16
+ * pbmenv available_versions
17
+ * pbmenv versions
18
+ * pbmenv install $version
19
+ * pbmenv uninstall $version
20
+ * API
21
+ * Pbmenv.available_versions
22
+ * https://github.com/splaplapla/procon_bypass_man/tags からバージョンのリストを取ってくる
23
+ * Pbmenv.versions
24
+ * /usr/share/pbm/#{version} を返す
25
+ * Pbmenv.install(version)
26
+ * https://github.com/splaplapla/procon_bypass_man/archive/refs/tags/v#{version}.tar.gz をダウンロードして、
27
+ * /usr/share/pbm/#{version} に app.rb, pbm.servive, setting.yml を配備する
28
+ * /usr/share/pbm/#{version} を /usr/share/pbm/current へのシムリンクを作成する
29
+ * Pbmenv.uninstall(version)
30
+ * /usr/share/pbm/current が削除対象だったら例外を投げる
31
+ * /usr/share/pbm/#{version} を 削除する
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pbmenv. 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]/pbmenv/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Development
42
+ * docker-compose build --no-cache
43
+ * docker-compose run app bash
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
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 "pbmenv"
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/docker/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "pbmenv", github: 'splaplapla/pbmenv', branch: :master
@@ -0,0 +1,14 @@
1
+ version: '2'
2
+ services:
3
+ app:
4
+ environment:
5
+ - CI=1
6
+ build: .
7
+ command: bash
8
+ volumes:
9
+ - './:/pbmenv'
10
+ - bundle_path:/bundle
11
+ environment:
12
+ - BUNDLE_PATH=/bundle
13
+ volumes:
14
+ bundle_path:
data/exe/pbmenv ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "pbmenv"
6
+
7
+ Pbmenv::CLI.run ARGV
data/lib/pbmenv/cli.rb ADDED
@@ -0,0 +1,19 @@
1
+ module Pbmenv
2
+ class CLI
3
+ def self.run(argv)
4
+ sub_command = argv[0]
5
+ case sub_command
6
+ when 'available_versions', 'av'
7
+ Pbmenv.available_versions.each { |x| puts x }
8
+ when 'versions', 'list'
9
+ Pbmenv.versions.each { |x| puts x }
10
+ when 'install', 'i'
11
+ sub_command_arg = argv[1]
12
+ Pbmenv.install(sub_command_arg)
13
+ when 'uninstall'
14
+ sub_command_arg = argv[1]
15
+ Pbmenv.uninstall(sub_command_arg)
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/pbmenv/pbm.rb ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open-uri'
4
+ require 'json'
5
+
6
+ module Pbmenv
7
+ class PBM
8
+ def available_versions
9
+ response = URI.open 'https://api.github.com/repos/splaplapla/procon_bypass_man/tags'
10
+ JSON.parse(response.read)
11
+ end
12
+
13
+ def versions
14
+ Dir.glob("#{Pbmenv::PBM_DIR}/v*")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pbmenv
4
+ VERSION = "0.1.0"
5
+ end
data/lib/pbmenv.rb ADDED
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "pbmenv/version"
4
+ require_relative "pbmenv/cli"
5
+ require_relative "pbmenv/pbm"
6
+
7
+ module Pbmenv
8
+ PBM_DIR = "/usr/share/pbm"
9
+
10
+ def self.available_versions
11
+ Pbmenv::PBM.new.available_versions.map { |x| x["name"] =~ /^v([\d.]+)/ && $1 }.compact
12
+ end
13
+
14
+ def self.versions
15
+ Pbmenv::PBM.new.versions.map { |name| Pathname.new(name).basename.to_s =~ /^v([\d.]+)/ && $1 }.compact
16
+ end
17
+
18
+ def self.install(version)
19
+ raise "Need a version" if version.nil?
20
+
21
+ if File.exists?("/usr/share/pbm/v#{version}")
22
+ return false
23
+ end
24
+
25
+ download_src(version)
26
+ system_with_puts <<~SHELL
27
+ mkdir -p #{PBM_DIR}/v#{version} && cp -r procon_bypass_man-#{version}/project_template/* #{PBM_DIR}/v#{version}/
28
+ SHELL
29
+ use version
30
+ rescue => e
31
+ system_with_puts "rm -rf #{PBM_DIR}/v#{version}"
32
+ raise
33
+ ensure
34
+ system_with_puts "rm -rf ./procon_bypass_man-#{version}"
35
+ end
36
+
37
+ # TODO currentが挿しているバージョンはどうする?
38
+ def self.uninstall(version)
39
+ raise "Need a version" if version.nil?
40
+
41
+ unless File.exists?("/usr/share/pbm/v#{version}")
42
+ return false
43
+ end
44
+ system_with_puts "rm -rf #{PBM_DIR}/v#{version}"
45
+ end
46
+
47
+ def self.use(version)
48
+ raise "Need a version" if version.nil?
49
+
50
+ unless File.exists?("/usr/share/pbm/v#{version}")
51
+ return false
52
+ end
53
+
54
+ if File.exists?("#{PBM_DIR}/current")
55
+ system_with_puts "unlink #{PBM_DIR}/current"
56
+ end
57
+ system_with_puts "ln -s #{PBM_DIR}/v#{version} #{PBM_DIR}/current"
58
+ end
59
+
60
+ def self.download_src(version)
61
+ if ENV["DEBUG_INSTALL"]
62
+ shell = <<~SHELL
63
+ git clone https://github.com/splaplapla/procon_bypass_man.git procon_bypass_man-#{version}
64
+ SHELL
65
+ else
66
+ shell = <<~SHELL
67
+ curl -L https://github.com/splaplapla/procon_bypass_man/archive/refs/tags/v#{version}.tar.gz | tar xvz
68
+ SHELL
69
+ end
70
+ system_with_puts(shell)
71
+ unless File.exists?("procon_bypass_man-#{version}/project_template")
72
+ raise "This version is not support by pbmenv"
73
+ end
74
+ end
75
+
76
+ def self.system_with_puts(shell)
77
+ puts "[SHELL] #{shell}"
78
+ system(shell)
79
+ end
80
+ end
data/pbmenv.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/pbmenv/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "pbmenv"
7
+ spec.version = Pbmenv::VERSION
8
+ spec.authors = ["jiikko"]
9
+ spec.email = ["n905i.1214@gmail.com"]
10
+
11
+ spec.summary = "A package manager of PBM"
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/splaplapla/pbmenv"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ # Uncomment to register a new dependency of your gem
29
+ # spec.add_dependency "example-gem", "~> 1.0"
30
+
31
+ # For more information and examples about making a new gem, checkout our
32
+ # guide at: https://bundler.io/guides/creating_gem.html
33
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pbmenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - jiikko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A package manager of PBM
14
+ email:
15
+ - n905i.1214@gmail.com
16
+ executables:
17
+ - pbmenv
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".circleci/config.yml"
22
+ - ".gitignore"
23
+ - ".rspec"
24
+ - CHANGELOG.md
25
+ - CODE_OF_CONDUCT.md
26
+ - Dockerfile
27
+ - Gemfile
28
+ - Gemfile.lock
29
+ - LICENSE.txt
30
+ - README.md
31
+ - Rakefile
32
+ - bin/console
33
+ - bin/setup
34
+ - docker-compose.yml
35
+ - docker/Gemfile
36
+ - exe/pbmenv
37
+ - lib/pbmenv.rb
38
+ - lib/pbmenv/cli.rb
39
+ - lib/pbmenv/pbm.rb
40
+ - lib/pbmenv/version.rb
41
+ - pbmenv.gemspec
42
+ homepage: https://github.com/splaplapla/pbmenv
43
+ licenses:
44
+ - MIT
45
+ metadata:
46
+ homepage_uri: https://github.com/splaplapla/pbmenv
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.4.0
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.2.3
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: A package manager of PBM
66
+ test_files: []