gemcutter 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,44 +8,3 @@ Rake::TestTask.new(:test) do |t|
8
8
  t.test_files = FileList['test/*_test.rb']
9
9
  t.verbose = true
10
10
  end
11
-
12
- begin
13
- require 'jeweler'
14
- Jeweler::Tasks.new do |gem|
15
- gem.name = "gemcutter"
16
- gem.version = "0.6.1"
17
- gem.summary = "Commands to interact with RubyGems.org"
18
- gem.description = "Adds several commands to RubyGems for managing gems and more on RubyGems.org."
19
- gem.email = "nick@quaran.to"
20
- gem.homepage = "http://rubygems.org"
21
- gem.authors = ["Nick Quaranto"]
22
- gem.files = FileList["lib/rubygems_plugin.rb",
23
- "lib/rubygems/commands/*",
24
- "test/helper.rb",
25
- "test/*_test.rb",
26
- "MIT-LICENSE",
27
- "Rakefile"]
28
- gem.test_files = []
29
- gem.executables = []
30
- %w[rake shoulda activesupport webmock rr].each do |dep|
31
- gem.add_development_dependency(dep)
32
- end
33
- gem.post_install_message = <<MESSAGE
34
-
35
- ========================================================================
36
-
37
- Thanks for installing Gemcutter! You can now run:
38
-
39
- gem push merged into RubyGems 1.3.6
40
- gem owner merged into RubyGems 1.3.6
41
- gem webhook register urls to be pinged when gems are pushed
42
- gem yank remove a specific version of a gem from RubyGems.org
43
-
44
- ========================================================================
45
-
46
- MESSAGE
47
- end
48
- Jeweler::RubyforgeTasks.new
49
- rescue LoadError
50
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
51
- end
@@ -16,12 +16,13 @@ class Gem::Commands::YankCommand < Gem::Command
16
16
  end
17
17
 
18
18
  def usage
19
- "#{program_name} GEM -v VERSION [--undo]"
19
+ "#{program_name} GEM -v VERSION [-p PLATFORM] [--undo]"
20
20
  end
21
21
 
22
22
  def initialize
23
23
  super 'yank', description
24
24
  add_version_option("remove")
25
+ add_platform_option("remove")
25
26
  add_option('--undo') do |value, options|
26
27
  options[:undo] = true
27
28
  end
@@ -29,12 +30,14 @@ class Gem::Commands::YankCommand < Gem::Command
29
30
 
30
31
  def execute
31
32
  sign_in
32
- version = get_version_from_requirements(options[:version])
33
+ version = get_version_from_requirements(options[:version])
34
+ platform = get_platform_from_requirements(options)
35
+
33
36
  if !version.nil?
34
37
  if options[:undo]
35
- unyank_gem(version)
38
+ unyank_gem(version, platform)
36
39
  else
37
- yank_gem(version)
40
+ yank_gem(version, platform)
38
41
  end
39
42
  else
40
43
  say "A version argument is required: #{usage}"
@@ -42,22 +45,22 @@ class Gem::Commands::YankCommand < Gem::Command
42
45
  end
43
46
  end
44
47
 
45
- def yank_gem(version)
48
+ def yank_gem(version, platform)
46
49
  say "Yanking gem from RubyGems.org..."
47
- yank_api_request(:delete, version, "api/v1/gems/yank")
50
+ yank_api_request(:delete, version, platform, "api/v1/gems/yank")
48
51
  end
49
52
 
50
- def unyank_gem(version)
53
+ def unyank_gem(version, platform)
51
54
  say "Unyanking gem from RubyGems.org..."
52
- yank_api_request(:put, version, "api/v1/gems/unyank")
55
+ yank_api_request(:put, version, platform, "api/v1/gems/unyank")
53
56
  end
54
57
 
55
58
  private
56
- def yank_api_request(method, version, api)
59
+ def yank_api_request(method, version, platform, api)
57
60
  name = get_one_gem_name
58
61
  response = rubygems_api_request(method, api) do |request|
59
62
  request.add_field("Authorization", Gem.configuration.rubygems_api_key)
60
- request.set_form_data({'gem_name' => name, 'version' => version})
63
+ request.set_form_data({'gem_name' => name, 'version' => version, 'platform' => platform})
61
64
  end
62
65
  say response.body
63
66
  end
@@ -69,4 +72,8 @@ class Gem::Commands::YankCommand < Gem::Command
69
72
  nil
70
73
  end
71
74
  end
75
+
76
+ def get_platform_from_requirements(requirements)
77
+ Gem.platforms[1].to_s if requirements.key? :added_platform
78
+ end
72
79
  end
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'rubygems/command'
2
3
  require 'test/unit'
3
4
 
4
5
  require 'shoulda'
@@ -16,10 +17,10 @@ WebMock.disable_net_connect!
16
17
 
17
18
  class CommandTest < ActiveSupport::TestCase
18
19
  include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
19
- include WebMock
20
+ include WebMock::API
20
21
 
21
22
  def teardown
22
- reset_webmock
23
+ WebMock.reset!
23
24
  end
24
25
  end
25
26
 
@@ -4,13 +4,14 @@ require 'lib/rubygems/commands/yank_command'
4
4
  class YankCommandTest < CommandTest
5
5
  context "yanking" do
6
6
  setup do
7
- @gem = "MyGem"
8
- @version = '0.1.0'
9
- @command = Gem::Commands::YankCommand.new
7
+ @gem = "MyGem"
8
+ @version = '0.1.0'
9
+ @platform = nil
10
+ @command = Gem::Commands::YankCommand.new
10
11
  stub(@command).say
11
12
  end
12
13
 
13
- %w[-v --version].each do |option|
14
+ %w[-v --version -p --platform].each do |option|
14
15
  should "raise an error with no version with #{option}" do
15
16
  assert_raise OptionParser::MissingArgument do
16
17
  @command.handle_options([@gem, option])
@@ -35,10 +36,10 @@ class YankCommandTest < CommandTest
35
36
  end
36
37
 
37
38
  should 'invoke yank_gem' do
38
- stub(@command).yank_gem(@version)
39
+ stub(@command).yank_gem(@version, @platform)
39
40
  @command.execute
40
41
  assert_received(@command) do |command|
41
- command.yank_gem(@version)
42
+ command.yank_gem(@version, @platform)
42
43
  end
43
44
  end
44
45
 
@@ -49,6 +50,33 @@ class YankCommandTest < CommandTest
49
50
  assert_requested(:delete, @api,
50
51
  :headers => { 'Authorization' => 'key' })
51
52
  end
53
+
54
+ context 'with a platform specified' do
55
+ setup do
56
+ stub_api_key("key")
57
+ @api = "https://rubygems.org/api/v1/gems/yank"
58
+ @platform = "x86-darwin-10"
59
+ stub_request(:delete, @api).to_return(:body => "Successfully yanked")
60
+ @command.handle_options([@gem, "-v", @version, "-p", @platform])
61
+ end
62
+
63
+ should 'say gem was yanked' do
64
+ @command.execute
65
+ assert_received(@command) do |command|
66
+ command.say("Yanking gem from Gemcutter...")
67
+ command.say("Successfully yanked")
68
+ end
69
+ end
70
+
71
+ should 'invoke yank_gem' do
72
+ stub(@command).yank_gem(@version, @platform)
73
+ @command.execute
74
+ assert_received(@command) do |command|
75
+ command.yank_gem(@version, @platform)
76
+ end
77
+ end
78
+ end
79
+
52
80
  end
53
81
 
54
82
  context 'unyanking a gem' do
@@ -68,10 +96,10 @@ class YankCommandTest < CommandTest
68
96
  end
69
97
 
70
98
  should 'invoke unyank_gem' do
71
- stub(@command).unyank_gem(@version)
99
+ stub(@command).unyank_gem(@version, @platform)
72
100
  @command.execute
73
101
  assert_received(@command) do |command|
74
- command.unyank_gem(@version)
102
+ command.unyank_gem(@version, @platform)
75
103
  end
76
104
  end
77
105
 
@@ -81,5 +109,34 @@ class YankCommandTest < CommandTest
81
109
  assert_requested(:put, @api, :headers => { 'Authorization' => 'key' })
82
110
  end
83
111
  end
112
+
113
+
114
+ context 'with a platform specified' do
115
+ setup do
116
+ stub_api_key("key")
117
+ @api = "https://rubygems.org/api/v1/gems/unyank"
118
+ @platform = "x86-darwin-10"
119
+ stub_request(:put, @api).to_return(:body => "Successfully unyanked")
120
+ @command.handle_options([@gem, "-v", @version, "-p", @platform, "--undo"])
121
+ end
122
+
123
+ should 'say gem was unyanked' do
124
+ @command.execute
125
+ assert_received(@command) do |command|
126
+ command.say("Re-indexing gem")
127
+ command.say("Successfully unyanked")
128
+ end
129
+ end
130
+
131
+ should 'invoke unyank_gem' do
132
+ stub(@command).unyank_gem(@version, @platform)
133
+ @command.execute
134
+ assert_received(@command) do |command|
135
+ command.unyank_gem(@version, @platform)
136
+ end
137
+ end
138
+ end
139
+
84
140
  end
141
+
85
142
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemcutter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease: false
4
+ hash: 3
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nick Quaranto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-17 00:00:00 -05:00
18
+ date: 2011-02-26 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -124,8 +124,8 @@ post_install_message: |+
124
124
 
125
125
  ========================================================================
126
126
 
127
- rdoc_options:
128
- - --charset=UTF-8
127
+ rdoc_options: []
128
+
129
129
  require_paths:
130
130
  - lib
131
131
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  requirements: []
150
150
 
151
151
  rubyforge_project:
152
- rubygems_version: 1.3.7
152
+ rubygems_version: 1.5.2
153
153
  signing_key:
154
154
  specification_version: 3
155
155
  summary: Commands to interact with RubyGems.org