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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d0571ccb74e305b920a551cbfc38be6be94017e8e2607e0dad5323bd6c99b8b
4
- data.tar.gz: 43c91d5f74d7deaad58a1eecd4b019e20eb026492e9a59d6047c64be9d1041c8
3
+ metadata.gz: e40a64d19b26927827dcd2b8e511f59631dc586873c2bf245707756e3c0f2c81
4
+ data.tar.gz: ac81b9e13f015242be665e4d8d9886373d4db64abdbb9d8650168f020d1e9ed4
5
5
  SHA512:
6
- metadata.gz: cf556cd3908ee87cdce571df1346878a9e4e007013f77a537009031c32b99daff8493dc18f73af12bd671164338eeeacabd54d282bf4844920aa3b52d052b864
7
- data.tar.gz: 3f9f5e660f3d985f671d9c406a4da492f64eb29e845b163d8503fa401df17f6e0957fc6d7de413175e980d45bab1465072d9db632353a3e076e109440a6c7684
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
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'random_yesno'
5
+
6
+ puts RandomYesNo.show # ARGV[0] for :force
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.0
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
- homepage: https://i-love-ruby.gitlab.io
21
- licenses: []
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