auto_gem_updater 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f27bbafff841d80287d644d440c72e680ce9db59e20300703551f458e61126bb
4
- data.tar.gz: 7304d86bb6820fc67a2d86b6941f89ecdc4595a807fce60e6cd43cf15b26333f
3
+ metadata.gz: 19efb6f3b4c7a4addef0cb642dc113cc493bc27b096b9257df2b89c19a7ba474
4
+ data.tar.gz: b5aed85f9230a958d73af310eea18c0bdf5d0c1e89dec639295c5804ce13a763
5
5
  SHA512:
6
- metadata.gz: 4c1b80e54a8a86f1c3891043fd967cef72cabf28d335a4417b9d1407050f5e199dd416445a4193c1b2379d397b29ee86456fb9d0ae28b88133af262d6159e9d9
7
- data.tar.gz: 82ebe33ffc6562842be77f2e18c959ffda556ca5a6ec1e42ff68fea55110d2709b7fe67768c6970cae49be2d23ec730b01969626cbcb4dfd93ef52edf15862cb
6
+ metadata.gz: b2a845a49a1bf9f66c4804904a1a57561b3065079035b377343570a9f8fe2e169987de9d4710017a2796900cccb8bbe07bada5beddca2206f0f655f688875f14
7
+ data.tar.gz: 810843c61d0b27bdd892bd739f44825c5a423e7d6802b7835da56c21ad9da758c85a175025ae6320290d148eccd67df45ef6c355fd8b99a0a9a8362ce92793e8
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ auto_gem_updater (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.8.0)
12
+ rspec-core (~> 3.8.0)
13
+ rspec-expectations (~> 3.8.0)
14
+ rspec-mocks (~> 3.8.0)
15
+ rspec-core (3.8.0)
16
+ rspec-support (~> 3.8.0)
17
+ rspec-expectations (3.8.2)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-mocks (3.8.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-support (3.8.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ auto_gem_updater!
30
+ bundler (~> 1.17)
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.17.2
Binary file
@@ -1,4 +1,5 @@
1
- require "auto_gem_updater/version"
1
+ require 'auto_gem_updater/version'
2
+ require 'auto_gem_updater/railtie'
2
3
 
3
4
  module AutoGemUpdater
4
5
  end
@@ -0,0 +1,47 @@
1
+ require 'open3'
2
+
3
+ module AutoGemUpdater
4
+ class Outdated
5
+ NONUPDATABLE_GEMS = %w[
6
+ actioncable actionmailer actionpack actionview activejob activemodel
7
+ activerecord activestorage activesupport rails nokogiri
8
+ ].freeze
9
+
10
+ GEM_LINE_REGEX =
11
+ /(?<gem>[\w-]+)\s{1}\(newest\s{1}(?<newest>[\d\.]+)\,\s{1}installed\s{1}(?<installed>[\d\.]+)\)/
12
+
13
+ def self.perform
14
+ new.perform
15
+ end
16
+
17
+ private_class_method :new
18
+
19
+ def perform
20
+ outdated_gems = []
21
+
22
+ Open3
23
+ .popen3('bundle outdated --strict --parseable') do |_stdin, stdout, _stderr, _wait_thr|
24
+ while (line = stdout.gets)
25
+ parsed_data = parse_line(line)
26
+ next if parsed_data.nil? || NONUPDATABLE_GEMS.include?(parsed_data[:name])
27
+
28
+ outdated_gems.push(parsed_data)
29
+ end
30
+ end
31
+
32
+ outdated_gems
33
+ end
34
+
35
+ private
36
+
37
+ def parse_line(line)
38
+ return unless (match_data = line.match(GEM_LINE_REGEX))
39
+
40
+ {
41
+ name: match_data[:gem],
42
+ newest: match_data[:newest],
43
+ installed: match_data[:installed]
44
+ }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,8 @@
1
+ module AutoGemUpdater
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ path = File.expand_path(__dir__)
5
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module AutoGemUpdater
2
+ module System
3
+ def system_command(command)
4
+ system(command, %i[out err] => File::NULL)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../outdated'
2
+ require_relative '../updater'
3
+
4
+ namespace :auto_gem_updater do
5
+ desc 'Outdated gems minus exluded list'
6
+ task :outdated do
7
+ AutoGemUpdater::Outdated.perform
8
+ end
9
+
10
+ desc 'Auto Updates the Gems'
11
+ task update: :environment do
12
+ outdated_gems = AutoGemUpdater::Outdated.perform
13
+
14
+ AutoGemUpdater::Updater.perform(outdated_gems)
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ require 'open3'
2
+ require_relative 'system'
3
+
4
+ module AutoGemUpdater
5
+ class Updater
6
+ include System
7
+
8
+ def self.perform(outdated_gems)
9
+ new(outdated_gems).perform
10
+ end
11
+
12
+ def initialize(outdated_gems)
13
+ @outdated_gems = outdated_gems
14
+ end
15
+ private_class_method :new
16
+
17
+ def perform
18
+ return unless outdated_gems.any?
19
+ return unless system("git checkout -b auto_gem_updates_#{Time.now.strftime('%d_%m_%Y')}")
20
+
21
+ outdated_gems.each do |name:, newest:, installed:|
22
+ puts "Updating #{name} from #{installed} to #{newest}"
23
+ system_command("bundle update #{name} --conservative")
24
+
25
+ if system_command("rspec")
26
+ puts "Update checks passed commiting update to #{name}"
27
+
28
+ system_command("git add .")
29
+ system_command("git commit -m 'Update the gem #{name} from #{installed} to #{newest}'")
30
+ end
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :outdated_gems
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module AutoGemUpdater
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Venables
@@ -64,13 +64,20 @@ files:
64
64
  - ".travis.yml"
65
65
  - CODE_OF_CONDUCT.md
66
66
  - Gemfile
67
+ - Gemfile.lock
67
68
  - LICENSE.txt
68
69
  - README.md
69
70
  - Rakefile
71
+ - auto_gem_updater-0.1.0.gem
70
72
  - auto_gem_updater.gemspec
71
73
  - bin/console
72
74
  - bin/setup
73
75
  - lib/auto_gem_updater.rb
76
+ - lib/auto_gem_updater/outdated.rb
77
+ - lib/auto_gem_updater/railtie.rb
78
+ - lib/auto_gem_updater/system.rb
79
+ - lib/auto_gem_updater/tasks/auto_gem_updater.rake
80
+ - lib/auto_gem_updater/updater.rb
74
81
  - lib/auto_gem_updater/version.rb
75
82
  homepage:
76
83
  licenses: