ruby_auto_installer 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 77a8817f8690ba1b8f4c7d6c5c5e07f7c2e52cac3142dc7e02ff952ad8312820
4
+ data.tar.gz: 59397547d59e822626a2d735eedd5ec81436f2607bb2312a84c0cc3b09d1ee4f
5
+ SHA512:
6
+ metadata.gz: b1cac6fa0ccb3d664ee156681cacfd5e67ceeabe27ab82c44f344912dca595ec16352577e05ce8e4d985f8f8e793e080021449d3f442ae12397f483b93e561b1
7
+ data.tar.gz: 76097c65df8018c83c1171ba0023fc68860d65d3001093a681905556c0ac47e714347711a4c77877d33735f84abccbe70e27ac562c03aaaee60c22690a19cad2
@@ -0,0 +1,11 @@
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
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 1.17.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ruby_auto_installer.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 J Miles
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.
@@ -0,0 +1,32 @@
1
+ # RubyAutoInstaller
2
+
3
+ RubyAutoInstaller is designed to be run automatically (cronjob, startup, etc) and install Ruby versions.
4
+ This saves the downtime of waiting for new Ruby versions to download an compile.
5
+
6
+ ## Installation
7
+
8
+ $ gem install ruby_auto_installer
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ Usage:
14
+ ruby_auto_installer update
15
+
16
+ Options:
17
+ -n, [--manager-name=MANAGER_NAME] # Manager to use (asdf/rbenv/rvm)
18
+ -v, [--verbose] # Verbose output
19
+ -g, [--greedy] # Install all versions, not just latest patch
20
+ -m, [--min-version=MIN_VERSION] # Minimum Ruby version to consider (i.e."2.0")
21
+ -d, [--dry_run] # List versions that would be installed, but do not install
22
+ ```
23
+
24
+ By default only the latest patch version will be installed
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mc-squared/ruby_auto_installer.
29
+
30
+ ## License
31
+
32
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruby_auto_installer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -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,4 @@
1
+ #!/usr/bin/env ruby
2
+ require "ruby_auto_installer"
3
+
4
+ RubyAutoInstaller::CLI.start
@@ -0,0 +1,8 @@
1
+ require "ruby_auto_installer/cli"
2
+ require "ruby_auto_installer/managers/asdf"
3
+ require "ruby_auto_installer/version"
4
+
5
+ module RubyAutoInstaller
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,110 @@
1
+ require "thor"
2
+
3
+ module RubyAutoInstaller
4
+ class CLI < Thor
5
+ desc "update", "install new ruby versions using a version manager"
6
+ method_option :manager_name, aliases: "-n", desc: "Manager to use (asdf/rbenv/rvm)"
7
+ method_option :verbose, aliases: "-v", desc: "Verbose output"
8
+ method_option :greedy, aliases: "-g", desc: "Install all versions, not just latest patch"
9
+ method_option :min_version, aliases: "-m", desc: "Minimum Ruby version to consider (i.e.\"2.0\")"
10
+ method_option :dry_run, aliases: "-d", desc: "List versions that would be installed, but do not install"
11
+ def update
12
+ @verbose = options[:verbose]
13
+ manager_name = options[:manager_name]
14
+
15
+ if options[:manager_name].nil?
16
+ debug "Finding manager..."
17
+ if Managers::Asdf.present?
18
+ debug "Found asdf version manager"
19
+ manager_name = "asdf"
20
+ elsif Managers::Rbenv.present?
21
+ debug "Found rbenv version manager"
22
+ manager_name = "rbenv"
23
+ elsif Managers::Rvm.present?
24
+ debug "Found rvm version manager"
25
+ manager_name = "rvm"
26
+ else
27
+ raise "Failed to find a version manager"
28
+ end
29
+ end
30
+
31
+ debug "Attempting to use #{manager_name} version manager"
32
+ manager = load_manager(manager_name)
33
+
34
+ debug "Updating #{manager_name}"
35
+ manager.update
36
+
37
+ debug "Currently installed versions:"
38
+ installed = strip_lines(manager.installed_versions)
39
+ debug installed
40
+
41
+ debug "Available versions:"
42
+ available = strip_lines(standard_releases_only(manager.all_versions))
43
+ debug available
44
+
45
+ if options[:greedy].nil?
46
+ latest = []
47
+ available.sort_by! { |version| Gem::Version.new(version) }
48
+ loop do
49
+ last = available.last
50
+ latest << last
51
+
52
+ available.reject! { |version| version[0..2] == last[0..2] }
53
+ break if available.empty?
54
+ end
55
+ available = latest
56
+ end
57
+
58
+ debug "Versions to be installed:"
59
+ install_versions = missing_releases(installed, available)
60
+
61
+ unless options[:min_version].nil?
62
+ install_versions.reject! { |version| version <= options[:min_version] }
63
+ end
64
+
65
+ debug install_versions
66
+
67
+ install_versions.each do |version|
68
+ if options[:dry_run]
69
+ puts "DRY RUN: Would install #{version}"
70
+ else
71
+ manager.install(version)
72
+ end
73
+ end
74
+
75
+ manager.refresh
76
+
77
+ puts "All done!"
78
+ end
79
+
80
+ private
81
+
82
+ def standard_releases_only(versions)
83
+ versions.select { |line| line.match("^[0-9]*.[0-9]*.[0-9]*$") }
84
+ end
85
+
86
+ def missing_releases(installed, available)
87
+ available.reject { |version| installed.include? version }
88
+ end
89
+
90
+ def strip_lines(str)
91
+ str.map(&:strip)
92
+ end
93
+
94
+ def load_manager(name)
95
+ manager = "RubyAutoInstaller::Managers::#{name.capitalize}".
96
+ split("::").
97
+ inject(Object) { |o, c| o.const_get c }
98
+
99
+ unless manager.present?
100
+ raise "Failed to load manager #{name}"
101
+ end
102
+
103
+ manager
104
+ end
105
+
106
+ def debug(msg)
107
+ puts msg if @verbose
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,29 @@
1
+ module RubyAutoInstaller
2
+ module Managers
3
+ class Asdf
4
+ def self.present?
5
+ system("asdf --version")
6
+ end
7
+
8
+ def self.update
9
+ `asdf update`
10
+ `asdf plugin-update ruby`
11
+ end
12
+
13
+ def self.all_versions
14
+ `asdf list-all ruby`.lines
15
+ end
16
+
17
+ def self.installed_versions
18
+ `asdf list ruby`.lines
19
+ end
20
+
21
+ def self.install(version)
22
+ system("asdf install ruby #{version}")
23
+ end
24
+
25
+ def self.refresh
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module RubyAutoInstaller
2
+ module Managers
3
+ class Rbenv
4
+ def self.present?
5
+ system("rbenv version")
6
+ end
7
+
8
+ def self.update
9
+ # Not yet implemented
10
+ end
11
+
12
+ def self.all_versions
13
+ `rbenv install -l`.lines
14
+ end
15
+
16
+ def self.installed_versions
17
+ `rbenv versions`.lines
18
+ end
19
+
20
+ def self.install(version)
21
+ system("rbenv install ruby #{version}")
22
+ end
23
+
24
+ def self.refresh
25
+ system("rbenv rehash")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module RubyAutoInstaller
2
+ module Managers
3
+ class Rvm
4
+ def self.present?
5
+ system("rvm --version")
6
+ end
7
+
8
+ def self.update
9
+ `rvm get stable`
10
+ `rvm reload`
11
+ end
12
+
13
+ def self.all_versions
14
+ `rvm list --all`.lines
15
+ end
16
+
17
+ def self.installed_versions
18
+ `rvm list`.lines
19
+ end
20
+
21
+ def self.install(version)
22
+ system("rvm install #{version}")
23
+ end
24
+
25
+ def self.refresh
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module RubyAutoInstaller
2
+ VERSION = "0.1.4"
3
+ end
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ruby_auto_installer/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruby_auto_installer"
8
+ spec.version = RubyAutoInstaller::VERSION
9
+ spec.authors = ["J Miles"]
10
+ spec.email = ["j.milesy.nz@gmail.com"]
11
+
12
+ spec.summary = %q{A ruby version manager manager}
13
+ spec.description = %q{Auto-installs versions of ruby missing from the system}
14
+ spec.homepage = "https://www.github.com/MC-Squared/ruby_auto_installer"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = spec.homepage
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+
42
+ spec.add_runtime_dependency "thor", "~> 0.20.3"
43
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_auto_installer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - J Miles
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-11-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.20.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.20.3
69
+ description: Auto-installs versions of ruby missing from the system
70
+ email:
71
+ - j.milesy.nz@gmail.com
72
+ executables:
73
+ - ruby_auto_installer
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - exe/ruby_auto_installer
87
+ - lib/ruby_auto_installer.rb
88
+ - lib/ruby_auto_installer/cli.rb
89
+ - lib/ruby_auto_installer/managers/asdf.rb
90
+ - lib/ruby_auto_installer/managers/rbenv.rb
91
+ - lib/ruby_auto_installer/managers/rvm.rb
92
+ - lib/ruby_auto_installer/version.rb
93
+ - ruby_auto_installer.gemspec
94
+ homepage: https://www.github.com/MC-Squared/ruby_auto_installer
95
+ licenses:
96
+ - MIT
97
+ metadata:
98
+ homepage_uri: https://www.github.com/MC-Squared/ruby_auto_installer
99
+ source_code_uri: https://www.github.com/MC-Squared/ruby_auto_installer
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.7.6
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: A ruby version manager manager
120
+ test_files: []