teratail-sdk-ruby 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
+ SHA1:
3
+ metadata.gz: 0962e9367338022be3a444cea54aaae00cd5e9c2
4
+ data.tar.gz: 7725e64d85bdfd6c74566c132f2a014c3658dd49
5
+ SHA512:
6
+ metadata.gz: b59faf843022558d0a8240051e292ef57f7fcaf7964b83944a68046d3ab190b01ce4558a852e0e33c2462c8290cb74fb0d3080d57410ff87e988685a720a5d05
7
+ data.tar.gz: 9fd7de6ae0d9f96c20d3cd4dec76afc27c7af82752f13832dedf3c11cbd0d3b4bd2b5bb0d417286b40d84fff26ab25b57bef4264e4b81ca28370fa6bf7d8afaf
@@ -0,0 +1,52 @@
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
+ vender
52
+ test_config.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -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 yo.hira.dev@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,8 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rspec'
8
+ end
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ teratail-sdk-ruby (0.1.0)
5
+ rest-client (~> 2.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.3.0)
11
+ diff-lcs (1.2.5)
12
+ domain_name (0.5.20161021)
13
+ unf (>= 0.0.5, < 1.0.0)
14
+ http-cookie (1.0.3)
15
+ domain_name (~> 0.5)
16
+ mime-types (3.1)
17
+ mime-types-data (~> 3.2015)
18
+ mime-types-data (3.2016.0521)
19
+ netrc (0.11.0)
20
+ parser (2.3.2.0)
21
+ ast (~> 2.2)
22
+ powerpack (0.1.1)
23
+ rainbow (2.1.0)
24
+ rake (10.4.2)
25
+ rest-client (2.0.0)
26
+ http-cookie (>= 1.0.2, < 2.0)
27
+ mime-types (>= 1.16, < 4.0)
28
+ netrc (~> 0.8)
29
+ rspec (3.5.0)
30
+ rspec-core (~> 3.5.0)
31
+ rspec-expectations (~> 3.5.0)
32
+ rspec-mocks (~> 3.5.0)
33
+ rspec-core (3.5.4)
34
+ rspec-support (~> 3.5.0)
35
+ rspec-expectations (3.5.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.5.0)
38
+ rspec-mocks (3.5.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.5.0)
41
+ rspec-support (3.5.0)
42
+ rubocop (0.45.0)
43
+ parser (>= 2.3.1.1, < 3.0)
44
+ powerpack (~> 0.1)
45
+ rainbow (>= 1.99.1, < 3.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (~> 1.0, >= 1.0.1)
48
+ ruby-progressbar (1.8.1)
49
+ unf (0.1.4)
50
+ unf_ext
51
+ unf_ext (0.0.7.2)
52
+ unicode-display_width (1.1.1)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ bundler (~> 1.13)
59
+ rake (~> 10.0)
60
+ rspec
61
+ rubocop (~> 0.45.0)
62
+ teratail-sdk-ruby!
63
+
64
+ BUNDLED WITH
65
+ 1.13.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 yukito ohira
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,2 @@
1
+ # teratail-sdk-ruby
2
+ teratail-sdk-ruby
@@ -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,15 @@
1
+ module ApiClientHelper
2
+ def make_request_parameter(page, limit)
3
+ "?page=#{page}&limit=#{limit}"
4
+ end
5
+
6
+ def make_request_header(access_token)
7
+ if access_token != ''
8
+ {
9
+ 'Authorization' => "Bearer #{access_token}"
10
+ }
11
+ else
12
+ {}
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ teratail:
2
+ host: https://teratail.com/api/v1/
3
+
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+ require 'yaml'
4
+ require './lib/teratail/common/api_client_helper.rb'
5
+
6
+ class QuestionService
7
+ include ApiClientHelper
8
+ def initialize(access_token = '')
9
+ @access_token = access_token
10
+ @config = YAML.load_file('./lib/teratail/config.yml')
11
+ end
12
+
13
+ def find_all(page = 1, limit = 20)
14
+ path = "#{@config['teratail']['host']}questions#{make_request_parameter(page, limit)}"
15
+ response = RestClient.get(path, make_request_header(@access_token))
16
+ JSON.parse response.to_s
17
+ end
18
+
19
+ def find_one(question_id)
20
+ path = "#{@config['teratail']['host']}questions/#{question_id}"
21
+ response = RestClient.get(path, make_request_header(@access_token))
22
+ JSON.parse response.to_s
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+ require 'yaml'
4
+ require './lib/teratail/common/api_client_helper.rb'
5
+
6
+ class TagService
7
+ include ApiClientHelper
8
+
9
+ def initialize(access_token = '')
10
+ @access_token = access_token
11
+ @config = YAML.load_file('./lib/teratail/config.yml')
12
+ end
13
+
14
+ def find_all(page = 1, limit = 20)
15
+ path = "#{@config['teratail']['host']}tags#{make_request_parameter(page, limit)}"
16
+ response = RestClient.get(path, make_request_header(@access_token))
17
+ JSON.parse response.to_s
18
+ end
19
+
20
+ def find_one(tag_name)
21
+ path = "#{@config['teratail']['host']}tags/#{tag_name}"
22
+ response = RestClient.get(path, make_request_header(@access_token))
23
+ JSON.parse response.to_s
24
+ end
25
+
26
+ def find_by_tag_name(tag_name, page = 1, limit = 20)
27
+ path = "#{@config['teratail']['host']}tags/#{tag_name}/questions#{make_request_parameter(page, limit)}"
28
+ response = RestClient.get(path, make_request_header(@access_token))
29
+ JSON.parse response.to_s
30
+ end
31
+ end
@@ -0,0 +1,66 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+ require 'yaml'
4
+ require './lib/teratail/common/api_client_helper.rb'
5
+
6
+ class UserService
7
+ include ApiClientHelper
8
+ def initialize(access_token = '')
9
+ @access_token = access_token
10
+ @config = YAML.load_file('./lib/teratail/config.yml')
11
+ end
12
+
13
+ def find_all(page = 1, limit = 20)
14
+ path = "#{@config['teratail']['host']}users#{make_request_parameter(page, limit)}"
15
+ response = RestClient.get(path, make_request_header(@access_token))
16
+ JSON.parse response.to_s
17
+ end
18
+
19
+ def find_by_name(query, page = 1, limit = 20)
20
+ path = "#{@config['teratail']['host']}users/search#{make_request_parameter(page, limit)}&q=#{query}"
21
+ response = RestClient.get(path, make_request_header(@access_token))
22
+ JSON.parse response.to_s
23
+ end
24
+
25
+ def find_one(display_name)
26
+ path = "#{@config['teratail']['host']}users/#{display_name}"
27
+ response = RestClient.get(path, make_request_header(@access_token))
28
+ JSON.parse response.to_s
29
+ end
30
+
31
+ def find_my_tags(display_name, page = 1, limit = 20)
32
+ path = "#{@config['teratail']['host']}users/#{display_name}/tags#{make_request_parameter(page, limit)}"
33
+ response = RestClient.get(path, make_request_header(@access_token))
34
+ JSON.parse response.to_s
35
+ end
36
+
37
+ def find_clipped_question(display_name, page = 1, limit = 20)
38
+ path = "#{@config['teratail']['host']}users/#{display_name}/clips#{make_request_parameter(page, limit)}"
39
+ response = RestClient.get(path, make_request_header(@access_token))
40
+ JSON.parse response.to_s
41
+ end
42
+
43
+ def find_questions(display_name, page = 1, limit = 20)
44
+ path = "#{@config['teratail']['host']}users/#{display_name}/questions#{make_request_parameter(page, limit)}"
45
+ response = RestClient.get(path, make_request_header(@access_token))
46
+ JSON.parse response.to_s
47
+ end
48
+
49
+ def find_replies(display_name, page = 1, limit = 20)
50
+ path = "#{@config['teratail']['host']}users/#{display_name}/replies#{make_request_parameter(page, limit)}"
51
+ response = RestClient.get(path, make_request_header(@access_token))
52
+ JSON.parse response.to_s
53
+ end
54
+
55
+ def get_follower(display_name, page = 1, limit = 20)
56
+ path = "#{@config['teratail']['host']}users/#{display_name}/followers#{make_request_parameter(page, limit)}"
57
+ response = RestClient.get(path, make_request_header(@access_token))
58
+ JSON.parse response.to_s
59
+ end
60
+
61
+ def get_following(display_name, page = 1, limit = 20)
62
+ path = "#{@config['teratail']['host']}users/#{display_name}/followings#{make_request_parameter(page, limit)}"
63
+ response = RestClient.get(path, make_request_header(@access_token))
64
+ JSON.parse response.to_s
65
+ end
66
+ end
@@ -0,0 +1,23 @@
1
+ require './lib/teratail/service/question_service.rb'
2
+ require './lib/teratail/service/tag_service.rb'
3
+ require './lib/teratail/service/user_service.rb'
4
+
5
+ class Teratail
6
+ def initialize(access_token)
7
+ @question_service = QuestionService.new(access_token)
8
+ @tag_service = TagService.new(access_token)
9
+ @user_service = UserService.new(access_token)
10
+ end
11
+
12
+ def question
13
+ @question_service
14
+ end
15
+
16
+ def tag
17
+ @tag_service
18
+ end
19
+
20
+ def user
21
+ @user_service
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module TeratailSdkRuby
2
+ VERSION = "0.1.0"
3
+ end
data/setup ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ bundle install --path vender/bundle
3
+
@@ -0,0 +1,3 @@
1
+ module TeratailSdkRuby
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'teratail/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "teratail-sdk-ruby"
8
+ spec.version = TeratailSdkRuby::VERSION
9
+ spec.authors = ["yohira0616"]
10
+ spec.email = ["yukito.sys.so@gmail.com"]
11
+
12
+ spec.summary = %q{Programming Q&A Web Service Teratail(https://teratail.com/) SDK for ruby}
13
+ spec.description = %q{Programming Q&A Web Service Teratail(https://teratail.com/) SDK for ruby}
14
+ spec.homepage = "https://github.com/yohira0616/teratail-sdk-ruby"
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'] = "TODO: Set to 'http://mygemserver.com'"
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.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "rubocop","~> 0.45.0"
37
+ spec.add_runtime_dependency "rest-client", "~> 2.0.0"
38
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teratail-sdk-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - yohira0616
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-22 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.45.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.45.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.0
83
+ description: Programming Q&A Web Service Teratail(https://teratail.com/) SDK for ruby
84
+ email:
85
+ - yukito.sys.so@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - CODE_OF_CONDUCT.md
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - lib/teratail/common/api_client_helper.rb
99
+ - lib/teratail/config.yml
100
+ - lib/teratail/service/question_service.rb
101
+ - lib/teratail/service/tag_service.rb
102
+ - lib/teratail/service/user_service.rb
103
+ - lib/teratail/teratail.rb
104
+ - lib/teratail/version.rb
105
+ - setup
106
+ - src/teratail/version.rb
107
+ - teratail-sdk-ruby.gemspec
108
+ homepage: https://github.com/yohira0616/teratail-sdk-ruby
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Programming Q&A Web Service Teratail(https://teratail.com/) SDK for ruby
132
+ test_files: []