auto_gem_updater 0.1.1 → 0.2.0

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: 19efb6f3b4c7a4addef0cb642dc113cc493bc27b096b9257df2b89c19a7ba474
4
- data.tar.gz: b5aed85f9230a958d73af310eea18c0bdf5d0c1e89dec639295c5804ce13a763
3
+ metadata.gz: 3af27b6c7126319da9cf983b79b0b9b559fce9eb993c4a86c6becf6e17681761
4
+ data.tar.gz: 7f6905aa2a194ab992eff2583863606be74f767c2f4f88a79053739284d84db6
5
5
  SHA512:
6
- metadata.gz: b2a845a49a1bf9f66c4804904a1a57561b3065079035b377343570a9f8fe2e169987de9d4710017a2796900cccb8bbe07bada5beddca2206f0f655f688875f14
7
- data.tar.gz: 810843c61d0b27bdd892bd739f44825c5a423e7d6802b7835da56c21ad9da758c85a175025ae6320290d148eccd67df45ef6c355fd8b99a0a9a8362ce92793e8
6
+ metadata.gz: 77d4167fcb510af51af34c8160a4922165a5c8293daddef0146c52f8e96b8f92281fa17e5f1ffe662b6390d735f8c439ad822d7eee2c00331b2744b756589424
7
+ data.tar.gz: 1ad452e41a54e135b14b00badce55ccab5524d784ccd241c7905a03bd36d48da4b281e04689430ca8a2106307eef31ac08d7b2041f87afa00f834611f1b78f45
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ *.gem
@@ -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('bundle outdated --strict --parseable') do |_stdin, stdout, _stderr, _wait_thr|
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? || NONUPDATABLE_GEMS.include?(parsed_data[:name])
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 :outdated do
7
- AutoGemUpdater::Outdated.perform
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
- outdated_gems = AutoGemUpdater::Outdated.perform
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(outdated_gems)
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("rspec")
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("git add .")
29
- system_command("git commit -m 'Update the gem #{name} from #{installed} to #{newest}'")
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
@@ -1,3 +1,3 @@
1
1
  module AutoGemUpdater
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.1.1
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
Binary file