gem_import_export 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Peer Allan
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.
@@ -0,0 +1,29 @@
1
+ = gem_import_export
2
+
3
+ This is a simple command plugin for rubygems (http://rubygems.rubyforge.net) which adds the commands "import" and "export". The primary purpose for this plugin is to allow user to specify create mirrors of a gem environment on one machine and them import that environment onto another machine.
4
+
5
+ The export command generates a yaml file for each gem and each version of that gem that you currently have installed on the machine where you run the command. The import command reads from that yaml file and installs each gem, and its corresponding version, listed.
6
+
7
+ The other use for this could be the creation of gem environment "templates" where you export your listing and edit it or create a new yaml file with a selection of gems you want installed.
8
+
9
+ Please add any comments or suggestions to the issues for the github project http://github.com/pallan/gem_import_export/issues
10
+
11
+ == Requirements
12
+
13
+ Command plugins require Rubygems >= 1.3.2
14
+
15
+ == Usage
16
+
17
+ # exports all gems installed into a yaml file
18
+ gem export gems.yml
19
+
20
+ # imports all gems listed in the yaml file
21
+ gem import gems.yml
22
+
23
+ == Todo
24
+
25
+ * have the import command add the necessary sources that are included in the export file
26
+
27
+ == Copyright
28
+
29
+ Copyright (c) 2009 Peer Allan. See LICENSE for details.
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "gem_import_export"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "peer@canadadrugs.com"
10
+ gem.homepage = "http://github.com/pallan/gem_import_export"
11
+ gem.authors = ["Peer Allan"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'spec/rake/spectask'
20
+ Spec::Rake::SpecTask.new(:spec) do |spec|
21
+ spec.libs << 'lib' << 'spec'
22
+ spec.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
24
+
25
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.pattern = 'spec/**/*_spec.rb'
28
+ spec.rcov = true
29
+ end
30
+
31
+
32
+ task :default => :spec
33
+
34
+ require 'rake/rdoctask'
35
+ Rake::RDocTask.new do |rdoc|
36
+ if File.exist?('VERSION.yml')
37
+ config = YAML.load(File.read('VERSION.yml'))
38
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
39
+ else
40
+ version = ""
41
+ end
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "gem_import_export #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
48
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,48 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{gem_import_export}
5
+ s.version = "0.0.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Peer Allan"]
9
+ s.date = %q{2009-05-11}
10
+ s.email = %q{peer@canadadrugs.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "gem_import_export.gemspec",
23
+ "lib/rubygems/commands/export_command.rb",
24
+ "lib/rubygems/commands/import_command.rb",
25
+ "lib/rubygems_plugin.rb",
26
+ "spec/gem_import_export_spec.rb",
27
+ "spec/spec_helper.rb"
28
+ ]
29
+ s.homepage = %q{http://github.com/pallan/gem_import_export}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.3}
33
+ s.summary = %q{Adds the commands to RubyGems for importing and exporting repositories using a command plugin}
34
+ s.test_files = [
35
+ "spec/gem_import_export_spec.rb",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+
39
+ if s.respond_to? :specification_version then
40
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
+ else
45
+ end
46
+ else
47
+ end
48
+ end
@@ -0,0 +1,55 @@
1
+ require 'rubygems/command'
2
+
3
+ ##
4
+ # An alternate to Gem::Commands::QueryCommand that searches for gems starting
5
+ # with the the supplied argument.
6
+
7
+ class Gem::Commands::ExportCommand < Gem::Command
8
+
9
+ def initialize
10
+ super 'export', 'Dumps your currently installed gems into yaml'
11
+ end
12
+
13
+ def arguments # :nodoc:
14
+ "GEMFILE location to save the export to"
15
+ end
16
+
17
+ def defaults_str # :nodoc:
18
+ ""
19
+ end
20
+
21
+ def usage # :nodoc:
22
+ "#{program_name} GEMFILE"
23
+ end
24
+
25
+ def execute
26
+
27
+ export_file = get_one_optional_argument
28
+
29
+ unless export_file then
30
+ raise Gem::CommandLineError,
31
+ "Please specify a file to save the export to"
32
+ end
33
+
34
+ dep = Gem::Dependency.new //, Gem::Requirement.default
35
+ specs = Gem.source_index.search dep
36
+
37
+ gems = []
38
+
39
+ specs.map do |spec|
40
+ gems << {
41
+ :name => spec.name,
42
+ :version => spec.version.to_s,
43
+ :install_options => ''
44
+ }
45
+ end
46
+
47
+ output = {'sources' => Gem.sources, 'gems' => gems}
48
+
49
+ File.open(export_file, 'w') do |f|
50
+ f.write output.to_yaml
51
+ end
52
+ end
53
+
54
+ end
55
+
@@ -0,0 +1,55 @@
1
+ require 'rubygems/command'
2
+ require 'rubygems/commands/install_command'
3
+
4
+ class Gem::Commands::ImportCommand < Gem::Commands::InstallCommand
5
+
6
+ def initialize
7
+ super
8
+ end
9
+
10
+ def arguments # :nodoc:
11
+ "GEM_LIST Yaml file with the gems to install"
12
+ end
13
+
14
+ def usage # :nodoc:
15
+ "#{program_name} GEMSPEC_FILE"
16
+ end
17
+
18
+ def execute
19
+ gemspec = get_one_gem_name
20
+
21
+ unless gemspec then
22
+ raise Gem::CommandLineError,
23
+ "Please specify a gem yaml file on the command line"
24
+ end
25
+
26
+ unless File.exist?(gemspec) then
27
+ raise Gem::CommandLineError,
28
+ "Specified file #{gemspec} does not exist"
29
+ end
30
+
31
+ options[:ignore_dependencies] = true
32
+ installed_gems = []
33
+
34
+ data = YAML.load_file( gemspec )
35
+ data['gems'].each do |g|
36
+ begin
37
+ inst = Gem::DependencyInstaller.new options
38
+ inst.install g[:name], g[:version]
39
+
40
+ inst.installed_gems.each do |spec|
41
+ say "Successfully installed #{spec.full_name}"
42
+ end
43
+
44
+ installed_gems.push(*inst.installed_gems)
45
+ rescue Gem::InstallError => e
46
+ alert_error "Error installing #{gem_name}:\n\t#{e.message}"
47
+ exit_code |= 1
48
+ rescue Gem::GemNotFoundException => e
49
+ alert_error e.message
50
+ exit_code |= 2
51
+ end
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :import
4
+ Gem::CommandManager.instance.register_command :export
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "GemImportExport" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'gem_import_export'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_import_export
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Peer Allan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-11 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: peer@canadadrugs.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - gem_import_export.gemspec
33
+ - lib/rubygems/commands/export_command.rb
34
+ - lib/rubygems/commands/import_command.rb
35
+ - lib/rubygems_plugin.rb
36
+ - spec/gem_import_export_spec.rb
37
+ - spec/spec_helper.rb
38
+ has_rdoc: true
39
+ homepage: http://github.com/pallan/gem_import_export
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.5
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Adds the commands to RubyGems for importing and exporting repositories using a command plugin
66
+ test_files:
67
+ - spec/gem_import_export_spec.rb
68
+ - spec/spec_helper.rb