mediawiki-gateway 0.3.8 → 0.4.1

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.
@@ -1,6 +1,4 @@
1
1
  module MediaWiki
2
- require 'activesupport'
3
-
4
2
  class << self
5
3
 
6
4
  # Extract base name. If there are no subpages, return page name.
@@ -49,7 +47,7 @@ module MediaWiki
49
47
  # taking care not to mangle slashes or colons
50
48
  # [wiki] Page name string in Wiki format
51
49
  def wiki_to_uri(wiki)
52
- wiki.to_s.split('/').map {|chunk| CGI.escape(chunk.tr(' ', '_')) }.join('/').gsub('%3A', ':') if wiki
50
+ wiki.to_s.split('/').map {|chunk| CGI.escape(CGI.unescape(chunk).tr(' ', '_')) }.join('/').gsub('%3A', ':') if wiki
53
51
  end
54
52
 
55
53
  # Return current version of MediaWiki::Gateway
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mediawiki-gateway}
8
- s.version = "0.3.8"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jani Patokallio"]
12
- s.date = %q{2011-04-14}
12
+ s.date = %q{2011-05-18}
13
13
  s.description = %q{}
14
14
  s.email = %q{jpatokal@iki.fi}
15
15
  s.extra_rdoc_files = [
@@ -20,11 +20,15 @@ Gem::Specification.new do |s|
20
20
  "Rakefile",
21
21
  "config/hosts.yml",
22
22
  "doc/classes/MediaWiki.html",
23
+ "doc/classes/MediaWiki/APIError.html",
23
24
  "doc/classes/MediaWiki/Config.html",
25
+ "doc/classes/MediaWiki/Exception.html",
24
26
  "doc/classes/MediaWiki/Gateway.html",
27
+ "doc/classes/MediaWiki/Unauthorized.html",
25
28
  "doc/created.rid",
26
29
  "doc/files/README.html",
27
30
  "doc/files/lib/media_wiki/config_rb.html",
31
+ "doc/files/lib/media_wiki/exception_rb.html",
28
32
  "doc/files/lib/media_wiki/gateway_rb.html",
29
33
  "doc/files/lib/media_wiki/utils_rb.html",
30
34
  "doc/files/script/create_page_rb.html",
@@ -43,6 +47,7 @@ Gem::Specification.new do |s|
43
47
  "doc/rdoc-style.css",
44
48
  "lib/media_wiki.rb",
45
49
  "lib/media_wiki/config.rb",
50
+ "lib/media_wiki/exception.rb",
46
51
  "lib/media_wiki/gateway.rb",
47
52
  "lib/media_wiki/utils.rb",
48
53
  "mediawiki-gateway.gemspec",
data/spec/gateway_spec.rb CHANGED
@@ -44,7 +44,7 @@ describe MediaWiki::Gateway do
44
44
  it "should raise an error" do
45
45
  lambda do
46
46
  @gateway.login('bogususer', 'sekrit')
47
- end.should raise_error(StandardError)
47
+ end.should raise_error(MediaWiki::Unauthorized)
48
48
  end
49
49
 
50
50
  end
@@ -54,7 +54,7 @@ describe MediaWiki::Gateway do
54
54
  it "should raise an error" do
55
55
  lambda do
56
56
  @gateway.login('atlasmw', 'sekrit')
57
- end.should raise_error(StandardError)
57
+ end.should raise_error(MediaWiki::Unauthorized)
58
58
  end
59
59
 
60
60
  end
@@ -64,7 +64,7 @@ describe MediaWiki::Gateway do
64
64
  it "should raise an error" do
65
65
  lambda do
66
66
  @gateway.login('atlasmw', 'wombat', 'bogusdomain')
67
- end.should raise_error(StandardError)
67
+ end.should raise_error(MediaWiki::Unauthorized)
68
68
  end
69
69
 
70
70
  end
@@ -93,7 +93,7 @@ describe MediaWiki::Gateway do
93
93
  it "should raise an error" do
94
94
  lambda do
95
95
  @gateway.send(:get_token, 'import', 'Main Page')
96
- end.should raise_error(StandardError)
96
+ end.should raise_error(MediaWiki::Unauthorized)
97
97
  end
98
98
 
99
99
  end
@@ -350,7 +350,7 @@ describe MediaWiki::Gateway do
350
350
  it "should raise an error" do
351
351
  lambda do
352
352
  @gateway.create("Main Page", "Some new content")
353
- end.should raise_error(StandardError)
353
+ end.should raise_error(MediaWiki::APIError)
354
354
  end
355
355
 
356
356
  end
@@ -440,7 +440,7 @@ describe MediaWiki::Gateway do
440
440
  it "should raise an error" do
441
441
  lambda do
442
442
  @gateway.delete("Missing Page")
443
- end.should raise_error(StandardError)
443
+ end.should raise_error(MediaWiki::APIError)
444
444
  end
445
445
  end
446
446
  end
@@ -454,7 +454,7 @@ describe MediaWiki::Gateway do
454
454
  it "should raise an error" do
455
455
  lambda do
456
456
  @gateway.delete("Deletable Page")
457
- end.should raise_error(StandardError)
457
+ end.should raise_error(MediaWiki::Unauthorized)
458
458
  end
459
459
 
460
460
  end
@@ -499,7 +499,7 @@ describe MediaWiki::Gateway do
499
499
  it "should raise an error" do
500
500
  lambda do
501
501
  @gateway.undelete("Undeletable Page")
502
- end.should raise_error(StandardError)
502
+ end.should raise_error(MediaWiki::APIError)
503
503
  end
504
504
 
505
505
  end
@@ -565,7 +565,7 @@ describe MediaWiki::Gateway do
565
565
  it "should raise an error" do
566
566
  lambda do
567
567
  @gateway.search("")
568
- end.should raise_error(StandardError)
568
+ end.should raise_error(MediaWiki::APIError)
569
569
  end
570
570
 
571
571
  end
@@ -644,7 +644,7 @@ describe MediaWiki::Gateway do
644
644
  it "should raise an error" do
645
645
  lambda do
646
646
  @gateway.import(import_file)
647
- end.should raise_error(StandardError)
647
+ end.should raise_error(MediaWiki::Unauthorized)
648
648
  end
649
649
 
650
650
  end
@@ -758,7 +758,7 @@ describe MediaWiki::Gateway do
758
758
  it "should raise an error" do
759
759
  lambda do
760
760
  @gateway.send(:get_userrights_token, 'nosuchuser')
761
- end.should raise_error(StandardError)
761
+ end.should raise_error(MediaWiki::APIError)
762
762
  end
763
763
  end
764
764
 
data/spec/spec_helper.rb CHANGED
@@ -5,12 +5,10 @@ Spec::Runner.configure do |config|
5
5
  config.mock_with RR::Adapters::Rspec
6
6
  end
7
7
 
8
- require 'active_support/version'
9
- if ActiveSupport::VERSION::MAJOR >= 3
10
- # :nodoc: Rails 3: #to_xml is defined in ActiveModel::Serializers::Xml
8
+ # :nodoc: Rails 2.3.x: Hash#to_xml is defined in active_support
9
+ # :nodoc: Rails 3: #to_xml is defined in ActiveModel::Serializers::Xml
10
+ require 'active_support'
11
+ unless Hash.method_defined? :to_xml
11
12
  require 'active_model'
12
13
  Hash.send(:include, ActiveModel::Serializers::Xml)
13
- else
14
- # :nodoc: Rails 2.3.x: Hash#to_xml is defined in active_support
15
- require 'active_support'
16
14
  end
data/spec/utils_spec.rb CHANGED
@@ -62,6 +62,10 @@ describe MediaWiki do
62
62
  MediaWiki.wiki_to_uri('Zoo:Phở/B&r/B z').should == 'Zoo:Ph%E1%BB%9F/B%26r/B_z'
63
63
  end
64
64
 
65
+ it "should preserve any URL-encoded characters" do
66
+ MediaWiki.wiki_to_uri('Zoo:Ph%E1%BB%9F/B%26r/B_z').should == 'Zoo:Ph%E1%BB%9F/B%26r/B_z'
67
+ end
68
+
65
69
  it "should pass through nil" do
66
70
  MediaWiki.wiki_to_uri(nil).should be_nil
67
71
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki-gateway
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 8
10
- version: 0.3.8
8
+ - 4
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jani Patokallio
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-14 00:00:00 +10:00
18
+ date: 2011-05-18 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -103,11 +103,15 @@ files:
103
103
  - Rakefile
104
104
  - config/hosts.yml
105
105
  - doc/classes/MediaWiki.html
106
+ - doc/classes/MediaWiki/APIError.html
106
107
  - doc/classes/MediaWiki/Config.html
108
+ - doc/classes/MediaWiki/Exception.html
107
109
  - doc/classes/MediaWiki/Gateway.html
110
+ - doc/classes/MediaWiki/Unauthorized.html
108
111
  - doc/created.rid
109
112
  - doc/files/README.html
110
113
  - doc/files/lib/media_wiki/config_rb.html
114
+ - doc/files/lib/media_wiki/exception_rb.html
111
115
  - doc/files/lib/media_wiki/gateway_rb.html
112
116
  - doc/files/lib/media_wiki/utils_rb.html
113
117
  - doc/files/script/create_page_rb.html
@@ -126,6 +130,7 @@ files:
126
130
  - doc/rdoc-style.css
127
131
  - lib/media_wiki.rb
128
132
  - lib/media_wiki/config.rb
133
+ - lib/media_wiki/exception.rb
129
134
  - lib/media_wiki/gateway.rb
130
135
  - lib/media_wiki/utils.rb
131
136
  - mediawiki-gateway.gemspec