NAME
Bundler::MultiGem::Model::Gem - The utility to install multiple versions of the same ruby gem
VERSION
Version 0.02
SYNOPSIS
This module contains utility functions for manipulating gems
SUBROUTINES
new
Takes an hash reference parameter. You should provide: * name
: string, gem name in repository * main_module
: string, gem main module name * source
: string, e.g. "https://rubygems.org"
* versions
: array ref of strings, e.g. [qw( 0.0.5 0.1.0 )]
my $config = {
name => "jsonschema_serializer",
main_module => "JsonschemaSerializer",
source => "https://rubygems.org",
versions => [qw( 0.0.5 0.1.0 )]
};
my $gem = Bundler::MultiGem::Model::Gem->new($config);
config config getter
name
name
getter
$gem->name; # "jsonschema_serializer"
source
source
getter
$gem->source; # "https://rubygems.org"
main_module
main_module
getter
$gem->main_module; # "JsonschemaSerializer"
versions
versions
getter
$gem->versions; # [qw( 0.0.5 0.1.0 )]
vname
vname
getter: combine gem name and version and format it * v
: string, a gem version reference
$gem->name; # "jsonschema_serializer"
my $v = "0.0.5";
$gem->vname($v); # "v005-jsonschema_serializer"
vmodule_name
vmodule_name
getter: combine gem name and version and format it * v
: string, a gem version reference
$gem->main_module; # "JsonschemaSerializer"
my $v = "0.0.5";
$gem->vmodule_name($v); # "V005::JsonschemaSerializer"
apply
This function apply all the transformation to the gem versions to be reused in the same Gemfile
: dir
, a Bundler::MultiGem::Model::Directories
instance
For each gem version it will: * fetch the gem version * extract it into a target directory * process_gemfile
* rename_main_file
* rename the lib directory including the version name * for each rb
, rake
and Rakefile
apply process_single_file
Caveats: * if you are renaming foo-bar
to V123::Foo::Bar
, also partial matches will be renamed: e.g. foo-bar_baz
* this is intended for benchmarking simple gems, it may break with very complex gems * the use case leading this development was benchmarking serialization gems performance
process_gemfile
Manipulates original gemfile as follows: * rename foo.gemspec
for v 0.1.0
into v010-foo.gemspec
* remove line importing gem version (usually require_relative 'lib/foo/version'
) * replace main_module version with the actual version (Foo::VERSION
with '0.1.0'
) * replace gem name reference with gem vname (foo
with v010-foo
) * replace gem main_module reference with gem vmodule_name (Foo
with V010::Foo
) * unlink the original foo.gemspec
rename_main_file
Manipulates original gemfile as follows: * rename lib/foo.rb
for v 0.1.0
into lib/v010-foo.rb
* add on top of lib/v010-foo.rb
: module V010; end
for namespacing * copy the rest of original below
This step allows to add a namespace with the gem version (a kind of shading). All the other replacement are done with other rb, rake and Rakfile files.
process_single_file
Manipulates each file as follows: * create a backup of the original file .bak
* replace gem name reference with gem vname (foo
with v010-foo
) * replace gem main_module reference with gem vmodule_name (Foo
with V010::Foo
) * unlink the backup .bak
fetch
This is an alias of the system command gem fetch
my $gem->name; # "foo"
my $fp = "pkg/v010-foo.gem"
my $gv = "0.1.0";
$gem->fetch($fp, $gv); # if $fp found, do nothing, else fetch gem version and rename it
EXPORTS
gem_vname
Reusable function to combine and format gem name and version
use Bundler::MultiGem::Model::Gem qw(gem_vname);
gem_vname("foo", "0.1.0"); # v010-foo
gem_vname("foo_bar", "0.1.0"); # v010-foo_bar
gem_vname("foo-bar", "0.1.0"); # v010-foo-bar
gem_vmodule_name
Reusable function to combine and format gem main module and version
use Bundler::MultiGem::Model::Gem qw(gem_vmodule_name);
gem_vname("Foo", "0.1.0"); # V010::Foo
gem_vname("FooBar", "0.1.0"); # V010::FooBar
gem_vname("Foo::Bar", "0.1.0"); # V010::Foo::Bar
norm_v
Utility function to normalize version name
use Bundler::MultiGem::Model::Gem qw(norm_v);
norm_v("123"); #v123
norm_v("1.23"); #v123
norm_v("12.3"); #v123
norm_v("1.2.3"); #v123
unpack_gem
This is an alias of the system command gem unpack
AUTHOR
Mauro Berlanda, <kupta at cpan.org>
BUGS
Please report any bugs or feature requests to https://github.com/mberlanda/Bundler-MultiGem/issues, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=.. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Bundler::MultiGem::Directories
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/Public/Dist/Display.html?Name=Bundler-MultiGem
Github Repository
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2018 Mauro Berlanda.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.