docbase 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 151bf8c6289ab8b74c375048d99a1cf1cfcb6ea8
4
+ data.tar.gz: f97b6b6d6f19d9e6841720116ef55d3a74cb3b96
5
+ SHA512:
6
+ metadata.gz: 8213d466ced2ce304a1bee3d4816fd09d59711aec4b9f1d35ef6ab4ddc5b5f153307139e905faee806b2d09b08522e12cc94d5dbae3d89e9ce7681a4d96143af
7
+ data.tar.gz: a63a92e62858cde3d0cbd18c55fe32a615519defe4ececee404d064d0f64c53ca0732ea7c19e826706441d904d553de99ba6f2134a3bbd0948713f0376446876
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.8
5
+ - 2.2.4
6
+ - 2.3.0
7
+ - ruby-head
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ 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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in docbase.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 danny.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,112 @@
1
+ # docbase-ruby
2
+
3
+ [![Build Status](https://travis-ci.org/krayinc/docbase-ruby.svg?branch=master)](https://travis-ci.org/krayinc/docbase-ruby)
4
+
5
+ DocBase API Client, written in Ruby.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'docbase'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install docbase
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ client = DocBase::Client.new(access_token: 'your_access_token', team: 'your_team')
27
+ ```
28
+
29
+ or
30
+
31
+ ```ruby
32
+ ENV['DOCBASE_ACCESS_TOKEN'] = 'your_access_token'
33
+
34
+ client = DocBase::Client.new(team: 'your_team')
35
+ ```
36
+
37
+ ### teams
38
+
39
+ ```ruby
40
+ client.teams.body
41
+ # => [{ domain: 'kray', name: 'kray' }, { domain: 'danny', name: 'danny' }]
42
+ ```
43
+ ### tags
44
+
45
+ ```ruby
46
+ client.tags.body
47
+ # => [{ name: 'ruby' }, { name: 'rails' }]
48
+ ```
49
+
50
+ ### groups
51
+
52
+ ```ruby
53
+ client.groups.body
54
+ # => [{ id: 1, name: 'DocBase' }, { id: 2, name: 'kray' }]
55
+ ```
56
+
57
+ ### posts
58
+
59
+ ```ruby
60
+ params = {
61
+ title: 'memo title',
62
+ body: 'memo body',
63
+ draft: false,
64
+ tags: ['rails', 'ruby'],
65
+ scope: 'group',
66
+ groups: [1],
67
+ notice: true,
68
+ }
69
+
70
+ client.posts(params).body
71
+ # => {
72
+ # id: 1,
73
+ # title: 'memo title',
74
+ # body: 'memo body',
75
+ # draft: false,
76
+ # url: 'https://kray.docbase.io/posts/1',
77
+ # created_at: '2015-03-10T12:01:54+09:00',
78
+ # tags: [
79
+ # { name: 'rails' },
80
+ # { name: 'ruby' },
81
+ # ],
82
+ # scope: 'group',
83
+ # groups: [
84
+ # { name: 'DocBase' }
85
+ # ],
86
+ # user: {
87
+ # id: 1,
88
+ # name: 'danny'
89
+ # },
90
+ # }
91
+ ```
92
+
93
+ ### switch team
94
+
95
+ ```ruby
96
+ client = DocBase::Client.new(access_token: 'your_access_token', team: 'kray')
97
+ client.tags.body
98
+ # => [{ name: 'ruby' }, { name: 'rails' }]
99
+
100
+ client.team = 'danny'
101
+ client.tags.body
102
+ # => [{ name: 'javascript' }, { name: 'react' }]
103
+ ```
104
+
105
+ ## API Document
106
+
107
+ [https://help.docbase.io/posts/45703](https://help.docbase.io/posts/45703)
108
+
109
+ ## License
110
+
111
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
112
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "docbase"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'docbase/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'docbase'
7
+ spec.version = DocBase::VERSION
8
+ spec.authors = ['danny']
9
+ spec.email = ['danny@kray.jp']
10
+
11
+ spec.summary = 'DocBase API Client, written in Ruby'
12
+ spec.description = 'DocBase API Client, written in Ruby'
13
+ spec.homepage = 'https://github.com/krayinc/docbase-ruby'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'faraday', '~> 0.9.2'
21
+ spec.add_runtime_dependency 'faraday_middleware', '~> 0.10.0'
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.4.0'
25
+ end
@@ -0,0 +1,4 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'docbase/version'
4
+ require 'docbase/client'
@@ -0,0 +1,59 @@
1
+ module DocBase
2
+ class Client
3
+ DEFAULT_URL = 'https://api.docbase.io'
4
+ USER_AGENT = "DocBase Ruby Gem #{DocBase::VERSION}"
5
+
6
+ class NotSetTeamError < StandardError; end
7
+
8
+ def initialize(access_token: nil, url: nil, team: nil)
9
+ @access_token = access_token || ENV['DOCBASE_ACCESS_TOKEN']
10
+ @team = team
11
+ @url = url || DEFAULT_URL
12
+ end
13
+
14
+ def team=(team)
15
+ @team = team
16
+ end
17
+
18
+ def team
19
+ @team
20
+ end
21
+
22
+ def team!
23
+ raise NotSetTeamError unless @team
24
+ @team
25
+ end
26
+
27
+ def teams
28
+ connection.get('/teams')
29
+ end
30
+
31
+ def tags
32
+ connection.get("/teams/#{team!}/tags")
33
+ end
34
+
35
+ def groups
36
+ connection.get("/teams/#{team!}/groups")
37
+ end
38
+
39
+ def posts(params)
40
+ connection.post("/teams/#{team!}/posts", params)
41
+ end
42
+
43
+ def connection
44
+ @connection ||= Faraday.new({ url: @url, headers: headers }) do |faraday|
45
+ faraday.request :json
46
+ faraday.response :json
47
+ faraday.adapter Faraday.default_adapter
48
+ end
49
+ end
50
+
51
+ def headers
52
+ {
53
+ 'Accept' => 'application/json',
54
+ 'User-Agent' => USER_AGENT,
55
+ 'X-DocBaseToken' => @access_token,
56
+ }
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module DocBase
2
+ VERSION = '0.1.2'
3
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docbase
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - danny
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 3.4.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 3.4.0
83
+ description: DocBase API Client, written in Ruby
84
+ email:
85
+ - danny@kray.jp
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - docbase.gemspec
101
+ - lib/docbase.rb
102
+ - lib/docbase/client.rb
103
+ - lib/docbase/version.rb
104
+ homepage: https://github.com/krayinc/docbase-ruby
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.0.14
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: DocBase API Client, written in Ruby
128
+ test_files: []