lacomartincik-gem_multirep 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT LICENSE
2
+
3
+ Copyright (c) 2009 Ladislav Martincik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,23 @@
1
+ == Description
2
+
3
+ A gem command plugin which helps you have multiple local repositories of GEMs on your computer.
4
+
5
+ == Install
6
+
7
+ Install the gem with:
8
+
9
+ gem source -a http://gems.github.com && sudo gem install lacomartincik-gem_multirep
10
+
11
+ == Examples
12
+
13
+ == Bugs/Tickets
14
+
15
+ Please submit tickets through {github's issue tracker}[http://github.com/lacomartincik/gem_multirep/issues].
16
+
17
+ == TODO
18
+
19
+ * Tests!
20
+
21
+ == LICENSE
22
+
23
+ See LICENSE.txt
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ begin
5
+ require 'rcov/rcovtask'
6
+
7
+ Rcov::RcovTask.new do |t|
8
+ t.libs << 'test'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ t.rcov_opts = ["-T -x '/Library/Ruby/*'"]
11
+ t.verbose = true
12
+ end
13
+ rescue LoadError
14
+ puts "Rcov not available. Install it for rcov-related tasks with: sudo gem install rcov"
15
+ end
16
+
17
+ begin
18
+ require 'jeweler'
19
+ Jeweler::Tasks.new do |s|
20
+ s.name = "gem_multirep"
21
+ s.description = 'A gem command plugin which helps you have multiple local repositories of GEMs on your computer.'
22
+ s.summary = "A gem command plugin which helps you have multiple local repositories of GEMs on your computer."
23
+ s.email = "ladislav.martincik@gmail.com"
24
+ s.homepage = "http://github.com/lacomartincik/gem_multirep"
25
+ s.authors = ["Ladislav Martincik"]
26
+ s.has_rdoc = true
27
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
28
+ s.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
29
+ end
30
+
31
+ rescue LoadError
32
+ puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
33
+ end
34
+
35
+ Rake::TestTask.new do |t|
36
+ t.libs << 'lib'
37
+ t.pattern = 'test/**/*_test.rb'
38
+ t.verbose = false
39
+ end
40
+
41
+ Rake::RDocTask.new do |rdoc|
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = 'test'
44
+ rdoc.options << '--line-numbers' << '--inline-source'
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
48
+
49
+ task :default => :test
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 1
3
+ :patch: 0
4
+ :major: 0
@@ -0,0 +1,96 @@
1
+ require 'yaml'
2
+
3
+ require 'rubygems/command'
4
+ require 'rubygems/multirep'
5
+
6
+ #new, #execute, #arguments, #defaults_str, #description and #usage
7
+ #Gem.ensure_gem_subdirectories @gem_home
8
+ class Gem::Commands::MultirepCommand < Gem::Command
9
+
10
+ system_config_path =
11
+ begin
12
+ require 'Win32API'
13
+
14
+ CSIDL_COMMON_APPDATA = 0x0023
15
+ path = 0.chr * 260
16
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP', 'L'
17
+ SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
18
+
19
+ path.strip
20
+ rescue LoadError
21
+ '/etc'
22
+ end
23
+
24
+ DEFAULT_CONFIG_FILE = File.join system_config_path, 'repositories_gemrc'
25
+
26
+ def initialize
27
+ @repositories = []
28
+
29
+ super 'multirep', "Add capability to have multiple local GEM repositories"
30
+
31
+ add_option('-a', '--add PATH', 'Add new repository to list') do |value, options|
32
+ options[:add] = value
33
+ end
34
+
35
+ add_option('-r', '--remove PATH', 'Remove repository from list') do |value, options|
36
+ options[:remove] = value
37
+ end
38
+
39
+ remove_option '--config-file'
40
+ end
41
+
42
+ def usage # :nodoc:
43
+ "#{program_name}"
44
+ end
45
+
46
+ def description # :nodoc:
47
+ ""
48
+ end
49
+
50
+ def execute
51
+ @repositories = load_file(DEFAULT_CONFIG_FILE)
52
+
53
+ if options[:add] || options[:remove]
54
+ if options[:add]
55
+ require 'ruby-debug'
56
+ debugger
57
+
58
+ @repositories << options[:add]
59
+ elsif options[:remove]
60
+ @repositories.delete(options[:remove])
61
+ end
62
+
63
+ save_file(DEFAULT_CONFIG_FILE)
64
+ end
65
+
66
+ say "List of repositories:"
67
+ say @repositories
68
+ end
69
+
70
+ private
71
+
72
+ def load_file(filename)
73
+ begin
74
+ YAML.load(File.read(filename)) if filename and File.exist?(filename)
75
+ rescue ArgumentError
76
+ warn "Failed to load #{filename}"
77
+ rescue Errno::EACCES
78
+ warn "Failed to load #{filename} due to permissions problem."
79
+ end or []
80
+ end
81
+
82
+ def save_file(filename)
83
+ begin
84
+ return unless filename
85
+
86
+ File.open( filename, 'w' ) do |out|
87
+ YAML.dump( @repositories, out )
88
+ end
89
+ rescue ArgumentError
90
+ warn "Failed to write #{filename}"
91
+ rescue Errno::EACCES
92
+ warn "Failed to write #{filename} due to permissions problem."
93
+ end
94
+ end
95
+
96
+ end
@@ -0,0 +1,3 @@
1
+ module Gem::Multirep
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :multirep
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lacomartincik-gem_multirep
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ladislav Martincik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-05 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A gem command plugin which helps you have multiple local repositories of GEMs on your computer.
17
+ email: ladislav.martincik@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE.txt
24
+ - README.rdoc
25
+ files:
26
+ - LICENSE.txt
27
+ - README.rdoc
28
+ - Rakefile
29
+ - VERSION.yml
30
+ - lib/rubygems/commands/multirep_command.rb
31
+ - lib/rubygems/multirep.rb
32
+ - lib/rubygems_plugin.rb
33
+ has_rdoc: true
34
+ homepage: http://github.com/lacomartincik/gem_multirep
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --charset=UTF-8
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.2.0
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: A gem command plugin which helps you have multiple local repositories of GEMs on your computer.
59
+ test_files: []
60
+