hackernews_api_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +13 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +5 -0
  6. data/CODE_OF_CONDUCT.md +84 -0
  7. data/Gemfile +14 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +43 -0
  10. data/Rakefile +37 -0
  11. data/Steepfile +27 -0
  12. data/lib/hackernews_api_client/client.rb +7 -0
  13. data/lib/hackernews_api_client/end_points/get_item.rb +11 -0
  14. data/lib/hackernews_api_client/end_points/top_stories.rb +11 -0
  15. data/lib/hackernews_api_client/end_points.rb +6 -0
  16. data/lib/hackernews_api_client/faraday/connection.rb +28 -0
  17. data/lib/hackernews_api_client/faraday/request.rb +13 -0
  18. data/lib/hackernews_api_client/logger.rb +13 -0
  19. data/lib/hackernews_api_client/requests/get_item.rb +16 -0
  20. data/lib/hackernews_api_client/requests/top_stories.rb +15 -0
  21. data/lib/hackernews_api_client/responses/get_item.rb +15 -0
  22. data/lib/hackernews_api_client/responses/top_stories.rb +15 -0
  23. data/lib/hackernews_api_client/version.rb +5 -0
  24. data/lib/hackernews_api_client.rb +21 -0
  25. data/rbs_collection.lock.yaml +129 -0
  26. data/rbs_collection.yaml +21 -0
  27. data/sig/end_points/get_item.rbs +13 -0
  28. data/sig/end_points/top_stories.rbs +13 -0
  29. data/sig/end_points.rbs +9 -0
  30. data/sig/faraday/connection.rbs +13 -0
  31. data/sig/faraday/request.rbs +13 -0
  32. data/sig/hackernews_api_client.rbs +5 -0
  33. data/sig/logger.rbs +10 -0
  34. data/sig/requests/get_item.rbs +13 -0
  35. data/sig/requests/top_stories.rbs +12 -0
  36. data/sig/responses/get_item.rbs +12 -0
  37. data/sig/responses/top_stories.rbs +12 -0
  38. metadata +96 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 31e9816fe7ea14643fb1195849947f6e13741cdc8c2730ecefdde7278f0ac084
4
+ data.tar.gz: d95b80c27543e7298759c5820ee9d5125fa9fb68f72212026328ef1a75650965
5
+ SHA512:
6
+ metadata.gz: 8c6f6af7378903af7077e0a2e63ef2c09a02f36762bd6e0bae096e4b7af2aa378cfd743ae18276a128a3435c981a3e34e208060b61d09050855613706552518f
7
+ data.tar.gz: c266ebbc184b6f00e542deaca32da488f1d9ea62262e683d2731590466acc7166c5b9cf61389212357726fde230563425a0a7acccc47bcaa03b7e323d14e6cc6
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-02-16
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at teitei.tk@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in hackernews_api_client.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
13
+
14
+ gem "steep", "~> 1.3"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 teitei-tk
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.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # HackernewsApiClient
2
+
3
+ This API Client made by Ruby is a client that uses the Hacker News API.
4
+
5
+ ## Installation
6
+
7
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
16
+
17
+ ## Usage
18
+
19
+ see: [https://hackernews.api-docs.io/v0/overview/introduction](https://hackernews.api-docs.io/v0/overview/introduction)
20
+
21
+ ```ruby
22
+ require "hackernews_api_client"
23
+
24
+ client = HackernewsApiClient::Client.new
25
+ req = HackernewsApiClient::Requests::TopStories.new
26
+ res = client.top_stories(req: req)
27
+ puts res.as_json
28
+ ```
29
+
30
+ ## Development
31
+
32
+ ```sh
33
+ $ bundle install
34
+ $ bundle exec rbs collection install
35
+ ```
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the HackernewsApiClient project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/hackernews_api_client/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,37 @@
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
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
13
+
14
+ task :timeline do
15
+ require "hackernews_api_client"
16
+
17
+ client = HackernewsApiClient::Client.new
18
+ req = HackernewsApiClient::Requests::TopStories.new
19
+ res = client.top_stories(req: req)
20
+
21
+ ret = res.as_json.map.with_index do |item_id, i|
22
+ item_req = HackernewsApiClient::Requests::GetItem.new(item_id: item_id)
23
+ item_res = client.get_item(req: item_req)
24
+ json = item_res.as_json
25
+
26
+ puts "---------------------------------"
27
+ puts "title: #{json[:title]}"
28
+ puts "url: #{json[:url]}"
29
+ puts "#{json[:score]} points, by #{json[:by]}, #{Time.at(json[:time]).to_s}"
30
+ puts "--------------------------------"
31
+
32
+ if i >= 30
33
+ break
34
+ end
35
+ end
36
+
37
+ end
data/Steepfile ADDED
@@ -0,0 +1,27 @@
1
+ # D = Steep::Diagnostic
2
+ #
3
+ target :lib do
4
+ signature "sig"
5
+
6
+ check "lib" # Directory name
7
+ collection_config "rbs_collection.yaml"
8
+ # check "Gemfile" # File name
9
+ # ignore "lib/templates/*.rb"
10
+
11
+ # library "pathname", "set" # Standard libraries
12
+ # library "strong_json" # Gems
13
+
14
+ # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
15
+ # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
16
+ # configure_code_diagnostics do |hash| # You can setup everything yourself
17
+ # hash[D::Ruby::NoMethod] = :information
18
+ # end
19
+ end
20
+
21
+ # target :test do
22
+ # signature "sig", "sig-private"
23
+ #
24
+ # check "test"
25
+ #
26
+ # # library "pathname", "set" # Standard libraries
27
+ # end
@@ -0,0 +1,7 @@
1
+ module HackernewsApiClient
2
+ class Client
3
+ include HackernewsApiClient::Faraday::Connection
4
+ include HackernewsApiClient::Faraday::Request
5
+ include HackernewsApiClient::EndPoints
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module HackernewsApiClient
2
+ module EndPoints
3
+ module GetItem
4
+ def get_item(req:)
5
+ ret = get(req.path)
6
+
7
+ HackernewsApiClient::Responses::GetItem.new(raw: ret)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module HackernewsApiClient
2
+ module EndPoints
3
+ module TopStories
4
+ def top_stories(req:)
5
+ ret = get(req.path)
6
+
7
+ HackernewsApiClient::Responses::TopStories.new(raw: ret)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module HackernewsApiClient
2
+ module EndPoints
3
+ include HackernewsApiClient::EndPoints::TopStories
4
+ include HackernewsApiClient::EndPoints::GetItem
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HackernewsApiClient
4
+ module Faraday
5
+ module Connection
6
+ private
7
+
8
+ def connection
9
+ @connection ||=
10
+ begin
11
+ options = {
12
+ headers: {
13
+ 'Accept' => 'application/json; charset=utf-8',
14
+ 'User-Agent' => "HackerNews Ruby Client/#{HackernewsApiClient::VERSION}"
15
+ }
16
+ }
17
+
18
+ url = "https://hacker-news.firebaseio.com"
19
+ ::Faraday.new(url, options) do |connection|
20
+ connection.request :url_encoded
21
+ connection.response :logger, HackernewsApiClient::Logger.default
22
+ connection.adapter ::Faraday.default_adapter
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HackernewsApiClient
4
+ module Faraday
5
+ module Request
6
+ def get(path, options = {})
7
+ connection.get do |req|
8
+ req.url(path, options)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require "logger"
2
+
3
+ module HackernewsApiClient
4
+ class Logger < ::Logger
5
+ def self.default
6
+ return @default if @default
7
+
8
+ logger = new STDOUT
9
+ logger.level = Logger::WARN
10
+ @default = logger
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module HackernewsApiClient
2
+ module Requests
3
+ class GetItem
4
+ attr_reader :item_id, :options
5
+
6
+ def initialize(item_id:, options: {})
7
+ @item_id = item_id
8
+ @options = options if options.empty? ? {} : options
9
+ end
10
+
11
+ def path
12
+ "/v0/item/#{@item_id}.json"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module HackernewsApiClient
2
+ module Requests
3
+ class TopStories
4
+ attr_reader :options
5
+
6
+ def initialize(options: {})
7
+ @options = options if options.empty? ? {} : options
8
+ end
9
+
10
+ def path
11
+ "/v0/topstories.json"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module HackernewsApiClient
2
+ module Responses
3
+ class GetItem
4
+ attr_reader :raw_response
5
+
6
+ def initialize(raw:)
7
+ @raw_response = raw
8
+ end
9
+
10
+ def as_json
11
+ JSON.parse(@raw_response.body, symbolize_names: true)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module HackernewsApiClient
2
+ module Responses
3
+ class TopStories
4
+ attr_reader :raw_response
5
+
6
+ def initialize(raw:)
7
+ @raw_response = raw
8
+ end
9
+
10
+ def as_json
11
+ JSON.parse(@raw_response.body, symbolize_names: true)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HackernewsApiClient
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ require_relative "hackernews_api_client/version"
6
+ require_relative "hackernews_api_client/logger"
7
+ require_relative "hackernews_api_client/requests/top_stories"
8
+ require_relative "hackernews_api_client/responses/top_stories"
9
+ require_relative "hackernews_api_client/requests/get_item"
10
+ require_relative "hackernews_api_client/responses/get_item"
11
+ require_relative "hackernews_api_client/faraday/connection"
12
+ require_relative "hackernews_api_client/faraday/request"
13
+ require_relative "hackernews_api_client/end_points/top_stories"
14
+ require_relative "hackernews_api_client/end_points/get_item"
15
+ require_relative "hackernews_api_client/end_points"
16
+ require_relative "hackernews_api_client/client"
17
+
18
+ module HackernewsApiClient
19
+ class Error < StandardError; end
20
+ # Your code goes here...
21
+ end
@@ -0,0 +1,129 @@
1
+ ---
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+ path: ".gem_rbs_collection"
8
+ gems:
9
+ - name: logger
10
+ version: '0'
11
+ source:
12
+ type: stdlib
13
+ - name: faraday
14
+ version: '2.5'
15
+ source:
16
+ type: git
17
+ name: ruby/gem_rbs_collection
18
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
19
+ remote: https://github.com/ruby/gem_rbs_collection.git
20
+ repo_dir: gems
21
+ - name: activesupport
22
+ version: '7.0'
23
+ source:
24
+ type: git
25
+ name: ruby/gem_rbs_collection
26
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
27
+ remote: https://github.com/ruby/gem_rbs_collection.git
28
+ repo_dir: gems
29
+ - name: ast
30
+ version: '2.4'
31
+ source:
32
+ type: git
33
+ name: ruby/gem_rbs_collection
34
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
35
+ remote: https://github.com/ruby/gem_rbs_collection.git
36
+ repo_dir: gems
37
+ - name: concurrent-ruby
38
+ version: '1.1'
39
+ source:
40
+ type: git
41
+ name: ruby/gem_rbs_collection
42
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
43
+ remote: https://github.com/ruby/gem_rbs_collection.git
44
+ repo_dir: gems
45
+ - name: csv
46
+ version: '0'
47
+ source:
48
+ type: stdlib
49
+ - name: fileutils
50
+ version: '0'
51
+ source:
52
+ type: stdlib
53
+ - name: i18n
54
+ version: '1.10'
55
+ source:
56
+ type: git
57
+ name: ruby/gem_rbs_collection
58
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
59
+ remote: https://github.com/ruby/gem_rbs_collection.git
60
+ repo_dir: gems
61
+ - name: json
62
+ version: '0'
63
+ source:
64
+ type: stdlib
65
+ - name: listen
66
+ version: '3.2'
67
+ source:
68
+ type: git
69
+ name: ruby/gem_rbs_collection
70
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
71
+ remote: https://github.com/ruby/gem_rbs_collection.git
72
+ repo_dir: gems
73
+ - name: minitest
74
+ version: '0'
75
+ source:
76
+ type: stdlib
77
+ - name: parallel
78
+ version: '1.20'
79
+ source:
80
+ type: git
81
+ name: ruby/gem_rbs_collection
82
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
83
+ remote: https://github.com/ruby/gem_rbs_collection.git
84
+ repo_dir: gems
85
+ - name: rainbow
86
+ version: '3.0'
87
+ source:
88
+ type: git
89
+ name: ruby/gem_rbs_collection
90
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
91
+ remote: https://github.com/ruby/gem_rbs_collection.git
92
+ repo_dir: gems
93
+ - name: securerandom
94
+ version: '0'
95
+ source:
96
+ type: stdlib
97
+ - name: strscan
98
+ version: '0'
99
+ source:
100
+ type: stdlib
101
+ - name: monitor
102
+ version: '0'
103
+ source:
104
+ type: stdlib
105
+ - name: uri
106
+ version: '0'
107
+ source:
108
+ type: stdlib
109
+ - name: forwardable
110
+ version: '0'
111
+ source:
112
+ type: stdlib
113
+ - name: date
114
+ version: '0'
115
+ source:
116
+ type: stdlib
117
+ - name: mutex_m
118
+ version: '0'
119
+ source:
120
+ type: stdlib
121
+ - name: singleton
122
+ version: '0'
123
+ source:
124
+ type: stdlib
125
+ - name: time
126
+ version: '0'
127
+ source:
128
+ type: stdlib
129
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,21 @@
1
+ # Download sources
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+
8
+ # A directory to install the downloaded RBSs
9
+ path: .gem_rbs_collection
10
+
11
+ gems:
12
+ # Skip loading rbs gem's RBS.
13
+ # It's unnecessary if you don't use rbs as a library.
14
+ - name: rbs
15
+ ignore: true
16
+ - name: steep
17
+ ignore: true
18
+ - name: hackernews_api_client
19
+ ignore: true
20
+ - name: logger
21
+ - name: faraday
@@ -0,0 +1,13 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+
5
+ module HackernewsApiClient
6
+ module EndPoints
7
+ module GetItem
8
+ include _FaradayRequestable
9
+
10
+ def get_item: (req: HackernewsApiClient::Requests::GetItem) -> HackernewsApiClient::Responses::GetItem
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+
5
+ module HackernewsApiClient
6
+ module EndPoints
7
+ module TopStories
8
+ include _FaradayRequestable
9
+
10
+ def top_stories: (req: HackernewsApiClient::Requests::TopStories) -> untyped
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ interface _FaradayRequestable
2
+ def get: (String path, ?Hash[untyped, untyped] options) -> ::Faraday::Response
3
+ end
4
+
5
+ module HackernewsApiClient
6
+ module EndPoints
7
+ include HackernewsApiClient::EndPoints::TopStories
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module HackernewsApiClient
5
+ module Faraday
6
+ module Connection
7
+ @connection: ::Faraday::Connection
8
+
9
+ private
10
+ def connection: -> ::Faraday::Connection
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module HackernewsApiClient
5
+ module Faraday
6
+ module Request
7
+ def get: (untyped path, ?Hash[untyped, untyped] options) -> ::Faraday::Response
8
+
9
+ private
10
+ def connection: -> ::Faraday::Connection
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module HackernewsApiClient
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ Error: StandardError
5
+ end
data/sig/logger.rbs ADDED
@@ -0,0 +1,10 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module HackernewsApiClient
5
+ class Logger < ::Logger
6
+ self.@default: Logger
7
+
8
+ def self.default: -> Logger?
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module HackernewsApiClient
5
+ module Requests
6
+ class GetItem
7
+ attr_reader item_id: Integer
8
+ attr_reader options: Hash[untyped, untyped]
9
+ def initialize: (item_id: Integer, ?options: Hash[untyped, untyped]) -> void
10
+ def path: -> String
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module HackernewsApiClient
5
+ module Requests
6
+ class TopStories
7
+ attr_reader options: Hash[Symbol, String]
8
+ def initialize: (?options: Hash[Symbol, String]) -> void
9
+ def path: -> String
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module HackernewsApiClient
5
+ module Responses
6
+ class GetItem
7
+ attr_reader raw_response: ::Faraday::Response
8
+ def initialize: (raw: ::Faraday::Response) -> void
9
+ def as_json: -> Object
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Classes
4
+ module HackernewsApiClient
5
+ module Responses
6
+ class TopStories
7
+ attr_reader raw_response: ::Faraday::Response
8
+ def initialize: (raw: ::Faraday::Response) -> void
9
+ def as_json: -> Array[Integer]
10
+ end
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hackernews_api_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - teitei-tk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ description:
28
+ email:
29
+ - teitei.tk@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - ".ruby-version"
37
+ - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - Steepfile
44
+ - lib/hackernews_api_client.rb
45
+ - lib/hackernews_api_client/client.rb
46
+ - lib/hackernews_api_client/end_points.rb
47
+ - lib/hackernews_api_client/end_points/get_item.rb
48
+ - lib/hackernews_api_client/end_points/top_stories.rb
49
+ - lib/hackernews_api_client/faraday/connection.rb
50
+ - lib/hackernews_api_client/faraday/request.rb
51
+ - lib/hackernews_api_client/logger.rb
52
+ - lib/hackernews_api_client/requests/get_item.rb
53
+ - lib/hackernews_api_client/requests/top_stories.rb
54
+ - lib/hackernews_api_client/responses/get_item.rb
55
+ - lib/hackernews_api_client/responses/top_stories.rb
56
+ - lib/hackernews_api_client/version.rb
57
+ - rbs_collection.lock.yaml
58
+ - rbs_collection.yaml
59
+ - sig/end_points.rbs
60
+ - sig/end_points/get_item.rbs
61
+ - sig/end_points/top_stories.rbs
62
+ - sig/faraday/connection.rbs
63
+ - sig/faraday/request.rbs
64
+ - sig/hackernews_api_client.rbs
65
+ - sig/logger.rbs
66
+ - sig/requests/get_item.rbs
67
+ - sig/requests/top_stories.rbs
68
+ - sig/responses/get_item.rbs
69
+ - sig/responses/top_stories.rbs
70
+ homepage: https://github.com/teitei-tk/hackernews_api_client_rb
71
+ licenses:
72
+ - MIT
73
+ metadata:
74
+ homepage_uri: https://github.com/teitei-tk/hackernews_api_client_rb
75
+ source_code_uri: https://github.com/teitei-tk/hackernews_api_client_rb
76
+ changelog_uri: https://github.com/teitei-tk/hackernews_api_client_rb/blob/main/CHANGELOG.md
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.6.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubygems_version: 3.4.6
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Client for HackerNews APIs
96
+ test_files: []