Class: Wikian::Contributions
- Inherits:
-
Subcommand
- Object
- Subcommand
- Wikian::Contributions
- Defined in:
- lib/wikian/contributions.rb
Constant Summary collapse
- DEFAULT_MAX_CONTRIBUTIONS =
20
Instance Attribute Summary
Attributes inherited from Subcommand
#api_url, #args, #config, #debug, #output_file, #query, #res, #res_body, #title
Instance Method Summary collapse
-
#initialize(args) ⇒ Contributions
constructor
A new instance of Contributions.
- #template ⇒ Object
Methods inherited from Subcommand
#doit, #make_template, #non_opt_args, #response_file, #write_response
Constructor Details
#initialize(args) ⇒ Contributions
Returns a new instance of Contributions.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wikian/contributions.rb', line 9 def initialize(args) super max_contributions = args.find(&:numeric?) || DEFAULT_MAX_CONTRIBUTIONS raise(BadUrlError, "Try passing the '-t' option") unless config['meta']['site'] @output_file = 'User:' + ENV['WIKI_USER'] + '.contributions.' + config['meta']['site'] @params.merge!('ucuser' => ENV['WIKI_USER'], 'uclimit' => max_contributions, 'format' => Wikian::RESPONSE_FORMAT) @query = @params.to_query @api_url = URI("https://#{config['meta']['site']}/w/api.php?#{query}") rescue => e puts "#{e.class} in #{__FILE__}", e. exit end |
Instance Method Details
#template ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/wikian/contributions.rb', line 28 def template <<~eos # for a list of parameters to use here see: https://www.mediawiki.org/wiki/API:Usercontribs meta: site: en.wikipedia.org headers: user-agent: Wikian api: action: - query list: - usercontribs ucprop: - title - comment - timestamp - sizediff eos end |