Permalink
Browse files

Moving the gem out of lib/ and into gem/

  • Loading branch information...
1 parent aff9ab4 commit 868568029e56f931c25f7508ea52e5e827eb5e06 @qrush qrush committed Aug 21, 2009
View
@@ -8,8 +8,8 @@ require 'tasks/rails'
namespace :test do
Rake::TestTask.new(:commands) do |t|
- t.libs << "test"
- t.test_files = FileList['test/commands/*_test.rb']
+ t.libs << "gem/test"
+ t.test_files = FileList['gem/test/*_test.rb']
t.verbose = true
end
end
@@ -3,6 +3,8 @@
class Gem::AbstractCommand < Gem::Command
include Gem::LocalRemoteOptions
+ URL = "http://gemcutter.org"
+
def api_key
Gem.configuration[:gemcutter_key]
end
@@ -17,7 +19,7 @@ def setup
end
def sign_in
- say "Enter your Gemcutter credentials. Don't have an account yet? Create one at #{GemCutter::URL}/sign_up"
+ say "Enter your Gemcutter credentials. Don't have an account yet? Create one at #{URL}/sign_up"
email = ask("Email: ")
password = ask_for_password("Password: ")
@@ -86,7 +88,9 @@ def http_proxy
end
def ask_for_password(message)
- password = ui.ask_for_password(message)
+ system "stty -echo"
+ password = ask(message)
+ system "stty echo"
ui.say("\n")
password
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -14,11 +14,11 @@ def execute
end
def tumble
- if Gem.sources.include?(GemCutter::URL)
- Gem.sources.delete GemCutter::URL
+ if Gem.sources.include?(URL)
+ Gem.sources.delete URL
Gem.configuration.write
else
- Gem.sources.unshift GemCutter::URL
+ Gem.sources.unshift URL
Gem.configuration.write
end
end
@@ -7,16 +7,3 @@
require "commands/#{command}"
Gem::CommandManager.instance.register_command command.to_sym
end
-
-class GemCutter
- URL = "http://gemcutter.org" unless const_defined?(:URL)
-end
-
-class Gem::StreamUI
- def ask_for_password(message)
- system "stty -echo"
- password = ask(message)
- system "stty echo"
- password
- end
-end
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../command_helper'
+require 'command_helper'
class Gem::Commands::FakeCommand < Gem::AbstractCommand
def description
@@ -83,7 +83,7 @@ class AbstractCommandTest < CommandTest
@email = "email"
@password = "password"
@key = "key"
- mock(@command).say("Enter your Gemcutter credentials. Don't have an account yet? Create one at #{GemCutter::URL}/sign_up")
+ mock(@command).say("Enter your Gemcutter credentials. Don't have an account yet? Create one at #{Gem::AbstractCommand::URL}/sign_up")
mock(@command).ask("Email: ") { @email }
mock(@command).ask_for_password("Password: ") { @password }
FakeWeb.register_uri :get, "https://#{@email}:#{@password}@gemcutter.heroku.com/api_key", :body => @key
@@ -10,7 +10,7 @@
FakeWeb.allow_net_connect = false
-$:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
+$:.unshift File.expand_path(File.join(File.dirname(__FILE__), ".."))
require "rubygems_plugin"
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../command_helper'
+require 'command_helper'
require 'net/scp'
class MigrateCommandTest < CommandTest
@@ -72,12 +72,12 @@ class MigrateCommandTest < CommandTest
assert_received(@command) { |subject| subject.say(anything) }
assert_received(@command) { |subject| subject.terminate_interaction }
end
-
+
should "know the project name if it exists in the gem" do
stub(@command).rubygem.with() { {'rubyforge_project' => 'rails'} }
assert_equal 'rails', @command.project_name
end
-
+
should "fall back to the gem name when trying to find the rubyforge project" do
stub(@command).rubygem.with() { {'name' => 'rails'} }
assert_equal 'rails', @command.project_name
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../command_helper'
+require 'command_helper'
class PushCommandTest < CommandTest
context "pushing" do
@@ -1,17 +1,17 @@
-require File.dirname(__FILE__) + '/../command_helper'
+require 'command_helper'
class TumbleCommandTest < CommandTest
context "with a tumbler and some sources" do
setup do
- @sources = ["gems.rubyforge.org", GemCutter::URL]
+ @sources = ["gems.rubyforge.org", Gem::AbstractCommand::URL]
stub(Gem).sources { @sources }
@command = Gem::Commands::TumbleCommand.new
end
should "show sources" do
mock(@command).say("Your gem sources are now:")
mock(@command).say("- #{@sources.first}")
- mock(@command).say("- #{GemCutter::URL}")
+ mock(@command).say("- #{Gem::AbstractCommand::URL}")
@command.show_sources
end
end
@@ -27,16 +27,16 @@ class TumbleCommandTest < CommandTest
end
should "add gemcutter as first source" do
- mock(@sources).unshift(GemCutter::URL)
+ mock(@sources).unshift(Gem::AbstractCommand::URL)
mock(@config).write
@command.tumble
end
should "remove gemcutter if it's in the sources" do
- mock(@sources).include?(GemCutter::URL) { true }
+ mock(@sources).include?(Gem::AbstractCommand::URL) { true }
mock(@config).write
- mock(@sources).delete(GemCutter::URL)
+ mock(@sources).delete(Gem::AbstractCommand::URL)
@command.tumble
end

0 comments on commit 8685680

Please sign in to comment.