notion_rb 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: af1c989c52ce6480f7489063cd08d7da219a8fc91bea649ceff3efe47bc2923d
4
+ data.tar.gz: 9f36492672b7a0cad654134d70d6aa35caaddf6e2a8658bd18623c93b28eb373
5
+ SHA512:
6
+ metadata.gz: 6bc60a74e1ca83371a739be3cf5d481dfc559040c2515f1c2e558fb2b373aa8026a1889810e2407374997c01e319f6a94d9e8a5ae05eb9e5c1e4fad57b8ea7fa
7
+ data.tar.gz: adc870ab2481292372c72298003a692fe013d024a3fbb4be49d199065535dcc87d88ac068e0ccfa11c21d45ee453c7e33f7a2043fbb029d6605bb142ca2b4910
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,14 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-11-22 12:42:58 -0300 using RuboCop version 0.76.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
12
+ # URISchemes: http, https
13
+ Metrics/LineLength:
14
+ Max: 87
@@ -0,0 +1 @@
1
+ 2.5.7
@@ -0,0 +1,14 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ branches:
8
+ only:
9
+ - master
10
+ before_install:
11
+ - gem install bundler -v 1.17.3
12
+ - export TOKEN_V2=TEST_TOKEN
13
+ script:
14
+ - bundle exec rspec
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tpgunther@uc.cl. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in notion_rb.gemspec
6
+ gemspec
@@ -0,0 +1,115 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ notion_rb (0.1.0)
5
+ mechanize
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.0.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ zeitwerk (~> 2.2)
16
+ addressable (2.7.0)
17
+ public_suffix (>= 2.0.2, < 5.0)
18
+ ast (2.4.0)
19
+ byebug (11.0.1)
20
+ concurrent-ruby (1.1.5)
21
+ connection_pool (2.2.2)
22
+ crack (0.4.3)
23
+ safe_yaml (~> 1.0.0)
24
+ diff-lcs (1.3)
25
+ domain_name (0.5.20190701)
26
+ unf (>= 0.0.5, < 1.0.0)
27
+ factory_bot (5.1.1)
28
+ activesupport (>= 4.2.0)
29
+ hashdiff (1.0.0)
30
+ http-cookie (1.0.3)
31
+ domain_name (~> 0.5)
32
+ i18n (1.7.0)
33
+ concurrent-ruby (~> 1.0)
34
+ jaro_winkler (1.5.4)
35
+ mechanize (2.7.6)
36
+ domain_name (~> 0.5, >= 0.5.1)
37
+ http-cookie (~> 1.0)
38
+ mime-types (>= 1.17.2)
39
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
40
+ net-http-persistent (>= 2.5.2)
41
+ nokogiri (~> 1.6)
42
+ ntlm-http (~> 0.1, >= 0.1.1)
43
+ webrobots (>= 0.0.9, < 0.2)
44
+ mime-types (3.3)
45
+ mime-types-data (~> 3.2015)
46
+ mime-types-data (3.2019.1009)
47
+ mini_portile2 (2.4.0)
48
+ minitest (5.13.0)
49
+ net-http-digest_auth (1.4.1)
50
+ net-http-persistent (3.1.0)
51
+ connection_pool (~> 2.2)
52
+ nokogiri (1.10.7)
53
+ mini_portile2 (~> 2.4.0)
54
+ ntlm-http (0.1.1)
55
+ parallel (1.19.1)
56
+ parser (2.6.5.0)
57
+ ast (~> 2.4.0)
58
+ public_suffix (4.0.1)
59
+ rainbow (3.0.0)
60
+ rake (10.5.0)
61
+ rspec (3.9.0)
62
+ rspec-core (~> 3.9.0)
63
+ rspec-expectations (~> 3.9.0)
64
+ rspec-mocks (~> 3.9.0)
65
+ rspec-core (3.9.0)
66
+ rspec-support (~> 3.9.0)
67
+ rspec-expectations (3.9.0)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.9.0)
70
+ rspec-mocks (3.9.0)
71
+ diff-lcs (>= 1.2.0, < 2.0)
72
+ rspec-support (~> 3.9.0)
73
+ rspec-support (3.9.0)
74
+ rubocop (0.77.0)
75
+ jaro_winkler (~> 1.5.1)
76
+ parallel (~> 1.10)
77
+ parser (>= 2.6)
78
+ rainbow (>= 2.2.2, < 4.0)
79
+ ruby-progressbar (~> 1.7)
80
+ unicode-display_width (>= 1.4.0, < 1.7)
81
+ ruby-progressbar (1.10.1)
82
+ safe_yaml (1.0.5)
83
+ single_cov (1.3.2)
84
+ thread_safe (0.3.6)
85
+ tzinfo (1.2.5)
86
+ thread_safe (~> 0.1)
87
+ unf (0.1.4)
88
+ unf_ext
89
+ unf_ext (0.0.7.6)
90
+ unicode-display_width (1.6.0)
91
+ vcr (5.0.0)
92
+ webmock (3.7.6)
93
+ addressable (>= 2.3.6)
94
+ crack (>= 0.3.2)
95
+ hashdiff (>= 0.4.0, < 2.0.0)
96
+ webrobots (0.1.2)
97
+ zeitwerk (2.2.2)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ bundler (~> 1.17.0)
104
+ byebug
105
+ factory_bot
106
+ notion_rb!
107
+ rake (~> 10.0)
108
+ rspec (~> 3.0)
109
+ rubocop
110
+ single_cov
111
+ vcr
112
+ webmock
113
+
114
+ BUNDLED WITH
115
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Tomas Gunther
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,92 @@
1
+ ## Description
2
+
3
+ Unofficial Ruby Client for Notion.so API v3. Based on https://github.com/jamalex/notion-py
4
+
5
+ This is a early version, some functionality is not developed yet
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'notion_rb'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install notion_rb
22
+
23
+ ## Usage
24
+
25
+ ### Basic
26
+
27
+ ```ruby
28
+ # Obtain the `token_v2` value by inspecting your browser cookies on a logged-in session on Notion.so
29
+ ENV['TOKEN_V2'] = '<some token>'
30
+
31
+ # Get the block
32
+ block = NotionRb::Block.new('https://www.notion.so/some_org/some-title-30d7f6e4c2284cbab860a6f40ed3372e')
33
+
34
+ # Some title
35
+ block.title
36
+
37
+ # It changes on real time on Notion
38
+ block.title = "A better title"
39
+ ```
40
+
41
+ ### Children
42
+
43
+ ```ruby
44
+ # Gets children of the current block
45
+ block.children
46
+
47
+ # Creates and returns a new empty child block
48
+ block.create_child
49
+ ```
50
+
51
+ ### Delete and restore
52
+
53
+ ```ruby
54
+ # Soft delete the current block
55
+ block.destroy
56
+
57
+ # Restores the block
58
+ block.restore
59
+ ```
60
+
61
+ ### Metadata
62
+
63
+ ```ruby
64
+ # Get the block metadata, for example a code block
65
+ block.metadata
66
+ # {
67
+ # properties: { 'language' => [['ruby']], 'title' => [['Code']] },
68
+ # language: value['properties']['language'][0][0]
69
+ # }
70
+
71
+ # if the object is a row from a collection
72
+ block.metadata
73
+ # {:color=>"black", :block_color=>"white", "Tags"=>"new tag", "Name"=>"A new name"}
74
+ ```
75
+
76
+ ## Development
77
+
78
+ Run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
79
+
80
+ 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).
81
+
82
+ ## Contributing
83
+
84
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tpgunther/notion_rb. 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.
85
+
86
+ ## License
87
+
88
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
89
+
90
+ ## Code of Conduct
91
+
92
+ Everyone interacting in the NotionRb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tpgunther/notion_rb/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'notion_rb'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require 'mechanize'
3
+ require 'json'
4
+
5
+ require 'notion_rb/version'
6
+
7
+ require 'notion_rb/api/base'
8
+ require 'notion_rb/api/create'
9
+ require 'notion_rb/api/destroy'
10
+ require 'notion_rb/api/get'
11
+ require 'notion_rb/api/query_collection'
12
+ require 'notion_rb/api/restore'
13
+ require 'notion_rb/api/update'
14
+
15
+ require 'notion_rb/utils/block_cache'
16
+ require 'notion_rb/utils/types'
17
+ require 'notion_rb/utils/converter'
18
+ require 'notion_rb/utils/parser'
19
+ require 'notion_rb/utils/uuid_validator'
20
+
21
+ require 'notion_rb/block'
22
+
23
+ module NotionRb
24
+ def self.config
25
+ @config ||= {}
26
+ end
27
+
28
+ def self.configure
29
+ yield(config)
30
+ end
31
+ end