proxy-mate 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/proxy-mate +10 -0
- data/lib/proxy_mate.rb +64 -0
- data/lib/proxy_mate/version.rb +5 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 96c213b51f76c34faa61934bf6480cc075d33a063c0756dc8d7c435404c117e6
|
4
|
+
data.tar.gz: 41e83005ab697e99f74898449fe42acc4b16d9eb73fa554b424349e12155847c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c07c9e324f370753a696fb0f44986744ca110b02d22fd42cdf89db62e70ef6c7ca5417aa60328bf30d0e943d2b211776a425de03fcb1d2247621a770f69da73b
|
7
|
+
data.tar.gz: c4434c8aff88b78f32cd799d53c72d261c845aca2aa449fe7518815c1506cab86e64596ff50420048a5aff5a39297d1837367afb60ebac1207d78cc0bcd42d24
|
data/bin/proxy-mate
ADDED
data/lib/proxy_mate.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'proxy_mate/version'
|
4
|
+
require 'prawn'
|
5
|
+
require 'prawn/measurement_extensions'
|
6
|
+
|
7
|
+
class ProxyMate # rubocop:disable Style/Documentation
|
8
|
+
PAGE_SIZE = 'A4'
|
9
|
+
PAGE_WIDTH = 210.mm
|
10
|
+
PAGE_HEIGHT = 297.mm
|
11
|
+
CARD_WIDTH = 63.5.mm
|
12
|
+
CARD_HEIGHT = 88.9.mm
|
13
|
+
X_GAP = (PAGE_WIDTH - 3 * CARD_WIDTH) / 4
|
14
|
+
Y_GAP = (PAGE_HEIGHT - 3 * CARD_HEIGHT) / 4
|
15
|
+
CARDS_PER_PAGE = 9
|
16
|
+
|
17
|
+
def initialize(card_image_paths, file_name)
|
18
|
+
@card_image_paths = card_image_paths
|
19
|
+
@file_name = file_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate
|
23
|
+
Prawn::Document.generate(file_name, document_options) do |pdf|
|
24
|
+
card_image_paths.each.with_index do |card_image_path, i|
|
25
|
+
pdf.start_new_page if (i % CARDS_PER_PAGE).zero? && i.positive?
|
26
|
+
add_card(pdf, card_image_path)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :card_image_paths, :file_name
|
34
|
+
|
35
|
+
def document_options
|
36
|
+
{
|
37
|
+
margin: 0,
|
38
|
+
print_scaling: :none,
|
39
|
+
page_size: PAGE_SIZE
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_card(pdf, card_image_path)
|
44
|
+
pdf.image(
|
45
|
+
card_image_path,
|
46
|
+
at: positions.next,
|
47
|
+
width: CARD_WIDTH,
|
48
|
+
height: CARD_HEIGHT
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def positions
|
53
|
+
@positions ||= Enumerator.new do |out|
|
54
|
+
n = 0
|
55
|
+
loop do
|
56
|
+
x = X_GAP + (n % 3) * (CARD_WIDTH + X_GAP)
|
57
|
+
y = PAGE_HEIGHT - Y_GAP - (n / 3) * (CARD_HEIGHT + Y_GAP)
|
58
|
+
out << [x, y]
|
59
|
+
n += 1
|
60
|
+
n = 0 if n == CARDS_PER_PAGE
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: proxy-mate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Helge Rausch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: prawn
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Generates a PDF with standard size playing cards of your choice
|
56
|
+
email:
|
57
|
+
- helge@rausch.io
|
58
|
+
executables:
|
59
|
+
- proxy-mate
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- bin/proxy-mate
|
64
|
+
- lib/proxy_mate.rb
|
65
|
+
- lib/proxy_mate/version.rb
|
66
|
+
homepage: https://github.com/tsujigiri/proxy-mate/
|
67
|
+
licenses: []
|
68
|
+
metadata:
|
69
|
+
homepage_uri: https://github.com/tsujigiri/proxy-mate/
|
70
|
+
source_code_uri: https://github.com/tsujigiri/proxy-mate/
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.0.3
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Generates a PDF with standard size playing cards of your choice
|
90
|
+
test_files: []
|