mediawiki-gateway 0.1.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/.gitignore +3 -0
- data/README +12 -0
- data/Rakefile +40 -0
- data/VERSION +1 -0
- data/config/hosts.yml +17 -0
- data/doc/classes/MediaWiki.html +189 -0
- data/doc/classes/MediaWiki/Config.html +269 -0
- data/doc/classes/MediaWiki/Gateway.html +952 -0
- data/doc/created.rid +1 -0
- data/doc/files/README_txt.html +117 -0
- data/doc/files/media_wiki/config_rb.html +108 -0
- data/doc/files/media_wiki/gateway_rb.html +113 -0
- data/doc/files/media_wiki/utils_rb.html +101 -0
- data/doc/files/script/create_page_rb.html +115 -0
- data/doc/files/script/delete_book_rb.html +108 -0
- data/doc/files/script/export_xml_rb.html +114 -0
- data/doc/files/script/get_page_rb.html +114 -0
- data/doc/files/script/import_xml_rb.html +114 -0
- data/doc/files/script/undelete_page_rb.html +101 -0
- data/doc/files/script/upload_commons_rb.html +109 -0
- data/doc/files/script/upload_file_rb.html +115 -0
- data/doc/fr_class_index.html +29 -0
- data/doc/fr_file_index.html +38 -0
- data/doc/fr_method_index.html +49 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/media_wiki.rb +3 -0
- data/lib/media_wiki/config.rb +69 -0
- data/lib/media_wiki/gateway.rb +307 -0
- data/lib/media_wiki/utils.rb +18 -0
- data/mediawiki-gateway.gemspec +88 -0
- data/script/create_page.rb +14 -0
- data/script/delete_book.rb +14 -0
- data/script/export_xml.rb +14 -0
- data/script/get_page.rb +12 -0
- data/script/import_xml.rb +14 -0
- data/script/run_fake_media_wiki.rb +8 -0
- data/script/undelete_page.rb +15 -0
- data/script/upload_commons.rb +42 -0
- data/script/upload_file.rb +14 -0
- data/spec/fake_media_wiki/api_pages.rb +131 -0
- data/spec/fake_media_wiki/app.rb +262 -0
- data/spec/fake_media_wiki/query_handling.rb +112 -0
- data/spec/gateway_spec.old +535 -0
- data/spec/gateway_spec.rb +653 -0
- data/spec/import-test-data.xml +68 -0
- metadata +115 -0
data/.gitignore
ADDED
data/README
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
= MediaWiki::Gateway
|
2
|
+
|
3
|
+
Ruby framework for MediaWiki API manipulation
|
4
|
+
|
5
|
+
== Example
|
6
|
+
|
7
|
+
Simple page creation script:
|
8
|
+
|
9
|
+
mw = MediaWiki::Gateway.new('http://my-wiki.example/w/api.php')
|
10
|
+
mw.login('RubyBot', 'pa$$w0rd')
|
11
|
+
mw.create('PageTitle', 'Hello world!', 'Comment: My first page')
|
12
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
|
6
|
+
task :default => ['spec']
|
7
|
+
|
8
|
+
desc 'generate API documentation to doc/index.html'
|
9
|
+
|
10
|
+
Rake::RDocTask.new do |rd|
|
11
|
+
rd.rdoc_dir = 'doc'
|
12
|
+
rd.main = 'README.txt'
|
13
|
+
rd.rdoc_files.include "README.txt", "lib/media_wiki/**/*\.rb", "script/**/*\.rb"
|
14
|
+
rd.options << '--inline-source'
|
15
|
+
rd.options << '--line-numbers'
|
16
|
+
rd.options << '--all'
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Run all specs"
|
20
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
21
|
+
t.spec_files = FileList['spec/**/*.rb']
|
22
|
+
t.spec_opts = ['--debugger']
|
23
|
+
t.rcov = true
|
24
|
+
t.rcov_opts = ['--exclude', 'spec,gems']
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'jeweler'
|
30
|
+
Jeweler::Tasks.new do |gemspec|
|
31
|
+
gemspec.name = "mediawiki-gateway"
|
32
|
+
gemspec.summary = "Connect to the mediawiki API"
|
33
|
+
gemspec.description = ""
|
34
|
+
gemspec.email = "jpatokal@iki.fi"
|
35
|
+
gemspec.homepage = "http://github.com/jpatokal/media_wiki_gateway"
|
36
|
+
gemspec.authors = ["Jani Patokallio"]
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
40
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/config/hosts.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
en-wp:
|
3
|
+
url: http://en.wikipedia.org/w/api.php
|
4
|
+
pw: herb
|
5
|
+
user: Jpatokal
|
6
|
+
commons:
|
7
|
+
url: http://commons.wikimedia.org/w/api.php
|
8
|
+
pw: herb
|
9
|
+
user: Jpatokal
|
10
|
+
en-wt:
|
11
|
+
url: http://wikitravel.org/wiki/en/api.php
|
12
|
+
pw: herb
|
13
|
+
user: Jpatokal
|
14
|
+
local:
|
15
|
+
url: http://localhost/w/api.php
|
16
|
+
pw: wombat
|
17
|
+
user: Atlasmw
|
@@ -0,0 +1,189 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: MediaWiki</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">MediaWiki</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/media_wiki/config_rb.html">
|
59
|
+
media_wiki/config.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../files/media_wiki/gateway_rb.html">
|
63
|
+
media_wiki/gateway.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/media_wiki/utils_rb.html">
|
67
|
+
media_wiki/utils.rb
|
68
|
+
</a>
|
69
|
+
<br />
|
70
|
+
</td>
|
71
|
+
</tr>
|
72
|
+
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div id="method-list">
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
89
|
+
|
90
|
+
<div class="name-list">
|
91
|
+
<a href="#M000001">version</a>
|
92
|
+
<a href="#M000002">wiki_to_uri</a>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
<!-- if includes -->
|
100
|
+
|
101
|
+
<div id="section">
|
102
|
+
|
103
|
+
<div id="class-list">
|
104
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
105
|
+
|
106
|
+
Class <a href="MediaWiki/Config.html" class="link">MediaWiki::Config</a><br />
|
107
|
+
Class <a href="MediaWiki/Gateway.html" class="link">MediaWiki::Gateway</a><br />
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<!-- if method_list -->
|
118
|
+
<div id="methods">
|
119
|
+
<h3 class="section-bar">Public Class methods</h3>
|
120
|
+
|
121
|
+
<div id="method-M000001" class="method-detail">
|
122
|
+
<a name="M000001"></a>
|
123
|
+
|
124
|
+
<div class="method-heading">
|
125
|
+
<a href="#M000001" class="method-signature">
|
126
|
+
<span class="method-name">version</span><span class="method-args">()</span>
|
127
|
+
</a>
|
128
|
+
</div>
|
129
|
+
|
130
|
+
<div class="method-description">
|
131
|
+
<p><a class="source-toggle" href="#"
|
132
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
133
|
+
<div class="method-source-code" id="M000001-source">
|
134
|
+
<pre>
|
135
|
+
<span class="ruby-comment cmt"># File media_wiki/utils.rb, line 5</span>
|
136
|
+
5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">version</span>
|
137
|
+
6: <span class="ruby-value str">"0.0.1"</span>
|
138
|
+
7: <span class="ruby-keyword kw">end</span>
|
139
|
+
</pre>
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div id="method-M000002" class="method-detail">
|
145
|
+
<a name="M000002"></a>
|
146
|
+
|
147
|
+
<div class="method-heading">
|
148
|
+
<a href="#M000002" class="method-signature">
|
149
|
+
<span class="method-name">wiki_to_uri</span><span class="method-args">(wiki)</span>
|
150
|
+
</a>
|
151
|
+
</div>
|
152
|
+
|
153
|
+
<div class="method-description">
|
154
|
+
<p>
|
155
|
+
Convert a Wiki page name ("getting there & away") to URI-safe
|
156
|
+
format ("getting_there_%26_away"), taking care not to mangle
|
157
|
+
slashes
|
158
|
+
</p>
|
159
|
+
<dl>
|
160
|
+
<dt>wiki</dt><dd>Page name string in Wiki format
|
161
|
+
|
162
|
+
</dd>
|
163
|
+
</dl>
|
164
|
+
<p><a class="source-toggle" href="#"
|
165
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
166
|
+
<div class="method-source-code" id="M000002-source">
|
167
|
+
<pre>
|
168
|
+
<span class="ruby-comment cmt"># File media_wiki/utils.rb, line 12</span>
|
169
|
+
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wiki_to_uri</span>(<span class="ruby-identifier">wiki</span>)
|
170
|
+
13: <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>
|
171
|
+
14: <span class="ruby-keyword kw">end</span>
|
172
|
+
</pre>
|
173
|
+
</div>
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
|
177
|
+
|
178
|
+
</div>
|
179
|
+
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
|
184
|
+
<div id="validator-badges">
|
185
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
</body>
|
189
|
+
</html>
|
@@ -0,0 +1,269 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: MediaWiki::Config</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">MediaWiki::Config</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/media_wiki/config_rb.html">
|
59
|
+
media_wiki/config.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000023">abort</a>
|
90
|
+
<a href="#M000022">new</a>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<div id="attribute-list">
|
106
|
+
<h3 class="section-bar">Attributes</h3>
|
107
|
+
|
108
|
+
<div class="name-list">
|
109
|
+
<table>
|
110
|
+
<tr class="top-aligned-row context-row">
|
111
|
+
<td class="context-item-name">article</td>
|
112
|
+
<td class="context-item-value"> [R] </td>
|
113
|
+
<td class="context-item-desc"></td>
|
114
|
+
</tr>
|
115
|
+
<tr class="top-aligned-row context-row">
|
116
|
+
<td class="context-item-name">desc</td>
|
117
|
+
<td class="context-item-value"> [R] </td>
|
118
|
+
<td class="context-item-desc"></td>
|
119
|
+
</tr>
|
120
|
+
<tr class="top-aligned-row context-row">
|
121
|
+
<td class="context-item-name">file</td>
|
122
|
+
<td class="context-item-value"> [R] </td>
|
123
|
+
<td class="context-item-desc"></td>
|
124
|
+
</tr>
|
125
|
+
<tr class="top-aligned-row context-row">
|
126
|
+
<td class="context-item-name">pw</td>
|
127
|
+
<td class="context-item-value"> [R] </td>
|
128
|
+
<td class="context-item-desc"></td>
|
129
|
+
</tr>
|
130
|
+
<tr class="top-aligned-row context-row">
|
131
|
+
<td class="context-item-name">summary</td>
|
132
|
+
<td class="context-item-value"> [R] </td>
|
133
|
+
<td class="context-item-desc"></td>
|
134
|
+
</tr>
|
135
|
+
<tr class="top-aligned-row context-row">
|
136
|
+
<td class="context-item-name">target</td>
|
137
|
+
<td class="context-item-value"> [R] </td>
|
138
|
+
<td class="context-item-desc"></td>
|
139
|
+
</tr>
|
140
|
+
<tr class="top-aligned-row context-row">
|
141
|
+
<td class="context-item-name">url</td>
|
142
|
+
<td class="context-item-value"> [R] </td>
|
143
|
+
<td class="context-item-desc"></td>
|
144
|
+
</tr>
|
145
|
+
<tr class="top-aligned-row context-row">
|
146
|
+
<td class="context-item-name">user</td>
|
147
|
+
<td class="context-item-value"> [R] </td>
|
148
|
+
<td class="context-item-desc"></td>
|
149
|
+
</tr>
|
150
|
+
</table>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
<!-- if method_list -->
|
157
|
+
<div id="methods">
|
158
|
+
<h3 class="section-bar">Public Class methods</h3>
|
159
|
+
|
160
|
+
<div id="method-M000022" class="method-detail">
|
161
|
+
<a name="M000022"></a>
|
162
|
+
|
163
|
+
<div class="method-heading">
|
164
|
+
<a href="#M000022" class="method-signature">
|
165
|
+
<span class="method-name">new</span><span class="method-args">(args, type = "read")</span>
|
166
|
+
</a>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
<div class="method-description">
|
170
|
+
<p><a class="source-toggle" href="#"
|
171
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
172
|
+
<div class="method-source-code" id="M000022-source">
|
173
|
+
<pre>
|
174
|
+
<span class="ruby-comment cmt"># File media_wiki/config.rb, line 9</span>
|
175
|
+
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">type</span> = <span class="ruby-value str">"read"</span>)
|
176
|
+
10: <span class="ruby-ivar">@summary</span> = <span class="ruby-value str">"Automated edit via MediaWiki::Gateway"</span>
|
177
|
+
11: <span class="ruby-ivar">@opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
|
178
|
+
12: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-value str">"Usage: [options]"</span>
|
179
|
+
13:
|
180
|
+
14: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-h"</span>, <span class="ruby-value str">"--host HOST"</span>, <span class="ruby-value str">"Use preconfigured HOST in config/hosts.yml"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">host_id</span><span class="ruby-operator">|</span>
|
181
|
+
15: <span class="ruby-identifier">yaml</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-value str">'config/hosts.yml'</span>)
|
182
|
+
16: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">yaml</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">host_id</span>
|
183
|
+
17: <span class="ruby-identifier">host</span> = <span class="ruby-identifier">yaml</span>[<span class="ruby-identifier">host_id</span>]
|
184
|
+
18: <span class="ruby-ivar">@url</span> = <span class="ruby-identifier">host</span>[<span class="ruby-value str">'url'</span>]
|
185
|
+
19: <span class="ruby-ivar">@pw</span> = <span class="ruby-identifier">host</span>[<span class="ruby-value str">'pw'</span>]
|
186
|
+
20: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">host</span>[<span class="ruby-value str">'user'</span>]
|
187
|
+
21: <span class="ruby-keyword kw">else</span>
|
188
|
+
22: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Host #{host_id} not found in config/hosts.yml"</span>
|
189
|
+
23: <span class="ruby-keyword kw">end</span>
|
190
|
+
24: <span class="ruby-keyword kw">end</span>
|
191
|
+
25:
|
192
|
+
26: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"upload"</span>
|
193
|
+
27: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-d"</span>, <span class="ruby-value str">"--description DESCRIPTION"</span>, <span class="ruby-value str">"Description of file to upload"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">desc</span><span class="ruby-operator">|</span>
|
194
|
+
28: <span class="ruby-ivar">@desc</span> = <span class="ruby-identifier">desc</span>
|
195
|
+
29: <span class="ruby-keyword kw">end</span>
|
196
|
+
30: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-t"</span>, <span class="ruby-value str">"--target-file TARGET-FILE"</span>, <span class="ruby-value str">"Target file name to upload to"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">target</span><span class="ruby-operator">|</span>
|
197
|
+
31: <span class="ruby-ivar">@target</span> = <span class="ruby-identifier">target</span>
|
198
|
+
32: <span class="ruby-keyword kw">end</span>
|
199
|
+
33: <span class="ruby-keyword kw">else</span>
|
200
|
+
34: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-a"</span>, <span class="ruby-value str">"--article ARTICLE"</span>, <span class="ruby-value str">"Name of article in Wiki"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">article</span><span class="ruby-operator">|</span>
|
201
|
+
35: <span class="ruby-ivar">@article</span> = <span class="ruby-identifier">article</span>
|
202
|
+
36: <span class="ruby-keyword kw">end</span>
|
203
|
+
37: <span class="ruby-keyword kw">end</span>
|
204
|
+
38:
|
205
|
+
39: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-n"</span>, <span class="ruby-value str">"--username USERNAME"</span>, <span class="ruby-value str">"Username for login"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
|
206
|
+
40: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">user</span>
|
207
|
+
41: <span class="ruby-keyword kw">end</span>
|
208
|
+
42:
|
209
|
+
43: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-p"</span>, <span class="ruby-value str">"--password PASSWORD"</span>, <span class="ruby-value str">"Password for login"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pw</span><span class="ruby-operator">|</span>
|
210
|
+
44: <span class="ruby-ivar">@pw</span> = <span class="ruby-identifier">pw</span>
|
211
|
+
45: <span class="ruby-keyword kw">end</span>
|
212
|
+
46:
|
213
|
+
47: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">"read"</span>
|
214
|
+
48: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-s"</span>, <span class="ruby-value str">"--summary SUMMARY"</span>, <span class="ruby-value str">"Edit summary for this change"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">summary</span><span class="ruby-operator">|</span>
|
215
|
+
49: <span class="ruby-ivar">@summary</span> = <span class="ruby-identifier">summary</span>
|
216
|
+
50: <span class="ruby-keyword kw">end</span>
|
217
|
+
51: <span class="ruby-keyword kw">end</span>
|
218
|
+
52:
|
219
|
+
53: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-u"</span>, <span class="ruby-value str">"--url URL"</span>, <span class="ruby-value str">"MediaWiki API URL"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">url</span><span class="ruby-operator">|</span>
|
220
|
+
54: <span class="ruby-ivar">@url</span> = <span class="ruby-identifier">url</span>
|
221
|
+
55: <span class="ruby-keyword kw">end</span>
|
222
|
+
56: <span class="ruby-keyword kw">end</span>
|
223
|
+
57: <span class="ruby-ivar">@opts</span>.<span class="ruby-identifier">parse!</span>
|
224
|
+
58: <span class="ruby-identifier">abort</span>(<span class="ruby-value str">"URL (-u) or valid host (-h) is mandatory."</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@url</span>
|
225
|
+
59: <span class="ruby-keyword kw">end</span>
|
226
|
+
</pre>
|
227
|
+
</div>
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
232
|
+
|
233
|
+
<div id="method-M000023" class="method-detail">
|
234
|
+
<a name="M000023"></a>
|
235
|
+
|
236
|
+
<div class="method-heading">
|
237
|
+
<a href="#M000023" class="method-signature">
|
238
|
+
<span class="method-name">abort</span><span class="method-args">(error)</span>
|
239
|
+
</a>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
<div class="method-description">
|
243
|
+
<p><a class="source-toggle" href="#"
|
244
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
245
|
+
<div class="method-source-code" id="M000023-source">
|
246
|
+
<pre>
|
247
|
+
<span class="ruby-comment cmt"># File media_wiki/config.rb, line 61</span>
|
248
|
+
61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">abort</span>(<span class="ruby-identifier">error</span>)
|
249
|
+
62: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Error: #{error}\n\n#{@opts.to_s}"</span>
|
250
|
+
63: <span class="ruby-identifier">exit</span>
|
251
|
+
64: <span class="ruby-keyword kw">end</span>
|
252
|
+
</pre>
|
253
|
+
</div>
|
254
|
+
</div>
|
255
|
+
</div>
|
256
|
+
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
|
264
|
+
<div id="validator-badges">
|
265
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
266
|
+
</div>
|
267
|
+
|
268
|
+
</body>
|
269
|
+
</html>
|