virtual_name_card 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -7
- data/lib/virtual_name_card/generator.rb +48 -5
- data/lib/virtual_name_card/image.rb +9 -0
- data/lib/virtual_name_card/version.rb +1 -1
- data/lib/virtual_name_card.rb +1 -0
- data/virtual_name_card.gemspec +3 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4da962b8dc697177c91319e2ae3c361025dbe80ce48ce544af70e60f2edbae76
|
4
|
+
data.tar.gz: b8c5353cee1336039b21e911ddb74cab6ea0c29336b831795014cb3392e244e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b75f50a5c198d9d27fa0efdb22a034bad70ca1de489cf09bd9fe779e2c48bc9434b70113a53783e0d4dcd1aaf11a91c30a0e8237a497d0117b4736931711e71
|
7
|
+
data.tar.gz: d98a8fe0d831c35c0a80c12351e5147cd467e8bfe40807bf1f585e8a6d00e502e1e6cb195a78bbc1d7504afd593c4c077b24e9cefd90c34be7ef954e39aeb84b
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# VirtualNameCard
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/virtual_name_card`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
@@ -14,15 +10,39 @@ gem 'virtual_name_card'
|
|
14
10
|
|
15
11
|
And then execute:
|
16
12
|
|
17
|
-
|
13
|
+
```
|
14
|
+
$ bundle
|
15
|
+
```
|
18
16
|
|
19
17
|
Or install it yourself as:
|
20
18
|
|
21
|
-
|
19
|
+
```
|
20
|
+
$ gem install virtual_name_card
|
21
|
+
```
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
```ruby
|
26
|
+
# You can try bellow commands by `bin/console`
|
27
|
+
|
28
|
+
image = VirtualNameCard::Generator.build
|
29
|
+
|
30
|
+
# Return the location of the current working file
|
31
|
+
image.mini_magick_image.path
|
32
|
+
|
33
|
+
# Return the underlying temporary file
|
34
|
+
image.mini_magick_image.tempfile
|
35
|
+
|
36
|
+
# Generate image to `./generated_file.png`
|
37
|
+
VirtualNameCard::Generator.generate(
|
38
|
+
name_kanji: "道川 雅嘉",
|
39
|
+
name_romaji: "Michikawa Masayoshi",
|
40
|
+
role: "CTO",
|
41
|
+
email: "masayoshi.michikawa@refcome.com",
|
42
|
+
twitter_account: "michiomochi",
|
43
|
+
url: "https://about.refcome.com/",
|
44
|
+
)
|
45
|
+
```
|
26
46
|
|
27
47
|
## Development
|
28
48
|
|
@@ -1,11 +1,20 @@
|
|
1
1
|
require 'mini_magick'
|
2
|
+
require "rqrcode"
|
3
|
+
require "chunky_png"
|
2
4
|
|
3
5
|
module VirtualNameCard
|
4
6
|
class Generator
|
5
7
|
GENERATED_FILE_PATH = File.expand_path("../../generated_file.png", __dir__)
|
6
8
|
|
7
9
|
class << self
|
8
|
-
|
10
|
+
# @param [String] name_kanji
|
11
|
+
# @param [String] name_romaji
|
12
|
+
# @param [String, nil] role
|
13
|
+
# @param [String, nil] email
|
14
|
+
# @param [String, nil] twitter_account
|
15
|
+
# @param [String, nil] url
|
16
|
+
# @return [VirtualNameCard::Image]
|
17
|
+
def build(name_kanji:, name_romaji:, role: nil, email: nil, twitter_account: nil, url: nil)
|
9
18
|
base_image_path =
|
10
19
|
if twitter_account
|
11
20
|
File.expand_path("../../base_images/with_twitter.jpg", __dir__)
|
@@ -30,18 +39,29 @@ module VirtualNameCard
|
|
30
39
|
twitter_account_combine(image: image, text: twitter_account)
|
31
40
|
end
|
32
41
|
|
33
|
-
|
42
|
+
if url
|
43
|
+
image = url_combine(image: image, url: url)
|
44
|
+
end
|
45
|
+
|
46
|
+
VirtualNameCard::Image.new(mini_magic_image: image)
|
34
47
|
end
|
35
48
|
|
36
|
-
|
37
|
-
|
49
|
+
# @param [String] name_kanji
|
50
|
+
# @param [String] name_romaji
|
51
|
+
# @param [String, nil] role
|
52
|
+
# @param [String, nil] email
|
53
|
+
# @param [String, nil] twitter_account
|
54
|
+
# @param [String, nil] url
|
55
|
+
def generate(name_kanji:, name_romaji:, role: nil, email: nil, twitter_account: nil, url: nil)
|
56
|
+
image = build(
|
38
57
|
name_kanji: name_kanji,
|
39
58
|
name_romaji: name_romaji,
|
40
59
|
role: role,
|
41
60
|
email: email,
|
42
61
|
twitter_account: twitter_account,
|
62
|
+
url: url,
|
43
63
|
)
|
44
|
-
image.write GENERATED_FILE_PATH
|
64
|
+
image.mini_magic_image.write GENERATED_FILE_PATH
|
45
65
|
end
|
46
66
|
|
47
67
|
private def name_kanji_combine(image:, text:)
|
@@ -93,6 +113,29 @@ module VirtualNameCard
|
|
93
113
|
config.fill "#593535"
|
94
114
|
end
|
95
115
|
end
|
116
|
+
|
117
|
+
private def url_combine(image:, url:)
|
118
|
+
qr_image = RQRCode::QRCode.new(url).as_png(
|
119
|
+
bit_depth: 1,
|
120
|
+
border_modules: 4,
|
121
|
+
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
122
|
+
color: 'black',
|
123
|
+
file: nil,
|
124
|
+
fill: 'white',
|
125
|
+
module_px_size: 6,
|
126
|
+
resize_exactly_to: false,
|
127
|
+
resize_gte_to: false,
|
128
|
+
size: 240,
|
129
|
+
).yield_self do |png|
|
130
|
+
MiniMagick::Image.read(png.to_s)
|
131
|
+
end
|
132
|
+
|
133
|
+
image.composite(qr_image) do |config|
|
134
|
+
config.compose "Over"
|
135
|
+
config.gravity "east"
|
136
|
+
config.geometry "+110+345"
|
137
|
+
end
|
138
|
+
end
|
96
139
|
end
|
97
140
|
end
|
98
141
|
end
|
data/lib/virtual_name_card.rb
CHANGED
data/virtual_name_card.gemspec
CHANGED
@@ -35,6 +35,9 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.require_paths = ["lib"]
|
36
36
|
|
37
37
|
spec.add_dependency "mini_magick"
|
38
|
+
spec.add_dependency "rqrcode"
|
39
|
+
spec.add_dependency "chunky_png"
|
40
|
+
|
38
41
|
spec.add_development_dependency "bundler"
|
39
42
|
spec.add_development_dependency "rake"
|
40
43
|
spec.add_development_dependency "minitest"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtual_name_card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michikawa Masayoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rqrcode
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: chunky_png
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: bundler
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +134,7 @@ files:
|
|
106
134
|
- fonts/Noto_Sans_JP/OFL.txt
|
107
135
|
- lib/virtual_name_card.rb
|
108
136
|
- lib/virtual_name_card/generator.rb
|
137
|
+
- lib/virtual_name_card/image.rb
|
109
138
|
- lib/virtual_name_card/version.rb
|
110
139
|
- virtual_name_card.gemspec
|
111
140
|
homepage: https://github.com/refcome/virtual_name_card
|