mediawiki-gateway 0.1.5 → 0.1.6
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/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/classes/MediaWiki/Config.html +12 -12
- data/doc/classes/MediaWiki/Gateway.html +167 -163
- data/doc/classes/MediaWiki.html +49 -12
- data/doc/created.rid +1 -1
- data/doc/files/README.html +6 -1
- data/doc/files/lib/media_wiki/config_rb.html +1 -1
- data/doc/files/lib/media_wiki/gateway_rb.html +1 -1
- data/doc/files/lib/media_wiki/utils_rb.html +1 -1
- data/doc/files/script/create_page_rb.html +1 -1
- data/doc/files/script/delete_batch_rb.html +1 -1
- data/doc/files/script/export_xml_rb.html +1 -1
- data/doc/files/script/get_page_rb.html +1 -1
- data/doc/files/script/import_xml_rb.html +1 -1
- data/doc/files/script/run_fake_media_wiki_rb.html +1 -1
- data/doc/files/script/upload_commons_rb.html +7 -1
- data/doc/files/script/upload_file_rb.html +1 -1
- data/doc/fr_method_index.html +24 -23
- data/lib/media_wiki/utils.rb +8 -1
- data/mediawiki-gateway.gemspec +6 -4
- data/spec/gateway_spec.rb +0 -24
- data/spec/utils_spec.rb +48 -0
- metadata +6 -4
data/doc/classes/MediaWiki.html
CHANGED
@@ -58,14 +58,14 @@
|
|
58
58
|
<a href="../files/lib/media_wiki/config_rb.html">
|
59
59
|
lib/media_wiki/config.rb
|
60
60
|
</a>
|
61
|
-
<br />
|
62
|
-
<a href="../files/lib/media_wiki/gateway_rb.html">
|
63
|
-
lib/media_wiki/gateway.rb
|
64
|
-
</a>
|
65
61
|
<br />
|
66
62
|
<a href="../files/lib/media_wiki/utils_rb.html">
|
67
63
|
lib/media_wiki/utils.rb
|
68
64
|
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/lib/media_wiki/gateway_rb.html">
|
67
|
+
lib/media_wiki/gateway.rb
|
68
|
+
</a>
|
69
69
|
<br />
|
70
70
|
</td>
|
71
71
|
</tr>
|
@@ -88,6 +88,7 @@
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
89
89
|
|
90
90
|
<div class="name-list">
|
91
|
+
<a href="#M000003">uri_to_wiki</a>
|
91
92
|
<a href="#M000001">version</a>
|
92
93
|
<a href="#M000002">wiki_to_uri</a>
|
93
94
|
</div>
|
@@ -118,6 +119,38 @@ Class <a href="MediaWiki/Gateway.html" class="link">MediaWiki::Gateway</a><br />
|
|
118
119
|
<div id="methods">
|
119
120
|
<h3 class="section-bar">Public Class methods</h3>
|
120
121
|
|
122
|
+
<div id="method-M000003" class="method-detail">
|
123
|
+
<a name="M000003"></a>
|
124
|
+
|
125
|
+
<div class="method-heading">
|
126
|
+
<a href="#M000003" class="method-signature">
|
127
|
+
<span class="method-name">uri_to_wiki</span><span class="method-args">(uri)</span>
|
128
|
+
</a>
|
129
|
+
</div>
|
130
|
+
|
131
|
+
<div class="method-description">
|
132
|
+
<p>
|
133
|
+
Convert URL-ized page name ("getting_there_%26_away") into Wiki
|
134
|
+
display format page name ("getting there & away")
|
135
|
+
</p>
|
136
|
+
<dl>
|
137
|
+
<dt>wiki</dt><dd>Page name string in URL
|
138
|
+
|
139
|
+
</dd>
|
140
|
+
</dl>
|
141
|
+
<p><a class="source-toggle" href="#"
|
142
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
143
|
+
<div class="method-source-code" id="M000003-source">
|
144
|
+
<pre>
|
145
|
+
<span class="ruby-comment cmt"># File lib/media_wiki/utils.rb, line 19</span>
|
146
|
+
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri_to_wiki</span>(<span class="ruby-identifier">uri</span>)
|
147
|
+
20: <span class="ruby-constant">CGI</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">tr</span>(<span class="ruby-value str">'_'</span>, <span class="ruby-value str">' '</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>
|
148
|
+
21: <span class="ruby-keyword kw">end</span>
|
149
|
+
</pre>
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
|
121
154
|
<div id="method-M000001" class="method-detail">
|
122
155
|
<a name="M000001"></a>
|
123
156
|
|
@@ -128,14 +161,18 @@ Class <a href="MediaWiki/Gateway.html" class="link">MediaWiki::Gateway</a><br />
|
|
128
161
|
</div>
|
129
162
|
|
130
163
|
<div class="method-description">
|
164
|
+
<p>
|
165
|
+
TODO sync this automatically with Gem <a
|
166
|
+
href="MediaWiki.html#M000001">version</a>
|
167
|
+
</p>
|
131
168
|
<p><a class="source-toggle" href="#"
|
132
169
|
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
133
170
|
<div class="method-source-code" id="M000001-source">
|
134
171
|
<pre>
|
135
|
-
<span class="ruby-comment cmt"># File lib/media_wiki/utils.rb, line
|
136
|
-
|
137
|
-
|
138
|
-
|
172
|
+
<span class="ruby-comment cmt"># File lib/media_wiki/utils.rb, line 6</span>
|
173
|
+
6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">version</span>
|
174
|
+
7: <span class="ruby-value str">"0.1.5"</span>
|
175
|
+
8: <span class="ruby-keyword kw">end</span>
|
139
176
|
</pre>
|
140
177
|
</div>
|
141
178
|
</div>
|
@@ -165,10 +202,10 @@ slashes
|
|
165
202
|
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
166
203
|
<div class="method-source-code" id="M000002-source">
|
167
204
|
<pre>
|
168
|
-
<span class="ruby-comment cmt"># File lib/media_wiki/utils.rb, line
|
169
|
-
|
170
|
-
|
171
|
-
|
205
|
+
<span class="ruby-comment cmt"># File lib/media_wiki/utils.rb, line 13</span>
|
206
|
+
13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wiki_to_uri</span>(<span class="ruby-identifier">wiki</span>)
|
207
|
+
14: <span class="ruby-identifier">wiki</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>).<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">chunk</span><span class="ruby-operator">|</span> <span class="ruby-constant">CGI</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">chunk</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'_'</span>)) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'/'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">wiki</span>
|
208
|
+
15: <span class="ruby-keyword kw">end</span>
|
172
209
|
</pre>
|
173
210
|
</div>
|
174
211
|
</div>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Fri, 26 Nov 2010 15:36:02 +1100
|
data/doc/files/README.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Fri
|
59
|
+
<td>Fri Nov 26 10:40:15 +1100 2010</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -85,6 +85,11 @@
|
|
85
85
|
mw.login('RubyBot', 'pa$$w0rd')
|
86
86
|
mw.create('PageTitle', 'Hello world!', 'Comment: My first page')
|
87
87
|
</pre>
|
88
|
+
<h2>Credits</h2>
|
89
|
+
<p>
|
90
|
+
Thanks to John Carney, Mike Williams, Dan Heath and the rest of the Lonely
|
91
|
+
Planet Atlas team.
|
92
|
+
</p>
|
88
93
|
|
89
94
|
</div>
|
90
95
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Fri
|
59
|
+
<td>Fri Nov 26 10:40:15 +1100 2010</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -68,6 +68,12 @@
|
|
68
68
|
|
69
69
|
<div id="contextContent">
|
70
70
|
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
Sample script for uploading files to Mediawiki Commons (interactive)
|
74
|
+
</p>
|
75
|
+
|
76
|
+
</div>
|
71
77
|
|
72
78
|
<div id="requires-list">
|
73
79
|
<h3 class="section-bar">Required files</h3>
|
data/doc/fr_method_index.html
CHANGED
@@ -20,29 +20,30 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/MediaWiki/Config.html#
|
24
|
-
<a href="classes/MediaWiki/Gateway.html#
|
25
|
-
<a href="classes/MediaWiki/Gateway.html#
|
26
|
-
<a href="classes/MediaWiki/Gateway.html#
|
27
|
-
<a href="classes/MediaWiki/Gateway.html#
|
28
|
-
<a href="classes/MediaWiki/Gateway.html#
|
29
|
-
<a href="classes/MediaWiki/Gateway.html#
|
30
|
-
<a href="classes/MediaWiki/Gateway.html#
|
31
|
-
<a href="classes/MediaWiki/Gateway.html#
|
32
|
-
<a href="classes/MediaWiki/Gateway.html#
|
33
|
-
<a href="classes/MediaWiki/Gateway.html#
|
34
|
-
<a href="classes/MediaWiki/Gateway.html#
|
35
|
-
<a href="classes/MediaWiki/Gateway.html#
|
36
|
-
<a href="classes/MediaWiki/Gateway.html#
|
37
|
-
<a href="classes/MediaWiki/Gateway.html#
|
38
|
-
<a href="classes/MediaWiki/Gateway.html#
|
39
|
-
<a href="classes/MediaWiki/
|
40
|
-
<a href="classes/MediaWiki/
|
41
|
-
<a href="classes/MediaWiki/Gateway.html#
|
42
|
-
<a href="classes/MediaWiki/Gateway.html#
|
43
|
-
<a href="classes/MediaWiki/Gateway.html#
|
44
|
-
<a href="classes/MediaWiki/Gateway.html#
|
45
|
-
<a href="classes/MediaWiki/Gateway.html#
|
23
|
+
<a href="classes/MediaWiki/Config.html#M000026">abort (MediaWiki::Config)</a><br />
|
24
|
+
<a href="classes/MediaWiki/Gateway.html#M000008">create (MediaWiki::Gateway)</a><br />
|
25
|
+
<a href="classes/MediaWiki/Gateway.html#M000009">delete (MediaWiki::Gateway)</a><br />
|
26
|
+
<a href="classes/MediaWiki/Gateway.html#M000015">download (MediaWiki::Gateway)</a><br />
|
27
|
+
<a href="classes/MediaWiki/Gateway.html#M000017">export (MediaWiki::Gateway)</a><br />
|
28
|
+
<a href="classes/MediaWiki/Gateway.html#M000019">extensions (MediaWiki::Gateway)</a><br />
|
29
|
+
<a href="classes/MediaWiki/Gateway.html#M000006">get (MediaWiki::Gateway)</a><br />
|
30
|
+
<a href="classes/MediaWiki/Gateway.html#M000024">get_response (MediaWiki::Gateway)</a><br />
|
31
|
+
<a href="classes/MediaWiki/Gateway.html#M000021">get_token (MediaWiki::Gateway)</a><br />
|
32
|
+
<a href="classes/MediaWiki/Gateway.html#M000022">get_undelete_token (MediaWiki::Gateway)</a><br />
|
33
|
+
<a href="classes/MediaWiki/Gateway.html#M000014">image_info (MediaWiki::Gateway)</a><br />
|
34
|
+
<a href="classes/MediaWiki/Gateway.html#M000016">import (MediaWiki::Gateway)</a><br />
|
35
|
+
<a href="classes/MediaWiki/Gateway.html#M000011">list (MediaWiki::Gateway)</a><br />
|
36
|
+
<a href="classes/MediaWiki/Gateway.html#M000005">login (MediaWiki::Gateway)</a><br />
|
37
|
+
<a href="classes/MediaWiki/Gateway.html#M000023">make_api_request (MediaWiki::Gateway)</a><br />
|
38
|
+
<a href="classes/MediaWiki/Gateway.html#M000018">namespaces_by_prefix (MediaWiki::Gateway)</a><br />
|
39
|
+
<a href="classes/MediaWiki/Config.html#M000025">new (MediaWiki::Config)</a><br />
|
40
|
+
<a href="classes/MediaWiki/Gateway.html#M000004">new (MediaWiki::Gateway)</a><br />
|
41
|
+
<a href="classes/MediaWiki/Gateway.html#M000007">render (MediaWiki::Gateway)</a><br />
|
42
|
+
<a href="classes/MediaWiki/Gateway.html#M000012">search (MediaWiki::Gateway)</a><br />
|
43
|
+
<a href="classes/MediaWiki/Gateway.html#M000020">semantic_query (MediaWiki::Gateway)</a><br />
|
44
|
+
<a href="classes/MediaWiki/Gateway.html#M000010">undelete (MediaWiki::Gateway)</a><br />
|
45
|
+
<a href="classes/MediaWiki/Gateway.html#M000013">upload (MediaWiki::Gateway)</a><br />
|
46
|
+
<a href="classes/MediaWiki.html#M000003">uri_to_wiki (MediaWiki)</a><br />
|
46
47
|
<a href="classes/MediaWiki.html#M000001">version (MediaWiki)</a><br />
|
47
48
|
<a href="classes/MediaWiki.html#M000002">wiki_to_uri (MediaWiki)</a><br />
|
48
49
|
</div>
|
data/lib/media_wiki/utils.rb
CHANGED
@@ -2,8 +2,9 @@ module MediaWiki
|
|
2
2
|
|
3
3
|
class << self
|
4
4
|
|
5
|
+
# TODO sync this automatically with Gem version
|
5
6
|
def version
|
6
|
-
"0.
|
7
|
+
"0.1.6"
|
7
8
|
end
|
8
9
|
|
9
10
|
# Convert a Wiki page name ("getting there & away") to URI-safe format ("getting_there_%26_away"),
|
@@ -13,6 +14,12 @@ module MediaWiki
|
|
13
14
|
wiki.to_s.split('/').map {|chunk| CGI.escape(chunk.tr(' ', '_')) }.join('/') if wiki
|
14
15
|
end
|
15
16
|
|
17
|
+
# Convert URL-ized page name ("getting_there_%26_away") into Wiki display format page name ("getting there & away")
|
18
|
+
# [wiki] Page name string in URL
|
19
|
+
def uri_to_wiki(uri)
|
20
|
+
CGI.unescape(uri).tr('_', ' ') if uri
|
21
|
+
end
|
22
|
+
|
16
23
|
end
|
17
24
|
|
18
25
|
end
|
data/mediawiki-gateway.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mediawiki-gateway}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.6"
|
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"]
|
@@ -58,9 +58,10 @@ Gem::Specification.new do |s|
|
|
58
58
|
"spec/fake_media_wiki/app.rb",
|
59
59
|
"spec/fake_media_wiki/query_handling.rb",
|
60
60
|
"spec/gateway_spec.rb",
|
61
|
-
"spec/import-test-data.xml"
|
61
|
+
"spec/import-test-data.xml",
|
62
|
+
"spec/utils_spec.rb"
|
62
63
|
]
|
63
|
-
s.homepage = %q{http://github.com/jpatokal/
|
64
|
+
s.homepage = %q{http://github.com/jpatokal/mediawiki-gateway}
|
64
65
|
s.require_paths = ["lib"]
|
65
66
|
s.rubygems_version = %q{1.3.7}
|
66
67
|
s.summary = %q{Connect to the mediawiki API}
|
@@ -68,7 +69,8 @@ Gem::Specification.new do |s|
|
|
68
69
|
"spec/fake_media_wiki/api_pages.rb",
|
69
70
|
"spec/fake_media_wiki/app.rb",
|
70
71
|
"spec/fake_media_wiki/query_handling.rb",
|
71
|
-
"spec/gateway_spec.rb"
|
72
|
+
"spec/gateway_spec.rb",
|
73
|
+
"spec/utils_spec.rb"
|
72
74
|
]
|
73
75
|
|
74
76
|
if s.respond_to? :specification_version then
|
data/spec/gateway_spec.rb
CHANGED
@@ -22,30 +22,6 @@ describe MediaWiki::Gateway do
|
|
22
22
|
$fake_media_wiki.reset
|
23
23
|
end
|
24
24
|
|
25
|
-
describe '.wiki_to_uri' do
|
26
|
-
|
27
|
-
it "should underscore spaces" do
|
28
|
-
MediaWiki.wiki_to_uri('getting there').should == 'getting_there'
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should escape ampersands" do
|
32
|
-
MediaWiki.wiki_to_uri('getting there & away').should == 'getting_there_%26_away'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should escape UTF-8" do
|
36
|
-
MediaWiki.wiki_to_uri('Phở').should == 'Ph%E1%BB%9F'
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should escape each path component but leave slashes untouched" do
|
40
|
-
MediaWiki.wiki_to_uri('Phở/B&r/B z').should == 'Ph%E1%BB%9F/B%26r/B_z'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should pass through nil" do
|
44
|
-
MediaWiki.wiki_to_uri(nil).should == nil
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
25
|
describe '#login' do
|
50
26
|
|
51
27
|
describe "with a valid username & password" do
|
data/spec/utils_spec.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'media_wiki'
|
2
|
+
|
3
|
+
describe MediaWiki do
|
4
|
+
|
5
|
+
describe '.wiki_to_uri' do
|
6
|
+
|
7
|
+
it "should underscore spaces" do
|
8
|
+
MediaWiki.wiki_to_uri('getting there').should == 'getting_there'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should escape ampersands" do
|
12
|
+
MediaWiki.wiki_to_uri('getting there & away').should == 'getting_there_%26_away'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should escape UTF-8" do
|
16
|
+
MediaWiki.wiki_to_uri('Phở').should == 'Ph%E1%BB%9F'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should escape each path component but leave slashes untouched" do
|
20
|
+
MediaWiki.wiki_to_uri('Phở/B&r/B z').should == 'Ph%E1%BB%9F/B%26r/B_z'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should pass through nil" do
|
24
|
+
MediaWiki.wiki_to_uri(nil).should == nil
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.uri_to_wiki' do
|
30
|
+
|
31
|
+
it "should replace underscores with spaces" do
|
32
|
+
MediaWiki.uri_to_wiki('getting_there').should == 'getting there'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should unescape ampersands" do
|
36
|
+
MediaWiki.uri_to_wiki('getting_there_%26_away').should == 'getting there & away'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should decode escaped UTF-8" do
|
40
|
+
MediaWiki.uri_to_wiki('Ph%E1%BB%9F').should == 'Phở'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should pass through nil" do
|
44
|
+
MediaWiki.uri_to_wiki(nil).should == nil
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jani Patokallio
|
@@ -126,8 +126,9 @@ files:
|
|
126
126
|
- spec/fake_media_wiki/query_handling.rb
|
127
127
|
- spec/gateway_spec.rb
|
128
128
|
- spec/import-test-data.xml
|
129
|
+
- spec/utils_spec.rb
|
129
130
|
has_rdoc: true
|
130
|
-
homepage: http://github.com/jpatokal/
|
131
|
+
homepage: http://github.com/jpatokal/mediawiki-gateway
|
131
132
|
licenses: []
|
132
133
|
|
133
134
|
post_install_message:
|
@@ -165,3 +166,4 @@ test_files:
|
|
165
166
|
- spec/fake_media_wiki/app.rb
|
166
167
|
- spec/fake_media_wiki/query_handling.rb
|
167
168
|
- spec/gateway_spec.rb
|
169
|
+
- spec/utils_spec.rb
|