growi-client 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac56c4422e6572699058511873cfed8cf01f01fc15b688e4aa13bd8a19fb4592
4
+ data.tar.gz: 0eb97e2e86c0ec4fe870ff56e14fe2cf965d5a6d82314bd53465232412c5b9dc
5
+ SHA512:
6
+ metadata.gz: ee9245bcda0307298726bda847805cf25b4f02c69e5304f4e7709c2f4142ed52401d118260ebcffeee3a01efb805a51b2da0cbf699e4961f3f607df4f935ee1a
7
+ data.tar.gz: 74c8108b80b7623f9494d224ada9404bc4671213bee37ad3679fe3689796c18ca50a9ed1a86ca4bc7fd88d4c9d4efc61abb6a004ff150c40883cf55004684835
@@ -0,0 +1,53 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ Gemfile.lock
46
+ .ruby-version
47
+ .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ # RSpec
53
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.15.4
@@ -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 tatsurou313@gmail.com. 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
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in growi-client.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 ryu-sato
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 TODO: Ryu Sato <ryu@weseek.co.jp>
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,221 @@
1
+ [![wercker status](https://app.wercker.com/status/837aadfe3b9e25cf5aacd36ae2bdc6a4/s/master "wercker status")](https://app.wercker.com/project/byKey/837aadfe3b9e25cf5aacd36ae2bdc6a4)
2
+
3
+ # growi-client -- client of growi with use API
4
+
5
+ A client of growi with use API.
6
+
7
+ ## Compatibility
8
+
9
+ growi-client is passed the test of these Growi versions.
10
+
11
+ |growi-client|Growi|
12
+ | --- | --- |
13
+ |0.9.0|3.1.12|
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'growi-client'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install growi-client
30
+
31
+ ## Usage
32
+
33
+ Export these environments.
34
+
35
+ ```
36
+ export GROWI_ACCESS_TOKEN=0123456789abcdef0123456789abcdef0123456789ab
37
+ export GROWI_URL=http://localhost:3000/
38
+ ```
39
+
40
+ ```ruby
41
+ require 'growi-client'
42
+
43
+ growi_client = GrowiClient.new(growi_url: ENV['GROWI_URL'], access_token: ENV['GROWI_ACCESS_TOKEN'])
44
+
45
+ p growi_client.page_exist?( path_exp: '/' )
46
+ p growi_client.attachment_exist?( path_exp: '/', attachment_name: 'LICENSE.txt' )
47
+ ```
48
+
49
+ ## Examples
50
+
51
+ ```ruby
52
+ # get page's ID
53
+ p growi_client.page_id( path_exp: '/' )
54
+ ```
55
+
56
+ ```ruby
57
+ # Check existence of page by page path (you can use regular expression)
58
+ growi_client.page_exist?( path_exp: '/' )
59
+ ```
60
+
61
+ ```ruby
62
+ # Check existence of attachment by file name of attachment
63
+ growi_client.attachment_exist?( path_exp: '/', attachment_name: 'LICENSE.txt' )
64
+ ```
65
+
66
+ ```ruby
67
+ # get attachment's ID
68
+ p growi_client.attachment_id( path_exp: '/', attachment_name: 'LICENSE.txt' )
69
+ ```
70
+
71
+ ```ruby
72
+ # get attachment (return data is object of GrowiAttachment)
73
+ p growi_client.attachment( path_exp: '/', attachment_name: 'LICENSE.txt' )
74
+ ```
75
+
76
+ ```ruby
77
+ # pages list
78
+ req = GApiRequestPagesList.new path_exp: '/'
79
+ p growi_client.request(req)
80
+ ```
81
+
82
+ ```ruby
83
+ # pages get - path_exp
84
+ req = GApiRequestPagesList.new path_exp: '/'
85
+ p growi_client.request(req)
86
+ ```
87
+
88
+ ```ruby
89
+ # pages get - page_id
90
+ req = GApiRequestPagesGet.new page_id: growi_client.page_id(path_exp: '/')
91
+ p growi_client.request(req)
92
+ ```
93
+
94
+ ```ruby
95
+ # pages get - revision_id
96
+ reqtmp = GApiRequestPagesList.new path_exp: '/'
97
+ ret = growi_client.request(reqtmp)
98
+ path = ret.data[0].path
99
+ revision_id = ret.data[0].revision._id
100
+ req = GApiRequestPagesGet.new path: path, revision_id: revision_id
101
+ p growi_client.request(req)
102
+ ```
103
+
104
+ ```ruby
105
+ # pages create
106
+ test_page_path = '/tmp/growi-client test page'
107
+ body = "# growi-client\n"
108
+ req = GApiRequestPagesCreate.new path: test_page_path,
109
+ body: body
110
+ p growi_client.request(req)
111
+ ```
112
+
113
+ ```ruby
114
+ # pages update
115
+ test_page_path = '/tmp/growi-client test page'
116
+ test_cases = [nil, GrowiPage::GRANT_PUBLIC, GrowiPage::GRANT_RESTRICTED,
117
+ GrowiPage::GRANT_SPECIFIED, GrowiPage::GRANT_OWNER]
118
+ page_id = growi_client.page_id(path_exp: test_page_path)
119
+
120
+ body = "# growi-client\n"
121
+ test_cases.each do |grant|
122
+ body = body + grant.to_s
123
+ req = GApiRequestPagesUpdate.new page_id: page_id,
124
+ body: body, grant: grant
125
+ p growi_client.request(req)
126
+ end
127
+ ```
128
+
129
+ ```ruby
130
+ # pages seen
131
+ page_id = growi_client.page_id(path_exp: '/')
132
+ req = GApiRequestPagesSeen.new page_id: page_id
133
+ p growi_client.request(req)
134
+ ```
135
+
136
+ ```ruby
137
+ # likes add
138
+ test_page_path = '/tmp/growi-client test page'
139
+ page_id = growi_client.page_id(path_exp: test_page_path)
140
+ req = GApiRequestLikesAdd.new page_id: page_id
141
+ p growi_client.request(req)
142
+ ```
143
+
144
+ ```ruby
145
+ # likes remove
146
+ test_page_path = '/tmp/growi-client test page'
147
+ page_id = growi_client.page_id(path_exp: test_page_path)
148
+ req = GApiRequestLikesRemove.new page_id: page_id
149
+ p growi_client.request(req)
150
+ ```
151
+
152
+ ```ruby
153
+ # update post
154
+ test_page_path = '/tmp/growi-client test page'
155
+ req = GApiRequestPagesUpdatePost.new path: test_page_path
156
+ p growi_client.request(req)
157
+ ```
158
+
159
+
160
+ ```ruby
161
+ # attachments list
162
+ test_page_path = '/tmp/growi-client test page'
163
+ page_id = growi_client.page_id(path_exp: test_page_path)
164
+ req = GApiRequestAttachmentsList.new page_id: page_id
165
+ p growi_client.request(req)
166
+ ```
167
+
168
+ ```ruby
169
+ # attachments add
170
+ test_page_path = '/tmp/growi-client test page'
171
+ page_id = growi_client.page_id(path_exp: test_page_path)
172
+ req = GApiRequestAttachmentsAdd.new page_id: page_id,
173
+ file: File.new('LICENSE.txt')
174
+ p growi_client.request(req)
175
+ ```
176
+
177
+ ```ruby
178
+ # attachments remove
179
+ test_page_path = '/tmp/growi-client test page'
180
+ page_id = growi_client.page_id(path_exp: test_page_path)
181
+ reqtmp = GApiRequestAttachmentsList.new page_id: page_id
182
+ ret = growi_client.request(reqtmp)
183
+ attachment_id = ret.data[0]._id
184
+ req = GApiRequestAttachmentsRemove.new attachment_id: attachment_id
185
+ p growi_client.request(req)
186
+ ```
187
+
188
+ ### Basic Authentication
189
+
190
+ ```ruby
191
+ require 'growi-client'
192
+
193
+ # Create growiclient instance with username and password that is used by basic authentication
194
+ growi_client = GrowiClient.new(growi_url: ENV['GROWI_URL'], access_token: ENV['GROWI_ACCESS_TOKEN'],
195
+ rest_client_param: { user: 'who', password: 'bar'})
196
+
197
+ # Check existence of page
198
+ p growi_client.page_exist?( path_exp: '/' ) ? '/ exist' : '/ not exist'
199
+
200
+ # Create page whose path is '/tmp'
201
+ req = GApiRequestPagesCreate.new path: '/tmp', body: 'tmp'
202
+ p growi_client.request(req)
203
+ ```
204
+
205
+ ## Development
206
+
207
+ 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.
208
+
209
+ 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).
210
+
211
+ ## Contributing
212
+
213
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ryu-sato/growi-client. 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.
214
+
215
+ ## License
216
+
217
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
218
+
219
+ ## Code of Conduct
220
+
221
+ Everyone interacting in the Growi::Client project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ryu-satgrowiwi-client/blob/master/CODE_OF_CONDUCT.md).
@@ -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 "growi-client"
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__)
@@ -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