drg 0.16.0 → 1.0.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
  SHA1:
3
- metadata.gz: f3ec2da36e33e6a4ba09189233dd40b01401b1e7
4
- data.tar.gz: 6e95adec97a178eedff8e6377ee4be64cdf3fd7d
3
+ metadata.gz: bbd1cdfa7fcb5728da7c9c46598e8ea6d3ea5c3b
4
+ data.tar.gz: 110ed7e88d039ff17af04a3c156c76142b8c1818
5
5
  SHA512:
6
- metadata.gz: 0cec841fbfa30623d4edc7e534be902ebe919b4d9ce927822758f39cc6eea3ed411ca9c281f51b1da95b55669a2995405248742169de35d91051f022c9ae4210
7
- data.tar.gz: 99cb20b249bed5bc2a089248fa88e2ece5c976f9618e34fceb7f635e3ff772de2fb971b705edfc7f0e751408a3058b615315722daee465bde781f5f204ecfc61
6
+ metadata.gz: 10daff99eaf9c71b0c770588fa498a14978abecbdd3ca939bce01106027d8bbc03ce7d6c8d3d217ad2daa315ece08c5374c037c3efb9ab03bedf22b62619b225
7
+ data.tar.gz: 29b5b8801c69cb2215f105c72d08df7757fc17bc86e56dede81ae107a5e49c92753af326b2e794595edb062bbc0ec7bae63d77ee079d3c49049d2e07d979a91c
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.2.1
4
- before_install: gem install bundler -v 1.10.4
5
+ - 2.2.2
6
+ - 2.2.3
7
+ before_install: gem install bundler -v 1.10.5
data/Gemfile CHANGED
@@ -2,12 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in drg.gemspec
4
4
  gemspec
5
- # gem 'duck_puncher'
6
- group :development, :test do
7
- # gem 'rubocop', '~> 0.29', require: false
8
- gem "pry", '~> 0.10'
9
- gem 'object_tracker', '>= 1.0.5'
10
- gem 'byebug', require: false
5
+
6
+ group :test do
7
+ gem 'rake', '10.4.2'
8
+ gem 'byebug' if RUBY_VERSION >= '2.0.0'
11
9
  end
12
- gem 'ruby_parser', '3.7.1'
13
- gem 'slop'
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
- # DRG
2
- [![Code Climate](https://codeclimate.com/github/ridiculous/drg/badges/gpa.svg)](https://codeclimate.com/github/ridiculous/drg)
3
- [![Gem Version](https://badge.fury.io/rb/drg.svg)](http://badge.fury.io/rb/drg)
1
+ # DRG [![Code Climate](https://codeclimate.com/github/ridiculous/drg/badges/gpa.svg)](https://codeclimate.com/github/ridiculous/drg) [![Gem Version](https://badge.fury.io/rb/drg.svg)](http://badge.fury.io/rb/drg) [![Build Status](https://travis-ci.org/ridiculous/drg.svg)](https://travis-ci.org/ridiculous/drg)
2
+
4
3
 
5
4
  A Ruby utility to help automate dependency management using Bundler. You can pin Gem versions to the current or the next
6
5
  available level.
@@ -18,14 +17,16 @@ gem 'drg'
18
17
  ## Tasks
19
18
 
20
19
  ```bash
21
- rake drg:pin
22
- rake drg:pin:major
23
- rake drg:pin:minor
24
- rake drg:pin:patch
25
- rake drg:pin:latest
26
- rake drg:pin:patch_latest
27
- rake drg:pin:minor_latest
28
- rake drg:unpin
20
+ % rake -T
21
+ rake drg:pin # Pin the gems in your Gemfile to the current version in the Gemfile.lock
22
+ rake drg:pin:major # Add the approximate major version of your gems (rails, "~> 4")
23
+ rake drg:pin:minor # Add the approximate minor version of your gems (rails, "~> 4.2")
24
+ rake drg:pin:patch # Add the approximate patch version of your gems (rails, "~> 4.2.3")
25
+ rake drg:pin:latest[gem] # Pin the given gem to the latest version (defaults to all gems)
26
+ rake drg:pin:minor_latest[gem] # Pin the given gem to the latest available patch version (defaults to all gems)
27
+ rake drg:pin:patch_latest[gem] # Pin the given gem to the latest available minor version (defaults to all gems)
28
+ rake drg:unpin # Unpin the gems in your Gemfile
29
+ rake spec # Run all tests
29
30
  ```
30
31
 
31
32
  ### drg:pin
@@ -56,116 +57,11 @@ gem 'therubyracer', '0.12.2', platforms: :ruby
56
57
  gem 'drg', '0.4.1' # need this
57
58
  ```
58
59
 
59
- ### drg:pin:minor
60
-
61
- Want to pin gems at their __minor__ version?
62
-
63
- ```bash
64
- rake drg:pin:minor
65
- ```
66
-
67
- This task will update your Gemfile with the approximate gem's minor version. It'll change:
68
-
69
- ```ruby
70
- gem 'rails', '4.2.3'
71
- ```
72
-
73
- to:
74
-
75
- ```ruby
76
- gem 'rails', '~> 4.2'
77
- ```
78
-
79
- ### drg:pin:patch
80
-
81
- Want to pin gems at their __patch__ version?
82
-
83
- ```bash
84
- rake drg:pin:patch
85
- ```
86
-
87
- This task will update your Gemfile with the approximate gem's patch version. It'll change:
88
-
89
- ```ruby
90
- gem 'rails', '4.2.3'
91
- ```
92
-
93
- to
94
-
95
- ```ruby
96
- gem 'rails', '~> 4.2.3'
97
- ```
98
-
99
- This can be combined with `bundle update` to quickly update all gems to the latest version.
100
-
101
- ### drg:pin:major
102
-
103
- Pins your gems at the major level:
104
-
105
- ```bash
106
- rake drg:pin:major
107
- ```
108
-
109
- ### drg:pin:latest
110
-
111
- Updates each outdated gem to the latest available version:
112
-
113
- ```bash
114
- rake drg:pin:latest #=> updates all gems in the Gemfile
115
- rake drg:pin:latest[<gem>] #=> updates only the specified <gem>
116
- ```
117
-
118
- ### drg:pin:patch_latest
119
-
120
- Updates the patch version for each outdated gem to the latest version:
121
-
122
- ```bash
123
- rake drg:pin:patch_latest #=> updates all gems in the Gemfile
124
- rake drg:pin:patch_latest[<gem>] #=> updates only the specified <gem>
125
- ```
126
-
127
- ### drg:pin:minor_latest
128
-
129
- Same as `patch_latest` except it updates the minor version to the latest
130
-
131
- ```bash
132
- rake drg:pin:minor_latest #=> updates all gems in the Gemfile
133
- rake drg:pin:minor_latest[<gem>] #=> updates only the specified <gem>
134
- ```
135
-
136
- ### drg:unpin
137
-
138
- Remove the versions from your Gemfile. A clean start!
139
-
140
- ```bash
141
- rake drg:unpin
142
- ```
143
-
144
60
  ### Automation
145
61
 
146
- I use the following bash script to update all gems to the latest [major|minor|patch] version, run all tests and then add
147
- the result if the specs pass or rollback the changes if they fail.
148
-
149
- ```bash
150
- #!/bin/bash
151
- git add Gemfile
152
- for cmd in $@; do
153
- echo " * Updating $cmd versions"
154
- bundle exec rake drg:pin:${cmd}_latest
155
- bundle update
156
- bundle exec rspec . -t ~js
157
- if [ $? -eq 0 ]
158
- then
159
- echo " * Tests passed after updating $cmd versions. Adding Gemfile ..."
160
- git add Gemfile*
161
- else
162
- echo " * Tests failed after updating $cmd versions. Reverting change to Gemfile ..." >&2
163
- git checkout -- Gemfile*
164
- bundle
165
- exit 1
166
- fi
167
- done
168
- ```
62
+ I use the [bin/drg](https://github.com/ridiculous/drg/blob/master/bin/drg) bash script to update all gems to the latest
63
+ [major|minor|patch] version, run all tests and then add the result if the specs pass or rollback the changes if they
64
+ fail (e.g. `bin/drg patch`).
169
65
 
170
66
  ### Skipping gems
171
67
 
data/Rakefile CHANGED
@@ -6,5 +6,5 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
6
6
  spec.pattern = 'spec/lib/**/*_spec.rb'
7
7
  end
8
8
 
9
- desc 'Run specs'
9
+ desc 'Run all specs'
10
10
  task default: :spec
data/bin/console CHANGED
@@ -4,7 +4,10 @@ require 'bundler/setup'
4
4
  require 'pp'
5
5
  require 'rspec'
6
6
  require 'irb'
7
- require 'object_tracker'
8
7
  require_relative '../spec/spec_helper'
8
+ begin
9
+ require 'object_tracker'
10
+ rescue LoadError
11
+ end
9
12
 
10
13
  IRB.start
data/bin/drg ADDED
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+
3
+ if [ "$#" == 0 ]; then
4
+ echo "Usage: $0 [ major|minor|patch ]"
5
+ echo ""
6
+ exit 1
7
+ fi
8
+
9
+ git add Gemfile
10
+ for cmd in $@; do
11
+ echo " * Updating $cmd versions"
12
+ bundle exec rake drg:pin:${cmd}_latest
13
+ bundle update
14
+ bundle exec rspec . -t ~js
15
+ if [ $? -eq 0 ]
16
+ then
17
+ echo " * Tests passed after updating $cmd versions. Adding Gemfile ..."
18
+ git add Gemfile*
19
+ else
20
+ echo " * Tests failed after updating $cmd versions. Reverting change to Gemfile ..." >&2
21
+ git checkout -- Gemfile*
22
+ bundle
23
+ exit 1
24
+ fi
25
+ done
data/drg.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.add_dependency 'bundler', '~> 1.10'
19
19
  spec.add_dependency 'duck_puncher', '>= 2.0.0', '<= 3.0.0'
20
- spec.add_dependency 'highline', '~> 1.7'
20
+ spec.add_dependency 'highline', '~> 1.6'
21
21
 
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
23
  spec.add_development_dependency 'rspec', '>= 3.2', '< 4'
data/lib/drg.rb CHANGED
@@ -2,8 +2,8 @@ require 'pathname'
2
2
  require 'ostruct'
3
3
  require 'set'
4
4
  require 'bundler'
5
+ require 'highline'
5
6
  require 'duck_puncher'
6
- require 'highline/import'
7
7
  require 'drg/version'
8
8
 
9
9
  module DRG
@@ -14,30 +14,36 @@ module DRG
14
14
  end
15
15
 
16
16
  def perform(gem_name = nil)
17
+ updated_gems = []
17
18
  if gem_name
18
- update gem_name
19
+ updated_gems << update(gem_name)
19
20
  else
20
21
  Updater.new.perform do |gems|
21
22
  load_versions gems
22
- gems.each &method(:update)
23
+ gems.each do |gem|
24
+ updated_gems << update(gem)
25
+ end
23
26
  end
24
27
  end
28
+ updated_gems.compact!
25
29
  log %Q(Done)
30
+ log %Q(You may want to run: "bundle update #{updated_gems.join ' '}") if updated_gems.any?
26
31
  gemfile.write if gemfile.saved_lines.any?
27
32
  end
28
33
 
29
34
  # @note calls #latest_minor_version and #latest_patch_version
35
+ # @returns [nil|String]
30
36
  def update(gem_name)
31
37
  spec = ::Bundler.locked_gems.specs.find { |spec| spec.name == gem_name }
32
38
  gem = spec && gemfile.find_by_name(spec.name)
33
- if gem
34
- latest_version = public_send("latest_#{type}_version", spec.name, spec.version)
35
- if latest_version
36
- log %Q(Updating "#{spec.name}" from #{spec.version.to_s} to #{latest_version})
37
- gemfile.update gem, latest_version
38
- else
39
- log %Q(No newer #{type} versions found for "#{spec.name}")
40
- end
39
+ return nil unless gem
40
+ latest_version = public_send("latest_#{type}_version", spec.name, spec.version)
41
+ if latest_version
42
+ log %Q(Updating "#{spec.name}" from #{spec.version.to_s} to #{latest_version})
43
+ gemfile.update gem, latest_version
44
+ spec.name
45
+ else
46
+ log %Q(No newer #{type} versions found for "#{spec.name}"), :grey
41
47
  end
42
48
  end
43
49
 
data/lib/drg/tasks/log.rb CHANGED
@@ -4,7 +4,7 @@ module DRG
4
4
  module_function
5
5
 
6
6
  def log(msg = nil, color = :green)
7
- say %Q( <%= color('#{msg}', :#{color}) %>)
7
+ HighLine.new.say %Q( <%= color('#{msg}', :#{color}) %>)
8
8
  end
9
9
  end
10
10
  end
data/lib/drg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DRG
2
- VERSION = '0.16.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
data/lib/tasks/drg.rake CHANGED
@@ -1,43 +1,43 @@
1
1
  require 'rake'
2
2
 
3
3
  namespace :drg do
4
- desc "Pins the gems in your Gemfile to the current version in the Gemfile.lock"
4
+ desc "Pin the gems in your Gemfile to the current version in the Gemfile.lock"
5
5
  task :pin do
6
6
  DRG::Tasks::Pinner.new.perform
7
7
  end
8
8
 
9
- desc 'Unpins the gems in your the Gemfile'
9
+ desc 'Unpin the gems in your the Gemfile'
10
10
  task :unpin do
11
11
  DRG::Tasks::Pinner.new.unpin
12
12
  end
13
13
 
14
14
  namespace :pin do
15
- desc 'Adds the fuzzy match operator to the minor version of your gems (e.g. rails, "~> 4.2")'
15
+ desc 'Add the approximate minor version of your gems (rails, "~> 4.2")'
16
16
  task :minor do
17
17
  DRG::Tasks::Pinner.new(:minor).perform
18
18
  end
19
19
 
20
- desc 'Adds the fuzzy match operator to the major version of your gems (e.g. rails, "~> 4")'
20
+ desc 'Add the approximate major version of your gems (rails, "~> 4")'
21
21
  task :major do
22
22
  DRG::Tasks::Pinner.new(:major).perform
23
23
  end
24
24
 
25
- desc 'Adds the fuzzy match operator to the patch version of your gems (e.g. rails, "~> 4.2.3")'
25
+ desc 'Add the approximate patch version of your gems (rails, "~> 4.2.3")'
26
26
  task :patch do
27
27
  DRG::Tasks::Pinner.new(:patch).perform
28
28
  end
29
29
 
30
- desc 'Pins all gems [or the requested gem] to the latest version'
30
+ desc 'Pin the given gem to the latest version (defaults to all gems)'
31
31
  task :latest, [:gem_name] do |_, options|
32
32
  DRG::Tasks::ActivePinner.new(:available).perform(options[:gem_name])
33
33
  end
34
34
 
35
- desc 'Pins all gems [or the requested gem] to the latest available patch version'
35
+ desc 'Pin the given gem to the latest available patch version (defaults to all gems)'
36
36
  task :minor_latest, [:gem_name] do |_, options|
37
37
  DRG::Tasks::ActivePinner.new(:minor).perform(options[:gem_name])
38
38
  end
39
39
 
40
- desc 'Pins all gems [or the requested gem] to the latest available minor version'
40
+ desc 'Pin the given gem to the latest available minor version (defaults to all gems)'
41
41
  task :patch_latest, [:gem_name] do |_, options|
42
42
  DRG::Tasks::ActivePinner.new(:patch).perform(options[:gem_name])
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-05 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.7'
53
+ version: '1.6'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.7'
60
+ version: '1.6'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,7 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - bin/console
111
+ - bin/drg
111
112
  - bin/setup
112
113
  - drg.gemspec
113
114
  - lib/drg.rb