Code Monkey home page Code Monkey logo

confluencer's Introduction

confluencer

Easy to use, ActiveRecord-like classes to find spaces, pages and bookmarks as well as adding new ones and updating existing ones. It uses ruby’s method missing to translate methods to Confluence XMLRPC API (v2) call.

For Confluence XML RPC API documentation, please take a look at these links:

Confluence XML-RPC and SOAP APIs

Remote Confluence Data Objects

developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods

Installation

Install from rubygems

gem install qarioz-confluencer

Build and install from source

Clone the repository, build the gem, install the gem.

git clone git://github.com/qarioz/confluencer.git
cd confluencer
gem build confluencer.gemspec
gem install qarioz-confluencer-0.6.0.gem

Include in Gemfile

Or if you are using Gemfile, add this to your Gemfile

gem 'qarioz-confluencer', :git => 'git://github.com/qarioz/confluencer.git'

Usage

This is the usage example for confluencer

require 'confluencer'
begin
  #login
  client = Confluence::Client.new(url: "https://mywiki.atlassian.net/wiki/")
  client.login("username", "password")
  # no need to save resulting token; api handles it

  # get all spaces
  all_spaces = client.get_spaces
  # => [{'url', 'name', 'key', 'type'}]

  # get specific space
  test_space = client.get_space( "TestSpace")
  # => {'url', 'name', 'key', 'type', 'homepage'}

  # create a new space
  s = Confluence::Space.new
  # => {}

  # get pages from a space
  ps = client.get_pages( "TestSpace")
  # => [{ 'url', 'id', 'version', 'title', 'space', 'parentId', 'permissions'}]
  page_id = ps[0]['id'] # => "8345678"
  pidcl = page_id.class # => String

  # get comments from a page
  comments = client.get_comments( page_id)
  # => [{ 'modifier', 'creator', 'content', 'title',
  #       'parentId', 'id', 'pageId', 'modified', 'url', 'created'}]

  # create a comment
  new_comment = client.add_comment( {pageId: page_id, title: "ruby sez", content: "blah blah blah"})

  # create a label for a page
  label = client.add_label_by_name( "new-label", page_id)
  # => true

  #update a page
  npage = client.store_page(
      space: "TestSpace", title: "yapage29", content: "Here is the content, also from ruby")
  # => {'id', 'current', 'content', 'title', 'version', 'modifier',
  #     'url', 'homePage', 'creator', 'contentStatus', 'modified',
  #     'created', 'space', 'parentId', 'permissions'}
  # if "yapage29" exists, throws {Confluence::Error}Could not save or update record
rescue Exception => e
  puts "error: " + e.to_s
end

Troubleshooting

SSL Problem

If you get SSL Problem while using this gem on windows, follow the steps below to fix it.

Uncaught exception: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

This assumes your have already installed the [Rails Installer](railsinstaller.org) for Windows.

Download the ruby script to your Desktop folder from [gist.github.com/raw/867550/win_fetch_cacerts.rb](https://gist.github.com/raw/867550/win_fetch_cacerts.rb). Then in your command prompt, execute the ruby script:

ruby "%USERPROFILE%\Desktop\win_fetch_cacerts.rb"

Or copy paste the script below:

require 'net/http'

# create a path to the file "C:\RailsInstaller\cacert.pem"
cacert_file = File.join(%w{c: RailsInstaller cacert.pem})

Net::HTTP.start("curl.haxx.se") do |http|
  resp = http.get("/ca/cacert.pem")
  if resp.code == "200"
    open(cacert_file, "wb") { |file| file.write(resp.body) }
    puts "\n\nA bundle of certificate authorities has been installed to"
    puts "C:\\RailsInstaller\\cacert.pem\n"
    puts "* Please set SSL_CERT_FILE in your current command prompt session with:"
    puts "     set SSL_CERT_FILE=C:\\RailsInstaller\\cacert.pem"
    puts "* To make this a permanent setting, add it to Environment Variables"
    puts "  under Control Panel -> Advanced -> Environment Variables"
  else
    abort "\n\n>>>> A cacert.pem bundle could not be downloaded."
  end
end

Now make ruby aware of your certificate authority bundle by setting ‘SSL_CERT_FILE`. To set this in your current command prompt session, type:

set SSL_CERT_FILE=C:\RailsInstaller\cacert.pem

To make this a permanent setting, add this in your [control panel](www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/environment_variables.mspx?mfr=true).

The Manual Way (Boring)

Download the ‘cacert.pem` file from [curl.haxx.se/ca/cacert.pem](http://curl.haxx.se/ca/cacert.pem). Save this file to `C:RailsInstallercacert.pem`.

Now make ruby aware of your certificate authority bundle by setting ‘SSL_CERT_FILE`. To set this in your current command prompt session, type:

set SSL_CERT_FILE=C:\RailsInstaller\cacert.pem

To make this a permanent setting, add this in your [control panel](www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/environment_variables.mspx?mfr=true).

Copyright © 2010 Secret Sauce Partners, Inc. See LICENSE for details.

confluencer's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.