bundle_lock 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ ## 0.0.4 (2011-06-09)
2
+
3
+ * Added Maven Features and Current Version lookups.
4
+
5
+ ## 0.0.3 (2011-05-06)
6
+
7
+ * Gracefully handle cases where Gem.latest_version_for returns nil
8
+ (Example: non-public gems in vendor/)
9
+
10
+ ## 0.0.2 (2011-05-06)
11
+
12
+ * Explicit requirement for RubyGems 1.6.0 or later.
13
+
14
+ ## 0.0.1 (2011-05-05)
15
+
16
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bundle_lock.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Patrick Lenz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # bundle\_lock
2
+
3
+ ## Description
4
+
5
+ We found it difficult to keep Gemfile, Gemfile.lock and if using
6
+ Maven pom.xml in sync. This gem strives to make managing this easier.
7
+
8
+ A simple gem to analyze your `Gemfile` and `Gemfile.lock` to find
9
+ the currently locked versions for your app. Provides a list you can
10
+ copy and paste to your Gemfile.
11
+
12
+ Additionally finds out which of the gems in your project have newer
13
+ versions available and thus could potentially be updated.
14
+
15
+ Includes output for JRuby Maven Plugins to also list Gem dependencies
16
+ for both current and new/outdated gems in XML Maven Pom format.
17
+ Requires: https://github.com/mkristian/jruby-maven-plugins/
18
+
19
+ ## Installation
20
+
21
+ $ gem install bundle_lock
22
+
23
+ It currently requires RubyGems 1.6.0 or newer, which can be installed/updated with:
24
+
25
+ $ gem update --system [version]
26
+
27
+ (The version argument is not available on really old versions.)
28
+
29
+ ## Usage
30
+
31
+ From your Ruby project directory or your `Rails.root`:
32
+
33
+ $ bundle-lock [[version: current | new], [type: gemfile | maven]]
34
+
35
+ ## Example report
36
+
37
+ Finding current gems..
38
+
39
+ To Lock Current gem versions in Gemfile:
40
+ gem 'mail', '2.2.18'
41
+ gem 'hoptoad_notifier', '2.3'
42
+ gem 'devise', '1.3.3'
43
+ gem 'oa-oauth', '0.2.4'
44
+ gem 'twitter', '1.4.0'
45
+ gem 'kaminari', '0.12.1'
46
+ gem 'meta_search', '1.0.4'
47
+ gem 'paper_trail', '2'
48
+ gem 'jquery-rails', '0.2.7'
49
+ gem 'guard-rspec', '0.3.0'
50
+
51
+ Finding outdated gems..
52
+
53
+ Newer versions found for:
54
+ mail (2.3.0 > 2.2.18)
55
+ hoptoad_notifier (2.4.9 > 2.3)
56
+ devise (1.3.4 > 1.3.3)
57
+ oa-oauth (0.2.5 > 0.2.4)
58
+ twitter (1.4.1 > 1.4.0)
59
+ kaminari (0.12.4 > 0.12.1)
60
+ meta_search (1.0.5 > 1.0.4)
61
+ paper_trail (2.2.2 > 2)
62
+ jquery-rails (1.0 > 0.2.7)
63
+ guard-rspec (0.3.1 > 0.3.0)
64
+
65
+ Lock bundle to these versions by putting the following in your Gemfile:
66
+ gem 'mail', '2.3.0'
67
+ gem 'hoptoad_notifier', '2.4.9'
68
+ gem 'devise', '1.3.4'
69
+ gem 'oa-oauth', '0.2.5'
70
+ gem 'twitter', '1.4.1'
71
+ gem 'kaminari', '0.12.4'
72
+ gem 'meta_search', '1.0.5'
73
+ gem 'paper_trail', '2.2.2'
74
+ gem 'jquery-rails', '1.0'
75
+ gem 'guard-rspec', '0.3.1'
76
+
77
+ Maven Support:
78
+ <dependency>
79
+ <groupId>rubygems</groupId>
80
+ <artifactId>mail</artifactId>
81
+ <version>2.3.0</version>
82
+ <type>gem</type>
83
+ </dependency>
84
+ <dependency>
85
+ <groupId>rubygems</groupId>
86
+ <artifactId>hoptoad_notifier</artifactId>
87
+ <version>2.4.9</version>
88
+ <type>gem</type>
89
+ </dependency>
90
+ <dependency>
91
+ <groupId>rubygems</groupId>
92
+ <artifactId>devise</artifactId>
93
+ <version>1.3.4</version>
94
+ <type>gem</type>
95
+ </dependency>
96
+ <dependency>
97
+ <groupId>rubygems</groupId>
98
+ <artifactId>oa-oauth</artifactId>
99
+ <version>0.2.5</version>
100
+ <type>gem</type>
101
+ </dependency>
102
+ <dependency>
103
+ <groupId>rubygems</groupId>
104
+ <artifactId>twitter</artifactId>
105
+ <version>1.4.1</version>
106
+ <type>gem</type>
107
+ </dependency>
108
+ ...
109
+
110
+ ## License
111
+
112
+ Released under the MIT License. See the LICENSE file for further details.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ Rake::TestTask.new :test do |t|
6
+ t.libs << 'lib'
7
+ t.libs << 'test'
8
+ t.test_files = FileList['test/**/*_test.rb']
9
+ t.verbose = true
10
+ end
data/bin/bundle-lock ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # This allows compass to run easily from a git checkout without install.
3
+ # Credit: Compass [https://github.com/chriseppstein/compass/]
4
+ def fallback_load_path(path)
5
+ retried = false
6
+ begin
7
+ yield
8
+ rescue LoadError
9
+ unless retried
10
+ $: << path
11
+ retried = true
12
+ retry
13
+ end
14
+ raise
15
+ end
16
+ end
17
+
18
+ fallback_load_path(File.join(File.dirname(__FILE__), '..', 'lib')) do
19
+ require 'bundle_lock'
20
+ end
21
+
22
+ begin
23
+ args = ARGV
24
+ version = args[0] ||= 'all'
25
+ type = args[1] ||= 'all'
26
+ BundleLock.search!(version, type)
27
+ rescue NoMethodError => e
28
+ if e.message =~ /latest_version_for/
29
+ puts "ERROR: Please upgrade to at least RubyGems version 1.6.0 to use this tool."
30
+ puts "\n $ gem update --system"
31
+ puts
32
+ else
33
+ raise
34
+ end
35
+ end
36
+
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "bundle_lock/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "bundle_lock"
7
+ s.version = BundleLock::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Luis Ramos"]
10
+ s.email = ["lramos85@gmail.com"]
11
+ s.homepage = "https://github.com/lramos85/bundle_lock"
12
+ s.summary = %q{Find out current and outdated gems in your gem file and create lock including maven.}
13
+ s.description = %q{Find out current and outdated gems in your gem file and create lock including maven.}
14
+
15
+ s.rubyforge_project = "bundle_lock"
16
+
17
+ s.add_development_dependency 'builder', '~> 3.0'
18
+ s.add_development_dependency 'rr', '~> 1.0'
19
+ s.required_rubygems_version = ">= 1.6.0"
20
+
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ s.require_paths = ["lib"]
26
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'builder'
3
+ require 'bundle_lock/gem_dependency'
4
+ require 'bundle_lock/searcher'
5
+
6
+ module BundleLock
7
+ def self.search!(version='all',type='all')
8
+ Searcher.new.search!(version,type)
9
+ end
10
+ end
@@ -0,0 +1,42 @@
1
+ module BundleLock
2
+ class GemDependency
3
+ attr_reader :name, :version, :handwaving
4
+
5
+ VERSION_REGEXP = /^([\(])(.+?)(?:-.+)?([\)])$/
6
+ #GEMNAME_REGEXP = /\s(['"])(.+?)\1/
7
+
8
+ def initialize(gemfile_string)
9
+ self.name, self.version = gemfile_string.split(/\s/)
10
+ end
11
+
12
+ def name=(new_name)
13
+ @name = nil
14
+ if new_name #&& new_name.match(GEMNAME_REGEXP)
15
+ @name = new_name
16
+ end
17
+ end
18
+
19
+ def version=(new_version)
20
+ @version = nil
21
+ if new_version && new_version.match(VERSION_REGEXP)
22
+ #@handwaving = !$2.empty? && $2
23
+ @version = Gem::Version.new($2)
24
+ end
25
+ end
26
+
27
+ def handwaving?; !!handwaving; end
28
+
29
+ def to_s
30
+ "#{name}, Version: #{ version || 'Any' }"
31
+ end
32
+
33
+ def latest_version
34
+ @latest_version ||= Gem.latest_version_for(name)
35
+ end
36
+
37
+ def outdated?
38
+ return false unless version && latest_version
39
+ version < latest_version
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,112 @@
1
+ module BundleLock
2
+ class Searcher
3
+ class GemfileNotFound < StandardError; end
4
+
5
+ def search!(version='all',type='all')
6
+ puts "Finding current and outdated gems.."
7
+
8
+ unless version == 'new'
9
+ puts "#"*80
10
+ puts "# To Lock Current gem versions in Gemfile: "
11
+ puts "#"*80
12
+ current_gems.each do |gem|
13
+ puts " gem '#{gem.name}', '#{gem.version}'"
14
+ end
15
+ puts "#"*80
16
+ puts
17
+
18
+ unless type == 'gemfile'
19
+ puts "#"*80
20
+ puts "# To Lock Current gem versions for Maven by putting the following in your pom.xml: "
21
+ puts "#"*80
22
+ puts "The following assumes you already use Maven for Gem Dependencies *"
23
+ puts
24
+ xml = Builder::XmlMarkup.new(:target => $stdout, :indent => 2)
25
+ current_gems.each do |gem|
26
+ xml.dependency {
27
+ xml.groupId "rubygems"
28
+ xml.artifactId "#{gem.name}"
29
+ xml.version "#{gem.version}"
30
+ xml.type "gem"
31
+ }
32
+ end
33
+ puts
34
+ puts "*: JRuby Maven Info: https://github.com/mkristian/jruby-maven-plugins/"
35
+ puts "#"*80
36
+ end
37
+ puts
38
+ end
39
+
40
+ unless outdated_gems.empty? or version == 'current'
41
+ puts "#"*80
42
+ puts "# To Update and Lock New Gems: "
43
+ puts "#"*80
44
+ puts "\nNewer versions found for:"
45
+ outdated_gems.each do |gem|
46
+ puts " #{gem.name} (#{gem.latest_version} > #{gem.version})"
47
+ end
48
+
49
+ puts "\nLock bundle to NEW gem versions by putting the following in your Gemfile:"
50
+ outdated_gems.each do |gem|
51
+ puts " gem '#{gem.name}', '#{gem.latest_version}'"
52
+ end
53
+ puts "#"*80
54
+
55
+ unless type == 'gemfile'
56
+ puts "#"*80
57
+ puts "# To Lock NEW gems versions for Maven by putting the following in your pom.xml: "
58
+ puts "#"*80
59
+ puts "The following assumes you already use Maven for Gem Dependencies *"
60
+ puts
61
+ xml = Builder::XmlMarkup.new(:target => $stdout, :indent => 2)
62
+ outdated_gems.each do |gem|
63
+ xml.dependency {
64
+ xml.groupId "rubygems"
65
+ xml.artifactId "#{gem.name}"
66
+ xml.version "#{gem.version}"
67
+ xml.type "gem"
68
+ }
69
+ end
70
+ puts
71
+ puts "*: JRuby Maven Info: https://github.com/mkristian/jruby-maven-plugins/"
72
+ puts "#"*80
73
+ end
74
+ end
75
+
76
+ unless handwaving_gems.empty?
77
+ puts "\nYou may try to update non-specific dependencies via:"
78
+ puts " $ bundle update #{handwaving_gems.collect(&:name).join(' ')}"
79
+ puts "\nHandwaving specifications:"
80
+ handwaving_gems.collect do |g|
81
+ puts " #{g.name}: #{ [ g.handwaving, g.version ].join(' ') }"
82
+ end
83
+ end
84
+ end
85
+
86
+ def current_gems
87
+ @current_gems ||= all_gems.find_all()
88
+ end
89
+
90
+ def outdated_gems
91
+ @outdated_gems ||= all_gems.find_all(&:outdated?)
92
+ end
93
+
94
+ def handwaving_gems
95
+ @handwaving_gems ||= all_gems.find_all(&:handwaving?)
96
+ end
97
+
98
+ def gemfile
99
+ unless File.exists?('Gemfile.lock')
100
+ raise GemfileNotFound, 'Gemfile.lock not found! Please re-run in your Ruby project directory.'
101
+ end
102
+
103
+ @gemfile ||= File.read('Gemfile.lock').split(/\n/)
104
+ end
105
+
106
+ def all_gems
107
+ @all_gems ||= gemfile.grep(/^\s*.+\s\((?![~><=]).+?\)$/).collect do |gem|
108
+ GemDependency.new gem.strip()
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,3 @@
1
+ module BundleLock
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BundleOutdatedTest < Test::Unit::TestCase
4
+ def test_truth
5
+ assert true
6
+ end
7
+ end
@@ -0,0 +1,71 @@
1
+ require 'test_helper'
2
+ require 'bundle_outdated'
3
+
4
+ class GemDependencyTest < Test::Unit::TestCase
5
+ def setup
6
+ stub(Gem).latest_version_for('rails') { Gem::Version.new '3.1' }
7
+ end
8
+
9
+ def test_name_cleanup_double_quotes
10
+ gd = BundleOutdated::GemDependency.new 'gem "rails"'
11
+ assert_equal 'rails', gd.name
12
+ end
13
+
14
+ def test_name_cleanup_single_quotes
15
+ gd = BundleOutdated::GemDependency.new "gem 'rails'"
16
+ assert_equal 'rails', gd.name
17
+ end
18
+
19
+ def test_version_cleanup
20
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "3.1"'
21
+ assert_equal '3.1', gd.version.to_s
22
+ end
23
+
24
+ def test_version_garbage_cleanup
25
+ gd = BundleOutdated::GemDependency.new 'gem "rails", :require => "rails"'
26
+ assert_equal '', gd.version.to_s
27
+ end
28
+
29
+ def test_version_garbage_spermy
30
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "~> 3.1"'
31
+ assert_equal '3.1', gd.version.to_s
32
+ end
33
+
34
+ def test_version_with_handwaving
35
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "~> 3.1"'
36
+ assert gd.handwaving?
37
+ end
38
+
39
+ def test_version_without_handwaving
40
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "3.1"'
41
+ assert !gd.handwaving?
42
+ end
43
+
44
+ def test_inspection
45
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "~> 3.1"'
46
+ assert_equal 'rails, Version: 3.1', gd.to_s
47
+ end
48
+
49
+ def test_latest_version
50
+ gd = BundleOutdated::GemDependency.new 'gem "rails"'
51
+ assert_equal '3.1', gd.latest_version.to_s
52
+ end
53
+
54
+ def test_is_outdated
55
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "3.0.7"'
56
+ assert gd.outdated?
57
+ end
58
+
59
+ def test_is_not_outdated
60
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "3.1"'
61
+ assert !gd.outdated?
62
+ end
63
+
64
+ def test_outdated_handles_unavailable_gems
65
+ mock(Gem).latest_version_for('rails') { nil }
66
+ gd = BundleOutdated::GemDependency.new 'gem "rails", "3.1"'
67
+ assert_nothing_raised {
68
+ assert !gd.outdated?
69
+ }
70
+ end
71
+ end
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+ require 'bundle_outdated'
3
+
4
+ class SearcherTest < Test::Unit::TestCase
5
+ def setup
6
+ stub(File).read('Gemfile') { "gem 'rails', '~> 3.0'" }
7
+ stub(Gem).latest_version_for('rails') { Gem::Version.new('3.1') }
8
+ @searcher = BundleOutdated::Searcher.new
9
+ end
10
+
11
+ def test_all_gems_creates_gem_dependencies
12
+ assert_kind_of BundleOutdated::GemDependency, @searcher.all_gems.first
13
+ end
14
+
15
+ def test_all_gems_ignores_lines_without_gem
16
+ mock(File).read('Gemfile') { "source 'gemcutter.org'\ngem 'rails', '~> 3.0'" }
17
+ assert_equal 1, @searcher.all_gems.size
18
+ end
19
+
20
+ def test_gemfile_raises_error_if_no_gemfile_found
21
+ mock(File).exists?('Gemfile') { false }
22
+ assert_raises(BundleOutdated::Searcher::GemfileNotFound) {
23
+ @searcher.gemfile
24
+ }
25
+ end
26
+
27
+ def test_gemfile_reads_and_splits_gemfile
28
+ mock(File).read('Gemfile') { "gem 'rails', '3.0'" }
29
+ assert_equal ["gem 'rails', '3.0'"], @searcher.gemfile
30
+ end
31
+
32
+ def test_search_finds_all_outdated_gems
33
+ assert_equal 'rails', @searcher.outdated_gems.first.name
34
+ end
35
+
36
+ def test_search_finds_all_handwaving_gems
37
+ assert_equal 'rails', @searcher.handwaving_gems.first.name
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rr'
4
+
5
+ class Test::Unit::TestCase
6
+ include RR::Adapters::TestUnit
7
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bundle_lock
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.4
6
+ platform: ruby
7
+ authors:
8
+ - Luis Ramos
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-09 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: builder
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: "3.0"
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rr
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "1.0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ description: Find out current and outdated gems in your gem file and create lock including maven.
39
+ email:
40
+ - lramos85@gmail.com
41
+ executables:
42
+ - bundle-lock
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - CHANGELOG.md
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - bin/bundle-lock
55
+ - bundle_lock.gemspec
56
+ - lib/bundle_lock.rb
57
+ - lib/bundle_lock/gem_dependency.rb
58
+ - lib/bundle_lock/searcher.rb
59
+ - lib/bundle_lock/version.rb
60
+ - test/bundle_outdated_test.rb
61
+ - test/gem_dependency_test.rb
62
+ - test/searcher_test.rb
63
+ - test/test_helper.rb
64
+ has_rdoc: true
65
+ homepage: https://github.com/lramos85/bundle_lock
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options: []
70
+
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.6.0
85
+ requirements: []
86
+
87
+ rubyforge_project: bundle_lock
88
+ rubygems_version: 1.6.1
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Find out current and outdated gems in your gem file and create lock including maven.
92
+ test_files:
93
+ - test/bundle_outdated_test.rb
94
+ - test/gem_dependency_test.rb
95
+ - test/searcher_test.rb
96
+ - test/test_helper.rb