mirror of https://github.com/captn3m0/outliner.git synced 2024-07-12 15:27:56 +00:00

Initial Commit

This commit is contained in:
Nemo 2019-07-24 19:36:18 +05:30
commit d12681e05c
14 changed files with 340 additions and 0 deletions

.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@

CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
## Our Standards
Examples of behavior that contributes to creating a positive environment
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at me@captnemo.in. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

Gemfile Normal file
View File

@ -0,0 +1,4 @@
source "https://rubygems.org"
# Specify your gem's dependencies in outliner.gemspec

Gemfile.lock Normal file
View File

@ -0,0 +1,42 @@
remote: .
outliner (0.1.0)
httparty (~> 0.17)
remote: https://rubygems.org/
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
hashdiff (1.0.0)
httparty (0.17.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
minitest (5.8.5)
multi_xml (0.6.0)
public_suffix (3.1.1)
rake (10.5.0)
safe_yaml (1.0.5)
webmock (3.6.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
bundler (~> 2.0)
minitest (~> 5.8.4)
rake (~> 10.0)
webmock (~> 3.6.0)

README.md Normal file
View File

@ -0,0 +1,49 @@
# Outliner
A simple HTTParty based wrapper for the [Outline API](https://www.getoutline.com/developers).
## Installation
Add this line to your application's Gemfile:
gem 'outliner'
And then execute:
$ bundle
Or install it yourself as:
$ gem install outliner
## Usage
The API Client automatically picks up the Token from the `OUTLINE_TOKEN` environment variable. All the API calls are available with the `.` replaced with a `_` in the method name. So if you need to call the `collections.remove_user` API, use the `collections_remove_user` method.
require 'outliner'
client = Outliner.new('https://knowledge.example.com')
pp client.auth_info
pp client.collections_list(offset: 0, limit: 10)
## Development
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/captn3m0/outliner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## Code of Conduct
Everyone interacting in the Outliner projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/captn3m0/outliner/blob/master/CODE_OF_CONDUCT.md).
## License
Licensed under the [MIT License](https://nemo.mit-license.org/). See LICENSE file for details.

Rakefile Normal file
View File

@ -0,0 +1,2 @@
require "bundler/gem_tasks"
task :default => :spec

bin/console Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env ruby
require "bundler/setup"
require "outliner"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"

bin/setup Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
set -vx
bundle install
# Do any other automated setup that you need to do here

lib/outliner.rb Normal file
View File

@ -0,0 +1,5 @@
require "outliner/version"
module Outliner
class Error < StandardError; end

lib/outliner/client.rb Normal file
View File

@ -0,0 +1,29 @@
require 'httparty'
require 'json'
module Outliner
class Client
include HTTParty
def initialize(base_uri)
self.class.base_uri (base_uri + "/api")
def method_missing(method_name, params = {})
method_name = '/' + method_name.to_s.sub('_', '.')
body = {token: @token}.merge(params).to_json
options = {
body: body,
headers: {
'Content-Type': 'application/json',
'User-Agent': "Outliner/#{Outliner::VERSION}"
format: :json
self.class.post(method_name, options)

lib/outliner/version.rb Normal file
View File

@ -0,0 +1,3 @@
module Outliner
VERSION = "0.1.0"

outliner.gemspec Normal file
View File

@ -0,0 +1,34 @@
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "outliner/version"
require "outliner/client"
Gem::Specification.new do |spec|
spec.name = "outliner"
spec.version = Outliner::VERSION
spec.authors = ["Nemo"]
spec.email = ["rubygem.outliner@captnemo.in"]
spec.summary = "A simple HTTParty based client for outline knowledge base."
spec.homepage = "https://github.com/captn3m0/outliner"
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/captn3m0/outliner"
spec.metadata["changelog_uri"] = "https://github.com/captn3m0/outliner/blob/master/CHANGELOG.md"
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_dependency "httparty", "~> 0.17"
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "webmock", "~> 3.6.0"
spec.add_development_dependency "minitest", "~> 5.8.4"

test/fixtures/auth.info.200.json vendored Normal file
View File

@ -0,0 +1,26 @@
"data": {
"user": {
"id": "d7a6a7c0-9dda-4e01-8dc2-9b1905c08c40",
"createdAt": "2014-01-01T12:37:07.826Z",
"name": "Test User",
"isAdmin": true,
"isSuspended": false,
"avatarUrl": "https://example.com/avatar-url.jpg",
"email": "testuser@example.com"
"team": {
"id": "e0809f93-c199-4472-8a70-77eee3d67986",
"name": "Test Team",
"avatarUrl": "https://example.com/favicon-url.jpg",
"slackConnected": false,
"googleConnected": true,
"sharing": false,
"documentEmbeds": true,
"subdomain": "kb",
"url": "https://kb.example.com"
"status": 200,
"ok": true

test/test_client.rb Normal file
View File

@ -0,0 +1,41 @@
require 'outliner'
require 'minitest/autorun'
require 'webmock/minitest'
require 'json'
class ClientTest < Minitest::Test
TOKEN = "c4302eFAKE_TOKEN9b6e27bccb7"
def setup
@client = Outliner::Client.new BASE_URI
def test_client_initialized
assert_kind_of Outliner::Client, @client
def test_auth_info_api
mock('auth.info', 'auth.info.200')
auth_info = @client.auth_info
assert_equal "https://kb.example.com", auth_info['data']['team']['url']
def read_fixture(file)
File.read "test/fixtures/#{file}.json"
def mock(method_name, fixture_file, params = {})
stub_request(:post, BASE_URI + "/api/" + method_name)
body: params.merge({token: TOKEN}).to_json,
headers: {
'Content-Type'=> 'application/json'
).to_return(body: read_fixture(fixture_file))