random_yesno 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -0
- data/bin/yesno +6 -0
- data/lib/random_yesno.rb +11 -0
- data/test/test_random_yesno.rb +16 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e40a64d19b26927827dcd2b8e511f59631dc586873c2bf245707756e3c0f2c81
|
4
|
+
data.tar.gz: ac81b9e13f015242be665e4d8d9886373d4db64abdbb9d8650168f020d1e9ed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50d072e16065659d0e1570fcb2ebd279751f0193ad973dc18cbd16676bd0158fb78fb0d3040e7f337cce5f92fd84dbb807fd3eb2cabe745237990156f6220487
|
7
|
+
data.tar.gz: 496623e348d8c344597fe07ea7a83a7ab6ccc4b4e90caaeaa782d8ea0ff9cd0ddca195d9331109eb70ced89be464df0c776d8b56630b676d3b954f0e0bec2ef3
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# random-yesno
|
2
|
+
Randomly show yes or no gifs
|
3
|
+
|
4
|
+
# Installation
|
5
|
+
|
6
|
+
With `bundle`, add this line to Gemfile:
|
7
|
+
|
8
|
+
gem "random_yesno"
|
9
|
+
|
10
|
+
Or install:
|
11
|
+
|
12
|
+
$ gem install random_yesno
|
13
|
+
|
14
|
+
# Usage
|
15
|
+
|
16
|
+
```
|
17
|
+
RandomUsername.show
|
18
|
+
|
19
|
+
=> {"answer"=>"no", "forced"=>false, "image"=>"https://yesno.wtf/assets/no/6-4bf0a784c173f70a0cab96efd9ff80c9.gif"}
|
20
|
+
```
|
21
|
+
|
22
|
+
```
|
23
|
+
$ ruby -Ilib ./bin/yesno
|
24
|
+
|
25
|
+
=> {"answer"=>"no", "forced"=>false, "image"=>"https://yesno.wtf/assets/no/6-4bf0a784c173f70a0cab96efd9ff80c9.gif"}
|
26
|
+
```
|
27
|
+
|
28
|
+
# Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Include tests with your changes (run `rake` to test)
|
33
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
6. Create new Pull Request
|
36
|
+
|
37
|
+
# Reference
|
38
|
+
|
39
|
+
1. JacobEvelyn: https://github.com/panorama-ed/gem-template
|
40
|
+
2. wycats: https://github.com/wycats/newgem-template
|
41
|
+
3. mdiebolt: https://github.com/polleverywhere/random_username
|
data/bin/yesno
ADDED
data/lib/random_yesno.rb
CHANGED
@@ -8,6 +8,17 @@ require 'json'
|
|
8
8
|
class RandomYesNo
|
9
9
|
URI = URI('https://yesno.wtf/api')
|
10
10
|
|
11
|
+
##
|
12
|
+
# This send a request to yesno.wtf/api to get a random yes/no gif file
|
13
|
+
#
|
14
|
+
# = Example
|
15
|
+
#
|
16
|
+
# Example json repose:
|
17
|
+
# {
|
18
|
+
# "answer": "yes",
|
19
|
+
# "forced": false,
|
20
|
+
# "image": "https://yesno.wtf/assets/yes/2.gif"
|
21
|
+
# }
|
11
22
|
def self.show
|
12
23
|
res = Net::HTTP.get_response(URI)
|
13
24
|
JSON.parse(res.body) if res.is_a?(Net::HTTPSuccess)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'random_yesno'
|
5
|
+
|
6
|
+
class TestRandomYesNo < Minitest::Test
|
7
|
+
def test_show
|
8
|
+
refute_empty response
|
9
|
+
assert response.keys.include?('answer')
|
10
|
+
assert response.keys.include?('image')
|
11
|
+
end
|
12
|
+
|
13
|
+
def response
|
14
|
+
@response ||= RandomYesNo.show
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random_yesno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trang Tung Nguyen
|
@@ -12,13 +12,18 @@ date: 2022-11-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description: Generates random yes/no gifs in json format
|
14
14
|
email: tungtrangn@gmail.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- yesno
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- README.md
|
21
|
+
- bin/yesno
|
19
22
|
- lib/random_yesno.rb
|
20
|
-
|
21
|
-
|
23
|
+
- test/test_random_yesno.rb
|
24
|
+
homepage: https://github.com/trangtungn/random-yesno
|
25
|
+
licenses:
|
26
|
+
- MIT
|
22
27
|
metadata: {}
|
23
28
|
post_install_message:
|
24
29
|
rdoc_options: []
|
@@ -39,4 +44,5 @@ rubygems_version: 3.3.7
|
|
39
44
|
signing_key:
|
40
45
|
specification_version: 4
|
41
46
|
summary: Generates random yes/no gifs
|
42
|
-
test_files:
|
47
|
+
test_files:
|
48
|
+
- test/test_random_yesno.rb
|