rwikibot 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/CHANGELOG +4 -0
  2. data/lib/rwikibot.rb +24 -1
  3. metadata +1 -1
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  RWikiBot ChangeLog
2
2
 
3
+ 1.0.7
4
+ - Added PAGEID_TO_TITLE
5
+ - Turned Logger level up to INFO- sorry for forgetting that :-)
6
+
3
7
  1.0.6
4
8
  - Added VERSION
5
9
  - Removed some _more_ debugging code
data/lib/rwikibot.rb CHANGED
@@ -26,7 +26,7 @@ class RWikiBot
26
26
  # New bots hope for three attributes, but require none. The first is simply the name of the bot for logging purposes. The second is the debug level constant, and third is the logfile.
27
27
  #
28
28
  # Example: bot = RWikiBot.new("My Neat Bot", Logger::DEBUG, "./rwikibot.log")
29
- def initialize (name = "Unnamed Bot", config = 'default', debuglevel = Logger::DEBUG, log_location = "./rwikibot.log" )
29
+ def initialize (name = "Unnamed Bot", config = 'default', debuglevel = Logger::INFO, log_location = "./rwikibot.log" )
30
30
 
31
31
  @botname = name
32
32
 
@@ -573,6 +573,29 @@ class RWikiBot
573
573
  return site_info.fetch('generator').split(' ')[1]
574
574
  end
575
575
 
576
+ # This method turns a pageid into a title. Why? Because I've written the rest of the methods title-centric, and I want to keep it that way. But, sometiumes you get a list of ids and not titles, and we have to do something about that.
577
+ #
578
+ # INPUT:: PageID - just one!
579
+ # OUTPUT:: A title in string form.
580
+ def pageid_to_title(id)
581
+
582
+ # Prepare the request! Notify the logger!
583
+ @wikibotlogger.debug "PAGEID TO TITLE - Preparing the requeset..."
584
+ post_me = {'prop' => 'info', 'pageids' => id}
585
+
586
+ # Make the request. Becuase we care.
587
+ @wikibotlogger.debug "PAGEID TO TITLE - Asking make_request to get revision for pageid #{id}"
588
+ id_result = make_request('query', post_me )
589
+ @wikibotlogger.debug "PAGEID TO TITLE - We should have a result now..."
590
+
591
+ #Process the results
592
+ @wikibotlogger.debug "PAGEID TO TITLE - Preparing results..."
593
+
594
+ return id_result.fetch('pages')[0].fetch('title')
595
+
596
+ end
597
+
598
+
576
599
  private
577
600
 
578
601
  # Make Request is a method that actually handles making the request to the API. Since the API is somewhat standardized, this method is able to accept the action and a hash of variables, and it handles all the fun things MediaWiki likes to be weird over, like cookies and limits and actions. Its very solid, but I didn't want it public because it also does some post processing, and that's not very OO.
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rwikibot
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.6
6
+ version: 1.0.7
7
7
  date: 2007-03-08 00:00:00 -06:00
8
8
  summary: A library for creating MediaWiki bots.
9
9
  require_paths: