gemcutter 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/commands/abstract_command.rb +26 -8
- data/lib/commands/tumble.rb +2 -21
- data/test/command_helper.rb +6 -0
- metadata +2 -3
@@ -5,10 +5,6 @@ class Gem::AbstractCommand < Gem::Command
|
|
5
5
|
|
6
6
|
URL = "http://gemcutter.org"
|
7
7
|
|
8
|
-
def api_key
|
9
|
-
Gem.configuration[:gemcutter_key]
|
10
|
-
end
|
11
|
-
|
12
8
|
def gemcutter_url
|
13
9
|
ENV['GEMCUTTER_URL'] || 'https://gemcutter.org'
|
14
10
|
end
|
@@ -30,20 +26,40 @@ class Gem::AbstractCommand < Gem::Command
|
|
30
26
|
|
31
27
|
case response
|
32
28
|
when Net::HTTPSuccess
|
33
|
-
|
34
|
-
|
35
|
-
say "Signed in. Your api key has been stored in ~/.gemrc"
|
29
|
+
self.api_key = response.body
|
30
|
+
say "Signed in. Your api key has been stored in ~/.gem/credentials"
|
36
31
|
else
|
37
32
|
say response.body
|
38
33
|
terminate_interaction
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
37
|
+
def credentials_path
|
38
|
+
File.join(Gem.user_home, '.gem', 'credentials')
|
39
|
+
end
|
40
|
+
|
41
|
+
def api_key
|
42
|
+
Gem.configuration.load_file(credentials_path)[:rubygems_api_key]
|
43
|
+
end
|
44
|
+
|
45
|
+
def api_key=(api_key)
|
46
|
+
config = Gem.configuration.load_file(credentials_path).merge(:rubygems_api_key => api_key)
|
47
|
+
|
48
|
+
dirname = File.dirname(credentials_path)
|
49
|
+
Dir.mkdir(dirname) unless File.exists?(dirname)
|
50
|
+
|
51
|
+
File.open(credentials_path, 'w') do |f|
|
52
|
+
f.write config.to_yaml
|
53
|
+
end
|
54
|
+
|
55
|
+
@rubygems_api_key = api_key
|
56
|
+
end
|
57
|
+
|
42
58
|
def make_request(method, path)
|
43
59
|
require 'net/http'
|
44
60
|
require 'net/https'
|
45
61
|
|
46
|
-
url = URI.parse("#{gemcutter_url}/#{path}")
|
62
|
+
url = URI.parse("#{gemcutter_url}/api/v1/#{path}")
|
47
63
|
|
48
64
|
http = proxy_class.new(url.host, url.port)
|
49
65
|
|
@@ -67,6 +83,8 @@ class Gem::AbstractCommand < Gem::Command
|
|
67
83
|
end
|
68
84
|
|
69
85
|
request = request_method.new(url.path)
|
86
|
+
request.add_field "User-Agent", "Gemcutter/0.2.0"
|
87
|
+
|
70
88
|
yield request if block_given?
|
71
89
|
http.request(request)
|
72
90
|
end
|
data/lib/commands/tumble.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Gem::Commands::TumbleCommand < Gem::AbstractCommand
|
2
2
|
def description
|
3
|
-
|
3
|
+
"Deprecated method of upgrading to Gemcutter.org for gem downloads"
|
4
4
|
end
|
5
5
|
|
6
6
|
def initialize
|
@@ -8,25 +8,6 @@ class Gem::Commands::TumbleCommand < Gem::AbstractCommand
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def execute
|
11
|
-
say "
|
12
|
-
tumble
|
13
|
-
show_sources
|
14
|
-
end
|
15
|
-
|
16
|
-
def tumble
|
17
|
-
if Gem.sources.include?(URL)
|
18
|
-
Gem.sources.delete URL
|
19
|
-
Gem.configuration.write
|
20
|
-
else
|
21
|
-
Gem.sources.unshift URL
|
22
|
-
Gem.configuration.write
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def show_sources
|
27
|
-
say "Your gem sources are now:"
|
28
|
-
Gem.sources.each do |source|
|
29
|
-
say "- #{source}"
|
30
|
-
end
|
11
|
+
say "This command is deprecated, Gemcutter.org is the primary source for gems."
|
31
12
|
end
|
32
13
|
end
|
data/test/command_helper.rb
CHANGED
@@ -22,3 +22,9 @@ require "rubygems_plugin"
|
|
22
22
|
class CommandTest < ActiveSupport::TestCase
|
23
23
|
include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
|
24
24
|
end
|
25
|
+
|
26
|
+
def stub_config(config)
|
27
|
+
file = Gem::ConfigFile.new({})
|
28
|
+
config.each { |key, value| file[key] = value }
|
29
|
+
stub(Gem).configuration { file }
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemcutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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-
|
12
|
+
date: 2009-12-08 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -57,7 +57,6 @@ post_install_message: |+
|
|
57
57
|
|
58
58
|
Thanks for installing Gemcutter! You can now run:
|
59
59
|
|
60
|
-
gem tumble use Gemcutter as your primary RubyGem source
|
61
60
|
gem push publish your gems for the world to use and enjoy
|
62
61
|
gem migrate take over your gem from RubyForge on Gemcutter
|
63
62
|
gem owner allow/disallow others to push to your gems
|