From 6153a1ff7b2b5f0db0fb15046c005a80492795b9 Mon Sep 17 00:00:00 2001
From: Mathieu Loiseau <loizbek@lezinter.net>
Date: Mon, 12 Mar 2018 18:34:45 +0100
Subject: [PATCH] logo

---
 DESCRIPTION                      |  2 +-
 R/class.R                        | 13 +++++++++++--
 man/connect-Mediawikir-method.Rd | 12 ++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 man/connect-Mediawikir-method.Rd

diff --git a/DESCRIPTION b/DESCRIPTION
index e81da53..925fa1f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -4,7 +4,7 @@ Title: Connects to a mediawiki instance and writes in it what you want
 Version: 0.1.0
 Author: Mathieu Loiseau
 Maintainer: Mathieu Loiseau <loiseaum@univ-grenoble-alpes.fr>
-Description: It can be used to post the output of an R script directly to a mediawiki instance
+Description: It can be used to post the output of an R script directly into a mediawiki instance
 License: MIT
 Encoding: UTF-8
 LazyData: true
diff --git a/R/class.R b/R/class.R
index 3ab3d67..b8c5e92 100644
--- a/R/class.R
+++ b/R/class.R
@@ -2,7 +2,15 @@
 #'
 #'@slot url the mediawiki instance base url
 #'@slot auth_token the current token used to edit the wiki (cf. https://www.mediawiki.org/wiki/Manual:Edit_token)
-setClass("Mediawikir", representation(url = "character", auth_token = "character"))
+setClass("Mediawikir", representation(url = "character", user_name = "character", auth_token = "character"))
+
+setGeneric("connect", function(.Object, pass){})
+#'Connects to mediawiki instance and gets token (to be called by constructor)
+#'
+setMethod("connect", "Mediawikir", function(.Object, pass){
+  library("RCurl")
+  paste("connecting : ", .Object@user_name, "/", pass)
+})
 
 #'Creates a new Mediawikir object instance
 #'
@@ -13,6 +21,7 @@ setClass("Mediawikir", representation(url = "character", auth_token = "character
 #' new("Mediawikir", "http://wiki.example.com", "admin", "theadmin'spassword")
 setMethod("initialize", "Mediawikir", function (.Object, instance_url, user, pass){
   .Object@url <- instance_url
-  .Object@auth_token <- paste(user, pass, sep=" / ")
+  .Object@user_name <- user
+  .Object@auth_token <- connect(.Object, pass)
   return(.Object)
 })
diff --git a/man/connect-Mediawikir-method.Rd b/man/connect-Mediawikir-method.Rd
new file mode 100644
index 0000000..9f6ae36
--- /dev/null
+++ b/man/connect-Mediawikir-method.Rd
@@ -0,0 +1,12 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/class.R
+\docType{methods}
+\name{connect,Mediawikir-method}
+\alias{connect,Mediawikir-method}
+\title{Connects to mediawiki instance and gets token (to be called by constructor)}
+\usage{
+\S4method{connect}{Mediawikir}(.Object, pass)
+}
+\description{
+Connects to mediawiki instance and gets token (to be called by constructor)
+}
-- 
GitLab