mediawiki-gateway 0.3.4 → 0.3.5

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/media_wiki.rb CHANGED
@@ -3,5 +3,5 @@ require File.dirname(__FILE__) + '/media_wiki/utils'
3
3
  require File.dirname(__FILE__) + '/media_wiki/gateway'
4
4
 
5
5
  module MediaWiki
6
- VERSION = "0.3.4"
6
+ VERSION = "0.3.5"
7
7
  end
@@ -122,7 +122,7 @@ module MediaWiki
122
122
  # Edit page
123
123
  #
124
124
  # Same options as create, but always overwrites existing pages (and creates them if they don't exist already).
125
- def edit(title, content, options)
125
+ def edit(title, content, options={})
126
126
  create(title, content, {:overwrite => true}.merge(options))
127
127
  end
128
128
 
@@ -35,15 +35,15 @@ module MediaWiki
35
35
  title.split('/').last if title
36
36
  end
37
37
 
38
- # Convert URL-ized page name ("getting_there_%26_away") into Wiki display format page name ("getting there & away").
39
- # Also strips out any illegal characters (#<>[]|{}, cf. http://meta.wikimedia.org/wiki/Help:Page_name#Restrictions).
38
+ # Convert URL-ized page name ("getting_there_%26_away") into Wiki display format page name ("Getting there & away").
39
+ # Also capitalizes first letter, replaces underscores with spaces and strips out any illegal characters (#<>[]|{}, cf. http://meta.wikimedia.org/wiki/Help:Page_name#Restrictions).
40
40
  #
41
41
  # [wiki] Page name string in URL
42
42
  def uri_to_wiki(uri)
43
- CGI.unescape(uri).tr('_', ' ').tr('#<>[]|{}', '') if uri
43
+ upcase_first_char(CGI.unescape(uri).tr('_', ' ').tr('#<>[]|{}', '')) if uri
44
44
  end
45
45
 
46
- # Convert a Wiki page name ("getting there & away") to URI-safe format ("getting_there_%26_away"),
46
+ # Convert a Wiki page name ("Getting there & away") to URI-safe format ("Getting_there_%26_away"),
47
47
  # taking care not to mangle slashes or colons
48
48
  # [wiki] Page name string in Wiki format
49
49
  def wiki_to_uri(wiki)
@@ -54,6 +54,12 @@ module MediaWiki
54
54
  def version
55
55
  MediaWiki::VERSION
56
56
  end
57
+
58
+ private
59
+
60
+ def upcase_first_char(str)
61
+ [ ActiveSupport::Multibyte::Chars.new(str.mb_chars.slice(0,1)).upcase.to_s, str.mb_chars.slice(1..-1) ].join
62
+ end
57
63
  end
58
64
 
59
65
  end
@@ -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.4"
8
+ s.version = "0.3.5"
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-02-07}
12
+ s.date = %q{2011-03-28}
13
13
  s.description = %q{}
14
14
  s.email = %q{jpatokal@iki.fi}
15
15
  s.extra_rdoc_files = [
data/spec/gateway_spec.rb CHANGED
@@ -362,7 +362,7 @@ describe MediaWiki::Gateway do
362
362
  describe "#edit" do
363
363
  before do
364
364
  $fake_media_wiki.reset
365
- @edit_page = @gateway.edit("Main Page", "Some new content", :summary => "The summary")
365
+ @edit_page = @gateway.edit("Main Page", "Some new content")
366
366
  end
367
367
 
368
368
  it "should overwrite the existing page" do
data/spec/utils_spec.rb CHANGED
@@ -71,11 +71,11 @@ describe MediaWiki do
71
71
  describe '.uri_to_wiki' do
72
72
 
73
73
  it "should replace underscores with spaces" do
74
- MediaWiki.uri_to_wiki('getting_there').should == 'getting there'
74
+ MediaWiki.uri_to_wiki('getting_there').should == 'Getting there'
75
75
  end
76
76
 
77
77
  it "should unescape ampersands" do
78
- MediaWiki.uri_to_wiki('getting_there_%26_away').should == 'getting there & away'
78
+ MediaWiki.uri_to_wiki('getting_there_%26_away').should == 'Getting there & away'
79
79
  end
80
80
 
81
81
  it "should decode escaped UTF-8" do
@@ -85,6 +85,12 @@ describe MediaWiki do
85
85
  it "should strip out illegal characters" do
86
86
  MediaWiki.uri_to_wiki('A#B<C>D[E]F|G{H}I').should == 'ABCDEFGHI'
87
87
  end
88
+
89
+ it "should capitalize the first character, even if UTF-8" do
90
+ MediaWiki.uri_to_wiki('óboy').should == 'Óboy'
91
+ MediaWiki.uri_to_wiki('%C3%B3boy').should == 'Óboy'
92
+ MediaWiki.uri_to_wiki('%E1%BB%9Fboy').should == 'Ởboy'
93
+ end
88
94
 
89
95
  it "should pass through nil" do
90
96
  MediaWiki.uri_to_wiki(nil).should be_nil
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
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-02-07 00:00:00 +11:00
18
+ date: 2011-03-28 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency