-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from kufu/qr-code
ビル来客システムのバージョンアップに対応し、QRコードバージョンが利用できるようにした
- Loading branch information
Showing
18 changed files
with
347 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require "mechanize" | ||
require "zip" | ||
require "fileutils" | ||
|
||
class QrCodePdf | ||
def initialize(pdf_url, prefix) | ||
@pdf_url = pdf_url | ||
@prefix = prefix | ||
@agent = Mechanize.new | ||
end | ||
|
||
def download | ||
@agent.get(@pdf_url).save_as("#{@prefix}_qr_code.zip") | ||
end | ||
|
||
def unzip | ||
dist_path = "#{@prefix}_qr_code" | ||
Dir.mkdir(dist_path) | ||
Zip::File.open("#{@prefix}_qr_code.zip") do |zip_file| | ||
zip_file.each do |entry| | ||
entry.extract("#{dist_path}/#{entry.name}") | ||
end | ||
end | ||
end | ||
|
||
def entry_qr_code_path | ||
qr_code_path = "#{@prefix}_qr_code" | ||
|
||
Dir.glob("#{qr_code_path}/*pdf") | ||
end | ||
|
||
def cleanup | ||
File.delete("#{@prefix}_qr_code.zip") | ||
FileUtils.rm_rf("#{@prefix}_qr_code") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.