mediawiki_api 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fe630268f2fdf52422e284a3e0b54fbdbb9467e
4
- data.tar.gz: 532a1ac7ddc4ed87d16c3fc1847b21401129adb5
3
+ metadata.gz: d6b88aaa6e65da0aa8d4629cd69fc50d9aeb1644
4
+ data.tar.gz: 4b574b4cf2969445362e345d3998fef3507b3671
5
5
  SHA512:
6
- metadata.gz: 08d7501addc1a9b128229aad08f894042100fd2bfac693fe13a894af70ff65261397c5fca1859886e8b760ab06889b5387586eae9294dc4ffc9df9da5df33e53
7
- data.tar.gz: a3a4b09267baea17ba859a3fbf20d900894fbc3d14efee4f8f047d2bbb97ddb652f137df08721b66cd5d66f3dca5dce2bc206585e93b51fa9b7c8ce81daff284
6
+ metadata.gz: 6674018af6ff2dac0c6ba3308ae16fe574b73e455307804c2dda0d960d51c6cc7a58e35f072a45b72a4e12137701a95d2588404c7528eddbb37dd627cbc12b85
7
+ data.tar.gz: 412f40dd8f00cf96a81e577eaed754eab2f6e90c74f1fa989a4b6c44954aaf554960575bb16dda8b3c635af1e372b8b3b75bb7a316190c3e4b0906ec4f5deccb
data/CREDITS CHANGED
@@ -5,6 +5,7 @@ following names for their contribution to the product.
5
5
  For further details on licensing, see the LICENSE file.
6
6
 
7
7
  == Developers ==
8
+ * Amir Aharoni
8
9
  * Chris McMahon
9
10
  * Jeff Hall
10
11
  * Željko Filipin
data/README.md CHANGED
@@ -35,6 +35,9 @@ TODO: Write usage instructions here
35
35
  > create_article "username", "password", "title", "content"
36
36
  => nil
37
37
 
38
+ > delete_article "username", "password", "title"
39
+ => nil
40
+
38
41
  > create_user "username", "password"
39
42
  eddfa276bcaabbaec3f813de78f052e3
40
43
  => nil
data/lib/mediawiki_api.rb CHANGED
@@ -39,6 +39,67 @@ module MediawikiApi
39
39
  $stderr.puts "There was a problem - new article creation was NOT successful."
40
40
  end
41
41
  end
42
+
43
+ def delete_article username, password, title
44
+ unless (ENV["API_URL"])
45
+ puts "API_URL is not defined - make sure to export a value for that variable before running this test."
46
+ end
47
+
48
+ # First request is solely to obtain a valid login token in the API response.
49
+ login_token_response = RestClient.post ENV["API_URL"], {
50
+ "format" => "json",
51
+ "action" => "login",
52
+ "lgname" => username,
53
+ "lgpassword" => password,
54
+ }
55
+
56
+ login_token_data = JSON.parse(login_token_response.body)
57
+ login_token = login_token_data["login"]["token"]
58
+ cookie = login_token_response.cookies
59
+
60
+ # Second request repeats the first request with the addition of the token (to complete the login).
61
+ complete_login_response = RestClient.post ENV["API_URL"], {
62
+ "format" => "json",
63
+ "action" => "login",
64
+ "lgname" => username,
65
+ "lgpassword" => password,
66
+ "lgtoken" => login_token},
67
+ {:cookies => cookie}
68
+
69
+ complete_login_data = JSON.parse(complete_login_response.body)
70
+ complete_login_status = complete_login_data["login"]["result"]
71
+
72
+ if (complete_login_status != "Success")
73
+ puts "There was a problem - login was NOT successful."
74
+ end
75
+
76
+ # First request is solely to obtain a valid delete token in the API response.
77
+ delete_token_response = RestClient.post ENV["API_URL"], {
78
+ "format" => "json",
79
+ "action" => "tokens",
80
+ "type" => "delete",
81
+ },
82
+ {:cookies => cookie}
83
+
84
+ delete_token_data = JSON.parse(delete_token_response.body)
85
+ delete_token = delete_token_data["tokens"]["deletetoken"]
86
+
87
+ # Second request repeats the first request
88
+ # with the addition of the token (to complete the article creation).
89
+ complete_delete_response = RestClient.post ENV["API_URL"], {
90
+ "format" => "json",
91
+ "action" => "delete",
92
+ "title" => title,
93
+ "token" => delete_token,
94
+ "reason" => "Deleted by browser tests",
95
+ },
96
+ {:cookies => cookie}
97
+
98
+ complete_delete_data = JSON.parse(complete_delete_response.body)
99
+
100
+ p complete_delete_data if complete_delete_data["error"]
101
+ end
102
+
42
103
  def create_user login, password
43
104
  # First request is solely to obtain a valid token in the API response.
44
105
  createaccount_token_response = RestClient.post ENV["API_URL"], {:action => "createaccount", :name => login, :password =>
@@ -1,3 +1,3 @@
1
1
  module MediawikiApi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -6,8 +6,8 @@ require "mediawiki_api/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "mediawiki_api"
8
8
  spec.version = MediawikiApi::VERSION
9
- spec.authors = ["Chris McMahon", "Jeff Hall", "Zeljko Filipin"]
10
- spec.email = ["cmcmahon@wikimedia.org", "jhall@wikimedia.org", "zeljko.filipin@gmail.com"]
9
+ spec.authors = ["Amir Aharoni", "Chris McMahon", "Jeff Hall", "Zeljko Filipin"]
10
+ spec.email = ["amir.aharoni@mail.huji.ac.il", "cmcmahon@wikimedia.org", "jhall@wikimedia.org", "zeljko.filipin@gmail.com"]
11
11
  spec.summary = %q{An easy way to work with MediaWiki API from Ruby.}
12
12
  spec.description = %q{Uses REST Client Ruby gem to communicate with MediaWiki API.}
13
13
  spec.homepage = "https://github.com/zeljkofilipin/mediawiki_api"
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
+ - Amir Aharoni
7
8
  - Chris McMahon
8
9
  - Jeff Hall
9
10
  - Zeljko Filipin
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2014-02-07 00:00:00.000000000 Z
14
+ date: 2014-02-11 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rest-client
@@ -34,6 +35,7 @@ dependencies:
34
35
  version: 1.6.7
35
36
  description: Uses REST Client Ruby gem to communicate with MediaWiki API.
36
37
  email:
38
+ - amir.aharoni@mail.huji.ac.il
37
39
  - cmcmahon@wikimedia.org
38
40
  - jhall@wikimedia.org
39
41
  - zeljko.filipin@gmail.com