pbmenv 0.1.3 → 0.1.7

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: 6c1836c83f6b1324c9bfc14479d1a633cb9a61983bc63ac506a11317f7d30cd5
4
- data.tar.gz: 39256579dd73802f3ba9cbebc0c881ae3dd456ff18991385fc3cdc0af8472339
3
+ metadata.gz: 7f3ac7d44e0f095598e3a3a80728d61cf0fc8f8bd363c50a37beaa1bc08537bc
4
+ data.tar.gz: 929ccd1944970ee956efe39855a17aa4c488462725ab7cf7c7f5b89dcca014bf
5
5
  SHA512:
6
- metadata.gz: ba1130d7ed07a4ee7efe76620bcc8315526d207bf9ee1644ccede776f76236d9fd8a28e1dc4841ad73fdb70f470d1b8dfa82305ce34e672beea312cdcaf82701
7
- data.tar.gz: aa59fe03426ef508147376f3c32681d254824e18316fd7f5be784b360e0259dab493c47a45e3b308e7571d5033712f58a544280d34d0099ab087cb1913b611fa
6
+ metadata.gz: af65fec992aeaaff02bf3ca0abc7f3f2c92f0deb5f065e4bce53b0169d1030f2f5f39cd0758bb630c016c0d66a53f6174ab1cd85b8017b7522d621c174493048
7
+ data.tar.gz: 9716ea9f4f06624680d5169bf7f2f36a36957fbf960966dfbab279708006f40ac6855ccaa8df93abd27bfa67b077c4c4ffb766eefee9a3b11816ae38ff29746a
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --require spec_helper
2
+ -f d
data/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
- ## [0.1.3] - 2021-10:22
1
+ ## [0.1.7] - 2022-01-11
2
+ - currentが存在しないときに、installを実行するとcurrentを貼るようにしました
3
+
4
+ ## [0.1.6] - 2021-12-01
5
+ - Improve spec
6
+ - installコマンドでcurrentの張り替えをしないようにしました。currentの参照を変えるときはuseコマンドを使ってください
7
+
8
+ ## [0.1.5] - 2021-11-16
9
+ - `/usr/share/pbm/shared/device_id` を作成するようにしました
10
+
11
+ ## [0.1.4] - 2021-11-15
12
+
13
+ - `/usr/share/pbm/current/device_id` にシムリンクを作成するようにしました
14
+
15
+ ## [0.1.3] - 2021-10-22
2
16
 
3
17
  - help的な出力をする
4
18
 
data/Dockerfile CHANGED
@@ -2,5 +2,6 @@ FROM ruby:2.5
2
2
 
3
3
  WORKDIR /pbmenv
4
4
 
5
+ ENV CI=1
5
6
  ADD docker/Gemfile .
6
- RUN apt-get update && apt-get install vim && gem i bundler && bundle install
7
+ RUN apt-get update && apt-get install vim -y && gem i bundler && bundle install
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pbmenv (0.1.3)
4
+ pbmenv (0.1.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -25,11 +25,12 @@ GEM
25
25
  rspec-mocks (3.10.2)
26
26
  diff-lcs (>= 1.2.0, < 2.0)
27
27
  rspec-support (~> 3.10.0)
28
- rspec-support (3.10.2)
28
+ rspec-support (3.10.3)
29
29
 
30
30
  PLATFORMS
31
31
  aarch64-linux
32
32
  arm64-darwin-20
33
+ arm64-darwin-21
33
34
  x86_64-linux
34
35
 
35
36
  DEPENDENCIES
@@ -39,4 +40,4 @@ DEPENDENCIES
39
40
  rspec
40
41
 
41
42
  BUNDLED WITH
42
- 2.2.16
43
+ 2.2.31
data/README.md CHANGED
@@ -17,6 +17,7 @@ gem 'pbmenv'
17
17
  * pbmenv available_versions
18
18
  * pbmenv versions
19
19
  * pbmenv install $version
20
+ * pbmenv use $version
20
21
  * pbmenv uninstall $version
21
22
  * API
22
23
  * Pbmenv.available_versions
@@ -26,6 +27,7 @@ gem 'pbmenv'
26
27
  * Pbmenv.install(version)
27
28
  * https://github.com/splaplapla/procon_bypass_man/archive/refs/tags/v#{version}.tar.gz をダウンロードして、
28
29
  * /usr/share/pbm/#{version} に app.rb, pbm.servive, setting.yml を配備する
30
+ * Pbmenv.use(version)
29
31
  * /usr/share/pbm/#{version} を /usr/share/pbm/current へのシムリンクを作成する
30
32
  * Pbmenv.uninstall(version)
31
33
  * /usr/share/pbm/current が削除対象だったら例外を投げる
@@ -40,5 +42,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
40
42
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
43
 
42
44
  ## Development
43
- * docker-compose build --no-cache
45
+ * docker-compose build --no-cache
44
46
  * docker-compose run app bash
47
+ * bin/rspec
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/lib/pbmenv/cli.rb CHANGED
@@ -10,6 +10,9 @@ module Pbmenv
10
10
  when 'install', 'i'
11
11
  sub_command_arg = argv[1]
12
12
  Pbmenv.install(sub_command_arg)
13
+ when 'use', 'u'
14
+ sub_command_arg = argv[1]
15
+ Pbmenv.use(sub_command_arg)
13
16
  when 'uninstall'
14
17
  sub_command_arg = argv[1]
15
18
  Pbmenv.uninstall(sub_command_arg)
@@ -18,7 +21,7 @@ module Pbmenv
18
21
  else
19
22
  puts <<~EOH
20
23
  Unknown command:
21
- available commands: available_versions, versions, install, uninstall
24
+ available commands: available_versions, versions, install, use, uninstall
22
25
  EOH
23
26
  end
24
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pbmenv
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.7"
5
5
  end
data/lib/pbmenv.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "securerandom"
4
+ require "pathname"
5
+
3
6
  require_relative "pbmenv/version"
4
7
  require_relative "pbmenv/cli"
5
8
  require_relative "pbmenv/pbm"
@@ -12,7 +15,7 @@ module Pbmenv
12
15
  end
13
16
 
14
17
  def self.versions
15
- Pbmenv::PBM.new.versions.map { |name| Pathname.new(name).basename.to_s =~ /^v([\d.]+)/ && $1 }.compact
18
+ Pbmenv::PBM.new.versions.map { |name| Pathname.new(name).basename.to_s =~ /^v([\d.]+)/ && $1 }.compact.sort_by {|x| Gem::Version.new(x) }.compact
16
19
  end
17
20
 
18
21
  def self.install(version)
@@ -26,15 +29,35 @@ module Pbmenv
26
29
  end
27
30
 
28
31
  download_src(version)
29
- system_with_puts <<~SHELL
32
+ system_and_puts <<~SHELL
30
33
  mkdir -p #{PBM_DIR}/v#{version} && cp -r procon_bypass_man-#{version}/project_template/* #{PBM_DIR}/v#{version}/
31
34
  SHELL
32
- use version
35
+
36
+ unless File.exists?("#{PBM_DIR}/shared")
37
+ system_and_puts <<~SHELL
38
+ mkdir -p #{PBM_DIR}/shared
39
+ SHELL
40
+ end
41
+
42
+ unless File.exists?("#{PBM_DIR}/shared/device_id")
43
+ File.write("#{PBM_DIR}/shared/device_id", "d_#{SecureRandom.uuid}")
44
+ end
45
+
46
+ system_and_puts <<~SHELL
47
+ ln -s #{PBM_DIR}/shared/device_id #{PBM_DIR}/v#{version}/device_id
48
+ SHELL
49
+
50
+ # 初回だけinstall時にcurrentを作成する
51
+ if not File.exists?("#{PBM_DIR}/current")
52
+ use(version)
53
+ end
33
54
  rescue => e
34
- system_with_puts "rm -rf #{PBM_DIR}/v#{version}"
55
+ system_and_puts "rm -rf #{PBM_DIR}/v#{version}"
35
56
  raise
36
57
  ensure
37
- system_with_puts "rm -rf ./procon_bypass_man-#{version}"
58
+ if Dir.exists?("./procon_bypass_man-#{version}")
59
+ system_and_puts "rm -rf ./procon_bypass_man-#{version}"
60
+ end
38
61
  end
39
62
 
40
63
  # TODO currentが挿しているバージョンはどうする?
@@ -44,20 +67,21 @@ module Pbmenv
44
67
  unless File.exists?("/usr/share/pbm/v#{version}")
45
68
  return false
46
69
  end
47
- system_with_puts "rm -rf #{PBM_DIR}/v#{version}"
70
+ system_and_puts "rm -rf #{PBM_DIR}/v#{version}"
48
71
  end
49
72
 
50
73
  def self.use(version)
51
74
  raise "Need a version" if version.nil?
75
+ version = versions.last if version == "latest"
52
76
 
53
- unless File.exists?("/usr/share/pbm/v#{version}")
77
+ if !File.exists?("/usr/share/pbm/#{version}") && !File.exists?("/usr/share/pbm/v#{version}")
54
78
  return false
55
79
  end
56
80
 
57
81
  if File.exists?("#{PBM_DIR}/current")
58
- system_with_puts "unlink #{PBM_DIR}/current"
82
+ system_and_puts "unlink #{PBM_DIR}/current"
59
83
  end
60
- system_with_puts "ln -s #{PBM_DIR}/v#{version} #{PBM_DIR}/current"
84
+ system_and_puts "ln -s #{PBM_DIR}/v#{version} #{PBM_DIR}/current"
61
85
  end
62
86
 
63
87
  def self.download_src(version)
@@ -66,17 +90,18 @@ module Pbmenv
66
90
  git clone https://github.com/splaplapla/procon_bypass_man.git procon_bypass_man-#{version}
67
91
  SHELL
68
92
  else
93
+ # TODO cache for testing
69
94
  shell = <<~SHELL
70
95
  curl -L https://github.com/splaplapla/procon_bypass_man/archive/refs/tags/v#{version}.tar.gz | tar xvz
71
96
  SHELL
72
97
  end
73
- system_with_puts(shell)
98
+ system_and_puts(shell)
74
99
  unless File.exists?("procon_bypass_man-#{version}/project_template")
75
100
  raise "This version is not support by pbmenv"
76
101
  end
77
102
  end
78
103
 
79
- def self.system_with_puts(shell)
104
+ def self.system_and_puts(shell)
80
105
  puts "[SHELL] #{shell}"
81
106
  system(shell)
82
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbmenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-22 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A package manager of PBM
14
14
  email:
@@ -32,6 +32,7 @@ files:
32
32
  - README.md
33
33
  - Rakefile
34
34
  - bin/console
35
+ - bin/rspec
35
36
  - bin/setup
36
37
  - docker-compose.yml
37
38
  - docker/Gemfile