crowi-client 0.1.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: 8056b8c63125de9e148e4dccc412fe10955dae96c0fd9560516259890895667a
4
+ data.tar.gz: 6b2b35608ded3dd75ba28720fe30667105c6dae9eb46a018924f6c9ba74f382c
5
+ SHA512:
6
+ metadata.gz: 7203510c3b681e0e159b2a40be38a16f760ca72f166e4438f40814b2916605c1f76042c62c5f5ae60832643d682b67ce533c3e46231e2a9391c901b962a58579
7
+ data.tar.gz: 26b3470383d8c2f2d201bc54328b0d750695bc87dab3d04f94ecf4925e539d457ff6c23a91577ad7f432f62d3f385d440b4864dc75ef1e1f901bdb39e5bf8b17
@@ -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 crowi-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,195 @@
1
+ # crowi-client -- client of crowi with use API
2
+
3
+ A client of crowi with use API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'crowi-client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install crowi-client
20
+
21
+ ## Usage
22
+
23
+ At first, you need to create setting file ```config/settings.yml``` in your application directory.
24
+ And set token key of crowi API, and URL of crowi (ex. http://localhost:3000) in ```settings.yml```.
25
+
26
+ ```YAML
27
+ # Example of config/settings.yml. YOU NEED TO REPLACE token!!!
28
+ token: xEKAueUZDrQlr30iFZr96ti3GUd8sqP/pTkS3DGrwcc=
29
+ url: http://localhost:3000/
30
+ ```
31
+
32
+ Then, you can use crowi client with ```require 'crowi-client'```.
33
+
34
+ ```ruby
35
+ require 'crowi-client'
36
+ puts CrowiClient.instance.page_exist?( path_exp: '/' )
37
+ puts CrowiClient.instance.attachment_exist?( path_exp: '/', attachment_name: 'LICENSE.txt' )
38
+ ```
39
+
40
+ ## Examples
41
+
42
+ ```ruby
43
+ # get page's ID
44
+ puts CrowiClient.instance.page_id( path_exp: '/' )
45
+ ```
46
+
47
+ ```ruby
48
+ # Check existence of page by page path (you can use regular expression)
49
+ CrowiClient.instance.page_exist?( path_exp: '/' )
50
+ ```
51
+
52
+ ```ruby
53
+ # Check existence of attachment by file name of attachment
54
+ CrowiClient.instance.attachment_exist?( path_exp: '/', attachment_name: 'LICENSE.txt' )
55
+ ```
56
+
57
+ ```ruby
58
+ # get attachment's ID
59
+ puts CrowiClient.instance.attachment_id( path_exp: '/', attachment_name: 'LICENSE.txt' )
60
+ ```
61
+
62
+ ```ruby
63
+ # get attachment (return data is object of CrowiAttachment)
64
+ puts CrowiClient.instance.attachment( path_exp: '/', attachment_name: 'LICENSE.txt' )
65
+ ```
66
+
67
+ ```ruby
68
+ # pages list
69
+ req = CPApiRequestPagesList.new path_exp: '/'
70
+ puts CrowiClient.instance.request(req)
71
+ ```
72
+
73
+ ```ruby
74
+ # pages get - path_exp
75
+ req = CPApiRequestPagesList.new path_exp: '/'
76
+ puts CrowiClient.instance.request(req)
77
+ ```
78
+
79
+ ```ruby
80
+ # pages get - page_id
81
+ req = CPApiRequestPagesGet.new page_id: CrowiClient.instance.page_id(path: '/')
82
+ puts CrowiClient.instance.request(req)
83
+ ```
84
+
85
+ ```ruby
86
+ # pages get - revision_id
87
+ reqtmp = CPApiRequestPagesList.new path_exp: '/'
88
+ ret = CrowiClient.instance.request(reqtmp)
89
+ path = ret.data[0].path
90
+ revision_id = ret.data[0].revision._id
91
+ req = CPApiRequestPagesGet.new path: path, revision_id: revision_id
92
+ puts CrowiClient.instance.request(req)
93
+ ```
94
+
95
+ ```ruby
96
+ # pages create
97
+ test_page_path = '/tmp/crowi-client test page'
98
+ body = "# crowi-client\n"
99
+ req = CPApiRequestPagesCreate.new path: test_page_path,
100
+ body: body
101
+ puts CrowiClient.instance.request(req)
102
+ ```
103
+
104
+ ```ruby
105
+ # pages update
106
+ test_page_path = '/tmp/crowi-client test page'
107
+ test_cases = [nil, CrowiPage::GRANT_PUBLIC, CrowiPage::GRANT_RESTRICTED,
108
+ CrowiPage::GRANT_SPECIFIED, CrowiPage::GRANT_OWNER]
109
+ page_id = CrowiClient.instance.page_id(path: test_page_path)
110
+
111
+ body = "# crowi-client\n"
112
+ test_cases.each do |grant|
113
+ body = body + grant.to_s
114
+ req = CPApiRequestPagesUpdate.new page_id: page_id,
115
+ body: body, grant: grant
116
+ puts CrowiClient.instance.request(req)
117
+ end
118
+ ```
119
+
120
+ ```ruby
121
+ # pages seen
122
+ page_id = CrowiClient.instance.page_id(path: '/')
123
+ req = CPApiRequestPagesSeen.new page_id: page_id
124
+ puts CrowiClient.instance.request(req)
125
+ ```
126
+
127
+ ```ruby
128
+ # likes add
129
+ test_page_path = '/tmp/crowi-client test page'
130
+ page_id = CrowiClient.instance.page_id(path: test_page_path)
131
+ req = CPApiRequestLikesAdd.new page_id: page_id
132
+ puts CrowiClient.instance.request(req)
133
+ ```
134
+
135
+ ```ruby
136
+ # likes remove
137
+ test_page_path = '/tmp/crowi-client test page'
138
+ page_id = CrowiClient.instance.page_id(path: test_page_path)
139
+ req = CPApiRequestLikesRemove.new page_id: page_id
140
+ puts CrowiClient.instance.request(req)
141
+ ```
142
+
143
+ ```ruby
144
+ # update post
145
+ test_page_path = '/tmp/crowi-client test page'
146
+ req = CPApiRequestPagesUpdatePost.new path: test_page_path
147
+ puts CrowiClient.instance.request(req)
148
+ ```
149
+
150
+
151
+ ```ruby
152
+ # attachments list
153
+ test_page_path = '/tmp/crowi-client test page'
154
+ page_id = CrowiClient.instance.page_id(path: test_page_path)
155
+ req = CPApiRequestAttachmentsList.new page_id: page_id
156
+ puts CrowiClient.instance.request(req)
157
+ ```
158
+
159
+ ```ruby
160
+ # attachments add
161
+ test_page_path = '/tmp/crowi-client test page'
162
+ page_id = CrowiClient.instance.page_id(path: test_page_path)
163
+ req = CPApiRequestAttachmentsAdd.new page_id: page_id,
164
+ file: File.new('LICENSE.txt')
165
+ puts CrowiClient.instance.request(req)
166
+ ```
167
+
168
+ ```ruby
169
+ # attachments remove
170
+ test_page_path = '/tmp/crowi-client test page'
171
+ page_id = CrowiClient.instance.page_id(path: test_page_path)
172
+ reqtmp = CPApiRequestAttachmentsList.new page_id: page_id
173
+ ret = CrowiClient.instance.request(reqtmp)
174
+ attachment_id = ret.data[0]._id
175
+ req = CPApiRequestAttachmentsRemove.new attachment_id: attachment_id
176
+ puts CrowiClient.instance.request(req)
177
+ ```
178
+
179
+ ## Development
180
+
181
+ 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.
182
+
183
+ 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).
184
+
185
+ ## Contributing
186
+
187
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ryu-sato/crowi-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.
188
+
189
+ ## License
190
+
191
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
192
+
193
+ ## Code of Conduct
194
+
195
+ Everyone interacting in the Crowi::Client project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ryu-sato/crowi-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 "crowi-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
@@ -0,0 +1,2 @@
1
+ url: http://localhost:3000/
2
+ token: 9MFP98pB81xFI/4EuBzoYgIGZvno5QT3kcgSB3oEuHE=
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "crowi/client/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "crowi-client"
8
+ spec.version = Crowi::Client::VERSION
9
+ spec.authors = ["Ryu Sato"]
10
+ spec.email = ["ryu@weseek.co.jp"]
11
+
12
+ spec.summary = %q{Client of crowi}
13
+ spec.description = %q{crowi-client is client of crowi with use API.}
14
+ spec.homepage = "https://github.com/ryu-sato/crowi-client"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ #spec.metadata["allowed_push_host"] = "http://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.15"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "rspec-json_matcher", "~> 0.1"
37
+ spec.add_development_dependency "rest-client", "~> 2.0"
38
+ spec.add_development_dependency "json", "~> 2.1"
39
+ spec.add_development_dependency "easy_settings", "~> 0.1"
40
+ end