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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5301e5087e8c893019aa4138e3f0c92899ee205e9c3e486e1de247b4457b4a3
4
- data.tar.gz: 1eb13ba9e7b41c303079978fd3918ce8ddb8b357382e68936da034c6617ed4db
3
+ metadata.gz: 3a493e46ec65a877444a775562fd0d40a1ce81690e40341b510a2371a87bafe4
4
+ data.tar.gz: 00cf057e1be9bfc51f0c1d8660c8293949b405e0db103b3aee580a5ac716f47f
5
5
  SHA512:
6
- metadata.gz: 2c234f460d68739ccbc3b428b7e073d790822683c50be67dc784a29ab138fa067c0ed3758cf4ea8b4e1f490c73eb3a0fc1700cc48de21c480a7d4e0763db8105
7
- data.tar.gz: 676fc885ae33537beb0ee2d713e9b845115a593dc3291555a4bf738f5919eb1ba666bd1c6593507a273c139374464368f2fb2fab5d28a187a526836a398bb92a
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- get_xkcd (0.1.0)
4
+ get_xkcd (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -63,4 +63,4 @@ DEPENDENCIES
63
63
  webmock (~> 3.0)
64
64
 
65
65
  BUNDLED WITH
66
- 2.2.3
66
+ 2.3.20
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]
@@ -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 number
22
- def self.fetch_random_issue_data
23
- uri = URI("https://xkcd.com/#{generate_random_issue_number}/info.0.json")
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"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GetXkcd
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.2"
5
5
  end
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.1.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-17 00:00:00.000000000 Z
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"