coda_docs 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/.rspec +3 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +7 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +69 -0
- data/LICENSE +674 -0
- data/README.md +48 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/coda_docs.gemspec +43 -0
- data/lib/coda_docs.rb +7 -0
- data/lib/coda_docs/client.rb +38 -0
- data/lib/coda_docs/client/account.rb +9 -0
- data/lib/coda_docs/client/columns.rb +14 -0
- data/lib/coda_docs/client/controls.rb +14 -0
- data/lib/coda_docs/client/docs.rb +24 -0
- data/lib/coda_docs/client/folders.rb +14 -0
- data/lib/coda_docs/client/formulas.rb +14 -0
- data/lib/coda_docs/client/miscellaneous.rb +9 -0
- data/lib/coda_docs/client/rows.rb +18 -0
- data/lib/coda_docs/client/sections.rb +14 -0
- data/lib/coda_docs/client/tables.rb +14 -0
- data/lib/coda_docs/version.rb +3 -0
- metadata +171 -0
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# CodaDocs
|
2
|
+
|
3
|
+
The Coda Docs Ruby library provides convenient access to the [Coda Docs API](https://coda.io/developers/apis/v1beta1) from applications written in the Ruby language.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'coda_docs'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install coda_docs
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
The library needs to be configured with your account's secret key which is available in your [Coda Docs Dashboard](https://coda.io/account). You can set the required key with the `CODA_DOCS_API_KEY` environment variable
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
CODA_DOCS_API_KEY=Vau7FXe57Ith6MxcMnT1QSzNZ0o1YZ8s
|
27
|
+
|
28
|
+
# New Coda Docs Client
|
29
|
+
client = CodaDocs::Client.new
|
30
|
+
```
|
31
|
+
or at the moment we create a new client.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require "coda_docs"
|
35
|
+
|
36
|
+
# New Coda Docs Client
|
37
|
+
client = CodaDocs::Client.new('Vau7FXe57Ith6MxcMnT1QSzNZ0o1YZ8s')
|
38
|
+
```
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
43
|
+
|
44
|
+
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).
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cmunozgar/coda_docs.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "coda_docs"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/coda_docs.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'coda_docs/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'coda_docs'
|
7
|
+
spec.version = CodaDocs::VERSION
|
8
|
+
spec.authors = ['Carlos Muñoz']
|
9
|
+
spec.email = ['carlos@monday.vc']
|
10
|
+
|
11
|
+
spec.summary = 'Coda Docs Api Gem'
|
12
|
+
spec.description = 'Gem to help integrate Ruby <> Coda Docs API (0.1.1-beta). Work is still in progress and everything is subject to change.'
|
13
|
+
spec.homepage = 'https://github.com/joinmonday/coda_docs'
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
spec.metadata['changelog_uri'] = spec.homepage
|
22
|
+
else
|
23
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
|
+
'public gem pushes.'
|
25
|
+
end
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = 'exe'
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ['lib']
|
35
|
+
|
36
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
37
|
+
spec.add_development_dependency 'dotenv', '~> 2.5'
|
38
|
+
spec.add_development_dependency 'pry', '~> 0.12'
|
39
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.6'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
+
spec.add_dependency 'httparty', '~> 0.16'
|
43
|
+
end
|
data/lib/coda_docs.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'coda_docs/client/docs'
|
2
|
+
require 'coda_docs/client/sections'
|
3
|
+
require 'coda_docs/client/folders'
|
4
|
+
require 'coda_docs/client/tables'
|
5
|
+
require 'coda_docs/client/rows'
|
6
|
+
require 'coda_docs/client/columns'
|
7
|
+
require 'coda_docs/client/formulas'
|
8
|
+
require 'coda_docs/client/controls'
|
9
|
+
require 'coda_docs/client/account'
|
10
|
+
require 'coda_docs/client/miscellaneous'
|
11
|
+
|
12
|
+
module CodaDocs
|
13
|
+
class Client
|
14
|
+
include HTTParty
|
15
|
+
include CodaDocs::Client::Docs
|
16
|
+
include CodaDocs::Client::Sections
|
17
|
+
include CodaDocs::Client::Folders
|
18
|
+
include CodaDocs::Client::Tables
|
19
|
+
include CodaDocs::Client::Rows
|
20
|
+
include CodaDocs::Client::Columns
|
21
|
+
include CodaDocs::Client::Formulas
|
22
|
+
include CodaDocs::Client::Controls
|
23
|
+
include CodaDocs::Client::Account
|
24
|
+
include CodaDocs::Client::Miscellaneous
|
25
|
+
base_uri 'https://coda.io/apis/v1beta1'
|
26
|
+
format :json
|
27
|
+
|
28
|
+
def initialize(access_token = nil)
|
29
|
+
access_token ||= ENV['CODA_DOCS_API_KEY']
|
30
|
+
self.class.default_options.merge!(
|
31
|
+
headers: {
|
32
|
+
'Authorization' => "Bearer #{access_token}",
|
33
|
+
'Content-Type' => 'application/json'
|
34
|
+
}
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Columns
|
4
|
+
def columns(doc_id, table_id, options = {})
|
5
|
+
response = self.class.get("/docs/#{doc_id}/tables/#{table_id}/columns", query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def column(doc_id, table_id, column_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}/tables/#{table_id}/columns/#{column_id}", query: options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Controls
|
4
|
+
def controls(doc_id, options = {})
|
5
|
+
response = self.class.get("/docs/#{doc_id}/controls", query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def formula(doc_id, control_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}/controls/#{control_id}", query: options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Docs
|
4
|
+
def docs(options = {})
|
5
|
+
response = self.class.get('/docs', query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def doc(doc_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}", query: options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_doc(title = 'Untitled', source_doc = nil)
|
14
|
+
self.class.post(
|
15
|
+
'/docs',
|
16
|
+
body: {
|
17
|
+
'title' => title,
|
18
|
+
'sourceDoc' => source_doc
|
19
|
+
}.to_json
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Folders
|
4
|
+
def folders(doc_id, options = {})
|
5
|
+
response = self.class.get("/docs/#{doc_id}/folders", query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def folder(doc_id, folder_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}/folders/#{folder_id}", query: options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Formulas
|
4
|
+
def formulas(doc_id, options = {})
|
5
|
+
response = self.class.get("/docs/#{doc_id}/formulas", query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def formula(doc_id, formula_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}/formulas/#{formula_id}", query: options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Rows
|
4
|
+
def rows(doc_id, table_id, options = {})
|
5
|
+
response = self.class.get("/docs/#{doc_id}/tables/#{table_id}/rows", query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def row(doc_id, table_id, row_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}/tables/#{table_id}/rows/#{row_id}", query: options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def delete_row(doc_id, table_id, row_id)
|
14
|
+
self.class.delete("/docs/#{doc_id}/tables/#{table_id}/rows/#{row_id}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Sections
|
4
|
+
def sections(doc_id, options = {})
|
5
|
+
response = self.class.get("/docs/#{doc_id}/sections", query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def section(doc_id, section_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}/sections/#{section_id}", query: options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CodaDocs
|
2
|
+
class Client
|
3
|
+
module Tables
|
4
|
+
def tables(doc_id, options = {})
|
5
|
+
response = self.class.get("/docs/#{doc_id}/tables", query: options)
|
6
|
+
response.parsed_response['items']
|
7
|
+
end
|
8
|
+
|
9
|
+
def table(doc_id, table_id, options = {})
|
10
|
+
self.class.get("/docs/#{doc_id}/tables/#{table_id}", query: options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coda_docs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carlos Muñoz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: httparty
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.16'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.16'
|
111
|
+
description: Gem to help integrate Ruby <> Coda Docs API (0.1.1-beta). Work is still
|
112
|
+
in progress and everything is subject to change.
|
113
|
+
email:
|
114
|
+
- carlos@monday.vc
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".travis.yml"
|
123
|
+
- Gemfile
|
124
|
+
- Gemfile.lock
|
125
|
+
- LICENSE
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- coda_docs.gemspec
|
131
|
+
- lib/coda_docs.rb
|
132
|
+
- lib/coda_docs/client.rb
|
133
|
+
- lib/coda_docs/client/account.rb
|
134
|
+
- lib/coda_docs/client/columns.rb
|
135
|
+
- lib/coda_docs/client/controls.rb
|
136
|
+
- lib/coda_docs/client/docs.rb
|
137
|
+
- lib/coda_docs/client/folders.rb
|
138
|
+
- lib/coda_docs/client/formulas.rb
|
139
|
+
- lib/coda_docs/client/miscellaneous.rb
|
140
|
+
- lib/coda_docs/client/rows.rb
|
141
|
+
- lib/coda_docs/client/sections.rb
|
142
|
+
- lib/coda_docs/client/tables.rb
|
143
|
+
- lib/coda_docs/version.rb
|
144
|
+
homepage: https://github.com/joinmonday/coda_docs
|
145
|
+
licenses: []
|
146
|
+
metadata:
|
147
|
+
allowed_push_host: https://rubygems.org
|
148
|
+
homepage_uri: https://github.com/joinmonday/coda_docs
|
149
|
+
source_code_uri: https://github.com/joinmonday/coda_docs
|
150
|
+
changelog_uri: https://github.com/joinmonday/coda_docs
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.7.7
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Coda Docs Api Gem
|
171
|
+
test_files: []
|