smarter_bundler 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -23,13 +23,27 @@ matrix:
23
23
  - rvm: 1.8.7
24
24
  env: RUBYGEMS_VERSION=1.8.25
25
25
 
26
+ - rvm: 1.9.2
27
+
26
28
  - rvm: 1.9.3
27
29
 
28
- - rvm: 2.2.1
30
+ - rvm: 2.0.0
31
+
32
+ - rvm: 2.1.0
33
+
34
+ - rvm: 2.1.10
35
+
36
+ - rvm: 2.2.0
37
+
38
+ - rvm: 2.2.2
29
39
 
30
40
  - rvm: 2.2.9
31
41
 
42
+ - rvm: 2.3.0
43
+
32
44
  - rvm: 2.3.6
33
45
 
46
+ - rvm: 2.4.0
47
+
34
48
  - rvm: 2.4.3
35
49
 
data/bin/test CHANGED
@@ -56,6 +56,9 @@ do
56
56
  cp -f Gemfile.default Gemfile
57
57
  # Exclude debugger - it breaks for many varied reasons on travis
58
58
  ../../exe/smarter_bundle --without debug
59
+ echo Gemfile changes:
60
+ diff Gemfile.default Gemfile
61
+ echo
59
62
  bundle exec ruby -e 'puts "Test of #{ENV['"'"'d'"'"']}/Gemfile with ruby #{RUBY_VERSION} passed at #{Time.now}!"'
60
63
  )
61
64
  done
@@ -5,6 +5,14 @@ module SmarterBundler
5
5
  class Bundle
6
6
  include SmarterBundler::Shell
7
7
 
8
+ KNOWN_ISSUES_192 = {
9
+ 'unicorn' => '5.0',
10
+ #'nokogiri' => '1.6.0',
11
+ 'jbuilder' => '2.0.0',
12
+ }
13
+
14
+
15
+
8
16
  def run(bundle_args)
9
17
  puts "Smarter Bundler will recursively install your gems and output the successful bundler output. This may take a while."
10
18
  count = 0
@@ -20,9 +28,13 @@ module SmarterBundler
20
28
  exit 1
21
29
  end
22
30
  previous_failure = failed_gem_and_version
23
- if install_failed_gem failed_gem_and_version
31
+ gem, version = *failed_gem_and_version
32
+ if install_failed_gem gem, version
24
33
  puts "Retrying seems to have fixed the problem"
25
- elsif ruby_version_clash(result) && gemfile.restrict_gem_version(*failed_gem_and_version)
34
+ elsif gemfile.restrict_gem_version(gem, known_issues(gem))
35
+ gemfile.save
36
+ count += 1
37
+ elsif ruby_version_clash(result) && gemfile.restrict_gem_version(gem, version)
26
38
  gemfile.save
27
39
  count += 1
28
40
  else
@@ -41,14 +53,22 @@ module SmarterBundler
41
53
  shell "bundle #{bundle_args}"
42
54
  end
43
55
 
44
- def install_failed_gem(failed_gem_and_version)
45
- shell? "gem install '#{failed_gem_and_version[0]}' -v '#{failed_gem_and_version[1]}'"
56
+ def install_failed_gem(gem, version)
57
+ shell? "gem install '#{gem}' -v '#{version}'"
46
58
  end
47
59
 
48
60
  def ruby_version_clash(result)
49
61
  result.output.select{|l| l =~ /requires Ruby version/}.any?
50
62
  end
51
63
 
64
+ def known_issues(gem)
65
+ if RUBY_VERSION < '1.9.3'
66
+ KNOWN_ISSUES_192[gem]
67
+ else
68
+ nil
69
+ end
70
+ end
71
+
52
72
  def parse_output(result)
53
73
  result.output.each do |line|
54
74
  if line =~ /Make sure that `gem install (\S+) -v '(\S+)'`/
@@ -15,19 +15,22 @@ module SmarterBundler
15
15
  end
16
16
 
17
17
  def restrict_gem_version gem, version_limit
18
+ return false unless version_limit.to_s =~ /\d\.\d/
18
19
  if @contents.select{|line| line =~ /^\s*gem\s+['"]#{gem}['"]/}.empty?
19
20
  @contents << "gem '#{gem}', '>=0'"
20
21
  end
21
22
  adjusted = false
22
23
  @contents.map! do |line|
23
- if line =~ /^(\s*gem\s+['"]#{gem}['"])(\s*,\*['"]([^'"]*)['"])?(.*)$/
24
+ if line =~ /^(\s*gem\s+['"]#{gem}['"])(\s*,\*['"]([^'"]*)['"])?(.*?)$/
24
25
  gem_and_name = $1
25
26
  rest_of_line = $4
26
27
  version = $3.to_s
28
+ puts "Found #{gem_name_name} with version spec: #{version} and other args: #{rest_of_line}"
27
29
  new_version = version.sub(/<=?\s*[^,\s]+/, '').sub(/^\s*,\s*/, '').sub(/\s*,\s*$/, '') + (version == '' ? '' : ', ') + "< #{version_limit}"
30
+ puts " Calculated new_version spec: #{new_version}"
28
31
  if new_version != version
29
32
  @changed = true
30
- rest_of_line.sub(/#.*/, '')
33
+ rest_of_line.sub!(/ # REQUIRED - Added by SmarterBundler.*/, '')
31
34
  rest_of_line << ' # REQUIRED - Added by SmarterBundler'
32
35
  line = "#{gem_and_name}, '#{new_version}'#{rest_of_line}"
33
36
  puts "Changed Gemfile line to: #{line}"
@@ -18,5 +18,6 @@ module SmarterBundler
18
18
  result = shell(command)
19
19
  result.status.success?
20
20
  end
21
+
21
22
  end
22
23
  end
@@ -1,3 +1,3 @@
1
1
  module SmarterBundler
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: smarter_bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -99,16 +99,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  segments:
101
101
  - 0
102
- hash: 1256460857645242723
102
+ hash: 1603618397689055998
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  none: false
105
105
  requirements:
106
106
  - - ! '>='
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
- segments:
110
- - 0
111
- hash: 1256460857645242723
112
109
  requirements: []
113
110
  rubyforge_project:
114
111
  rubygems_version: 1.8.23.2