drg 0.3.0 → 0.4.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: 8a225b05622730e75686a1128aed86ca6670044d
4
- data.tar.gz: bfafb71e3ead992a670f928004d2c4d948e1017c
3
+ metadata.gz: a23933b53f8d99da37f028d2ff6557c15d9e4fa7
4
+ data.tar.gz: 960ea1d49e98ec52a5ff05256ce5341d9faaea69
5
5
  SHA512:
6
- metadata.gz: 0bd3f7928f75664c1a66b2c01e0053c803780167c852b4b5f7fe215d3957ef41523cf2d085ef59e8c52ebd403a46d42e9b65cc6c670568bf165303f0ff200a75
7
- data.tar.gz: 6318a1728ff781d47a03e149d0b728c5508c6a9fdda5263796ef9510acd7dc09c26c677fcb23ab088035e050da6443d7d46fdba547528cb1e8ef0e6a0fb3e4ee
6
+ metadata.gz: 74176ab0b9a789aafa3e4373c6d993b7b4aa3c749921da8b06ae1f809792c51746e971d69985e30364f66360c397dfaa3a66fba2218e095ba86e6201c2bc5891
7
+ data.tar.gz: 10af8002f7fc2aca2c2cbd94f67b87f7fa9513b5b28c749885f84ad01d9327cb44709976bc931c54a0953ba77dce6753ce3b2f47cf2676fd3ed78f778e399aaf
data/README.md CHANGED
@@ -22,16 +22,64 @@ Or install it yourself as:
22
22
 
23
23
  ### Pinning Gems
24
24
 
25
- DRG can help you manage your project's gems by updating your Gemfile with pinned versions. Just run:
25
+ DRG really wants to help you manage your project's gems. But DRG doesn't want to replace Bundler. Instead we want to build on
26
+ it. You can "pin" all your versions to the current version listed in the Gemfile.lock:
26
27
 
27
28
  ```bash
28
29
  rake drg:pin
29
30
  ```
30
31
 
32
+ Which will change gems list in your Gemfile to their full version. So if you have a gemfile that looks like:
33
+
34
+ ```ruby
35
+ gem 'rails'
36
+ gem 'byebug', require: false
37
+ gem 'therubyracer', '~> 0.12', platforms: :ruby
38
+
39
+ # gotta include ourselves
40
+ gem 'drg'
41
+ ```
42
+
43
+ to
44
+
45
+ ```ruby
46
+ gem 'rails', '4.2.3'
47
+ gem 'byebug', '5.0.0', require: false
48
+ gem 'therubyracer', '0.12.2', platforms: :ruby
49
+
50
+ # gotta include ourselves
51
+ gem 'drg', '0.3.1'
52
+ ```
53
+
54
+ Although, you may want to pin gems with their _minor_ version (which allows updating patches). To do this, just run:
55
+
56
+ ```bash
57
+ rake drg:pin:minor
58
+ ```
59
+
60
+ This will change a gem listed like
61
+
62
+ ```ruby
63
+ gem 'rails', '4.2.3'
64
+ ```
65
+
66
+ to
67
+
68
+ ```ruby
69
+ gem 'rails', '~> 4.2'
70
+ ```
71
+
72
+ Pinning ignores gems that are fetched from somewhere other than rubygems. For example, gems listed with `:git`, `:github`,
73
+ or `:path` will be ignored.
74
+
75
+ There is also a `rake drg:pin:major` that does what you think.
76
+
77
+ This can be combined with `bundle update` to quickly update all gems to the latest patch level.
78
+
31
79
  ### Updating Gems
32
80
 
33
81
  DRG can also try to update all outdated gems to the most recent version. It'll update the gem and run your tests. If your
34
- tests pass, then it'll update your gemfile with the current version. Similar to what Gemnasium offers.
82
+ tests pass, then it'll update your gemfile with the current version. Similar to what Gemnasium offers (experience may vary).
35
83
 
36
84
  ```bash
37
85
  rake drg:update
data/drg.gemspec CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency 'ruby_parser', '>= 3.7.0', '< 4.0.0'
20
- spec.add_dependency 'ruby2ruby', '>= 2.2.0', '< 3.0.0'
19
+ # spec.add_dependency 'ruby_parser', '>= 3.7.0', '< 4.0.0'
20
+ # spec.add_dependency 'ruby2ruby', '>= 2.2.0', '< 3.0.0'
21
21
  spec.add_dependency 'bundler', '~> 1.10'
22
22
 
23
23
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -7,17 +7,17 @@ module DRG
7
7
  @file = ::Bundler.default_gemfile
8
8
  end
9
9
 
10
+ # @param [GemfileLine] gem
11
+ # @param [String] version to update the gem line with
10
12
  def update(gem, version)
11
- lines[gem] = gem.update(version)
13
+ lines[gem] = gem.update version
12
14
  end
13
15
 
14
16
  def find_by_name(name)
15
17
  lines.each_with_index.each do |line, index|
16
18
  next if line =~ /:?path:?\s*(=>)?\s*/
17
19
  next if line =~ /:?git(hub)?:?\s*(=>)?\s*/
18
- if line =~ /gem\s*['"]#{name}["']/
19
- return GemfileLine.new line, index
20
- end
20
+ return GemfileLine.new line, index if line =~ /gem\s*['"]#{name}["']/
21
21
  end
22
22
  nil
23
23
  end
@@ -27,7 +27,7 @@ module DRG
27
27
  end
28
28
 
29
29
  def write
30
- File.open(file, 'wb') do |f|
30
+ File.open file, 'wb' do |f|
31
31
  lines.each do |line|
32
32
  f << line
33
33
  end
@@ -8,7 +8,7 @@ module DRG
8
8
  line.to_s == other.to_s
9
9
  end
10
10
 
11
- # @param [Gem::Version] version responds to version.approximate_recommendation (~> 5.0)
11
+ # @param [String] version is the new value for the gem (add/replace)
12
12
  def update(version)
13
13
  if line =~ /,.+\n?/
14
14
  if line =~ /,\s*['"].+['"]/
@@ -24,6 +24,7 @@ module DRG
24
24
  line
25
25
  end
26
26
 
27
+ # @note not used
27
28
  def version
28
29
  line[/, (.+)\n?/, 1]
29
30
  end
@@ -1,23 +1,36 @@
1
1
  module DRG
2
2
  module Tasks
3
3
  class Pinner
4
- attr_reader :gemfile
4
+ attr_reader :gemfile, :type
5
5
 
6
- def initialize(gemfile = Gemfile.new)
7
- @gemfile = gemfile
6
+ def initialize(type = :patch)
7
+ @type = type
8
+ @gemfile = Gemfile.new
8
9
  end
9
10
 
10
11
  def perform
11
12
  log %Q(Pinning Gemfile "#{gemfile}")
12
13
  ::Bundler.locked_gems.specs.each do |spec|
13
- gem = gemfile.find_by_name(spec.name)
14
+ gem = gemfile.find_by_name spec.name
14
15
  next unless gem
15
- gemfile.update(gem, spec.version)
16
+ gemfile.update gem, public_send(type, spec.version.to_s)
16
17
  end
17
18
  gemfile.write
18
19
  log %Q(Done)
19
20
  end
20
21
 
22
+ def patch(version)
23
+ version
24
+ end
25
+
26
+ def minor(version)
27
+ "~> #{version[/(\d+\.\d+)/, 1]}"
28
+ end
29
+
30
+ def major(version)
31
+ "~> #{version[/(\d+)/, 1]}"
32
+ end
33
+
21
34
  private
22
35
 
23
36
  def log(msg = nil)
@@ -30,21 +30,21 @@ module DRG
30
30
  log(%Q(Tests passed after updating "#{name}" to version #{latest_version}))
31
31
  gemfile.update(gem, latest_version)
32
32
  else
33
- log(%Q(Tests failed after updating "#{name}" to version #{latest_version}))
34
33
  @failures << name
35
34
  end
36
35
  else
37
- log(%Q[Failed to install "#{name}" (#{latest_version})])
38
36
  @failures << name
39
37
  end
40
38
  end
41
39
 
40
+ # @note not used
42
41
  # @param [String] name of the gem
43
42
  # @param [String] current_version of the gem
44
43
  def new_versions(name, current_version)
45
44
  versions(name).select { |version| version > current_version }
46
45
  end
47
46
 
47
+ # @note not used
48
48
  # @param [String] name of the gem
49
49
  # @return [Array] a list of available versions (e.g. ['1.2.0', '1.1.0'])
50
50
  def versions(name)
data/lib/drg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Drg
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/tasks/drg.rake CHANGED
@@ -6,6 +6,16 @@ namespace :drg do
6
6
  DRG::Tasks::Pinner.new.perform
7
7
  end
8
8
 
9
+ namespace :pin do
10
+ task :minor do
11
+ DRG::Tasks::Pinner.new(:minor).perform
12
+ end
13
+
14
+ task :major do
15
+ DRG::Tasks::Pinner.new(:major).perform
16
+ end
17
+ end
18
+
9
19
  desc 'Updates your gems in the Gemfile to the latest compatible version'
10
20
  task :update do
11
21
  # sh 'cd /Users/ryanbuckley/apps/dontspreadit && which ruby'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
@@ -10,46 +10,6 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2015-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ruby_parser
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 3.7.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 4.0.0
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 3.7.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 4.0.0
33
- - !ruby/object:Gem::Dependency
34
- name: ruby2ruby
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 2.2.0
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: 3.0.0
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 2.2.0
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: 3.0.0
53
13
  - !ruby/object:Gem::Dependency
54
14
  name: bundler
55
15
  requirement: !ruby/object:Gem::Requirement