get_xkcd 0.1.0 → 0.2.2
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 +4 -4
- data/.github/workflows/release.yml +22 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile.lock +2 -2
- data/README.md +6 -0
- data/Rakefile +16 -0
- data/lib/get_xkcd/comic.rb +8 -3
- data/lib/get_xkcd/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a493e46ec65a877444a775562fd0d40a1ce81690e40341b510a2371a87bafe4
|
4
|
+
data.tar.gz: 00cf057e1be9bfc51f0c1d8660c8293949b405e0db103b3aee580a5ac716f47f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a49e8321ca2adb50f46a9b6e0cd3ee7a12774e38018ff5618eabd7873c089f0b317f363254320fde27b8e618cc11f33dd607d9abc23f1dac2af56945cd8e61b1
|
7
|
+
data.tar.gz: 3c9ab6dffcba5dd3addef67a80be690d5cd6aef4451f5295d1803114c84498d4a1eaa8aa907def8e1b4988e3b4c1c96074626d80d870efdc0aa5f39abce7ad11
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
on:
|
3
|
+
release:
|
4
|
+
types: [published]
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v3
|
10
|
+
- name: Bundle Install
|
11
|
+
run: bundle install
|
12
|
+
- name: Set Credentials
|
13
|
+
run: |
|
14
|
+
mkdir -p $HOME/.gem
|
15
|
+
touch $HOME/.gem/credentials
|
16
|
+
chmod 0600 $HOME/.gem/credentials
|
17
|
+
printf -- "---\n:github: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
|
18
|
+
env:
|
19
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
20
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
21
|
+
- name: Release Gem
|
22
|
+
run: rake publish_gem
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# 0.2.2
|
2
|
+
|
3
|
+
* Changes the Gem publishing workflow:
|
4
|
+
* Creates some new Rake tasks
|
5
|
+
* Updates the GitHub workflow for release.yml
|
6
|
+
|
7
|
+
# 0.2.1
|
8
|
+
|
9
|
+
* Updates Bundler version to fix issue with automatic deployment
|
10
|
+
|
11
|
+
# 0.2.0
|
12
|
+
|
13
|
+
* Adds functionality to get a specific issue
|
14
|
+
* Defines a `Comic::fetch_specific_issue_data` method
|
15
|
+
* Refactors the `Comic::fetch_random_issue_data` method to use `Comic::fetch_specific_issue_data`
|
16
|
+
|
1
17
|
# 0.1.0
|
2
18
|
|
3
19
|
* First version!
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,12 @@ Get data for the latest comic:
|
|
36
36
|
latest_issue_data = GetXkcd::Comic.fetch_latest_issue_data
|
37
37
|
```
|
38
38
|
|
39
|
+
Get data for a specific comic:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
specific_issue_data = GetXkcd::Comic.fetch_specific_issue_data(issue_number)
|
43
|
+
```
|
44
|
+
|
39
45
|
Get data for the a random comic:
|
40
46
|
|
41
47
|
```ruby
|
data/Rakefile
CHANGED
@@ -9,4 +9,20 @@ require "rubocop/rake_task"
|
|
9
9
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
12
|
+
desc "Build gem"
|
13
|
+
task :build_gem do
|
14
|
+
`rake build`
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Publish gem"
|
18
|
+
task publish_gem: [:build_gem] do
|
19
|
+
`gem push pkg/*.gem`
|
20
|
+
Rake::Task[:empty_pkg].invoke
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Empty pkg directory"
|
24
|
+
task :empty_pkg do
|
25
|
+
`rm -rf pkg/*`
|
26
|
+
end
|
27
|
+
|
12
28
|
task default: %i[spec rubocop]
|
data/lib/get_xkcd/comic.rb
CHANGED
@@ -18,9 +18,9 @@ module GetXkcd
|
|
18
18
|
JSON.parse(res.body)
|
19
19
|
end
|
20
20
|
|
21
|
-
# Get the json for the xkcd comic of a specific
|
22
|
-
def self.
|
23
|
-
uri = URI("https://xkcd.com/#{
|
21
|
+
# Get the json for the xkcd comic of a specific issue
|
22
|
+
def self.fetch_specific_issue_data(issue_number)
|
23
|
+
uri = URI("https://xkcd.com/#{issue_number}/info.0.json")
|
24
24
|
|
25
25
|
req = Net::HTTP::Get.new(uri)
|
26
26
|
req["Accept"] = "application/json"
|
@@ -31,6 +31,11 @@ module GetXkcd
|
|
31
31
|
JSON.parse(res.body)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Get the json for the xkcd comic of a random issue
|
35
|
+
def self.fetch_random_issue_data
|
36
|
+
fetch_specific_issue_data(generate_random_issue_number)
|
37
|
+
end
|
38
|
+
|
34
39
|
# Generate a random number up to the latest issue number (excluding 404)
|
35
40
|
def self.generate_random_issue_number
|
36
41
|
latest_issue_number = fetch_latest_issue_data["num"]
|
data/lib/get_xkcd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_xkcd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- superchilled
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This library provides methods to get the JSON data for either the most
|
14
14
|
recent XKCD comic or a random one, and then return the JSON data as a Ruby Hash.
|
@@ -19,6 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- ".github/workflows/main.yml"
|
22
|
+
- ".github/workflows/release.yml"
|
22
23
|
- ".gitignore"
|
23
24
|
- ".rake_tasks~"
|
24
25
|
- ".rspec"
|