safe_update 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: 76e32c112b1472705905d9ee7da198eb56be4a39
4
- data.tar.gz: 005240cf53a0e77b505ea876531c9ac91295ec76
3
+ metadata.gz: e95adcf65e5d5aa163064c2172366ce50f852b0b
4
+ data.tar.gz: 366a3554dfd2ca55f796946a1a1997402a608309
5
5
  SHA512:
6
- metadata.gz: 53e735d64c14e5e403bc160deefab71cd09eff6686b666515261a70b5189333d7cfbda62c69fd1292f179f1834805a139369a5963776d3ef32799afc7c5666bc
7
- data.tar.gz: f9f836d155ced363c29a8e89bdf59cca3faab248dadb0c61f64db04564f479f2eb1a1ad140f644deef1f7d503a003dc76d05f5862496e9edf15017a641520792
6
+ metadata.gz: dc1b7b38c84282724216b0eaf24c469acb4fc9e93720d464d5f8d0cb75cd73014f3d7651e6b500fd6c939619b472b526fa338f561fb3f4f3f4527eb01cb83b37
7
+ data.tar.gz: b60ad414fcf497af52f900269e5ede3f2875dea2692312e1290377772c1e6891d8ba8007183c233d2d28fafa9cbdc75295dd885c3bf0d07fccc2ce6589cfad0c
data/README.md CHANGED
@@ -56,9 +56,9 @@ FINISHED
56
56
 
57
57
  I've knocked this up really quickly, and it's pretty MVP-ish. Ideas for future include:
58
58
 
59
- - run your tests each update, and don't update problem gems
60
- - specify what update sizes you want to apply (major, minor, patch)
61
- - summary of what's happened at the end (eg. 2 major updates ignored, 5 minor updates applied, etc)
59
+ - run your tests each update, and don't update problem gems.
60
+ - specify what update sizes you want to apply (major, minor, patch); for now you need to rely on the [Gemfile version specifiers](http://bundler.io/gemfile.html).
61
+ - summary of what's happened at the end (eg. 2 major updates ignored, 5 minor updates applied, etc).
62
62
  - other ideas? Open an issue.
63
63
 
64
64
  ## Development
@@ -7,7 +7,9 @@ module SafeUpdate
7
7
  # or. react-rails (newest 1.6.0, installed 1.5.0)
8
8
  def initialize(line)
9
9
  @line = line
10
- raise "Unexpected output from `bundle outdated --parseable`: #{@line}" unless name.to_s.length > 0
10
+ if name.to_s.empty?
11
+ fail "Unexpected output from `bundle outdated --parseable`: #{@line}"
12
+ end
11
13
  end
12
14
 
13
15
  def update
@@ -16,10 +18,10 @@ module SafeUpdate
16
18
  puts " Newest: #{newest}. "
17
19
  puts "Installed: #{installed}."
18
20
  puts "Running `bundle update #{name}`..."
19
- %x(bundle update #{name})
21
+ `bundle update #{name}`
20
22
  puts "committing changes (message: '#{commit_message}')..."
21
- %x(git add -A)
22
- %x(git commit -m '#{commit_message}')
23
+ `git add Gemfile.lock`
24
+ `git commit -m '#{commit_message}'`
23
25
  end
24
26
 
25
27
  def name
@@ -45,7 +47,7 @@ module SafeUpdate
45
47
  private
46
48
 
47
49
  def commit_message
48
- "ran: bundle update #{name}"
50
+ "update gem: #{name}"
49
51
  end
50
52
 
51
53
  # returns the section of string that resides between marker1 and marker2
@@ -1,6 +1,8 @@
1
1
  module SafeUpdate
2
2
  class Updater
3
3
  def run
4
+ check_for_staged_changes
5
+ check_for_gemfile_lock_changes
4
6
  output_array = bundle_outdated_parseable.split(/\n+/)
5
7
  output_array.each do |line|
6
8
  OutdatedGem.new(line).update
@@ -10,17 +12,37 @@ module SafeUpdate
10
12
  puts 'FINISHED'
11
13
  end
12
14
 
15
+ private
16
+
13
17
  def bundle_outdated_parseable
14
- output = %x(bundle outdated --parseable)
18
+ output = `bundle outdated --parseable`
15
19
  if output.strip == "Unknown switches '--parseable'"
16
20
  # pre-1.12.0 version of bundler
17
- output = %x(bundle outdated)
21
+ output = `bundle outdated`
18
22
  output.gsub!(/(\n|.)*Outdated gems included in the bundle:/, '')
19
23
  output.gsub!(/ \* /, '')
20
24
  output.gsub!(/ in group.*/, '')
21
25
  end
22
26
 
23
- return output.strip
27
+ output.strip
28
+ end
29
+
30
+ def check_for_staged_changes
31
+ result = `git diff --name-only --cached`
32
+ if result.strip.length > 0
33
+ puts 'You have staged changes in git.'
34
+ puts 'Please commit or stash your changes before running safe_update'
35
+ exit 1
36
+ end
37
+ end
38
+
39
+ def check_for_gemfile_lock_changes
40
+ result = `git diff --name-only`
41
+ if result.include? 'Gemfile.lock'
42
+ puts 'You have uncommitted changes in your Gemfile.lock.'
43
+ puts 'Please commit or stash your changes before running safe_update'
44
+ exit 1
45
+ end
24
46
  end
25
47
  end
26
- end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module SafeUpdate
2
- VERSION = "0.1.0"
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/safe_update.rb CHANGED
@@ -5,9 +5,9 @@
5
5
  lib = File.expand_path('../../lib', __FILE__)
6
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
7
 
8
- require "safe_update/version"
9
- require "safe_update/updater"
10
- require "safe_update/outdated_gem"
8
+ require 'safe_update/version'
9
+ require 'safe_update/updater'
10
+ require 'safe_update/outdated_gem'
11
11
 
12
12
  module SafeUpdate
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_update
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
  - Joshua Paling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-29 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler