gem-manage-sources 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +49 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/lib/gem_manage_sources/commands/manage_sources_command.rb +103 -0
- data/lib/gem_manage_sources/sources.rb +88 -0
- data/lib/gem_manage_sources.rb +2 -0
- data/lib/rubygems_plugin.rb +6 -0
- data/spec/gem_manage_sources/commands/manage_sources_command_spec.rb +155 -0
- data/spec/gem_manage_sources/sources_spec.rb +103 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- metadata +92 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Britt Crawford
|
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.rdoc
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
= gem-manage-sources
|
2
|
+
|
3
|
+
Manage your gem sources so that you can use sources that are not always available without having to 'gem sources -a' and 'gem sources -r' all the time.
|
4
|
+
|
5
|
+
This is useful if you have a corporate gem server that lives within
|
6
|
+
a firewall and is not always accessible.
|
7
|
+
|
8
|
+
== Installation
|
9
|
+
|
10
|
+
gem install gem-manage-sources
|
11
|
+
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
First you have to create a sources.yml file using:
|
15
|
+
|
16
|
+
gem manage_sources --init
|
17
|
+
|
18
|
+
Now whenever you switch networks or want to check whether some of your sources are available use:
|
19
|
+
|
20
|
+
gem manage_sources --check
|
21
|
+
|
22
|
+
To add a source:
|
23
|
+
|
24
|
+
gem manage_sources --add http://source.com
|
25
|
+
|
26
|
+
To remove a source
|
27
|
+
|
28
|
+
gem manage_sources --remove http://source.com
|
29
|
+
|
30
|
+
== TODO
|
31
|
+
|
32
|
+
* Sources are not being removed when they go active...doh.
|
33
|
+
* Documentation
|
34
|
+
* JRuby (and *Ruby) support
|
35
|
+
* Find a better name
|
36
|
+
|
37
|
+
== Note on Patches/Pull Requests
|
38
|
+
|
39
|
+
* Fork the project.
|
40
|
+
* Make your feature addition or bug fix.
|
41
|
+
* Add tests for it. This is important so I don't break it in a
|
42
|
+
future version unintentionally.
|
43
|
+
* Commit, do not mess with rakefile, version, or history.
|
44
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
45
|
+
* Send me a pull request. Bonus points for topic branches.
|
46
|
+
|
47
|
+
== Copyright
|
48
|
+
|
49
|
+
Copyright (c) 2009 Britt Crawford. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "gem-manage-sources"
|
8
|
+
|
9
|
+
gem.summary = <<-SUMMARY
|
10
|
+
Manage your gem sources so that you can use sources that are not always available without having to 'gem sources -a' and 'gem sources -r' all the time.
|
11
|
+
SUMMARY
|
12
|
+
|
13
|
+
gem.description = <<-WTF
|
14
|
+
Manage your gem sources so that you can use sources that are not always available without having to 'gem sources -a' and 'gem sources -r' all the time. This is especially useful if you have a gem server that lives within a firewall.
|
15
|
+
WTF
|
16
|
+
|
17
|
+
gem.email = "britt.v.crawford@gmail.com"
|
18
|
+
gem.homepage = "http://github.com/britt/gem-manage-sources"
|
19
|
+
gem.authors = ["Britt Crawford"]
|
20
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
21
|
+
gem.add_development_dependency "yard", ">= 0"
|
22
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
23
|
+
end
|
24
|
+
Jeweler::GemcutterTasks.new
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'spec/rake/spectask'
|
30
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
32
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
36
|
+
spec.libs << 'lib' << 'spec'
|
37
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
38
|
+
spec.rcov = true
|
39
|
+
end
|
40
|
+
|
41
|
+
task :spec => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :spec
|
44
|
+
|
45
|
+
begin
|
46
|
+
require 'yard'
|
47
|
+
YARD::Rake::YardocTask.new
|
48
|
+
rescue LoadError
|
49
|
+
task :yardoc do
|
50
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
51
|
+
end
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.2
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'gem_manage_sources/sources'
|
3
|
+
|
4
|
+
module Gem
|
5
|
+
module Commands
|
6
|
+
class ManageSourcesCommand < Gem::Command
|
7
|
+
include Gem::Sources
|
8
|
+
|
9
|
+
def self.sources_file
|
10
|
+
File.join(ENV['HOME'], '.gem', 'ruby', 'sources.yml')
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super('manage-sources', 'Manage the sources RubyGems use to search for gems. (USE INSTEAD OF: sources)')
|
15
|
+
defaults.merge!(:sources_to_add => [], :sources_to_remove => [], :check_sources? => false, :init? => false)
|
16
|
+
|
17
|
+
add_option('-a', '--add SOURCE_URL', 'Add a gem source') do |value, options|
|
18
|
+
options[:sources_to_add] << value
|
19
|
+
end
|
20
|
+
|
21
|
+
add_option('-r', '--remove SOURCE_URL', 'Remove a gem source') do |value, options|
|
22
|
+
options[:sources_to_remove] << value
|
23
|
+
end
|
24
|
+
|
25
|
+
add_option('-c', '--check', 'Check gem sources. This will add or remove sources depending on availability.') do |value, options|
|
26
|
+
options[:check_sources?] = true
|
27
|
+
end
|
28
|
+
|
29
|
+
add_option('-i', '--init', 'Generate the sources.yml file from your existing gem sources.') do |value, options|
|
30
|
+
options[:init?] = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute
|
35
|
+
if options[:init?]
|
36
|
+
initialize_sources
|
37
|
+
elsif options[:check_sources?]
|
38
|
+
check_sources
|
39
|
+
elsif !options[:sources_to_add].empty?
|
40
|
+
add_sources(options[:sources_to_add])
|
41
|
+
elsif !options[:sources_to_remove].empty?
|
42
|
+
remove_sources(options[:sources_to_remove])
|
43
|
+
else
|
44
|
+
list
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize_sources
|
49
|
+
unless File.exist?(ManageSourcesCommand.sources_file)
|
50
|
+
@sources = List.new(:unchecked => currently_loaded_sources)
|
51
|
+
@sources.verify
|
52
|
+
@sources.dump(ManageSourcesCommand.sources_file)
|
53
|
+
end
|
54
|
+
list
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_sources
|
58
|
+
sources.unchecked.concat(currently_loaded_sources)
|
59
|
+
sources.verify
|
60
|
+
sources.sync
|
61
|
+
sources.dump(ManageSourcesCommand.sources_file)
|
62
|
+
list
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_sources(sources_to_add)
|
66
|
+
sources_to_add.each do |source|
|
67
|
+
if sources.add(source)
|
68
|
+
puts "Added #{source} to gem sources."
|
69
|
+
else
|
70
|
+
puts "** #{source} Unavailable ** Added to the list of inactive sources. "
|
71
|
+
end
|
72
|
+
end
|
73
|
+
sources.dump(ManageSourcesCommand.sources_file)
|
74
|
+
end
|
75
|
+
|
76
|
+
def remove_sources(sources_to_remove)
|
77
|
+
sources_to_remove.each do |source|
|
78
|
+
sources.remove(source)
|
79
|
+
puts "Removed #{source} from gem sources."
|
80
|
+
end
|
81
|
+
sources.dump(ManageSourcesCommand.sources_file)
|
82
|
+
end
|
83
|
+
|
84
|
+
def list
|
85
|
+
puts "*** CURRENT SOURCES ***"
|
86
|
+
puts ""
|
87
|
+
puts "** ACTIVE SOURCES **"
|
88
|
+
puts ""
|
89
|
+
sources.active.each { |source| puts source }
|
90
|
+
puts ""
|
91
|
+
puts "** INACTIVE SOURCES **"
|
92
|
+
puts ""
|
93
|
+
sources.inactive.each { |source| puts source }
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def sources
|
99
|
+
@sources ||= Gem::Sources::List.load_file(ManageSourcesCommand.sources_file)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Gem
|
5
|
+
module Sources
|
6
|
+
def currently_loaded_sources
|
7
|
+
`gem sources`.split("\n").select { |s| s.start_with?('http') }
|
8
|
+
end
|
9
|
+
|
10
|
+
class List
|
11
|
+
include Gem::Sources
|
12
|
+
|
13
|
+
attr_accessor :active, :inactive, :unchecked
|
14
|
+
|
15
|
+
def self.load_file(file_name)
|
16
|
+
List.new(YAML.load_file(file_name))
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(sources = {})
|
20
|
+
self.active = sources[:active] || []
|
21
|
+
self.inactive = sources[:inactive] || []
|
22
|
+
self.unchecked = sources[:unchecked] || []
|
23
|
+
end
|
24
|
+
|
25
|
+
def verify
|
26
|
+
@active, @inactive = all.partition { |source| source_available?(source) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def sync
|
30
|
+
current_sources = currently_loaded_sources
|
31
|
+
(active - current_sources).each { |source| add_system_source(source) }
|
32
|
+
(inactive & current_sources).each { |source| remove_system_source(source) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def add(source)
|
36
|
+
available = source_available?(source)
|
37
|
+
if available
|
38
|
+
self.active << source
|
39
|
+
else
|
40
|
+
self.inactive << source
|
41
|
+
end
|
42
|
+
available
|
43
|
+
end
|
44
|
+
|
45
|
+
def remove(source)
|
46
|
+
[@active, @unchecked, @inactive].each { |list| list.delete(source) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def all
|
50
|
+
(active + inactive + unchecked).uniq
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_h
|
54
|
+
{:active => active, :inactive => inactive}
|
55
|
+
end
|
56
|
+
|
57
|
+
def dump(file_name)
|
58
|
+
File.open(file_name, 'w') do |sources_file|
|
59
|
+
YAML.dump(to_h, sources_file)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def size
|
64
|
+
all.size
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def source_available?(host)
|
70
|
+
uri = URI.parse(host)
|
71
|
+
gemspec_path = uri.path[-1,1] == '/' ? "specs.4.8.gz" : "/specs.4.8.gz"
|
72
|
+
response = nil
|
73
|
+
Net::HTTP.start(uri.host, uri.port) {|http| response = http.head(uri.path + gemspec_path)}
|
74
|
+
response.is_a?(Net::HTTPOK)
|
75
|
+
rescue
|
76
|
+
false
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_system_source(source)
|
80
|
+
system("gem source -a #{source}")
|
81
|
+
end
|
82
|
+
|
83
|
+
def remove_system_source(source)
|
84
|
+
system("gem source -r #{source}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Gem::Commands::ManageSourcesCommand do
|
4
|
+
include Gem::Sources
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@test_sources_file = Dir.tmpdir + "/test_gem_sources.yml"
|
8
|
+
@command = Gem::Commands::ManageSourcesCommand.new
|
9
|
+
Gem::Commands::ManageSourcesCommand.stub!(:sources_file).and_return(@test_sources_file)
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
File.delete(@test_sources_file) if File.exist?(@test_sources_file)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "options" do
|
17
|
+
before(:each) do
|
18
|
+
@command.when_invoked {}
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "add" do
|
22
|
+
it "should be -a, --add" do
|
23
|
+
@command.invoke("-a", "http://gems.example.com")
|
24
|
+
@command.invoke("--add", "http://gems.example.com")
|
25
|
+
|
26
|
+
@command.options[:args].should be_empty
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should add the given source to :sources_to_add" do
|
30
|
+
@command.invoke("-a", "http://gems.example.com")
|
31
|
+
@command.options[:sources_to_add].should include("http://gems.example.com")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "remove" do
|
36
|
+
it "should be -r, --remove" do
|
37
|
+
@command.invoke("-r", "http://gems.example.com")
|
38
|
+
@command.invoke("--remove", "http://gems.example.com")
|
39
|
+
|
40
|
+
@command.options[:args].should be_empty
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should add the given source to :sources_to_add" do
|
44
|
+
@command.invoke("-r", "http://gems.example.com")
|
45
|
+
@command.options[:sources_to_remove].should include("http://gems.example.com")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "check" do
|
50
|
+
it "should be -c, --check" do
|
51
|
+
@command.invoke("-c")
|
52
|
+
@command.invoke("--check")
|
53
|
+
|
54
|
+
@command.options[:args].should be_empty
|
55
|
+
end
|
56
|
+
|
57
|
+
it "check_sources? should be true" do
|
58
|
+
@command.invoke("-c")
|
59
|
+
|
60
|
+
@command.options[:check_sources?].should be_true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "init" do
|
65
|
+
it "should be -i, --init" do
|
66
|
+
@command.invoke("-i")
|
67
|
+
@command.invoke("--init")
|
68
|
+
|
69
|
+
@command.options[:args].should be_empty
|
70
|
+
end
|
71
|
+
|
72
|
+
it "init? should be true" do
|
73
|
+
@command.invoke("-i")
|
74
|
+
|
75
|
+
@command.options[:init?].should be_true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "init" do
|
81
|
+
context "when there is no existing sources file" do
|
82
|
+
before(:each) do
|
83
|
+
Gem::Commands::ManageSourcesCommand.stub!(:sources_file).and_return(@test_sources_file)
|
84
|
+
File.exist?(@test_sources_file).should be_false
|
85
|
+
|
86
|
+
@sources = ['http://active.example.com','http://inactive.example.com']
|
87
|
+
@list = Gem::Sources::List.new(:unchecked => @sources)
|
88
|
+
|
89
|
+
@list.stub!(:source_available?) do |source|
|
90
|
+
source == 'http://active.example.com'
|
91
|
+
end
|
92
|
+
|
93
|
+
Gem::Sources::List.stub!(:new).and_return(@list)
|
94
|
+
|
95
|
+
@command.stub!(:currently_loaded_sources).and_return(@sources)
|
96
|
+
@command.stub!(:sources).and_return(@list)
|
97
|
+
@command.invoke('-i')
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should create ~/.gem/ruby/sources.yml" do
|
101
|
+
File.exist?(@test_sources_file).should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should add all of the existing sources" do
|
105
|
+
sources = Gem::Sources::List.load_file(@test_sources_file)
|
106
|
+
@sources.each do |source|
|
107
|
+
sources.all.should include(source)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should add unavailable sources to the inactive list" do
|
112
|
+
sources = Gem::Sources::List.load_file(@test_sources_file)
|
113
|
+
sources.active.should == ['http://active.example.com']
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should add available sources to the active list" do
|
117
|
+
sources = Gem::Sources::List.load_file(@test_sources_file)
|
118
|
+
sources.inactive.should == ['http://inactive.example.com']
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "check" do
|
124
|
+
before(:each) do
|
125
|
+
@sources = ['http://active.example.com','http://inactive.example.com']
|
126
|
+
@list = Gem::Sources::List.new(:unchecked => @sources)
|
127
|
+
|
128
|
+
@list.stub!(:sync)
|
129
|
+
@list.stub!(:source_available?) do |source|
|
130
|
+
source == 'http://active.example.com'
|
131
|
+
end
|
132
|
+
@list.verify
|
133
|
+
@list.dump(@test_sources_file)
|
134
|
+
|
135
|
+
@sources << 'http://another.example.com'
|
136
|
+
@command.stub!(:currently_loaded_sources).and_return(@sources)
|
137
|
+
@command.stub!(:sources).and_return(@list)
|
138
|
+
|
139
|
+
@command.invoke('-c')
|
140
|
+
@list = Gem::Sources::List.load_file(@test_sources_file)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should should add any new sources that have been added using 'gem source add'" do
|
144
|
+
@list.all.should include('http://another.example.com')
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should add unavailable sources to the inactive list" do
|
148
|
+
@list.inactive.sort.should == ['http://inactive.example.com', 'http://another.example.com'].sort
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should add available sources to the active list" do
|
152
|
+
@list.active.should == ['http://active.example.com']
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Gem::Sources do
|
4
|
+
include Gem::Sources
|
5
|
+
|
6
|
+
describe "#currently_loaded_sources" do
|
7
|
+
it "should load all of the sources from 'gem sources'" do
|
8
|
+
currently_loaded_sources.should == `gem sources`.split("\n").select { |s| s.start_with?('http') }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Gem::Sources::List do
|
13
|
+
before(:each) do
|
14
|
+
@sources = {
|
15
|
+
:active => ['http://active.example.com'],
|
16
|
+
:inactive => ['http://inactive.example.com']
|
17
|
+
}
|
18
|
+
@list = Gem::Sources::List.new(@sources)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "##load_file" do
|
22
|
+
it "should load the given YAML" do
|
23
|
+
@test_sources_file = Dir.tmpdir + "/test_gem_sources.yml"
|
24
|
+
File.open(@test_sources_file, 'w+') {|out| YAML.dump(@sources, out) }
|
25
|
+
|
26
|
+
file_list = Gem::Sources::List.load_file(@test_sources_file)
|
27
|
+
file_list.active.should == @list.active
|
28
|
+
file_list.inactive.should == @list.inactive
|
29
|
+
|
30
|
+
File.delete @test_sources_file
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#all" do
|
35
|
+
it "should include both active and inactive sources" do
|
36
|
+
@list.all.sort.should == ['http://active.example.com', 'http://inactive.example.com'].sort
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#to_h" do
|
41
|
+
it "should serialize to a hash" do
|
42
|
+
@list.to_h.should == @sources
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#dump" do
|
47
|
+
it "should dump the hash representation to the given file" do
|
48
|
+
io = mock('FILE')
|
49
|
+
File.stub(:open).and_yield(io)
|
50
|
+
YAML.should_receive(:dump).once.with(@list.to_h, io)
|
51
|
+
@list.dump('file')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#verify" do
|
56
|
+
it "should check all sources" do
|
57
|
+
@list.should_receive(:source_available?).exactly(@list.size).times.and_return(true)
|
58
|
+
@list.verify
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should sort the sources into active and inactive" do
|
62
|
+
@list.stub!(:source_available?).and_return(true, false)
|
63
|
+
@list.verify
|
64
|
+
@list.active.should_not be_empty
|
65
|
+
@list.inactive.should_not be_empty
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#add" do
|
70
|
+
it "should check if the source is available it to the appropriate list" do
|
71
|
+
@list.stub!(:source_available?).and_return(false)
|
72
|
+
@list.add('http://yas.example.com')
|
73
|
+
@list.inactive.should include('http://yas.example.com')
|
74
|
+
@list.active.should_not include('http://yas.example.com')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#remove" do
|
79
|
+
it "should remove the source from all lists" do
|
80
|
+
@list.remove('http://active.example.com')
|
81
|
+
@list.all.should_not include('http://active.example.com')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#sync" do
|
86
|
+
before(:each) do
|
87
|
+
@list.stub!(:currently_loaded_sources).and_return(['http://inactive.example.com'])
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should add all active sources that are not currently loaded" do
|
91
|
+
@list.should_receive(:add_system_source).once.with('http://active.example.com')
|
92
|
+
@list.stub!(:remove_system_source)
|
93
|
+
@list.sync
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should remove any inactive sources that are currently loaded" do
|
97
|
+
@list.should_receive(:remove_system_source).once.with('http://inactive.example.com')
|
98
|
+
@list.stub!(:add_system_source)
|
99
|
+
@list.sync
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'gem_manage_sources'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
require 'pp'
|
7
|
+
require 'tmpdir'
|
8
|
+
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gem-manage-sources
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Britt Crawford
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-29 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yard
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: |
|
36
|
+
Manage your gem sources so that you can use sources that are not always available without having to 'gem sources -a' and 'gem sources -r' all the time. This is especially useful if you have a gem server that lives within a firewall.
|
37
|
+
|
38
|
+
email: britt.v.crawford@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- LICENSE
|
45
|
+
- README.rdoc
|
46
|
+
files:
|
47
|
+
- .document
|
48
|
+
- .gitignore
|
49
|
+
- LICENSE
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- VERSION
|
53
|
+
- lib/gem_manage_sources.rb
|
54
|
+
- lib/gem_manage_sources/commands/manage_sources_command.rb
|
55
|
+
- lib/gem_manage_sources/sources.rb
|
56
|
+
- lib/rubygems_plugin.rb
|
57
|
+
- spec/gem_manage_sources/commands/manage_sources_command_spec.rb
|
58
|
+
- spec/gem_manage_sources/sources_spec.rb
|
59
|
+
- spec/spec.opts
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://github.com/britt/gem-manage-sources
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --charset=UTF-8
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.3.5
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Manage your gem sources so that you can use sources that are not always available without having to 'gem sources -a' and 'gem sources -r' all the time.
|
89
|
+
test_files:
|
90
|
+
- spec/gem_manage_sources/commands/manage_sources_command_spec.rb
|
91
|
+
- spec/gem_manage_sources/sources_spec.rb
|
92
|
+
- spec/spec_helper.rb
|