auto_gem_updater 0.1.1 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/auto_gem_updater/outdated.rb +9 -7
- data/lib/auto_gem_updater/tasks/auto_gem_updater.rake +8 -5
- data/lib/auto_gem_updater/updater.rb +10 -7
- data/lib/auto_gem_updater/version.rb +1 -1
- data/lib/auto_gem_updater.rb +30 -0
- metadata +1 -2
- data/auto_gem_updater-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3af27b6c7126319da9cf983b79b0b9b559fce9eb993c4a86c6becf6e17681761
|
4
|
+
data.tar.gz: 7f6905aa2a194ab992eff2583863606be74f767c2f4f88a79053739284d84db6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77d4167fcb510af51af34c8160a4922165a5c8293daddef0146c52f8e96b8f92281fa17e5f1ffe662b6390d735f8c439ad822d7eee2c00331b2744b756589424
|
7
|
+
data.tar.gz: 1ad452e41a54e135b14b00badce55ccab5524d784ccd241c7905a03bd36d48da4b281e04689430ca8a2106307eef31ac08d7b2041f87afa00f834611f1b78f45
|
data/.gitignore
CHANGED
@@ -2,14 +2,14 @@ require 'open3'
|
|
2
2
|
|
3
3
|
module AutoGemUpdater
|
4
4
|
class Outdated
|
5
|
-
NONUPDATABLE_GEMS = %w[
|
6
|
-
actioncable actionmailer actionpack actionview activejob activemodel
|
7
|
-
activerecord activestorage activesupport rails nokogiri
|
8
|
-
].freeze
|
9
|
-
|
10
5
|
GEM_LINE_REGEX =
|
11
6
|
/(?<gem>[\w-]+)\s{1}\(newest\s{1}(?<newest>[\d\.]+)\,\s{1}installed\s{1}(?<installed>[\d\.]+)\)/
|
12
7
|
|
8
|
+
def initialize
|
9
|
+
@bundle_outdated_command =
|
10
|
+
"bundle outdated --parseable #{AutoGemUpdater.outdated_options}"
|
11
|
+
end
|
12
|
+
|
13
13
|
def self.perform
|
14
14
|
new.perform
|
15
15
|
end
|
@@ -20,10 +20,10 @@ module AutoGemUpdater
|
|
20
20
|
outdated_gems = []
|
21
21
|
|
22
22
|
Open3
|
23
|
-
.popen3(
|
23
|
+
.popen3(bundle_outdated_command) do |_stdin, stdout, _stderr, _wait_thr|
|
24
24
|
while (line = stdout.gets)
|
25
25
|
parsed_data = parse_line(line)
|
26
|
-
next if parsed_data.nil? ||
|
26
|
+
next if parsed_data.nil? || AutoGemUpdater.ignore_gems.include?(parsed_data[:name])
|
27
27
|
|
28
28
|
outdated_gems.push(parsed_data)
|
29
29
|
end
|
@@ -34,6 +34,8 @@ module AutoGemUpdater
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
+
attr_reader :bundle_outdated_command
|
38
|
+
|
37
39
|
def parse_line(line)
|
38
40
|
return unless (match_data = line.match(GEM_LINE_REGEX))
|
39
41
|
|
@@ -3,14 +3,17 @@ require_relative '../updater'
|
|
3
3
|
|
4
4
|
namespace :auto_gem_updater do
|
5
5
|
desc 'Outdated gems minus exluded list'
|
6
|
-
task :
|
7
|
-
|
6
|
+
task outdated: :environment do
|
7
|
+
puts 'Outdated Gems'
|
8
|
+
puts '-' * 80
|
9
|
+
AutoGemUpdater::Outdated.perform.each do |name:, newest:, installed:|
|
10
|
+
puts "Gem: #{name} - current version: #{installed}, newest version: #{newest}"
|
11
|
+
end
|
12
|
+
puts '-' * 80
|
8
13
|
end
|
9
14
|
|
10
15
|
desc 'Auto Updates the Gems'
|
11
16
|
task update: :environment do
|
12
|
-
|
13
|
-
|
14
|
-
AutoGemUpdater::Updater.perform(outdated_gems)
|
17
|
+
AutoGemUpdater::Updater.perform
|
15
18
|
end
|
16
19
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'open3'
|
2
1
|
require_relative 'system'
|
2
|
+
require_relative 'outdated'
|
3
3
|
|
4
4
|
module AutoGemUpdater
|
5
5
|
class Updater
|
6
6
|
include System
|
7
7
|
|
8
|
-
def self.perform
|
9
|
-
new(outdated_gems).perform
|
8
|
+
def self.perform
|
9
|
+
new(outdated_gems: AutoGemUpdater::Outdated.perform).perform
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(outdated_gems)
|
12
|
+
def initialize(outdated_gems:)
|
13
13
|
@outdated_gems = outdated_gems
|
14
14
|
end
|
15
15
|
private_class_method :new
|
@@ -22,11 +22,14 @@ module AutoGemUpdater
|
|
22
22
|
puts "Updating #{name} from #{installed} to #{newest}"
|
23
23
|
system_command("bundle update #{name} --conservative")
|
24
24
|
|
25
|
-
if system_command(
|
25
|
+
if AutoGemUpdater.pre_checks.all? { |check| system_command(check) }
|
26
26
|
puts "Update checks passed commiting update to #{name}"
|
27
27
|
|
28
|
-
system_command(
|
29
|
-
system_command("git commit -m '
|
28
|
+
system_command('git add Gemfile.lock')
|
29
|
+
system_command("git commit -m 'Updated: #{name} from #{installed} to #{newest}'")
|
30
|
+
else
|
31
|
+
puts "Failed to update the gem #{name}"
|
32
|
+
system_command('git checkout .')
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
data/lib/auto_gem_updater.rb
CHANGED
@@ -2,4 +2,34 @@ require 'auto_gem_updater/version'
|
|
2
2
|
require 'auto_gem_updater/railtie'
|
3
3
|
|
4
4
|
module AutoGemUpdater
|
5
|
+
def self.configure
|
6
|
+
yield self
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.pre_checks=(pre_checks)
|
10
|
+
@pre_checks = pre_checks
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.pre_checks
|
14
|
+
@pre_checks || []
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.outdated_options=(outdated_options)
|
18
|
+
@outdated_options =
|
19
|
+
outdated_options.each_with_object('') do |option, options|
|
20
|
+
options << " --#{option}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.outdated_options
|
25
|
+
@outdated_options || '--strict'
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.ignore_gems=(ignore_gems)
|
29
|
+
@ignore_gems = ignore_gems
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.ignore_gems
|
33
|
+
@ignore_gems || []
|
34
|
+
end
|
5
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_gem_updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Venables
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- LICENSE.txt
|
69
69
|
- README.md
|
70
70
|
- Rakefile
|
71
|
-
- auto_gem_updater-0.1.0.gem
|
72
71
|
- auto_gem_updater.gemspec
|
73
72
|
- bin/console
|
74
73
|
- bin/setup
|
data/auto_gem_updater-0.1.0.gem
DELETED
Binary file
|