mediawiki_api 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/mediawiki_api/client.rb +8 -2
- data/lib/mediawiki_api/version.rb +1 -1
- data/spec/client_spec.rb +11 -0
- data/spec/spec_helper.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41c2dd44c6fc40c892dba0f16d889db55f0f3ae9
|
4
|
+
data.tar.gz: 2d5c82f2aae43baadb25ecc82be9555eeee75815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5645e2743b93f1143741a47dc05e9b19ee2508c8aa916bff6302d6e87e9de045e4996f59f803d69847eb5d91e6511737a2ed973358864810eff6140f074d2a4a
|
7
|
+
data.tar.gz: c5a9ecafd25845f3849efec516e45edd26dfb52469dcc838eaf431db440d6709977d831487abc8afb1c1238ddf305c3cd150ba23368f417de5eb51676d5086ff
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mediawiki_api (0.1.
|
4
|
+
mediawiki_api (0.1.1)
|
5
5
|
faraday (~> 0.9, >= 0.9.0)
|
6
6
|
faraday-cookie_jar (~> 0.0, >= 0.0.6)
|
7
7
|
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
crack (0.4.2)
|
13
13
|
safe_yaml (~> 1.0.0)
|
14
14
|
diff-lcs (1.2.5)
|
15
|
-
domain_name (0.5.
|
15
|
+
domain_name (0.5.18)
|
16
16
|
unf (>= 0.0.5, < 1.0.0)
|
17
17
|
faraday (0.9.0)
|
18
18
|
multipart-post (>= 1.2, < 3)
|
@@ -32,7 +32,7 @@ GEM
|
|
32
32
|
diff-lcs (>= 1.1.3, < 2.0)
|
33
33
|
rspec-mocks (2.14.6)
|
34
34
|
safe_yaml (1.0.1)
|
35
|
-
unf (0.1.
|
35
|
+
unf (0.1.4)
|
36
36
|
unf_ext
|
37
37
|
unf_ext (0.0.6)
|
38
38
|
webmock (1.17.4)
|
data/lib/mediawiki_api/client.rb
CHANGED
@@ -15,10 +15,12 @@ module MediawikiApi
|
|
15
15
|
class Client
|
16
16
|
attr_accessor :logged_in
|
17
17
|
|
18
|
-
def initialize(url)
|
18
|
+
def initialize(url, log=false)
|
19
19
|
@conn = Faraday.new(url: url) do |faraday|
|
20
20
|
faraday.request :url_encoded
|
21
|
-
|
21
|
+
if log then
|
22
|
+
faraday.response :logger
|
23
|
+
end
|
22
24
|
faraday.use :cookie_jar
|
23
25
|
faraday.adapter Faraday.default_adapter
|
24
26
|
end
|
@@ -69,6 +71,10 @@ module MediawikiApi
|
|
69
71
|
resp = @conn.post "", { action: "delete", title: title, reason: reason, token: token, format: "json" }
|
70
72
|
end
|
71
73
|
|
74
|
+
def get_wikitext(title)
|
75
|
+
resp = @conn.get "/w/index.php", { action: "raw", title: title }
|
76
|
+
end
|
77
|
+
|
72
78
|
protected
|
73
79
|
|
74
80
|
def get_token(type)
|
data/spec/client_spec.rb
CHANGED
@@ -101,6 +101,17 @@ describe MediawikiApi::Client do
|
|
101
101
|
# evaluate results
|
102
102
|
end
|
103
103
|
|
104
|
+
describe "#get_wikitext" do
|
105
|
+
before do
|
106
|
+
@get_req = stub_request(:get, index_url).with(query: { action: "raw", title: "Test" })
|
107
|
+
end
|
108
|
+
|
109
|
+
it "fetches a page" do
|
110
|
+
subject.get_wikitext("Test")
|
111
|
+
@get_req.should have_been_requested
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
104
115
|
describe "#create_account" do
|
105
116
|
it "creates an account when API returns Success" do
|
106
117
|
stub_request(:post, api_url).
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediawiki_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amir Aharoni
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-04-
|
15
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: faraday
|