qrgo 0.1.1 → 0.1.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: 2018725e38aef0e14c65578da89f45c022f9e779ac65b7ad1384c2f739746646
4
- data.tar.gz: 79f46351193f69978141ae054739716430977b8e9f992f96370dc144f0926865
3
+ metadata.gz: b670d2aaf9453b0ff3a7c3eb58d9a0b59d6cc5ce44b2501144b8e82dd44a36fc
4
+ data.tar.gz: e344b78fb831c248016586495166c04e3642a3e523f85e7dfd6920c0ed8f9be2
5
5
  SHA512:
6
- metadata.gz: dcc2ed6deeb17c9313119da2f07acbc1df21a17a8305feadd57700a0f0710905ddbaaac4e3851dcc4e4ba3b17f4fbe93b8a6c9f4052c4dc496dd700d85cc411e
7
- data.tar.gz: f81185fe8671c46ddb1b2ebfd642da8c414eb9429db7b8dd445458c4d981ec84cc077e1b7c7b1a0a8d79e5e0449f48270c66554a2d101145880aca3d74b59c0b
6
+ metadata.gz: 5512558948b3b48115191eb07fe77e3c91cce2634fd0aa37773b1f73ebbd68ddec4f22011043fd610e0e0e35409815c9d20623b11cf8ab16c16150dca3498c89
7
+ data.tar.gz: 673154dcbbb35487e86864d67a84d11cb0028c2eef0ee4584b6ee2ec0bd2dc00fd2d2a12098bc9a2a066c1b9d5f731d24ac6c97222b48aa7981fbab8b4236cdf
data/CHANGELOG.md CHANGED
@@ -3,3 +3,11 @@
3
3
  ## [0.1.0] - 2023-11-06
4
4
 
5
5
  - Initial release
6
+
7
+ ## [0.1.1] - 2024-02-06
8
+
9
+ - Minor bug fixes
10
+
11
+ ## [0.1.2] - 2024-02-07
12
+
13
+ - URLs are encoded, return type param for qr read method
data/README.md CHANGED
@@ -1,28 +1,22 @@
1
- # QRCode
1
+ # QR-GO Wrapper
2
+ [![Gem Version](https://badge.fury.io/rb/qrgo.svg)](https://badge.fury.io/rb/qrgo)
2
3
 
3
- TODO: Delete this and the text below, and describe your gem
4
+ This is a wrapper for the [GOQR api](https://goqr.me/), and can be found in the gem store here [https://rubygems.org/gems/qrgo](https://rubygems.org/gems/qrgo)
4
5
 
5
6
  ## Installation
6
7
 
7
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
8
 
9
9
  Install the gem and add to the application's Gemfile by executing:
10
10
 
11
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
11
+ gem install qrgo
12
12
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
13
+ Alternatively, you may add this to the Gemfile.
14
14
 
15
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
15
+ gem 'qrgo', '~> 0.1.1'
16
16
 
17
17
  ## Usage
18
18
 
19
- TODO: Write usage instructions here
20
-
21
- ## Development
22
-
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
-
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
19
+ Create and read QR Codes using the api's capability, within ruby applications.
26
20
 
27
21
  ## Contributing
28
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QRCode
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/qrcode.rb CHANGED
@@ -6,31 +6,36 @@ require 'json'
6
6
  module QRCode
7
7
  @base_url = "https://api.qrserver.com/v1/"
8
8
 
9
+ # @param [String] url = URL of the image of the QR Code
10
+ # @param [Integer] width = width of qr code image
11
+ # @param [Integer] url = height of qr code image
9
12
  def self.qr_create(url, width = 100, height = 100)
10
- uri = URI("#{@base_url}create-qr-code/?data=#{url}&size=#{width.to_s}x#{height.to_s}")
13
+ uri = URI("#{@base_url}create-qr-code/?data=#{CGI.escape(url)}&size=#{width.to_s}x#{height.to_s}")
11
14
 
12
15
  begin
13
- res = Net::HTTP.get_response(uri)
16
+ res = Net::HTTP.get_response(uri)
14
17
  rescue
15
- return "Failed to connect with API endpoint."
18
+ return "Failed to connect with API endpoint."
16
19
  end
17
20
 
18
21
  return res.body if res.is_a?(Net::HTTPSuccess)
19
22
  end
20
23
 
21
- def self.qr_read(url)
22
- uri = URI("#{@base_url}read-qr-code/?fileurl=#{url}")
24
+ # @param [String] url = URL of the image of the QR Code
25
+ # @param [String] output = "json" or "xml"
26
+ def self.qr_read(url, output = 'json')
27
+ uri = URI("#{@base_url}read-qr-code/?fileurl=#{CGI.escape(url)}&outputformat=#{output}")
23
28
 
24
29
  begin
25
- res = Net::HTTP.get_response(uri)
30
+ res = Net::HTTP.get_response(uri)
26
31
  rescue
27
- return "Failed to connect with API endpoint."
32
+ return "Failed to connect with API endpoint."
28
33
  end
29
34
 
30
35
  parsed_json = JSON.parse(res.body)[0]["symbol"][0];
31
36
 
32
37
  if ! parsed_json['error'].nil?
33
- return "Error: " + parsed_json['error'].to_s
38
+ return "Error: " + parsed_json['error'].to_s
34
39
  end
35
40
 
36
41
  return parsed_json['data'].to_s if res.is_a?(Net::HTTPSuccess)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrgo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Bradshaw