qrush-gemcutter 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -32,14 +32,14 @@ h2. Next up
32
32
 
33
33
  What's finished so far:
34
34
 
35
- * Simple API (list, push, update)
35
+ * Simple site (list, push, update)
36
36
  * Releasing/updating gems via @gem push@
37
+ * Project pages
38
+ * Authentication/accounts
39
+ * Gem server up and running
37
40
 
38
41
  What's coming:
39
42
 
40
- * Getting the gem server up and running with the index (and hopefully improving its speed)
41
- * Project pages
42
- * Authentication/accounts (moving to Rails to support this, probably)
43
43
  * RubyForge migration for gem projects
44
44
  * Fully fledged API documentation
45
45
  * Search via the API and site
@@ -1,18 +1,15 @@
1
1
  class Gem::Commands::DowngradeCommand < Gem::Command
2
- DESCRIPTION = 'Return to using RubyForge as your primary gem source'
3
-
4
2
  def description
5
- DESCRIPTION
3
+ 'Return to using RubyForge as your primary gem source'
6
4
  end
7
5
 
8
6
  def initialize
9
- super 'downgrade', DESCRIPTION
7
+ super 'downgrade', description
10
8
  end
11
9
 
12
10
  def execute
13
11
  say "Your primary gem source is now gems.rubyforge.org"
14
- Gem.sources.delete "http://gems.gemcutter.org"
15
- Gem.sources << "http://gems.rubyforge.org"
12
+ Gem.sources.delete URL
16
13
  Gem.configuration.write
17
14
  end
18
15
  end
data/lib/commands/push.rb CHANGED
@@ -1,10 +1,10 @@
1
+ require 'yaml'
1
2
  require 'net/http'
2
3
 
3
4
  class Gem::Commands::PushCommand < Gem::Command
4
- DESCRIPTION = 'Push a gem up to Gemcutter'
5
5
 
6
6
  def description
7
- DESCRIPTION
7
+ 'Push a gem up to Gemcutter'
8
8
  end
9
9
 
10
10
  def arguments
@@ -16,18 +16,20 @@ class Gem::Commands::PushCommand < Gem::Command
16
16
  end
17
17
 
18
18
  def initialize
19
- super 'push', DESCRIPTION
19
+ super 'push', description
20
20
  end
21
21
 
22
22
  def execute
23
23
  say "Pushing gem to Gemcutter..."
24
24
 
25
- gem = get_one_gem_name
26
- url = URI.parse("http://gemcutter.org/gems")
25
+ name = get_one_gem_name
26
+ site = ENV['TEST'] ? "local" : "org"
27
+ url = URI.parse("http://gemcutter.#{site}/gems")
28
+
27
29
  request = Net::HTTP::Post.new(url.path)
28
- request.body = File.open(gem).read
30
+ request.body = File.open(name).read
29
31
  request.content_length = request.body.size
30
- request.content_type = "application/octet-stream"
32
+ request.initialize_http_header("HTTP_AUTHORIZATION" => Gem.configuration[:gemcutter_key])
31
33
 
32
34
  response = Net::HTTP.new(url.host, url.port).start { |http| http.request(request) }
33
35
  say response.body
@@ -1,20 +1,57 @@
1
- class Gem::Commands::UpgradeCommand < Gem::Command
2
- DESCRIPTION = 'Upgrade your gem source to Gemcutter'
1
+ class Gem::StreamUI
2
+ def ask_for_password(message)
3
+ system "stty -echo"
4
+ password = ask(message)
5
+ system "stty echo"
6
+ password
7
+ end
8
+ end
3
9
 
10
+ class Gem::Commands::UpgradeCommand < Gem::Command
4
11
  def description
5
- DESCRIPTION
12
+ 'Upgrade your gem source to Gemcutter'
13
+ end
14
+
15
+ def ask_for_password(message)
16
+ ui.ask_for_password(message)
6
17
  end
7
18
 
8
19
  def initialize
9
- super 'upgrade', DESCRIPTION
20
+ super 'upgrade', description
10
21
  end
11
22
 
12
23
  def execute
13
- say "Upgrading your primary gem source to gems.gemcutter.org"
14
- Gem.sources.delete "http://gems.rubyforge.org"
15
- Gem.sources << "http://gems.gemcutter.org"
24
+ add_source
25
+ sign_in
26
+ end
27
+
28
+ def add_source
29
+ if Gem.sources.include?(URL)
30
+ say "Gemcutter is already your primary gem source. Please use `gem downgrade` if you wish to no longer use Gemcutter."
31
+ else
32
+ say "Upgrading your primary gem source to gemcutter.org"
33
+ Gem.sources.unshift URL
34
+ Gem.configuration.write
35
+ end
36
+ end
37
+
38
+ def sign_in
39
+ say "Enter your Gemcutter credentials. Don't have an account yet? Create one at #{URL}/sign_up"
40
+
41
+ email = ask("Email: ")
42
+ password = ask_for_password("Password: ")
43
+
44
+ site = ENV['TEST'] ? "local" : "org"
45
+ url = URI.parse("http://gemcutter.#{site}/api_key")
46
+
47
+ request = Net::HTTP::Get.new(url.path)
48
+ request.basic_auth email, password
49
+ response = Net::HTTP.new(url.host, url.port).start { |http| http.request(request) }
50
+
51
+ Gem.configuration[:gemcutter_key] = response.body
16
52
  Gem.configuration.write
17
53
  end
54
+
18
55
  end
19
56
 
20
57
  Gem::CommandManager.instance.register_command :upgrade
@@ -3,3 +3,5 @@ require 'rubygems/command_manager'
3
3
  require 'commands/downgrade'
4
4
  require 'commands/push'
5
5
  require 'commands/upgrade'
6
+
7
+ URL = "http://gemcutter.org" unless defined?(URL)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrush-gemcutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Quaranto
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-30 00:00:00 -07:00
12
+ date: 2009-06-04 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version:
49
49
  requirements: []
50
50
 
51
- rubyforge_project:
51
+ rubyforge_project: gemcutter
52
52
  rubygems_version: 1.2.0
53
53
  signing_key:
54
54
  specification_version: 3