multiversion 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in multiversion.gemspec
4
+ gemspec
@@ -0,0 +1,87 @@
1
+ # Multiversion
2
+
3
+ ## Overview
4
+
5
+ Use Bundler and RVM to test your library against different gem versions and/or ruby versions.
6
+
7
+ ## How it works
8
+
9
+ In your project create several Gemfiles with specified rvm alias in name. E.g:
10
+
11
+ Gemfile.RVM_ALIAS_NAME
12
+
13
+ Examples:
14
+
15
+ Gemfile.ar12_r186
16
+ Gemfile.ar30_r187
17
+ Gemfile.ar30_r192
18
+ Gemfile.ar31_r192
19
+
20
+ Create aliases
21
+
22
+ rvm alias create ar12_r186 ruby-1.8.6-p420
23
+ rvm alias create ar30_r187 ruby-1.8.7-p352
24
+ rvm alias create ar30_r192 ruby-1.9.2-p290
25
+ rvm alias create ar31_r192 ruby-1.9.2-p290
26
+
27
+
28
+ So in each Gemfile you specify certain gem versions gems you need.
29
+ Gemfile file name extension contains some unique name optionaly suffixed with ruby version.
30
+ So in our example Gemfiles with rvm aliases compination mean:
31
+
32
+ * ar12_r186 - test library with ActiveRecord v1.15.6 and ruby-1.8.6-p420
33
+ * ar30_r187 - test library with ActiveRecord v3.0.10 and ruby-1.8.7-p352
34
+ * ar30_r192 - test library with ActiveRecord v3.0.10 and ruby-1.9.2-p290
35
+ * ar31_r192 - test library with ActiveRecord v3.1.0 and ruby-1.9.2-p290
36
+
37
+ So Gemfile extension says about **main traits** of testing environment.
38
+ All certain gem versions are specified in corresponding Gemfile.
39
+
40
+ So for each extension name we explicit knows:
41
+
42
+ * which ruby version is required (through rvm alias)
43
+ * which gems versions are required (through Gemfile filename )
44
+
45
+ ## Executing commands
46
+
47
+ ### Common syntax
48
+
49
+ Synopsis:
50
+
51
+ multiversion [all|alias1,alias2,...] [exec|bundle|rspec] [args]
52
+
53
+ Examples:
54
+
55
+ multiversion ar1_186 exec ruby --version
56
+ multiversion ar3_193 exec ruby --version
57
+
58
+
59
+ ### Main execution wrapper
60
+
61
+ Execute any command under environment modified rvm/bundler:
62
+
63
+ multiversion [all|alias1,alias2,...] exec [command] [args]
64
+
65
+ ### Bundle command wrapper
66
+
67
+ Execute bundle command under environment modified rvm/bundler:
68
+
69
+ multiversion [all|alias1,alias2,...] bundle [bundler_command] [args]
70
+
71
+ Examples:
72
+
73
+ multiversion all bundle install
74
+
75
+
76
+ ### Rspec command wrapper
77
+
78
+ Execute rspec command under environment modified rvm/bundler:
79
+
80
+ multiversion [all|alias1,alias2,...] rspec [rspec args]
81
+
82
+ Examples:
83
+
84
+ multiversion all rspec -fs -c spec
85
+
86
+ **Note**. It use *multiversion-rspec* bin that detects rspec version.
87
+
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ MULTIVERSION_RSPEC_PATH = File.expand_path('../multiversion-rspec', __FILE__)
4
+
5
+ def print_usage
6
+ puts "Main command:"
7
+ puts "multiversion [all|version1,version2,...] exec command [args]"
8
+ puts "Helpers:"
9
+ puts "multiversion [all|version1,version2,...] rspec [rspec args]"
10
+ puts "multiversion [all|version1,version2,...] bundle [bundle args]"
11
+ abort
12
+ end
13
+
14
+ def get_gemfile_versions
15
+ Dir['Gemfile.*'].select { |file|
16
+ file !~ /\.lock$/
17
+ }.map { |gemfile|
18
+ gemfile.scan(/Gemfile\.(.*)/)
19
+ }.flatten.sort
20
+ end
21
+
22
+ def check_rvm_aliases(aliases)
23
+ rvm_aliases = `rvm alias list`.split("\n").map { |line| line.split("=>").first.strip }
24
+ unknown_aliases = aliases - rvm_aliases
25
+ abort "Unknown rvm aliases: #{unknown_aliases.inspect} " unless unknown_aliases.empty?
26
+ end
27
+
28
+ def execute_with_rvm_bundle(version, bundle_args)
29
+ gemfile="Gemfile.#{version}"
30
+
31
+ puts "***"
32
+ puts "*** Executing with RVM '#{version}' and BUNDLE_GEMFILE '#{gemfile}'"
33
+ puts "***"
34
+
35
+ cmd_name = 'rvm'
36
+ cmd_args = [ version, 'exec', 'bundle' ] + bundle_args
37
+
38
+ cmd_string = "export BUNDLE_GEMFILE=#{gemfile} && #{cmd_name}"
39
+ cmd_args.each { |arg|
40
+ cmd_string << ' ' << "'#{arg}'"
41
+ }
42
+
43
+ p cmd_string if ENV['MULTIVERSION_DEBUG']
44
+
45
+ system cmd_string
46
+ end
47
+
48
+
49
+ version = ARGV.shift
50
+ command = ARGV.shift
51
+
52
+ bundle_args =
53
+ case command
54
+ when "bundle"
55
+ ARGV
56
+ when "rspec"
57
+ ["exec", MULTIVERSION_RSPEC_PATH] + ARGV
58
+ when "exec"
59
+ ["exec"] + ARGV
60
+ else
61
+ []
62
+ end
63
+
64
+ if bundle_args.empty?
65
+ print_usage
66
+ else
67
+ versions = version == 'all' ?
68
+ get_gemfile_versions : version.split(',')
69
+
70
+ check_rvm_aliases(versions)
71
+
72
+ versions.each do |version|
73
+ execute_with_rvm_bundle(version, bundle_args)
74
+ end
75
+ end
76
+
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # Simple wrapper for spec/rspec script that:
5
+ #
6
+ # * detects rspec version from load path
7
+ # * prepends spec to load path in case rspec v1
8
+ #
9
+
10
+ rspec_major_version = nil
11
+
12
+ $LOAD_PATH.each do |path|
13
+ if path =~ /\/rspec-(\d+)/
14
+ rspec_major_version = $1.to_i
15
+ break
16
+ end
17
+ end
18
+
19
+ case rspec_major_version
20
+ when 1
21
+ $LOAD_PATH.unshift(File.join(Dir.pwd, "spec"))
22
+ require 'spec'
23
+ exit ::Spec::Runner::CommandLine.run
24
+ when 2
25
+ require 'rspec/core'
26
+ ::RSpec::Core::Runner.autorun
27
+ else
28
+ abort "Can't detect rspec version"
29
+ end
@@ -0,0 +1,5 @@
1
+ require "multiversion/version"
2
+
3
+ module Multiversion
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Multiversion
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "multiversion/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "multiversion"
7
+ s.version = Multiversion::VERSION
8
+ s.authors = ["Andriy Yanko"]
9
+ s.email = ["andriy.yanko@gmail.com"]
10
+ s.homepage = "https://github.com/railsware/multiversion"
11
+ s.summary = %q{Testing your library against different gem versions and ruby versions using RVM and Bundler}
12
+
13
+ s.rubyforge_project = "multiversion"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multiversion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andriy Yanko
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-11 00:00:00.000000000Z
13
+ dependencies: []
14
+ description:
15
+ email:
16
+ - andriy.yanko@gmail.com
17
+ executables:
18
+ - multiversion
19
+ - multiversion-rspec
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - Gemfile
25
+ - README.md
26
+ - Rakefile
27
+ - bin/multiversion
28
+ - bin/multiversion-rspec
29
+ - lib/multiversion.rb
30
+ - lib/multiversion/version.rb
31
+ - multiversion.gemspec
32
+ homepage: https://github.com/railsware/multiversion
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project: multiversion
52
+ rubygems_version: 1.8.6
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Testing your library against different gem versions and ruby versions using
56
+ RVM and Bundler
57
+ test_files: []