icanhazdadjoke 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.
- checksums.yaml +7 -0
- data/.github/workflows/gem-push-gpr.yml +37 -0
- data/.github/workflows/gem-push-rubygems.yml +36 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/README.md +59 -0
- data/Rakefile +10 -0
- data/exe/icanhazdadjoke +9 -0
- data/icanhazdadjoke.gemspec +24 -0
- data/lib/icanhazdadjoke/client.rb +17 -0
- data/lib/icanhazdadjoke.rb +8 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f5d22258966c840c26bebd915c170c594a388551e4e92dc445874e8e482b465
|
4
|
+
data.tar.gz: e0ef02bc284d329657febabfa8e52f3c7ce44334f4a75f222cc09e267654790e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ab0dff1d9a9207be7d24ee98e77e65e21979f0b281e755b9adc1a9ed544f0cd10b3f6560d5b988890b170796a8cfa58dce3c54bcb66f12b74bf9b5829008f38
|
7
|
+
data.tar.gz: 2a371bece3dd2b23af2188ced10e84cc1ce72ce5c278be663fc1e3dfb5021789aac6e8f4669a3a51499d61293e367da80d10d6886c2e2fef38ac59c6fe4f0068
|
@@ -0,0 +1,37 @@
|
|
1
|
+
name: Publish to GPR
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "main" ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
name: Build + Publish
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
packages: write
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- name: Set up Ruby 3.0.6
|
20
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
21
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
# uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
24
|
+
with:
|
25
|
+
ruby-version: 3.0.6
|
26
|
+
|
27
|
+
- name: Publish to GPR
|
28
|
+
run: |
|
29
|
+
mkdir -p $HOME/.gem
|
30
|
+
touch $HOME/.gem/credentials
|
31
|
+
chmod 0600 $HOME/.gem/credentials
|
32
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
33
|
+
gem build *.gemspec
|
34
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
35
|
+
env:
|
36
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
37
|
+
OWNER: ${{ github.repository_owner }}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: publish to Rubygems
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "main" ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
name: Build + Publish
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
packages: write
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- name: Set up Ruby 3.0.6
|
20
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
21
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
# uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
24
|
+
with:
|
25
|
+
ruby-version: 3.0.6
|
26
|
+
|
27
|
+
- name: Publish to RubyGems
|
28
|
+
run: |
|
29
|
+
mkdir -p $HOME/.gem
|
30
|
+
touch $HOME/.gem/credentials
|
31
|
+
chmod 0600 $HOME/.gem/credentials
|
32
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
33
|
+
gem build *.gemspec
|
34
|
+
gem push *.gem
|
35
|
+
env:
|
36
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# ICanHazDadJoke
|
2
|
+
|
3
|
+
Welcome to the `icanhazdadjoke` gem! This Ruby gem provides a simple interface to fetch jokes from the icanhazdadjoke API, which is a service for getting random dad jokes.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'icanhazdadjoke'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install icanhazdadjoke
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Require the gem in your code
|
24
|
+
|
25
|
+
Using the `icanhazdadjoke` gem is quite straightforward. Here's a quick example:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'icanhazdadjoke'
|
29
|
+
|
30
|
+
# Fetch a random dad joke
|
31
|
+
joke = ICanHazDadJoke.fetch_joke
|
32
|
+
puts joke
|
33
|
+
```
|
34
|
+
|
35
|
+
### Use the command line tool
|
36
|
+
|
37
|
+
You can also use the command line tool to fetch a random dad joke. Here's how:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
$ icanhazdadjoke
|
41
|
+
```
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/webmatze/icanhazdadjoke. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/webmatze/icanhazdadjoke/blob/main/CODE_OF_CONDUCT.md).
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
56
|
+
|
57
|
+
## Code of Conduct
|
58
|
+
|
59
|
+
Everyone interacting in the ICanHazDadJoke project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/webmatze/icanhazdadjoke/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/exe/icanhazdadjoke
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "icanhazdadjoke"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Mathias Karstädt"]
|
5
|
+
spec.email = ["mathias.karstaedt@gmail.com"]
|
6
|
+
|
7
|
+
spec.summary = %q{A simple Ruby client for the icanhazdadjoke API.}
|
8
|
+
spec.description = %q{This gem provides a simple interface to fetch jokes from the icanhazdadjoke API.}
|
9
|
+
spec.homepage = "https://github.com/webmatze/icanhazdadjoke"
|
10
|
+
spec.license = "MIT"
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
13
|
+
f.match(%r{^(test|spec|features|pkg|bin)/})
|
14
|
+
end
|
15
|
+
spec.bindir = "exe"
|
16
|
+
spec.executables << "icanhazdadjoke"
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "httparty"
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
22
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module ICanHazDadJoke
|
4
|
+
class Client
|
5
|
+
BASE_URI = 'https://icanhazdadjoke.com/'
|
6
|
+
|
7
|
+
def fetch_joke
|
8
|
+
response = HTTParty.get(BASE_URI, headers: { 'Accept' => 'application/json' })
|
9
|
+
if response.ok?
|
10
|
+
response.parsed_response['joke']
|
11
|
+
else
|
12
|
+
puts "Failed to fetch a joke: #{response.code}"
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: icanhazdadjoke
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mathias Karstädt
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description: This gem provides a simple interface to fetch jokes from the icanhazdadjoke
|
70
|
+
API.
|
71
|
+
email:
|
72
|
+
- mathias.karstaedt@gmail.com
|
73
|
+
executables:
|
74
|
+
- icanhazdadjoke
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".github/workflows/gem-push-gpr.yml"
|
79
|
+
- ".github/workflows/gem-push-rubygems.yml"
|
80
|
+
- ".gitignore"
|
81
|
+
- Gemfile
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- exe/icanhazdadjoke
|
85
|
+
- icanhazdadjoke.gemspec
|
86
|
+
- lib/icanhazdadjoke.rb
|
87
|
+
- lib/icanhazdadjoke/client.rb
|
88
|
+
homepage: https://github.com/webmatze/icanhazdadjoke
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.2.33
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: A simple Ruby client for the icanhazdadjoke API.
|
111
|
+
test_files: []
|