safe_update 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/safe_update +4 -0
- data/lib/safe_update.rb +13 -0
- data/lib/safe_update/outdated_gem.rb +56 -0
- data/lib/safe_update/updater.rb +26 -0
- data/lib/safe_update/version.rb +3 -0
- data/safe_update.gemspec +24 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 76e32c112b1472705905d9ee7da198eb56be4a39
|
4
|
+
data.tar.gz: 005240cf53a0e77b505ea876531c9ac91295ec76
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53e735d64c14e5e403bc160deefab71cd09eff6686b666515261a70b5189333d7cfbda62c69fd1292f179f1834805a139369a5963776d3ef32799afc7c5666bc
|
7
|
+
data.tar.gz: f9f836d155ced363c29a8e89bdf59cca3faab248dadb0c61f64db04564f479f2eb1a1ad140f644deef1f7d503a003dc76d05f5862496e9edf15017a641520792
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Joshua Paling
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# SafeUpdate
|
2
|
+
|
3
|
+
This automates the tedious but important process of updating your gems, one at a time.
|
4
|
+
|
5
|
+
When I first started ruby, I was told 'Never run `bundle update`'. The reality is, we should be keeping our gems as up to date as possible - but `bundle update` just isn't a great way to do it. It does everything in one hit, and it's hard to figure out the cause when things go wrong.
|
6
|
+
|
7
|
+
This gem does `bundle update` in a safer way. It takes the output of `bundle outdated`, and, for each outdated gem, it:
|
8
|
+
|
9
|
+
- runs `bundle update <gem_name>`
|
10
|
+
- commits to git with the message: `ran: bundle update <gem_name>`
|
11
|
+
|
12
|
+
Once you've got each gem updated, with one commit per gem, you can run your tests, and check everything is working. If something is broken, you can use `git bisect` to easily figure out the problem gem.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
$ gem install safe_update
|
17
|
+
|
18
|
+
And then, from your project's root directory, execute:
|
19
|
+
|
20
|
+
$ safe_update
|
21
|
+
|
22
|
+
Since this gem is not a dependency of your application, per se, there's no need to add it to your gemfile.
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
1. `cd /path/to/project`
|
27
|
+
2. `safe_update`
|
28
|
+
3. Watch your gems get updated and committed, one at a time. The output looks like this:
|
29
|
+
|
30
|
+
```
|
31
|
+
(... more goes here)
|
32
|
+
-------------
|
33
|
+
OUTDATED GEM: sprockets-rails
|
34
|
+
Newest: 3.0.3.
|
35
|
+
Installed: 3.0.0.
|
36
|
+
Running `bundle update sprockets-rails`...
|
37
|
+
committing changes (message: 'bundle update sprockets-rails')...
|
38
|
+
-------------
|
39
|
+
OUTDATED GEM: unf_ext
|
40
|
+
Newest: 0.0.7.2.
|
41
|
+
Installed: 0.0.7.1.
|
42
|
+
Running `bundle update unf_ext`...
|
43
|
+
committing changes (message: 'bundle update unf_ext')...
|
44
|
+
-------------
|
45
|
+
OUTDATED GEM: uniform_notifier
|
46
|
+
Newest: 1.10.0.
|
47
|
+
Installed: 1.9.0.
|
48
|
+
Running `bundle update uniform_notifier`...
|
49
|
+
committing changes (message: 'bundle update uniform_notifier')...
|
50
|
+
-------------
|
51
|
+
-------------
|
52
|
+
FINISHED
|
53
|
+
```
|
54
|
+
|
55
|
+
## Future
|
56
|
+
|
57
|
+
I've knocked this up really quickly, and it's pretty MVP-ish. Ideas for future include:
|
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)
|
62
|
+
- other ideas? Open an issue.
|
63
|
+
|
64
|
+
## Development
|
65
|
+
|
66
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
67
|
+
|
68
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joshuapaling/safe_update.
|
73
|
+
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
78
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "safe_update"
|
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
|
data/bin/setup
ADDED
data/exe/safe_update
ADDED
data/lib/safe_update.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# @ToDO - without changing the loadpath here,
|
2
|
+
# we get errors:
|
3
|
+
# /lib/safe_update.rb:4:in `require': cannot load such file -- safe_update/version
|
4
|
+
# See what we can do to resolve this.
|
5
|
+
lib = File.expand_path('../../lib', __FILE__)
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
|
+
|
8
|
+
require "safe_update/version"
|
9
|
+
require "safe_update/updater"
|
10
|
+
require "safe_update/outdated_gem"
|
11
|
+
|
12
|
+
module SafeUpdate
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module SafeUpdate
|
2
|
+
class OutdatedGem
|
3
|
+
attr_reader :newest, :installed, :requested
|
4
|
+
|
5
|
+
# line is a line from bundle outdated --parseable
|
6
|
+
# eg. react-rails (newest 1.6.0, installed 1.5.0, requested ~> 1.0)
|
7
|
+
# or. react-rails (newest 1.6.0, installed 1.5.0)
|
8
|
+
def initialize(line)
|
9
|
+
@line = line
|
10
|
+
raise "Unexpected output from `bundle outdated --parseable`: #{@line}" unless name.to_s.length > 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def update
|
14
|
+
puts '-------------'
|
15
|
+
puts "OUTDATED GEM: #{name}"
|
16
|
+
puts " Newest: #{newest}. "
|
17
|
+
puts "Installed: #{installed}."
|
18
|
+
puts "Running `bundle update #{name}`..."
|
19
|
+
%x(bundle update #{name})
|
20
|
+
puts "committing changes (message: '#{commit_message}')..."
|
21
|
+
%x(git add -A)
|
22
|
+
%x(git commit -m '#{commit_message}')
|
23
|
+
end
|
24
|
+
|
25
|
+
def name
|
26
|
+
string_between(@line, '', ' (newest')
|
27
|
+
end
|
28
|
+
|
29
|
+
def newest
|
30
|
+
string_between(@line, ' (newest ', ', installed')
|
31
|
+
end
|
32
|
+
|
33
|
+
def requested
|
34
|
+
string_between(@line, ', requested ', ')')
|
35
|
+
end
|
36
|
+
|
37
|
+
def installed
|
38
|
+
if @line.index('requested')
|
39
|
+
string_between(@line, ', installed ', ', requested')
|
40
|
+
else
|
41
|
+
string_between(@line, ', installed ', ')')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def commit_message
|
48
|
+
"ran: bundle update #{name}"
|
49
|
+
end
|
50
|
+
|
51
|
+
# returns the section of string that resides between marker1 and marker2
|
52
|
+
def string_between(string, marker1, marker2)
|
53
|
+
string[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SafeUpdate
|
2
|
+
class Updater
|
3
|
+
def run
|
4
|
+
output_array = bundle_outdated_parseable.split(/\n+/)
|
5
|
+
output_array.each do |line|
|
6
|
+
OutdatedGem.new(line).update
|
7
|
+
end
|
8
|
+
puts '-------------'
|
9
|
+
puts '-------------'
|
10
|
+
puts 'FINISHED'
|
11
|
+
end
|
12
|
+
|
13
|
+
def bundle_outdated_parseable
|
14
|
+
output = %x(bundle outdated --parseable)
|
15
|
+
if output.strip == "Unknown switches '--parseable'"
|
16
|
+
# pre-1.12.0 version of bundler
|
17
|
+
output = %x(bundle outdated)
|
18
|
+
output.gsub!(/(\n|.)*Outdated gems included in the bundle:/, '')
|
19
|
+
output.gsub!(/ \* /, '')
|
20
|
+
output.gsub!(/ in group.*/, '')
|
21
|
+
end
|
22
|
+
|
23
|
+
return output.strip
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/safe_update.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'safe_update/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "safe_update"
|
8
|
+
spec.version = SafeUpdate::VERSION
|
9
|
+
spec.authors = ["Joshua Paling"]
|
10
|
+
spec.email = ["joshua.paling@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Safely and automatically update your gems, one at a time, with one git commit per updated gem. }
|
13
|
+
spec.homepage = "https://github.com/joshuapaling/safe_update"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: safe_update
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joshua Paling
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-29 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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
|
+
description:
|
56
|
+
email:
|
57
|
+
- joshua.paling@gmail.com
|
58
|
+
executables:
|
59
|
+
- safe_update
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- exe/safe_update
|
73
|
+
- lib/safe_update.rb
|
74
|
+
- lib/safe_update/outdated_gem.rb
|
75
|
+
- lib/safe_update/updater.rb
|
76
|
+
- lib/safe_update/version.rb
|
77
|
+
- safe_update.gemspec
|
78
|
+
homepage: https://github.com/joshuapaling/safe_update
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.5.1
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Safely and automatically update your gems, one at a time, with one git commit
|
102
|
+
per updated gem.
|
103
|
+
test_files: []
|