mediawiktory 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/CONTRIBUTING.md +16 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +5 -5
  6. data/examples/query_generator.rb +1 -1
  7. data/lib/mediawiktory.rb +2 -1
  8. data/lib/mediawiktory/action.rb +9 -0
  9. data/lib/mediawiktory/client.rb +27 -2
  10. data/lib/mediawiktory/generated/abusefilters.rb +3 -3
  11. data/lib/mediawiktory/generated/abuselog.rb +2 -2
  12. data/lib/mediawiktory/generated/allcategories.rb +2 -2
  13. data/lib/mediawiktory/generated/alldeletedrevisions.rb +4 -4
  14. data/lib/mediawiktory/generated/allfileusages.rb +2 -2
  15. data/lib/mediawiktory/generated/allimages.rb +4 -4
  16. data/lib/mediawiktory/generated/alllinks.rb +3 -3
  17. data/lib/mediawiktory/generated/allmessages.rb +2 -2
  18. data/lib/mediawiktory/generated/allpages.rb +8 -8
  19. data/lib/mediawiktory/generated/allredirects.rb +3 -3
  20. data/lib/mediawiktory/generated/alltransclusions.rb +3 -3
  21. data/lib/mediawiktory/generated/allusers.rb +5 -5
  22. data/lib/mediawiktory/generated/backlinks.rb +3 -3
  23. data/lib/mediawiktory/generated/blocks.rb +3 -3
  24. data/lib/mediawiktory/generated/categories.rb +3 -3
  25. data/lib/mediawiktory/generated/categorymembers.rb +5 -5
  26. data/lib/mediawiktory/generated/checktoken.rb +1 -1
  27. data/lib/mediawiktory/generated/checkuser.rb +1 -1
  28. data/lib/mediawiktory/generated/checkuserlog.rb +1 -1
  29. data/lib/mediawiktory/generated/close-open-topic.rb +1 -1
  30. data/lib/mediawiktory/generated/contenttranslation.rb +1 -1
  31. data/lib/mediawiktory/generated/contenttranslationlangtrend.rb +1 -1
  32. data/lib/mediawiktory/generated/contributors.rb +4 -4
  33. data/lib/mediawiktory/generated/coordinates.rb +2 -2
  34. data/lib/mediawiktory/generated/cxpublish.rb +1 -1
  35. data/lib/mediawiktory/generated/delete.rb +1 -1
  36. data/lib/mediawiktory/generated/deletedrevisions.rb +3 -3
  37. data/lib/mediawiktory/generated/deletedrevs.rb +3 -3
  38. data/lib/mediawiktory/generated/deleteeducation.rb +1 -1
  39. data/lib/mediawiktory/generated/duplicatefiles.rb +1 -1
  40. data/lib/mediawiktory/generated/echomarkread.rb +1 -1
  41. data/lib/mediawiktory/generated/echomarkseen.rb +1 -1
  42. data/lib/mediawiktory/generated/edit-header.rb +1 -1
  43. data/lib/mediawiktory/generated/edit-post.rb +1 -1
  44. data/lib/mediawiktory/generated/edit-topic-summary.rb +1 -1
  45. data/lib/mediawiktory/generated/edit.rb +4 -4
  46. data/lib/mediawiktory/generated/editlist.rb +2 -2
  47. data/lib/mediawiktory/generated/embeddedin.rb +3 -3
  48. data/lib/mediawiktory/generated/enlist.rb +2 -2
  49. data/lib/mediawiktory/generated/expandtemplates.rb +1 -1
  50. data/lib/mediawiktory/generated/extlinks.rb +1 -1
  51. data/lib/mediawiktory/generated/extracts.rb +1 -1
  52. data/lib/mediawiktory/generated/exturlusage.rb +3 -3
  53. data/lib/mediawiktory/generated/featuredfeed.rb +2 -2
  54. data/lib/mediawiktory/generated/feedcontributions.rb +3 -3
  55. data/lib/mediawiktory/generated/feedrecentchanges.rb +2 -2
  56. data/lib/mediawiktory/generated/feedwatchlist.rb +3 -3
  57. data/lib/mediawiktory/generated/filearchive.rb +2 -2
  58. data/lib/mediawiktory/generated/filerepoinfo.rb +1 -1
  59. data/lib/mediawiktory/generated/fileusage.rb +3 -3
  60. data/lib/mediawiktory/generated/flow-parsoid-utils.rb +2 -2
  61. data/lib/mediawiktory/generated/gadgetcategories.rb +1 -1
  62. data/lib/mediawiktory/generated/gadgets.rb +1 -1
  63. data/lib/mediawiktory/generated/geosearch.rb +4 -4
  64. data/lib/mediawiktory/generated/globalallusers.rb +4 -4
  65. data/lib/mediawiktory/generated/globalblocks.rb +2 -2
  66. data/lib/mediawiktory/generated/globalgroups.rb +1 -1
  67. data/lib/mediawiktory/generated/globalusage.rb +1 -1
  68. data/lib/mediawiktory/generated/globaluserinfo.rb +1 -1
  69. data/lib/mediawiktory/generated/globaluserrights.rb +2 -2
  70. data/lib/mediawiktory/generated/imageinfo.rb +1 -1
  71. data/lib/mediawiktory/generated/images.rb +1 -1
  72. data/lib/mediawiktory/generated/imageusage.rb +3 -3
  73. data/lib/mediawiktory/generated/import.rb +2 -2
  74. data/lib/mediawiktory/generated/info.rb +2 -2
  75. data/lib/mediawiktory/generated/iwbacklinks.rb +2 -2
  76. data/lib/mediawiktory/generated/iwlinks.rb +2 -2
  77. data/lib/mediawiktory/generated/jsonconfig.rb +1 -1
  78. data/lib/mediawiktory/generated/langbacklinks.rb +2 -2
  79. data/lib/mediawiktory/generated/langlinks.rb +2 -2
  80. data/lib/mediawiktory/generated/links.rb +2 -2
  81. data/lib/mediawiktory/generated/linkshere.rb +3 -3
  82. data/lib/mediawiktory/generated/listpages.rb +3 -3
  83. data/lib/mediawiktory/generated/lists.rb +2 -2
  84. data/lib/mediawiktory/generated/liststudents.rb +1 -1
  85. data/lib/mediawiktory/generated/lock-topic.rb +1 -1
  86. data/lib/mediawiktory/generated/logevents.rb +5 -5
  87. data/lib/mediawiktory/generated/managetags.rb +1 -1
  88. data/lib/mediawiktory/generated/mobileview.rb +3 -3
  89. data/lib/mediawiktory/generated/moderate-post.rb +1 -1
  90. data/lib/mediawiktory/generated/moderate-topic.rb +1 -1
  91. data/lib/mediawiktory/generated/move.rb +1 -1
  92. data/lib/mediawiktory/generated/new-topic.rb +1 -1
  93. data/lib/mediawiktory/generated/notifications.rb +3 -3
  94. data/lib/mediawiktory/generated/oldreviewedpages.rb +4 -4
  95. data/lib/mediawiktory/generated/opensearch.rb +3 -3
  96. data/lib/mediawiktory/generated/options.rb +1 -1
  97. data/lib/mediawiktory/generated/pageimages.rb +1 -1
  98. data/lib/mediawiktory/generated/pageswithprop.rb +2 -2
  99. data/lib/mediawiktory/generated/pageterms.rb +1 -1
  100. data/lib/mediawiktory/generated/pagetriageaction.rb +1 -1
  101. data/lib/mediawiktory/generated/paraminfo.rb +3 -3
  102. data/lib/mediawiktory/generated/parse.rb +3 -3
  103. data/lib/mediawiktory/generated/prefixsearch.rb +1 -1
  104. data/lib/mediawiktory/generated/protect.rb +1 -1
  105. data/lib/mediawiktory/generated/protectedtitles.rb +4 -4
  106. data/lib/mediawiktory/generated/querypage.rb +1 -1
  107. data/lib/mediawiktory/generated/random.rb +2 -2
  108. data/lib/mediawiktory/generated/recentchanges.rb +6 -6
  109. data/lib/mediawiktory/generated/redirects.rb +3 -3
  110. data/lib/mediawiktory/generated/refresheducation.rb +1 -1
  111. data/lib/mediawiktory/generated/reply.rb +1 -1
  112. data/lib/mediawiktory/generated/reviewactivity.rb +1 -1
  113. data/lib/mediawiktory/generated/revisiondelete.rb +4 -4
  114. data/lib/mediawiktory/generated/revisions.rb +4 -4
  115. data/lib/mediawiktory/generated/rollback.rb +1 -1
  116. data/lib/mediawiktory/generated/search.rb +4 -4
  117. data/lib/mediawiktory/generated/setglobalaccountstatus.rb +2 -2
  118. data/lib/mediawiktory/generated/siteinfo.rb +2 -2
  119. data/lib/mediawiktory/generated/sitematrix.rb +4 -4
  120. data/lib/mediawiktory/generated/stabilize.rb +1 -1
  121. data/lib/mediawiktory/generated/stashedit.rb +2 -2
  122. data/lib/mediawiktory/generated/stashimageinfo.rb +1 -1
  123. data/lib/mediawiktory/generated/strikevote.rb +1 -1
  124. data/lib/mediawiktory/generated/tag.rb +1 -1
  125. data/lib/mediawiktory/generated/tags.rb +1 -1
  126. data/lib/mediawiktory/generated/templatedata.rb +1 -1
  127. data/lib/mediawiktory/generated/templates.rb +2 -2
  128. data/lib/mediawiktory/generated/titleblacklist.rb +1 -1
  129. data/lib/mediawiktory/generated/tokens.rb +1 -1
  130. data/lib/mediawiktory/generated/transcludedin.rb +3 -3
  131. data/lib/mediawiktory/generated/undelete.rb +1 -1
  132. data/lib/mediawiktory/generated/upload.rb +1 -1
  133. data/lib/mediawiktory/generated/usercontribs.rb +4 -4
  134. data/lib/mediawiktory/generated/userinfo.rb +1 -1
  135. data/lib/mediawiktory/generated/userrights.rb +2 -2
  136. data/lib/mediawiktory/generated/users.rb +2 -2
  137. data/lib/mediawiktory/generated/videoinfo.rb +1 -1
  138. data/lib/mediawiktory/generated/view-header.rb +1 -1
  139. data/lib/mediawiktory/generated/view-post-history.rb +1 -1
  140. data/lib/mediawiktory/generated/view-post.rb +1 -1
  141. data/lib/mediawiktory/generated/view-topic-history.rb +1 -1
  142. data/lib/mediawiktory/generated/view-topic-summary.rb +1 -1
  143. data/lib/mediawiktory/generated/view-topic.rb +1 -1
  144. data/lib/mediawiktory/generated/view-topiclist.rb +3 -3
  145. data/lib/mediawiktory/generated/visualeditor.rb +2 -2
  146. data/lib/mediawiktory/generated/watchlist.rb +5 -5
  147. data/lib/mediawiktory/generated/watchlistraw.rb +4 -4
  148. data/lib/mediawiktory/generated/wikibase.rb +1 -1
  149. data/lib/mediawiktory/generated/wikisets.rb +1 -1
  150. data/lib/mediawiktory/generated/zeroconfig.rb +1 -1
  151. data/lib/mediawiktory/mw_module.rb +6 -2
  152. data/lib/mediawiktory/page.rb +46 -0
  153. data/lib/mediawiktory/query.rb +21 -23
  154. data/lib/mediawiktory/version.rb +4 -1
  155. data/script/lib/parameter.rb +2 -5
  156. metadata +6 -4
  157. data/Gemfile.lock +0 -63
  158. data/lib/mediawiktory/array_with_keys.rb +0 -41
@@ -2,6 +2,6 @@ module MediaWiktory
2
2
  class Userinfo < MWModule
3
3
  symbol :userinfo
4
4
  prefix "ui"
5
- param :prop, Params::List[Params::Enum["blockinfo", "hasmsg", "groups", "implicitgroups", "rights", "changeablegroups", "options", "preferencestoken", "editcount", "ratelimits", "email", "realname", "acceptlang", "registrationdate", "unreadcount"]]
5
+ param :prop, Params::List[Params::Enum[:blockinfo, :hasmsg, :groups, :implicitgroups, :rights, :changeablegroups, :options, :preferencestoken, :editcount, :ratelimits, :email, :realname, :acceptlang, :registrationdate, :unreadcount]]
6
6
  end
7
7
  end
@@ -4,8 +4,8 @@ module MediaWiktory
4
4
  post!
5
5
  param :user, Params::String
6
6
  param :userid, Params::Integer
7
- param :add, Params::List[Params::Enum["bot", "sysop", "bureaucrat", "reviewer", "steward", "accountcreator", "import", "transwiki", "ipblock-exempt", "oversight", "founder", "rollbacker", "autoreviewer", "researcher", "filemover", "checkuser", "templateeditor", "massmessage-sender", "abusefilter", "epcoordinator", "eponline", "epcampus", "epinstructor", "suppress", "flow-bot", "confirmed"]]
8
- param :remove, Params::List[Params::Enum["bot", "sysop", "bureaucrat", "reviewer", "steward", "accountcreator", "import", "transwiki", "ipblock-exempt", "oversight", "founder", "rollbacker", "autoreviewer", "researcher", "filemover", "checkuser", "templateeditor", "massmessage-sender", "abusefilter", "epcoordinator", "eponline", "epcampus", "epinstructor", "suppress", "flow-bot", "confirmed"]]
7
+ param :add, Params::List[Params::Enum[:bot, :sysop, :bureaucrat, :reviewer, :steward, :accountcreator, :import, :transwiki, :"ipblock-exempt", :oversight, :founder, :rollbacker, :autoreviewer, :researcher, :filemover, :checkuser, :templateeditor, :"massmessage-sender", :abusefilter, :epcoordinator, :eponline, :epcampus, :epinstructor, :suppress, :"flow-bot", :confirmed]]
8
+ param :remove, Params::List[Params::Enum[:bot, :sysop, :bureaucrat, :reviewer, :steward, :accountcreator, :import, :transwiki, :"ipblock-exempt", :oversight, :founder, :rollbacker, :autoreviewer, :researcher, :filemover, :checkuser, :templateeditor, :"massmessage-sender", :abusefilter, :epcoordinator, :eponline, :epcampus, :epinstructor, :suppress, :"flow-bot", :confirmed]]
9
9
  param :reason, Params::String
10
10
  param :token, Params::String
11
11
  end
@@ -2,8 +2,8 @@ module MediaWiktory
2
2
  class Users < MWModule
3
3
  symbol :users
4
4
  prefix "us"
5
- param :prop, Params::List[Params::Enum["blockinfo", "groups", "implicitgroups", "rights", "editcount", "registration", "emailable", "gender"]]
5
+ param :prop, Params::List[Params::Enum[:blockinfo, :groups, :implicitgroups, :rights, :editcount, :registration, :emailable, :gender]]
6
6
  param :users, Params::List[Params::String]
7
- param :token, Params::List[Params::Enum["userrights"]]
7
+ param :token, Params::List[Params::Enum[:userrights]]
8
8
  end
9
9
  end
@@ -2,7 +2,7 @@ module MediaWiktory
2
2
  class Videoinfo < MWModule
3
3
  symbol :videoinfo
4
4
  prefix "vi"
5
- param :prop, Params::List[Params::Enum["timestamp", "user", "userid", "comment", "parsedcomment", "canonicaltitle", "url", "size", "dimensions", "sha1", "mime", "thumbmime", "mediatype", "metadata", "commonmetadata", "extmetadata", "archivename", "bitdepth", "uploadwarning", "derivatives"]]
5
+ param :prop, Params::List[Params::Enum[:timestamp, :user, :userid, :comment, :parsedcomment, :canonicaltitle, :url, :size, :dimensions, :sha1, :mime, :thumbmime, :mediatype, :metadata, :commonmetadata, :extmetadata, :archivename, :bitdepth, :uploadwarning, :derivatives]]
6
6
  param :limit, Params::IntegerOrMax
7
7
  param :start, Params::Timestamp
8
8
  param :end, Params::Timestamp
@@ -2,7 +2,7 @@ module MediaWiktory
2
2
  class ViewHeader < MWModule
3
3
  symbol :"view-header"
4
4
  prefix "vh"
5
- param :format, Params::Enum["html", "wikitext", "fixed-html"]
5
+ param :format, Params::Enum[:html, :wikitext, :"fixed-html"]
6
6
  param :revId, Params::String
7
7
  end
8
8
  end
@@ -3,6 +3,6 @@ module MediaWiktory
3
3
  symbol :"view-post-history"
4
4
  prefix "vph"
5
5
  param :postId, Params::String
6
- param :format, Params::Enum["html", "wikitext", "fixed-html"]
6
+ param :format, Params::Enum[:html, :wikitext, :"fixed-html"]
7
7
  end
8
8
  end
@@ -3,6 +3,6 @@ module MediaWiktory
3
3
  symbol :"view-post"
4
4
  prefix "vp"
5
5
  param :postId, Params::String
6
- param :format, Params::Enum["html", "wikitext", "fixed-html"]
6
+ param :format, Params::Enum[:html, :wikitext, :"fixed-html"]
7
7
  end
8
8
  end
@@ -2,6 +2,6 @@ module MediaWiktory
2
2
  class ViewTopicHistory < MWModule
3
3
  symbol :"view-topic-history"
4
4
  prefix "vth"
5
- param :format, Params::Enum["html", "wikitext", "fixed-html"]
5
+ param :format, Params::Enum[:html, :wikitext, :"fixed-html"]
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ module MediaWiktory
2
2
  class ViewTopicSummary < MWModule
3
3
  symbol :"view-topic-summary"
4
4
  prefix "vts"
5
- param :format, Params::Enum["html", "wikitext", "fixed-html"]
5
+ param :format, Params::Enum[:html, :wikitext, :"fixed-html"]
6
6
  param :revId, Params::String
7
7
  end
8
8
  end
@@ -2,6 +2,6 @@ module MediaWiktory
2
2
  class ViewTopic < MWModule
3
3
  symbol :"view-topic"
4
4
  prefix "vt"
5
- param :format, Params::Enum["html", "wikitext", "fixed-html"]
5
+ param :format, Params::Enum[:html, :wikitext, :"fixed-html"]
6
6
  end
7
7
  end
@@ -2,14 +2,14 @@ module MediaWiktory
2
2
  class ViewTopiclist < MWModule
3
3
  symbol :"view-topiclist"
4
4
  prefix "vtl"
5
- param :"offset-dir", Params::Enum["fwd", "rev"]
6
- param :sortby, Params::Enum["newest", "updated", "user"]
5
+ param :"offset-dir", Params::Enum[:fwd, :rev]
6
+ param :sortby, Params::Enum[:newest, :updated, :user]
7
7
  param :savesortby, Params::Boolean
8
8
  param :"offset-id", Params::String
9
9
  param :offset, Params::String
10
10
  param :"include-offset", Params::Boolean
11
11
  param :limit, Params::IntegerOrMax
12
12
  param :toconly, Params::Boolean
13
- param :format, Params::Enum["html", "wikitext", "fixed-html"]
13
+ param :format, Params::Enum[:html, :wikitext, :"fixed-html"]
14
14
  end
15
15
  end
@@ -2,8 +2,8 @@ module MediaWiktory
2
2
  class Visualeditor < Action
3
3
  symbol :visualeditor
4
4
  param :page, Params::String
5
- param :format, Params::Enum["json", "jsonfm"]
6
- param :paction, Params::Enum["parse", "metadata", "parsefragment", "serialize", "serializeforcache", "diff", "getlanglinks"]
5
+ param :format, Params::Enum[:json, :jsonfm]
6
+ param :paction, Params::Enum[:parse, :metadata, :parsefragment, :serialize, :serializeforcache, :diff, :getlanglinks]
7
7
  param :wikitext, Params::String
8
8
  param :oldid, Params::String
9
9
  param :html, Params::String
@@ -5,14 +5,14 @@ module MediaWiktory
5
5
  param :allrev, Params::Boolean
6
6
  param :start, Params::Timestamp
7
7
  param :end, Params::Timestamp
8
- param :namespace, Params::List[Params::Enum["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "100", "101", "108", "109", "118", "119", "2300", "2301", "2302", "2303", "710", "711", "446", "447", "2600", "828", "829"]]
8
+ param :namespace, Params::List[Params::Enum[:"0", :"1", :"2", :"3", :"4", :"5", :"6", :"7", :"8", :"9", :"10", :"11", :"12", :"13", :"14", :"15", :"100", :"101", :"108", :"109", :"118", :"119", :"2300", :"2301", :"2302", :"2303", :"710", :"711", :"446", :"447", :"2600", :"828", :"829"]]
9
9
  param :user, Params::String
10
10
  param :excludeuser, Params::String
11
- param :dir, Params::Enum["newer", "older"]
11
+ param :dir, Params::Enum[:newer, :older]
12
12
  param :limit, Params::IntegerOrMax
13
- param :prop, Params::List[Params::Enum["ids", "title", "flags", "user", "userid", "comment", "parsedcomment", "timestamp", "patrol", "sizes", "notificationtimestamp", "loginfo"]]
14
- param :show, Params::List[Params::Enum["minor", "!minor", "bot", "!bot", "anon", "!anon", "patrolled", "!patrolled", "unread", "!unread"]]
15
- param :type, Params::List[Params::Enum["edit", "external", "new", "log"]]
13
+ param :prop, Params::List[Params::Enum[:ids, :title, :flags, :user, :userid, :comment, :parsedcomment, :timestamp, :patrol, :sizes, :notificationtimestamp, :loginfo]]
14
+ param :show, Params::List[Params::Enum[:minor, :"!minor", :bot, :"!bot", :anon, :"!anon", :patrolled, :"!patrolled", :unread, :"!unread"]]
15
+ param :type, Params::List[Params::Enum[:edit, :external, :new, :log]]
16
16
  param :owner, Params::String
17
17
  param :token, Params::String
18
18
  param :continue, Params::String
@@ -3,13 +3,13 @@ module MediaWiktory
3
3
  symbol :watchlistraw
4
4
  prefix "wr"
5
5
  param :continue, Params::String
6
- param :namespace, Params::List[Params::Enum["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "100", "101", "108", "109", "118", "119", "2300", "2301", "2302", "2303", "710", "711", "446", "447", "2600", "828", "829"]]
6
+ param :namespace, Params::List[Params::Enum[:"0", :"1", :"2", :"3", :"4", :"5", :"6", :"7", :"8", :"9", :"10", :"11", :"12", :"13", :"14", :"15", :"100", :"101", :"108", :"109", :"118", :"119", :"2300", :"2301", :"2302", :"2303", :"710", :"711", :"446", :"447", :"2600", :"828", :"829"]]
7
7
  param :limit, Params::IntegerOrMax
8
- param :prop, Params::List[Params::Enum["changed"]]
9
- param :show, Params::List[Params::Enum["changed", "!changed"]]
8
+ param :prop, Params::List[Params::Enum[:changed]]
9
+ param :show, Params::List[Params::Enum[:changed, :"!changed"]]
10
10
  param :owner, Params::String
11
11
  param :token, Params::String
12
- param :dir, Params::Enum["newer", "older"]
12
+ param :dir, Params::Enum[:newer, :older]
13
13
  param :fromtitle, Params::String
14
14
  param :totitle, Params::String
15
15
  end
@@ -2,6 +2,6 @@ module MediaWiktory
2
2
  class Wikibase < MWModule
3
3
  symbol :wikibase
4
4
  prefix "wb"
5
- param :prop, Params::List[Params::Enum["url", "siteid"]]
5
+ param :prop, Params::List[Params::Enum[:url, :siteid]]
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@ module MediaWiktory
3
3
  symbol :wikisets
4
4
  prefix "ws"
5
5
  param :from, Params::String
6
- param :prop, Params::List[Params::Enum["type", "wikisincluded", "wikisnotincluded"]]
6
+ param :prop, Params::List[Params::Enum[:type, :wikisincluded, :wikisnotincluded]]
7
7
  param :limit, Params::IntegerOrMax
8
8
  param :orderbyname, Params::Boolean
9
9
  end
@@ -1,7 +1,7 @@
1
1
  module MediaWiktory
2
2
  class Zeroconfig < Action
3
3
  symbol :zeroconfig
4
- param :type, Params::Enum["config", "message"]
4
+ param :type, Params::Enum[:config, :message]
5
5
  param :agent, Params::String
6
6
  end
7
7
  end
@@ -100,12 +100,16 @@ module MediaWiktory
100
100
  attr_accessor :member_type
101
101
 
102
102
  def inspect
103
- "#<List#{member_type}>"
103
+ "#<List[#{member_type}]>"
104
104
  end
105
105
 
106
106
  alias_method :to_s, :inspect
107
107
  end
108
108
 
109
+ def value=(val)
110
+ super([*val])
111
+ end
112
+
109
113
  def self.valid?(val)
110
114
  member_type or fail(NotImplementedError, "Abstract list used as param type")
111
115
  val.is_a?(Array) && val.all?{|v| member_type.valid?(v)}
@@ -188,7 +192,7 @@ module MediaWiktory
188
192
 
189
193
  def coerce_modules(value)
190
194
  # making array of 1-item hashes
191
- value.map{|val|
195
+ [*value].map{|val|
192
196
  case val
193
197
  when Symbol
194
198
  {val => {}}
@@ -0,0 +1,46 @@
1
+ module MediaWiktory
2
+ class Page
3
+ attr_reader :id, :title, :raw
4
+
5
+ def initialize(raw)
6
+ @raw = raw
7
+ @title = raw.title
8
+ @id = raw.pageid
9
+ end
10
+
11
+ def content
12
+ revisions.first['*']
13
+ end
14
+
15
+ def missing?
16
+ !!raw.missing
17
+ end
18
+
19
+ def invalid?
20
+ !!raw.invalid
21
+ end
22
+
23
+ def exists?
24
+ !missing? && !invalid?
25
+ end
26
+
27
+ def merge!(other)
28
+ id == other.id or
29
+ fail(ArgumentError, "Trying to merge different pageids: #{id}/#{other.id}")
30
+
31
+ other.raw.each do |key, value|
32
+ raw.key?(key) or fail(ArgumentError, "Unknown key in continued page: #{key}")
33
+ next unless raw[key].is_a?(Array)
34
+ raw[key].concat(value)
35
+ end
36
+ end
37
+
38
+ def method_missing(sym, *args)
39
+ super unless args.empty?
40
+ exists? or
41
+ fail("Page #{title} is missing, can't access #{sym}")
42
+
43
+ raw.fetch(sym)
44
+ end
45
+ end
46
+ end
@@ -1,4 +1,4 @@
1
- require_relative 'array_with_keys'
1
+ require_relative 'page'
2
2
 
3
3
  module MediaWiktory
4
4
  class Query
@@ -7,18 +7,27 @@ module MediaWiktory
7
7
  end
8
8
 
9
9
  class Response < Action::Response
10
- def pages
11
- @pages ||= ArrayWithKeys.from_hash(raw.query.pages || {})
10
+ attr_reader :pages, :continue_params
11
+
12
+ def initialize(*)
13
+ super
14
+ @pages = ((raw.query.pages if raw.query) || {}).values.map(&Page.method(:new))
15
+ @continue_params = raw.continue && raw.continue.dup
16
+ end
17
+
18
+ def initialize_copy(other)
19
+ super(other)
20
+ @pages = other.pages.dup
12
21
  end
13
22
 
14
23
  def continue?
15
- !raw.continue.nil?
24
+ !@continue_params.nil?
16
25
  end
17
26
 
18
27
  def continue!
19
28
  continue? or fail(RuntimeError, "Response can not be continued")
20
29
 
21
- merge!(action.perform(raw.continue))
30
+ merge!(action.perform(@continue_params))
22
31
 
23
32
  self
24
33
  end
@@ -32,28 +41,17 @@ module MediaWiktory
32
41
  def merge!(other)
33
42
  # FIXME: not the brightest code in my life, faithfully
34
43
  # FIXME2: after this merge, only @pages are updated, but @raw.query.pages IS NOT
35
- other.pages.to_h.each do |k, p|
36
- if (existing = pages[k])
37
- merge_page(existing, p)
44
+ other.pages.each do |other_page|
45
+ existing = pages.detect{|p| p.id == other_page.id}
46
+
47
+ if existing
48
+ existing.merge!(other_page)
38
49
  else
39
- pages.push(p, p.id)
50
+ pages.push(other_page)
40
51
  end
41
52
  end
42
53
 
43
- raw.continue = other.raw.continue
44
- end
45
-
46
- def merge_page(existing, other)
47
- other.each do |k, v|
48
- case existing[k]
49
- when Array
50
- existing[k].concat(v)
51
- when Hash
52
- existing[k].merge!(v)
53
- else
54
- existing[k] = v
55
- end
56
- end
54
+ @continue_params = other.continue_params
57
55
  end
58
56
  end
59
57
  end
@@ -1,3 +1,6 @@
1
1
  module MediaWiktory
2
- VERSION = '0.0.1'
2
+ MAJOR = 0
3
+ MINOR = 0
4
+ PATCH = 2
5
+ VERSION = [MAJOR, MINOR, PATCH].join('.')
3
6
  end
@@ -106,7 +106,7 @@ module ApiParser
106
106
  vals.map(&:module).each{|m| m.write(base_path)}
107
107
  "Params::Modules#{vals.map(&:name).map(&:to_sym)}"
108
108
  else
109
- "Params::List[Params::Enum#{vals.map(&:name).map(&:to_s)}]"
109
+ "Params::List[Params::Enum#{vals.map(&:name).map(&:to_sym)}]"
110
110
  end
111
111
  when 'list of integers'
112
112
  'Params::List[Params::Integer]'
@@ -114,14 +114,11 @@ module ApiParser
114
114
  'Params::List[Params::Timestamp]'
115
115
  when 'enum'
116
116
  case
117
- #when name == 'generator'
118
- #vals.map(&:module).each{|m| m.write(base_path)}
119
- #"Params::Module#{vals.map(&:name).map{|n| ('g' + n).to_sym}}"
120
117
  when vals.first.module
121
118
  vals.map(&:module).each{|m| m.write(base_path)}
122
119
  "Params::Module#{vals.map(&:name).map(&:to_sym)}"
123
120
  else
124
- "Params::Enum#{vals.map(&:name).map(&:to_s)}"
121
+ "Params::Enum#{vals.map(&:name).map(&:to_sym)}"
125
122
  end
126
123
  else
127
124
  fail("Unrecognized param type: #{type}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiktory
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
7
  - Victor Shepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -72,7 +72,9 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
- - Gemfile.lock
75
+ - CHANGELOG.md
76
+ - CONTRIBUTING.md
77
+ - LICENSE.txt
76
78
  - README.md
77
79
  - bin/mediawiktory
78
80
  - doc/mediawiki_api_types.md
@@ -82,7 +84,6 @@ files:
82
84
  - lib/media_wiktory.rb
83
85
  - lib/mediawiktory.rb
84
86
  - lib/mediawiktory/action.rb
85
- - lib/mediawiktory/array_with_keys.rb
86
87
  - lib/mediawiktory/client.rb
87
88
  - lib/mediawiktory/generated/abusefiltercheckmatch.rb
88
89
  - lib/mediawiktory/generated/abusefilterchecksyntax.rb
@@ -303,6 +304,7 @@ files:
303
304
  - lib/mediawiktory/generated/wikisets.rb
304
305
  - lib/mediawiktory/generated/zeroconfig.rb
305
306
  - lib/mediawiktory/mw_module.rb
307
+ - lib/mediawiktory/page.rb
306
308
  - lib/mediawiktory/query.rb
307
309
  - lib/mediawiktory/version.rb
308
310
  - lib/nokogiri/more.rb
@@ -1,63 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mediawiktory (0.0.1)
5
- addressable
6
- faraday
7
- faraday_middleware
8
- hashie
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- addressable (2.3.8)
14
- crack (0.4.2)
15
- safe_yaml (~> 1.0.0)
16
- diff-lcs (1.2.5)
17
- faker (1.5.0)
18
- i18n (~> 0.5)
19
- faraday (0.9.1)
20
- multipart-post (>= 1.2, < 3)
21
- faraday_middleware (0.10.0)
22
- faraday (>= 0.7.4, < 0.10)
23
- hashie (3.4.2)
24
- i18n (0.7.0)
25
- mini_portile (0.6.2)
26
- multipart-post (2.0.0)
27
- naught (1.1.0)
28
- nokogiri (1.6.6.2)
29
- mini_portile (~> 0.6.0)
30
- rspec (3.3.0)
31
- rspec-core (~> 3.3.0)
32
- rspec-expectations (~> 3.3.0)
33
- rspec-mocks (~> 3.3.0)
34
- rspec-core (3.3.2)
35
- rspec-support (~> 3.3.0)
36
- rspec-expectations (3.3.1)
37
- diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.3.0)
39
- rspec-its (1.2.0)
40
- rspec-core (>= 3.0.0)
41
- rspec-expectations (>= 3.0.0)
42
- rspec-mocks (3.3.2)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.3.0)
45
- rspec-support (3.3.0)
46
- rubygems-tasks (0.2.4)
47
- safe_yaml (1.0.4)
48
- webmock (1.21.0)
49
- addressable (>= 2.3.6)
50
- crack (>= 0.3.2)
51
-
52
- PLATFORMS
53
- ruby
54
-
55
- DEPENDENCIES
56
- faker
57
- mediawiktory!
58
- naught
59
- nokogiri
60
- rspec
61
- rspec-its
62
- rubygems-tasks
63
- webmock